| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301 |
- using com.hnshituo.pur.vo;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinGrid;
- using Pur.Entity;
- using Pur.Entity.configureEntity;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Pur.ck;
- using CoreFS.CA06;
- using Pur.Pop_upWindow;
- using System.Collections;
- using Core.Mes.Client.Comm.Server;
- using Infragistics.Win.UltraWinEditors;
- namespace Pur.Balance
- {
- public partial class FrmFGPriceMainTain : FrmPmsBase
- {
- String fileName = "";//附件上传
- public string strPriceId="";
- public string strPriceName = "";
- public string tips = "0";
- public String strViewType = "";
- public FrmFGPriceMainTain()
- {
- InitializeComponent();
- }
- public FrmFGPriceMainTain(OpeBase OB)
- {
- InitializeComponent();
- this.ob = OB;
- ultraExpandableGroupBox1.Visible = true;
- }
- private void FrmFGPriceMainTain_Load(object sender, EventArgs e)
- {
- strViewType="";
- if(!String.IsNullOrEmpty(this.CustomInfo))
- {
- strViewType = this.CustomInfo;//1:提报界面,2,审核界面 其它:弹出框界面
- }
-
- if (strViewType == "2")
- {
- txt_status.Value = "1";
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { });
- GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] { "EVAMSG" });
- GridHelper.HidenColumns(ultraGrid3.DisplayLayout.Bands[0], new string[] { "EVARESULT" });
- GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { "priceVal", "priceVal1" });
- //ultraExpandableGroupBox1.Visible = false;
- }
- else if (strViewType == "1")
- {
- txt_status.SelectedIndex=0;
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { });
- GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] { });
- GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { "priceVal", "priceVal1" });
- }
- else
- {
- txt_remark.Enabled = false;
- txt_status.Value = "2";
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { });
- GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] { });
- GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { });
- }
- GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] { "CERTPATH" });
- ultraExpandableGroupBox1.Expanded = false;
- ultraExpandableGroupBox2.Expanded = false;
- ultraExpandableGroupBox3.Expanded = false;
- ultraExpandableGroupBox5.Expanded = false;
- ultraExpandableGroupBox4.Expanded = true;
- txt_createTimeBegin.Value = DateTime.Now.AddMonths(-2);
- txt_createTimeEnd.Value = DateTime.Now.AddDays(2);
- txt_createTimeBegin.Enabled = true;
- txt_createTimeEnd.Enabled = true;
- ck_createT.Checked = true;
- ex_fujian.Expanded = false;
- ex_yijian.Expanded = false;
- QureyBasePriceM("");//查询
- }
- #region 维护界面toolbar
- /// <summary>
- /// 维护界面toolbar
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "doQuery":
- QureyBasePriceM("");
- break;
- case "doAdd":
- AddBasePriceM();
- break;
- case "doEffect":
- doEffect();//提报
- break;
- case "doSure":
- doSure();//审核
- break;
- case "Save":
- saveFrmFGPriceMainTain();
- break;
- case "doDelete":
- DeleteBasePriceM();
- break;
- case "doExcel":
- doExcel();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 审核
- /// </summary>
- private void doSure()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择待审核的价格政策");
- return;
- }
- string oldstrname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
- string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
- string oldstritemcode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
- if (testPriceMStatus(oldstrid, 4) == false)
- {
- return;
- }
- ArrayList List1 = new ArrayList();//评标人意见
- ultraGrid3.UpdateData();
- int num = 0;
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- if (UserInfo.GetUserName() == row.Cells["EVAUSERNAME"].Text.ToString())
- {
- BalanceEvaUsers taskEva = new BalanceEvaUsers();
- taskEva.StandId = oldstrid;
- taskEva.Validflag = "1";
- taskEva.EvaMsg = row.GetCellValue("EvaMsg").ToString().Trim();
- taskEva.EvaResult = "1";//默认同意
- taskEva.EvaId = row.GetCellValue("EvaId").ToString().Trim();
- taskEva.UpdateUserId = UserInfo.GetUserID();
- taskEva.UpdateName = UserInfo.GetUserName();
- taskEva.UpdateTime = DateTime.Now;
- if (taskEva.EvaId == "")
- {
- MessageUtil.ShowTips("评审意见表第" + row.Index + "行的编号为空!");
- row.Activate();
- return;
- }
- List1.Add(taskEva);
- }
- num += 1;
- }
- if (List1.Count <= 0)
- {
- MessageUtil.ShowTips("无评审人员");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定审核通过价格政策:" + oldstrname + "?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doSurePriceM", new object[] { List1,num});
- if (re.Resultcode == 0)
- {
- MessageUtil.ShowTips("操作成功");
- QureyBasePriceM(oldstrid);
- CkClassCommon.doActiveSelRow(ultraGrid1, "id", oldstrid);
- }
- else
- {
- MessageUtil.ShowTips("操作失败:" + re.Resultmsg);
- }
- }
- /// <summary>
- /// 导出价格政策
- /// </summary>
- private void doExcel()
- {
- try
- {
- this.Cursor = Cursors.Default;
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择需导出明细的价格政策!");
- return;
- }
- //获取导出的采购计划行表
- ArrayList alUltraGrid = new ArrayList();
-
- alUltraGrid.Add(ultraGrid2);
- alUltraGrid.Add(ultraGrid3);
- alUltraGrid.Add(ultraGrid1);
- ArrayList alSheeft = new ArrayList();
-
- alSheeft.Add("价格政策明细");
- alSheeft.Add("价格政策评审明细");
- alSheeft.Add("价格政策清单");
- if (ultraGrid2.Rows.Count > 0)
- {
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "价格政策[" + ultraGrid1.ActiveRow.GetCellValue("name") + "]明细表");//导出excel
- }
- else
- {
- MessageUtil.ShowTips("价格政策:" + ultraGrid1.ActiveRow.GetCellValue("name") + "无可导出明细!");
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void QureyBasePriceM(String strId)
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- basepriceC.Clear();
- basepriceM.Clear();
- clearTab();
- BalanceBasepriceM pm = new BalanceBasepriceM();
- pm.Name = Qname.Text.Trim();
- pm.ItemName = QitemName.Text.Trim();
- if (txt_status.SelectedIndex != -1)
- {
- pm.Flag = txt_status.Value.ToString().Trim();
- }
- if (strViewType != "2")//提报界面
- {
- pm.DepartId = UserInfo.GetDeptid();
- }
- if (ck_createT.Checked == true)
- {
- if (txt_createTimeBegin.Text != "")
- {
- pm.CreateTime = Convert.ToDateTime(txt_createTimeBegin.Value);
- }
- if (txt_createTimeEnd.Text != "")
- {
- pm.DeleteTime = Convert.ToDateTime(txt_createTimeEnd.Value);
- }
- }
- DataTable re = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doQureyBasePriceM", new object[] { pm });
- GridHelper.CopyDataToDatatable(re, dataTable1, true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- if (String.IsNullOrEmpty(strId))
- {
- PublicTools.publicPms.doActiveSelRow(ultraGrid1, "id", strId);
- }
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 生效
- /// </summary>
- private void doEffect()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择待提报的价格政策");
- return;
- }
- string oldstrname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
- string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
- string oldstritemcode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
- if (testPriceMStatus(oldstrid, 1) == false)
- {
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定提报价格政策:" + oldstrname + "?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doEffectPriceM", new object[] { oldstrid });
- if (re.Resultcode == 0)
- {
- MessageUtil.ShowTips("操作成功");
- QureyBasePriceM(oldstrid);
- CkClassCommon.doActiveSelRow(ultraGrid1, "id", oldstrid);
- }
- else
- {
- MessageUtil.ShowTips("操作失败:" + re.Resultmsg);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- private void DeleteBasePriceM()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择待删除的价格政策");
- return;
- }
- string oldstrname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
- string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
- string oldstritemcode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
- //构建实体类
- BalanceBasepriceM pm = new BalanceBasepriceM();
- pm.Validflag = "0";
- pm.Id = oldstrid;
- pm.ItemCode = oldstritemcode;
- pm.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- pm.DeleteTime = DateTime.Now;
- pm.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- if (testPriceMStatus(oldstrid, 2) == false)
- {
- return;
- }
- //调用服务接口
- if (MessageUtil.ShowYesNoAndQuestion("确定删除价格政策:" + oldstrname) != DialogResult.Yes)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doUpdateBasePriceM", new object[] { pm });
- if (re.Resultcode == 0)
- {
- MessageBox.Show("删除成功", "提示");
- QureyBasePriceM("");
- }
- else
- {
- MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
- return;
- }
- }
- /// <summary>
- /// 保存价格政策
- /// </summary>
- private void saveFrmFGPriceMainTain()
- {
- try
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择价格政策进行操作");
- return;
- }
- List<BalanceBasepriceC> list = new List<BalanceBasepriceC>();
- string oldstrname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
- string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
- string oldstritemcode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
- if (testPriceMStatus(oldstrid, 2) == false)
- {
- return;
- }
- ultraGrid2.UpdateData();
- foreach (UltraGridRow row in ultraGrid2.Rows)
- {
- if (String.IsNullOrEmpty(row.GetCellValue("priceVal").ToString()))
- {
- MessageUtil.ShowTips("料型:" + row.GetCellValue("gradeLevel") + "价格1不能为空");
- row.Activated = true;
- return;
- }
- BalanceBasepriceC pc = new BalanceBasepriceC();
- pc.GradeLevel = row.GetCellValue("gradeLevel").ToString().Trim();
- pc.GradeValue = row.GetCellValue("gradeValue").ToString().Trim();
- pc.StandId = oldstrid;
- pc.Validflag = "1";
- if (String.IsNullOrEmpty(row.GetCellValue("id").ToString()))
- {
- pc.CreateUserid = UserInfo.GetUserID();
- pc.CreateName = UserInfo.GetUserName();
- pc.CreateTime = DateTime.Now;
- }
- else
- {
- pc.Id = row.GetCellValue("id").ToString().Trim();
- if (String.IsNullOrEmpty(pc.Id))
- {
- MessageUtil.ShowTips("未获取到料型:" + row.GetCellValue("gradeLevel") + "编码");
- }
- pc.UpdateUserid = UserInfo.GetUserID();
- pc.UpdateName = UserInfo.GetUserName();
- pc.UpdateTime = DateTime.Now;
- }
- pc.PriceVal = row.GetCellValue("priceVal").ToString().Trim();
- if (!String.IsNullOrEmpty(row.GetCellValue("priceVal1").ToString().Trim()))
- {
- pc.PriceVal1 = row.GetCellValue("priceVal1").ToString().Trim();
- }
- else
- {
- pc.PriceVal1 = "0";
- }
- list.Add(pc);
- }
- if (list.Count <= 0)
- {
- MessageUtil.ShowTips("未可修改或者新增项");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定保存?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceBasepriceCService", "doUpdateBasePriceC_batch", new object[] { list });
- if (re.Resultcode == 0)
- {
- MessageUtil.ShowTips("操作成功");
- }
- else
- {
- MessageUtil.ShowTips("操作失败:" + re.Resultmsg);
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败:" + ex.Message);
- }
- }
- /// <summary>
- /// 添加
- /// </summary>
- private void AddBasePriceM()
- {
- BalanceBasepriceM pm = new BalanceBasepriceM();
- if (String.IsNullOrEmpty(edtName.Text.Trim()))
- {
- MessageUtil.ShowTips("价格政策名称不能为空");
- edtName.Focus();
- return;
- }
- if (String.IsNullOrEmpty(txt_effectTime.Text.Trim()))
- {
- MessageUtil.ShowTips("请输入政策的生效时间");
- txt_effectTime.Focus();
- return;
- }
- if (String.IsNullOrEmpty(txt_VersionNo.Text.Trim()))
- {
- MessageUtil.ShowTips("版本号不能为空");
- txt_VersionNo.Focus();
- return;
- }
- if (String.IsNullOrEmpty(txt_itemName.Text.Trim()))
- {
- MessageUtil.ShowTips("适用物料不能为空");
- txt_itemName.Focus();
- return;
- }
- if (String.IsNullOrEmpty(txt_itemCode.Text.Trim()))
- {
- MessageUtil.ShowTips("适用物料不能为空");
- txt_itemName.Focus();
- return;
- }
- //DateTime time = DateTime.Parse(Convert.ToDateTime(txt_effectTime.Value).ToString("yyyy/MM/dd"));
- //pm.EffectiveTime = Convert.ToDateTime(time);
- if (String.IsNullOrEmpty(txt_remark.Text.Trim()))
- {
- MessageUtil.ShowTips("请填写申请部门意见");
- txt_remark.Focus();
- return;
- }
- pm.EffectiveTime = DateTime.Parse(Convert.ToDateTime(txt_effectTime.Value).ToString("yyyy/MM/dd"));
- pm.Remark = txt_remark.Text.Trim();
- pm.Name = edtName.Text.Trim();
- pm.VersionNo = txt_VersionNo.Text.Trim();
- pm.ItemName = txt_itemName.Text.Trim();
- pm.ItemCode = txt_itemCode.Text.Trim();
- pm.DepartId = UserInfo.GetDeptid();
- pm.DepartName = UserInfo.GetDepartment();
- if (testPriceM(pm, 1) == false)
- {
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定新增?") != DialogResult.Yes)
- {
- return;
- }
- pm.Flag = "0";
- pm.Validflag = "1";
- pm.CreateName = UserInfo.GetUserName();
- pm.CreateTime = System.DateTime.Now;
- pm.CreateUserid = UserInfo.GetUserID();
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doAddBasePriceM", new object[] { pm });
- if (re.Resultcode == 0)
- {
- MessageBox.Show("新增成功", "提示");
- QureyBasePriceM(re.Resultmsg);
-
- }
- else
- {
- MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
- return;
- }
- }
- #endregion
- #region 弹出框toolbar
- /// <summary>
- /// 弹出框toolbar
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "doQuery": // ButtonTool
- QureyBasePriceM("");
- break;
- case "doSelect": // ButtonTool
- doSelect();
- break;
- case "doExit": // ButtonTool
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 选择价格政策
- /// </summary>
- private void doSelect()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择价格政策");
- return;
- }
- strPriceName = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim();
- strPriceId = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
- if (testPriceMStatus(strPriceId, 3) == false)
- {
- return;
- }
- tips = "1";
- this.Close();
- }
- #endregion
- #region 界面事件
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- if (ultraGrid1.ActiveRow == null)
- {
- return;
- }
- String strId = ultraGrid1.ActiveRow.Cells["id"].Value.ToString();
- String strItemCode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString();
- if (String.IsNullOrEmpty(strId))
- {
- return;
- }
- if (String.IsNullOrEmpty(strItemCode))
- {
- MessageUtil.ShowTips("该价格政策物料编号不能为空,请维护");
- return;
- }
- BalanceBasepriceM pp = this.execute<BalanceBasepriceM>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "findById", new object[] { strId });
- //判断当前激活行是否为空
- txt_VersionNo.Text = pp.VersionNo;
- edtName.Text = pp.Name;
- txt_remark.Text = pp.Remark == null ? null : pp.Remark.Replace("\n", "\r\n");
- txt_itemCode.Text = pp.ItemCode;
- txt_itemName.Text = pp.ItemName;
- doQueryEva(strId);
- doQueryBasePriceC(strId, strItemCode);
- getOrderAppend(strId, "");
- }
- /// <summary>
- /// 物料选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_itemName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- frmPopMatSelect frm = new frmPopMatSelect(this.ob,"1");
- frm.ShowDialog();
- if (frm.tips == "1")
- {
- txt_itemCode.Text = frm.selectedItemCode;
- txt_itemName.Text = frm.SelectedItemName;
- }
- }
- #endregion
- #region 公共函数
- /// <summary>
- /// 校验重复性
- /// </summary>
- /// <param name="pm"></param>
- /// <param name="p"></param>
- /// <returns></returns>
- private bool testPriceM(BalanceBasepriceM pm, int p)
- {
- BalanceBasepriceM pp = new BalanceBasepriceM();
- pp.Name = pm.Name;
- pp.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "find", new object[] { pp, 0, 0 });
- if (dt != null && dt.Rows.Count > 0)
- {
- MessageUtil.ShowTips("已存在同名价格政策");
- return false;
- }
- pp.Name = null;
- pp.DeleteName = "1";
- pp.EffectiveTime = pm.EffectiveTime;
- pp.ItemCode = pm.ItemCode;
- DataTable re = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doQureyBasePriceM", new object[] { pp });
- if (re != null && re.Rows.Count > 0)
- {
- MessageUtil.ShowTips("当前物料:" + pm .ItemName+ "所维护的价格政策生效时间需大于已维护价格政策");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 校验政策状态
- /// </summary>
- /// <param name="pm"></param>
- /// <param name="p"></param>
- /// <returns></returns>
- private bool testPriceMStatus(String Id, int p)
- {
- if(String.IsNullOrEmpty(Id))
- {
- MessageUtil.ShowTips("价格政策头编号为空");
- return false;
- }
- BalanceBasepriceM pm= this.execute<BalanceBasepriceM>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "findById", new object[] {Id});
- if(pm==null)
- {
- MessageUtil.ShowTips("未发现价格政策:"+Id+"信息记录,或请刷新界面重试");
- return false;
- }
- if (pm.Validflag != "1")
- {
- MessageUtil.ShowTips("价格政策:" + Id + "信息记录,或请刷新界面重试");
- return false;
- }
- //提报
- if (p == 1)
- {
- if (pm.Flag != "0")
- {
- MessageUtil.ShowTips("价格政策:" + Id + "已提报,或请刷新界面重试");
- return false;
- }
- BalanceBasepriceC bc = new BalanceBasepriceC();
- bc.StandId = Id;
- bc.Validflag = "1";
- int count1 = this.execute<int>("com.hnshituo.pur.balance.service.BalanceBasepriceCService", "count", new object[] { bc});
- if (count1 <= 0)
- {
- MessageUtil.ShowTips("请维护价格政策行信息");
- return false;
- }
- BalanceEvaUsers ec = new BalanceEvaUsers();
- ec.StandId = Id;
- ec.Validflag = "1";
- int count2 = this.execute<int>("com.hnshituo.pur.balance.service.BalanceEvaUsersService", "count", new object[] { bc });
- if (count2 <= 0)
- {
- MessageUtil.ShowTips("请维护评审人员信息");
- return false;
- }
- }
- //删除
- else if (p == 2)
- {
- if (pm.Flag != "0")
- {
- MessageUtil.ShowTips("价格政策:" + Id + "已提报,无法删改,或请刷新界面重试");
- return false;
- }
- }
- //选择
- else if (p == 3)
- {
- if (pm.Flag != "2")
- {
- MessageUtil.ShowTips("价格政策:" + Id + "未评审通过,无法适用,或请刷新界面重试");
- return false;
- }
- }
- //审核
- else if (p == 4)
- {
- if (pm.Flag != "1")
- {
- MessageUtil.ShowTips("价格政策:" + Id + "未提报或者已审核,或请刷新界面重试");
- return false;
- }
- }
- //删除人员
- else if (p == 5)
- {
- if (pm.Flag == "2")
- {
- MessageUtil.ShowTips("价格政策:" + Id + "已审核,或请刷新界面重试");
- return false;
- }
- }
- //修改
- else if (p == 6)
- {
- if (pm.Flag == "2")
- {
- MessageUtil.ShowTips("价格政策:" + Id + "已审核,或请刷新界面重试");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数:"+p);
- return false;
- }
- return true;
- }
- /// <summary>
- /// 清空编辑区
- /// </summary>
- private void clearTab()
- {
- edtName.Clear();
- txt_effectTime.Value = DateTime.Now;
- txt_VersionNo.Clear();
- txt_remark.Clear();
- txt_itemCode.Text = "-";
- txt_itemName.Clear();
- }
- /// <summary>
- /// 给控件赋值
- /// </summary>
- /// <param name="sender"></param>
- private void getControlBoxValue()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- return;
- }
- String strId = ultraGrid1.ActiveRow.Cells["id"].Value.ToString();
- if (String.IsNullOrEmpty(strId))
- {
- return;
- }
- BalanceBasepriceM pp = this.execute<BalanceBasepriceM>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "findById", new object[] { strId });
- //判断当前激活行是否为空
- txt_VersionNo.Text = pp.VersionNo;
- edtName.Text = pp.Name;
- txt_remark.Text = pp.Remark;
- txt_itemCode.Text = pp.ItemCode;
- txt_itemName.Text = pp.ItemName;
- }
- /// <summary>
- /// 查询行
- /// </summary>
- /// <param name="strId"></param>
- /// <param name="strItemCode"></param>
- private void doQueryBasePriceC(String strId, String strItemCode)
- {
- dataTable2.Clear();
- BalanceBasepriceC pc = new BalanceBasepriceC();
- pc.StandId = strId;
- pc.Validflag = "1";
- DataTable re = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceBasepriceCService", "doQureyBasePriceC", new object[] { pc });
- if (re.Rows.Count > 0)
- {
- GridHelper.CopyDataToDatatable(re, dataTable2, true);
- }
- else
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("GRADELEVEL");
- dt.Columns.Add("GRADEVALUE");
- PurClassMatAttrEntity attrs = new PurClassMatAttrEntity();
- attrs.ItemCode = strItemCode;
- DataTable dtAttrs = this.execute<DataTable>("com.hnshituo.pur.configure.service.ClassMatAttrService", "find", new object[] { attrs, 0, 0 });
- if (dtAttrs == null || dtAttrs.Rows.Count <= 0)
- {
- MessageUtil.ShowTips("请维护在料型维护界面维护该物料的可用属性");
- return;
- }
- else
- {
- foreach (DataRow row in dtAttrs.Rows)
- {
- dt.Rows.Add(row["attrName"], row["attrCode"]);
- }
- }
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- }
- }
- /// <summary>
- /// 查询评审人员
- /// </summary>
- /// <param name="strId"></param>
- private void doQueryEva(string strId)
- {
- dataTable4.Clear();
- BalanceEvaUsers pc = new BalanceEvaUsers();
- pc.StandId = strId;
- pc.Validflag = "1";
- DataTable re = this.execute<DataTable>("com.hnshituo.pur.balance.service.BalanceEvaUsersService", "doQureyEva", new object[] { pc });
- GridHelper.CopyDataToDatatable(re, dataTable4, true);
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- #endregion
- #region 评审人员处理
- /// <summary>
- /// 新增评审人员
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_add_group_Click(object sender, EventArgs e)
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择价格政策");
- return;
- }
- string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
- if (testPriceMStatus(oldstrid, 5) == false)
- {
- return;
- }
- frmPopSelEvaGroup frm = new frmPopSelEvaGroup(this.ob);
- frm.ShowDialog();
- if (frm.dtEvaGroup != null)
- {
- ArrayList list = new ArrayList();
- DataTable dt = frm.dtEvaGroup;
- //移除目标表中没有的列
- foreach(DataRow row in dt.Rows)
- {
- BalanceEvaUsers user = new BalanceEvaUsers();
- user.StandId = oldstrid;
- user.EvaRoleId = row["EVAROLEID"].ToString().Trim();
- user.EvaRoleName = row["EVAROLENAME"].ToString().Trim();
- user.EvaUserId = row["EVAUSERNAME"].ToString().Trim();
- user.EvaUserName = row["EVAUSERNAME"].ToString().Trim();
- user.CreateName = UserInfo.GetUserName();
- user.CreateUserId = UserInfo.GetUserID();
- user.CreateTime = DateTime.Now;
- user.Validflag = "1";
- user.EvaOrgName = row["EVAORGNAME"].ToString().Trim();
- user.EvaOrgId = row["EVAORGID"].ToString().Trim();
- list.Add(user);
- }
- if (list.Count <= 0)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceEvaUsersService", "doInsert_Eva", new object[] { list });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("添加失败:" + crt.Resultmsg);
- return;
- }
- else
- {
- MessageUtil.ShowTips("成功添加");
- doQueryEva(oldstrid);
- }
- }
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- /// <summary>
- /// 删除评审人员
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_delete_man_Click(object sender, EventArgs e)
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择价格政策");
- return;
- }
- string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim();
- if (testPriceMStatus(oldstrid, 5) == false)
- {
- return;
- }
- if (ultraGrid3.ActiveRow == null)
- {
- MessageUtil.ShowTips("无可删除项");
- }
- String EvaId = ultraGrid3.ActiveRow.GetCellValue("EvaId").ToString().Trim();
- String EvaUserName = ultraGrid3.ActiveRow.GetCellValue("EVAUSERNAME").ToString().Trim();
- if (String.IsNullOrEmpty(EvaId))
- {
- MessageUtil.ShowTips("评审人意见编号为空");
- }
- BalanceEvaUsers taskEva = new BalanceEvaUsers();
- taskEva.StandId = oldstrid;
- taskEva.EvaId = EvaId;
- taskEva.Validflag = "0";
- taskEva.DeleteName = UserInfo.GetUserName();
- taskEva.DeleteUserId = UserInfo.GetUserID();
- taskEva.DeleteTime = DateTime.Now;
- if (MessageUtil.ShowYesNoAndQuestion("确定移除价格政策:" + oldstrid + " 的评审人员:" + EvaUserName + " ?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceEvaUsersService", "doUpdate", new object[] { taskEva });
- if (re.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败:" + re.Resultmsg);
- return;
- }
- else
- {
- MessageUtil.ShowTips("操作成功");
- doQueryEva(oldstrid);
- return;
- }
- }
- #endregion
- #region 附件处理
- /// <summary>
- /// 选择附件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txt_certPath_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- try
- {
- if (e.Button.Key.ToLower().Equals("insert"))
- {
- OpenFileDialog file = new OpenFileDialog();
- file.Multiselect = false;
- DialogResult drStat;
- drStat = file.ShowDialog();
- if (drStat == DialogResult.OK)
- {
- fileName = file.FileName;
- string filena = System.IO.Path.GetFileName(fileName);
- txt_certPath.Text = filena;
- }
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败:" + ex);
- }
- }
- /// <summary>
- /// 查看附件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void craftImg_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- try
- {
- UltraGridRow row = ultraGrid4.ActiveRow;
- string filePathOld = row.GetValue("certPathOld");
- if (e.Button.Key.ToLower().Equals("select"))
- {
- FrmPopFileShow down = new FrmPopFileShow(this.ob, filePathOld);
- down.DeleteButton.Visible = false;
- down.ShowDialog();
- }
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("操作失败:" + ex);
- }
- }
- /// <summary>
- /// 新增附件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_submitAppend_Click(object sender, EventArgs e)
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("未选择任务单");
- return;
- }
- string strId = ultraGrid1.ActiveRow.GetValue("id");
- if (String.IsNullOrEmpty(strId))
- {
- MessageUtil.ShowTips("价格政策号为空");
- return;
- }
- String filena = txt_certPath.Text.ToString().Trim();
- if (String.IsNullOrEmpty(filena) || String.IsNullOrEmpty(fileName))
- {
- MessageUtil.ShowTips("请选择待上传文件");
- return;
- }
- OrderAppend sat = new OrderAppend();
- sat.OrderId = strId;
- String filePathNew = "Pms/CERT/" + strId + "/";
- sat.CertPath = filena;
- sat.CertPathOld = filePathNew + filena;
- sat.CreateUserid = UserInfo.GetUserID();
- sat.CreateName = UserInfo.GetUserName();
- sat.CreateTime = DateTime.Now;
- sat.Validflag = "1";
- sat.CertDesc = txt_CERTDESC.Text.Trim();
- if (GetCraftFileCraftNoCnt(filena, strId) > 0)
- {
- MessageUtil.ShowTips("合同已存在该附件文件:" + filena);
- return;
- }
- List<FileBean> list = new List<FileBean>();
- FileBean bean = new FileBean();
- bean = new FileBean();
- bean.setFileName(filena);
- bean.setPathName(filePathNew);
- bean.setFile(FileHelper.FileToArray(fileName));
- list.Add(bean);
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
- if (isSuccess)
- {
- //开始写数据库
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderAppendService", "insert_append", new object[] { sat });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("上传失败:" + crt.Resultmsg);
- }
- else
- {
- MessageUtil.ShowTips("上传成功");
- ClearTab5();
- }
- }
- else
- {
- MessageBox.Show("上传失败");
- }
- //刷新界面并激活当前行
- Relocate(sat);
- }
- private void ClearTab5()
- {
- txt_certPath.Clear();
- txt_CERTDESC.Clear();
- fileName = "";
- }
- private void Relocate(OrderAppend sat)
- {
- getOrderAppend(sat.OrderId, sat.CertPath);
- }
- // 加载附件
- private void getOrderAppend(string strOrderId, string p)
- {
- fujian.Clear();
- OrderAppend append = new OrderAppend();
- append.OrderId = strOrderId;
- append.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.order.service.OrderAppendService", "find", new object[] { append, 0, 0 });
- GridHelper.CopyDataToDatatable(dt, dataTable6, true);
- GridHelper.RefreshAndAutoSize(ultraGrid4);
- if (!String.IsNullOrEmpty(p))
- {
- PublicTools.publicPms.doActiveSelRow(ultraGrid4, "CERTPATH", p);
- }
- }
- /// <summary>
- /// 判断是否之前已提交相同的文件
- /// </summary>
- /// <param name="craftNo"></param>
- /// <returns></returns>
- private int GetCraftFileCraftNoCnt(string CERT_PATH, string orderId)
- {
- OrderAppend sat = new OrderAppend();
- sat.CertPath = CERT_PATH;
- sat.OrderId = orderId;
- sat.Validflag = "1";
- int dt = this.execute<int>("com.hnshituo.pur.order.service.OrderAppendService", "count", new object[] { sat });
- return dt;
- }
- /// <summary>
- /// 删除附件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_deleteAppend_Click(object sender, EventArgs e)
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择价格政策头!");
- return;
- }
- String strId = uge.Cells["id"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strId))
- {
- MessageUtil.ShowTips("该价格政策头编号为空!");
- return;
- }
- UltraGridRow rowAppend = ultraGrid4.ActiveRow;
- if (rowAppend == null)
- {
- MessageUtil.ShowTips("请选择需删除的附件!");
- return;
- }
- String strAppendID = rowAppend.Cells["ID"].Value.ToString().Trim();
- String strcertPath = rowAppend.Cells["CERTPATH"].Value.ToString().Trim();
- String strCertPathOld = rowAppend.Cells["CERTPATHOLD"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strAppendID))
- {
- MessageUtil.ShowTips("该价格政策附件编号为空!");
- return;
- }
- if (String.IsNullOrEmpty(strCertPathOld))
- {
- MessageUtil.ShowTips("未获取到任务单附件地址信息!");
- return;
- }
- //验证任务单头是否可以增删改
- if (testOrderAppendStatus(strAppendID, 1) == false)
- {
- return;
- }
- OrderAppend append = new OrderAppend();
- append.Id = strAppendID;
- append.Validflag = "0";
- append.DeleteName = UserInfo.GetUserName();
- append.DeleteTime = DateTime.Now;
- append.DeleteUserid = UserInfo.GetUserID();
- if (MessageUtil.ShowYesNoAndQuestion("确定删除附件:" + strcertPath + "?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.order.service.OrderAppendService", "delete_append", new object[] { append });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("删除失败!" + crt.Resultmsg);
- return;
- }
- else
- {
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Delete(strCertPathOld);
- if (isSuccess)
- {
- MessageUtil.ShowTips("删除成功");
- }
- else
- {
- MessageBox.Show("删除成功");
- }
- }
- getOrderAppend(strId, "");
- }
- /// <summary>
- /// 验证价格政策输入数据的有效性
- /// </summary>
- /// <returns></returns>
- private bool testOrderAppendStatus(String strId, int p)// 验证合同附件
- {
- OrderAppend append = this.execute<OrderAppend>("com.hnshituo.pur.order.service.OrderAppendService", "findById", new object[] { strId });
- if (append == null)
- {
- MessageUtil.ShowTips("未发现价格政策附件:" + strId + "信息记录,可能已作废");
- return false;
- }
- if (append.Validflag != "1")
- {
- MessageUtil.ShowTips("价格政策附件:" + strId + "信息记录可能已作废");
- return false;
- }
- if (append.CreateUserid != UserInfo.GetUserID())
- {
- MessageUtil.ShowTips("非本人上传价格政策附件无权限进行增删改");
- return false;
- }
- if (p == 1)
- {
- }
- else
- {
- MessageUtil.ShowTips("未知参数:" + p + "");
- return false;
- }
- return true;
- }
- #endregion
- private void btn_remark_edit_Click(object sender, EventArgs e)
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- {
- MessageUtil.ShowTips("请选择价格政策头!");
- return;
- }
- String strId = uge.Cells["id"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strId))
- {
- MessageUtil.ShowTips("该价格政策头编号为空!");
- return;
- }
- BalanceBasepriceM pm = new BalanceBasepriceM();
- if (String.IsNullOrEmpty(txt_remark.Text.Trim()))
- {
- MessageUtil.ShowTips("请填写申请部门意见");
- txt_remark.Focus();
- return;
- }
- pm.Remark = txt_remark.Text.Trim();
- pm.Id = strId;
- if(testPriceMStatus(strId,6)==false)
- {
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定修改?") != DialogResult.Yes)
- {
- return;
- }
- pm.UpdateName = UserInfo.GetUserName();
- pm.UpdateTime = System.DateTime.Now;
- pm.UpdateUserid = UserInfo.GetUserID();
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doUpdate", new object[] { pm });
- if (re.Resultcode == 0)
- {
- MessageBox.Show("修改成功", "提示");
- QureyBasePriceM(strId);
- }
- else
- {
- MessageBox.Show("操作失败:" + re.Resultmsg, "提示");
- return;
- }
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key == "priceVal")
- {
- if (ultraGrid1.ActiveRow == null)
- {
- return;
- }
- String strItemCode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strItemCode))
- {
- MessageUtil.ShowTips("该价格政策物料编号不能为空,请维护");
- return;
- }
- if (strItemCode == "Y01010001")
- {
- ultraGrid2.UpdateData();
- double price1 = 0;
- double.TryParse(e.Cell.Row.Cells["priceVal"].Value.ToString(), out price1);
- e.Cell.Row.Cells["priceVal1"].Value = price1 + 20;
- }
- }
- }
- private void ck_createT_CheckedChanged(object sender, EventArgs e)
- {
- txt_createTimeBegin.Enabled = ck_createT.Checked;
- txt_createTimeEnd.Enabled = ck_createT.Checked;
- }
- }
- }
|