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 com.hnshituo.pur.vo; using Infragistics.Win.UltraWinEditors; using CoreFS.CA06;using Pur.Entity; using Core.Mes.Client.Comm.Control; using Pur.require_plan; using Pur.Pop_upWindow; using Pur.Entity; namespace Pur.Balance { public partial class FrmPurCicpPrice : FrmPmsBase { public FrmPurCicpPrice() { InitializeComponent(); } private void FrmPurCicpPrice_Load(object sender, EventArgs e) { clearEdtArea(); QureyCicpPriceM(); } #region toolbar工具栏 //toolbar工具栏加载 public override void ToolBar_Click(object sender, string ToolBarKey) { switch (ToolBarKey) { case "Query"://查询基价标准主表数据 QureyCicpPriceM(); //GetQueryPhysicWH(); break; case "Add"://增加基价标准主表 AddCicpPriceM(); break; case "Update"://修改基价标准主表 EditCicpPriceM(); break; case "Delete"://删除基价标准主表 DeleteCicpPriceM(); break; case "AddCicpPriceC": //新增基价标准明细表 AddCicpPriceC(); break; case "UpdateCicpPriceC"://修改基价标准明细表 EditCicpPriceC(); break; case "DeleteCicpPriceC"://删除基价标准明细表 DeleteCicpPriceC(); break; case "Close"://关闭窗口 this.Close(); break; } } #endregion #region toolbar事件 /// /// 删除一条明细 /// private void DeleteCicpPriceC() { try { //判断是否获取到焦点 if (ultraGrid2.ActiveRow != null) { string oldstrid = ultraGrid2.ActiveRow.Cells["id"].Value.ToString().Trim(); string oldstrstandid = ultraGrid2.ActiveRow.Cells["standId"].Value.ToString().Trim(); string oldchemcode = ultraGrid2.ActiveRow.Cells["chemCode"].Value.ToString().Trim(); ; //提示是否需要修改 if (MessageBox.Show("将修改明细表ID为[" + oldstrid + "]的信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { //构建实体类 BalanceCicpriceC pc = new BalanceCicpriceC(); pc.Validflag = "0"; pc.Id = oldstrid; pc.ChemCode = oldchemcode; pc.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); pc.DeleteTime = DateTime.Now; pc.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); //调用服务接口 CoreResult re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doUpdateCicpPriceC", new object[] { pc }); if (re.Resultcode == 0) { //DataTable tempData = (DataTable)re.Resultdata; //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true); MessageBox.Show("删除成功", "提示"); QureyCicpPriceM(); BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", oldstrstandid); } else { MessageBox.Show("操作失败:" + re.Resultmsg, "提示"); return; } } } else { MessageBox.Show("操作失败:请选择需修改的成分计价标准行", "提示"); return; } } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } private void EditCicpPriceC() { try { //判断是否获取到焦点 if (ultraGrid2.ActiveRow != null) { string strid = ultraGrid2.ActiveRow.Cells["id"].Value.ToString().Trim(); string strstandid = ultraGrid2.ActiveRow.Cells["standId"].Value.ToString().Trim(); //获取编辑框信息 // string strid = edtIdC.Text.ToString().Trim(); string strchemCode = edtChemCode.Text.ToString().Trim(); string strremark = edtRemarkC.Text.ToString().Trim(); double dbaddSubtValue = (double)edtAddSubtValue.Value; //构建实体类 BalanceCicpriceC pc = new BalanceCicpriceC(); //校验编辑框信息 if (edtup.Checked) { if (edtmaxVal.Value == null || edtMaxSign.Value==null) { MessageBox.Show("上限符号和上限值不能为空","提升"); edtmaxVal.Focus(); return; } else { pc.MaxVal = (double)edtmaxVal.Value; pc.MaxSign = edtMaxSign.Text; } } if (edtdown.Checked) { if(edtMinVal.Value==null||edtMinSign.Value==null) { MessageBox.Show("下限符号和下限值不能为空","提升"); edtMinVal.Focus(); return; } else { pc.MinVal = (double)edtMinVal.Value; pc.MinSign = edtMinSign.Text; } } if (edtup.Checked && edtdown.Checked) { double ii = (double)edtMinVal.Value; double jj = (double)edtmaxVal.Value; if (ii > jj) { MessageBox.Show("上限不能小于下限", "提示"); edtmaxVal.Focus(); return; } } if (string.IsNullOrEmpty(strid)) { MessageBox.Show("操作失败:ID不能为空", "提示"); edtId.Focus(); return; } if (string.IsNullOrEmpty(strstandid)) { MessageBox.Show("操作失败:标准号为空", "提示"); edtStandId.Focus(); return; } if (string.IsNullOrEmpty(strchemCode)) { MessageBox.Show("操作失败:元素编号为空", "提示"); edtChemCode.Focus(); return; } if (edtAddSubtValue.Value == null || edtAddSubtValue.Value.ToString()=="") { MessageBox.Show("操作失败:请输入加减额度", "提示"); edtAddSubtValue.Focus(); return; } //提示是否需要修改 if (MessageBox.Show("将修改明细表ID为[" + strid + "]的信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { pc.Id = strid; pc.StandId=strstandid; pc.Remark = strremark; pc.Validflag = "1"; pc.ChemCode = strchemCode; pc.AddSubtValue = dbaddSubtValue; pc.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); pc.UpdateTime = DateTime.Now; pc.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); //调用服务接口 CoreResult re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doUpdateCicpPriceC", new object[] { pc }); if (re.Resultcode == 0) { //DataTable tempData = (DataTable)re.Resultdata; //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true); MessageBox.Show("修改成功", "提示"); QureyCicpPriceM(); BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", strstandid); BalanceClassCommon.doActiveSelRow(ultraGrid2, "id", strid); } else { MessageBox.Show("操作失败:" + re.Resultmsg, "提示"); return; } } } else { MessageBox.Show("操作失败:请选择需修改的基价标准明细行", "提示"); return; } } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } private void AddCicpPriceC() { try { //判断是否获取到焦点 if (ultraGrid1.ActiveRow != null) { string strstandid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim(); //获取编辑框信息 string strchemCode = edtChemCode.Text.ToString().Trim(); string strchemname=edtChemName.Text.ToString().Trim(); string strremark = edtRemarkC.Text.ToString().Trim(); double dbaddSubtValue = (double)edtAddSubtValue.Value; //构建实体类 BalanceCicpriceC pc = new BalanceCicpriceC(); //校验编辑框信息 if (edtup.Checked) { if (edtmaxVal.Value == null || edtMaxSign.Value==null) { MessageBox.Show("上限符号和上限值不能为空","提升"); edtmaxVal.Focus(); return; } else { pc.MaxVal = (double)edtmaxVal.Value; pc.MaxSign = edtMaxSign.Text; } } if (edtdown.Checked) { if(edtMinVal.Value==null||edtMinSign.Value==null) { MessageBox.Show("下限符号和下限值不能为空","提升"); edtMinVal.Focus(); return; } else { pc.MinVal = (double)edtMinVal.Value; pc.MinSign = edtMinSign.Text; } } if (edtup.Checked && edtdown.Checked) { if ((double)edtMinVal.Value > (double)edtmaxVal.Value) { MessageBox.Show("上限不能小于下限", "提示"); edtmaxVal.Focus(); return; } } if (string.IsNullOrEmpty(strstandid)) { MessageBox.Show("操作失败:标准号为空", "提示"); edtStandId.Focus(); return; } if (string.IsNullOrEmpty(strchemCode)) { MessageBox.Show("操作失败:元素编号为空", "提示"); edtChemCode.Focus(); return; } if (edtAddSubtValue.Value == null || edtAddSubtValue.Value.ToString()=="") { MessageBox.Show("操作失败:请输入加减额度", "提示"); edtAddSubtValue.Focus(); return; } //提示是否需要修改 if (MessageBox.Show("将新增元素为[" + strchemname + "]的一条明细信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { pc.StandId = strstandid; pc.Remark = strremark; pc.Validflag = "1"; pc.ChemCode = strchemCode; pc.AddSubtValue = dbaddSubtValue; pc.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); pc.CreateTime = DateTime.Now; pc.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); //调用服务接口 CoreResult re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doAddCicpPriceC", new object[] { pc }); if (re.Resultcode == 0) { //DataTable tempData = (DataTable)re.Resultdata; //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true); MessageBox.Show("新增成功", "提示"); QureyCicpPriceM(); BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", strstandid); BalanceClassCommon.doActiveSelRow(ultraGrid2, "chemCode", strchemCode); } else { MessageBox.Show("操作失败:" + re.Resultmsg, "提示"); return; } } } else { MessageBox.Show("操作失败:请选择需新增的基价标准行", "提示"); return; } } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } /// /// 删除一条成分计价标准主表行信息 /// private void DeleteCicpPriceM() { try { //判断是否获取到焦点 if (ultraGrid1.ActiveRow != null) { string strId = ultraGrid1.ActiveRow.Cells["Id"].Value.ToString().Trim(); string strname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim(); string stritemcode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim(); //提示是否需要修改 if (MessageBox.Show("将删除名称为[" + strname + "]的成分计价标准信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { //构建实体类 BalanceCicpriceM pm = new BalanceCicpriceM(); pm.Validflag = "0"; pm.Id = strId; pm.ItemCode = stritemcode; pm.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); pm.DeleteTime = DateTime.Now; pm.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); //调用服务接口 CoreResult re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doUpdateCicpPriceM", new object[] { pm }); if (re.Resultcode == 0) { //DataTable tempData = (DataTable)re.Resultdata; //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true); MessageBox.Show("删除成功", "提示"); QureyCicpPriceM(); } else { MessageBox.Show("操作失败:" + re.Resultmsg, "提示"); return; } } } else { MessageBox.Show("操作失败:请选择需删除的成分计价标准行", "提示"); return; } } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } /// /// 编辑成分计价标准行信息 /// private void EditCicpPriceM() { try { //判断是否获取到焦点 if (ultraGrid1.ActiveRow != null) { string oldstrid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim(); string oldstrname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim(); //获取编辑框信息 string strname = edtName.Text.ToString().Trim(); string stritemCode = edtItemCode.Text.ToString().Trim(); string strremark = edtRemark.Text.ToString().Trim(); string stritemattrId = edtItemAttrId.Text.ToString().Trim(); //校验编辑框信息 if (string.IsNullOrEmpty(oldstrid)) { MessageBox.Show("操作失败:ID不能为空", "提示"); edtId.Focus(); return; } if (string.IsNullOrEmpty(strname)) { MessageBox.Show("操作失败:名称不能为空", "提示"); edtName.Focus(); return; } if (string.IsNullOrEmpty(stritemCode)) { MessageBox.Show("操作失败:请选择物料", "提示"); edtItemCode.Focus(); return; } //提示是否需要修改 if (MessageBox.Show("将修改名称为[" + oldstrname + "]的成分计价标准信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { //构建实体类 BalanceCicpriceM pm = new BalanceCicpriceM(); pm.Id = oldstrid; pm.Name = strname; pm.ItemCode = stritemCode; pm.ItemAttrId = stritemattrId; pm.Remark = strremark; pm.Validflag = "1"; pm.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); pm.UpdateTime = DateTime.Now; pm.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); //调用服务接口 CoreResult re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doUpdateCicpPriceM", new object[] { pm }); if (re.Resultcode == 0) { //DataTable tempData = (DataTable)re.Resultdata; //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true); MessageBox.Show("修改成功", "提示"); QureyCicpPriceM(); BalanceClassCommon.doActiveSelRow(ultraGrid1, "id", oldstrid); } else { MessageBox.Show("操作失败:" + re.Resultmsg, "提示"); return; } } } else { MessageBox.Show("操作失败:请选择需修改的成分计价标准行", "提示"); return; } } catch (Exception ex) { MessageBox.Show("操作失败" + ex.Message, "提示"); } } /// /// 新增一条基价标准主表行信息 /// private void AddCicpPriceM() { try { //获取编辑框信息 string strname = edtName.Text.ToString().Trim(); string stritemCode = edtItemCode.Text.ToString().Trim(); string strremark = edtRemark.Text.ToString().Trim(); string stritemattrId = edtItemAttrId.Text.ToString().Trim(); //校验编辑框信息 if (string.IsNullOrEmpty(strname)) { MessageBox.Show("操作失败:名称不能为空", "提示"); edtName.Focus(); return; } if (string.IsNullOrEmpty(stritemCode)) { MessageBox.Show("操作失败:请选择物料", "提示"); edtItemCode.Focus(); return; } //构建实体类 BalanceCicpriceM pm = new BalanceCicpriceM(); pm.Name = strname; pm.ItemCode = stritemCode; pm.ItemAttrId=stritemattrId; pm.Remark = strremark; pm.Validflag = "1"; pm.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); pm.CreateTime = DateTime.Now; pm.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); //调用服务接口 CoreResult re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doAddCicpPriceM", new object[] { pm }); if (re.Resultcode == 0) { //DataTable tempData = (DataTable)re.Resultdata; //GridHelper.CopyDataToDatatable(ref re.Resultdata, ref dataTable1, true); MessageBox.Show("新增成功", "提示"); QureyCicpPriceM(); BalanceClassCommon.doActiveSelRow(ultraGrid1, "name", strname); } else { MessageBox.Show("操作失败:" + re.Resultmsg, "提示"); return; } } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } /// /// 查询主表数据 /// private void QureyCicpPriceM() { try { //获取查询框数据 string strid = QId.Text.ToString().Trim(); string strname = Qname.Text.ToString().Trim(); //构建查询实体类 BalanceCicpriceM pm = new BalanceCicpriceM(); pm.Id = strid; pm.ItemName = strname; //调用服务器查询API进行查询 DataTable re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceMService", "doQureyCicpPriceM", new object[] { pm }); GridHelper.CopyDataToDatatable(ref re, ref dataTable1, true); } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } #endregion #region 页面点击事件 private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { try { //加载数据到编辑区 string strid = ultraGrid1.ActiveRow.Cells["id"].Value.ToString().Trim(); string strname = ultraGrid1.ActiveRow.Cells["name"].Value.ToString().Trim(); string stritemCode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim(); string stritemName = ultraGrid1.ActiveRow.Cells["itemName"].Value.ToString().Trim(); string strremark = ultraGrid1.ActiveRow.Cells["remark"].Value.ToString().Trim(); string stritemAttr = ultraGrid1.ActiveRow.Cells["itemAttr"].Value.ToString().Trim(); string stritemAttrId = ultraGrid1.ActiveRow.Cells["itemAttrId"].Value.ToString().Trim(); edtId.Text = strid; edtName.Text = strname; edtItemCode.Text = stritemCode; edtItemName.Text = stritemName; edtRemark.Text = strremark; edtItemAttr.Text = stritemAttr; edtItemAttrId.Text = stritemAttrId; //获取页面点击行的ID if (string.IsNullOrEmpty(strid)) { MessageBox.Show("操作失败:获取的ID为空", "提示"); } //构建实体类 BalanceCicpriceC pc = new BalanceCicpriceC(); pc.StandId = strid; pc.Validflag = "1"; //调用服务器查询API进行查询 DataTable re = this.execute("com.hnshituo.pur.balance.service.BalanceCicpriceCService", "doQureyCicpPriceC", new object[] { pc }); GridHelper.CopyDataToDatatable(ref re, ref dataTable2, true); } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { try { //加载数据到编辑区 string strid = ultraGrid2.ActiveRow.Cells["id"].Value.ToString().Trim(); string strremark = ultraGrid2.ActiveRow.Cells["remark"].Value.ToString().Trim(); string strstandId = ultraGrid2.ActiveRow.Cells["standId"].Value.ToString().Trim(); string strmaxsign = ultraGrid2.ActiveRow.Cells["maxSign"].Value.ToString().Trim(); string strminsign = ultraGrid2.ActiveRow.Cells["minSign"].Value.ToString().Trim(); if (ultraGrid2.ActiveRow.Cells["minVal"].Value == null) { edtMinVal.Value = null; } else { edtMinVal.Value =ultraGrid2.ActiveRow.Cells["minVal"].Value; } if(ultraGrid2.ActiveRow.Cells["maxVal"].Value == null) { edtmaxVal.Value = null; } else { edtmaxVal.Value = ultraGrid2.ActiveRow.Cells["maxVal"].Value; } if(ultraGrid2.ActiveRow.Cells["addSubtValue"].Value!=null) { edtAddSubtValue.Value=ultraGrid2.ActiveRow.Cells["addSubtValue"].Value; } else{ MessageBox.Show("数据异常:明细表ID为"+strid+"的加减额度为空","提示"); return; } string strchemCode = ultraGrid2.ActiveRow.Cells["chemCode"].Value.ToString().Trim(); string strchemName = ultraGrid2.ActiveRow.Cells["chemName"].Value.ToString().Trim(); edtIdC.Text = strid; edtRemarkC.Text = strremark; edtStandId.Text = strstandId; edtMaxSign.Text = strmaxsign; edtMinSign.Text = strminsign; edtChemCode.Text = strchemCode; edtChemName.Text = strchemName; //上限和下限是否可以判断 if (strmaxsign == "" || strmaxsign == null) { edtup.Checked = false; } else { edtup.Checked = true; } if (strminsign == "" || strminsign == null) { edtdown.Checked = false; } else { edtdown.Checked = true; } } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.Message, "提示"); } } private void clearEdtArea() { foreach (Control ctr in ultraExpandableGroupBox1.Controls) { if (ctr is Label) { continue; } if (ctr is UltraCheckEditor) { UltraCheckEditor ultcmb = (UltraCheckEditor)ctr; ultcmb.Checked = false; } if (ctr is UltraComboEditor) { UltraComboEditor ultcmb = (UltraComboEditor)ctr; ultcmb.Text = ""; ultcmb.Enabled = false; } if (ctr is CheckBox) { CheckBox cb = (CheckBox)ctr; cb.Checked = false; } ctr.Text = null; edtmaxVal.Enabled = false; edtMaxSign.Enabled = false; edtmaxVal.Value = null; edtMaxSign.Text = ""; edtMinVal.Enabled = false; edtMinSign.Enabled = false; edtMinVal.Value = null; edtMinSign.Text = ""; } } private void edtup_CheckedChanged(object sender, EventArgs e) { if (edtup.Checked) { edtmaxVal.Enabled = true; edtMaxSign.Enabled = true; } else { edtmaxVal.Enabled = false; edtMaxSign.Enabled = false; edtmaxVal.Value = null; edtMaxSign.Text = ""; } } private void edtdown_CheckedChanged(object sender, EventArgs e) { if (edtdown.Checked) { edtMinVal.Enabled = true; edtMinSign.Enabled = true; } else { edtMinVal.Enabled = false; edtMinSign.Enabled = false; edtMinVal.Value = null; edtMinSign.Text = ""; } } private void edtItemName_EditorButtonClick(object sender, EditorButtonEventArgs e) { FrmPurPlanMat matfrm = new FrmPurPlanMat(this.ob); matfrm.ShowDialog(); string strmatcode = matfrm.getItemCode(); string strmatname = matfrm.getItemName(); string stritemAttr = matfrm.ItemAttr; string stritemAttrId = matfrm.ItemAttrId; edtItemCode.Text = strmatcode; edtItemName.Text = strmatname; edtItemAttr.Text = stritemAttr; edtItemAttrId.Text = stritemAttrId; } private void edtChemName_EditorButtonClick(object sender, EditorButtonEventArgs e) { FrmPop_upChem chemfrm = new FrmPop_upChem(this.ob); chemfrm.ShowDialog(); string strchemcode = chemfrm.ChemCode; string strchemname = chemfrm.ChemName; edtChemCode.Text = strchemcode; edtChemName.Text = strchemname; } private void ultraGrid1_AfterCellActivate(object sender, EventArgs e) { ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0]; } private void ultraGrid2_AfterCellActivate(object sender, EventArgs e) { ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1]; } #endregion } }