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 /// /// 维护界面toolbar /// /// /// 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; } } /// /// 审核 /// 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("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); } } /// /// 导出价格政策 /// 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; } } /// /// 查询 /// 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("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; } } /// /// 生效 /// 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("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); } } /// /// 删除 /// 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("com.hnshituo.pur.balance.service.BalanceBasepriceMService", "doUpdateBasePriceM", new object[] { pm }); if (re.Resultcode == 0) { MessageBox.Show("删除成功", "提示"); QureyBasePriceM(""); } else { MessageBox.Show("操作失败:" + re.Resultmsg, "提示"); return; } } /// /// 保存价格政策 /// private void saveFrmFGPriceMainTain() { try { if (ultraGrid1.ActiveRow == null) { MessageUtil.ShowTips("请选择价格政策进行操作"); return; } List list = new List(); 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("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); } } /// /// 添加 /// 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("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 /// /// 弹出框toolbar /// /// /// 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; } } /// /// 选择价格政策 /// 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("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, ""); } /// /// 物料选择 /// /// /// 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 公共函数 /// /// 校验重复性 /// /// /// /// private bool testPriceM(BalanceBasepriceM pm, int p) { BalanceBasepriceM pp = new BalanceBasepriceM(); pp.Name = pm.Name; pp.Validflag = "1"; DataTable dt = this.execute("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("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; } /// /// 校验政策状态 /// /// /// /// private bool testPriceMStatus(String Id, int p) { if(String.IsNullOrEmpty(Id)) { MessageUtil.ShowTips("价格政策头编号为空"); return false; } BalanceBasepriceM pm= this.execute("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("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("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; } /// /// 清空编辑区 /// private void clearTab() { edtName.Clear(); txt_effectTime.Value = DateTime.Now; txt_VersionNo.Clear(); txt_remark.Clear(); txt_itemCode.Text = "-"; txt_itemName.Clear(); } /// /// 给控件赋值 /// /// 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("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; } /// /// 查询行 /// /// /// private void doQueryBasePriceC(String strId, String strItemCode) { dataTable2.Clear(); BalanceBasepriceC pc = new BalanceBasepriceC(); pc.StandId = strId; pc.Validflag = "1"; DataTable re = this.execute("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("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); } } /// /// 查询评审人员 /// /// private void doQueryEva(string strId) { dataTable4.Clear(); BalanceEvaUsers pc = new BalanceEvaUsers(); pc.StandId = strId; pc.Validflag = "1"; DataTable re = this.execute("com.hnshituo.pur.balance.service.BalanceEvaUsersService", "doQureyEva", new object[] { pc }); GridHelper.CopyDataToDatatable(re, dataTable4, true); GridHelper.RefreshAndAutoSize(ultraGrid3); } #endregion #region 评审人员处理 /// /// 新增评审人员 /// /// /// 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("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); } /// /// 删除评审人员 /// /// /// 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("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 附件处理 /// /// 选择附件 /// /// /// 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); } } /// /// 查看附件 /// /// /// 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); } } /// /// 新增附件 /// /// /// 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 list = new List(); 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("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("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); } } /// /// 判断是否之前已提交相同的文件 /// /// /// 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("com.hnshituo.pur.order.service.OrderAppendService", "count", new object[] { sat }); return dt; } /// /// 删除附件 /// /// /// 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("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, ""); } /// /// 验证价格政策输入数据的有效性 /// /// private bool testOrderAppendStatus(String strId, int p)// 验证合同附件 { OrderAppend append = this.execute("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("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; } } }