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 CoreFS.CA06; using System.Diagnostics; using System.Collections; using Infragistics.Win.UltraWinGrid; namespace Core.LZMes.Client.UIB { public partial class UIB010330 : FrmBase { public UIB010330() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Save": this.DoSave(); break; case "Delete": this.DoDelete(); break; } } //初始化下拉框数据 public void init() { DataTable dt = new DataTable(); ArrayList al = new ArrayList(); al.Add("UIB010330_01.INITSELECT"); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = dt; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); Init_ComboControl(this.SPECSTLGRD_comboBox, ref dt); dt = new DataTable(); al = new ArrayList(); al.Add("UIB010330_02.INITSELECT"); ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = dt; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); Init_ComboControl(this.SPECABBSYM_comboBox, ref dt); dt = new DataTable(); al = new ArrayList(); al.Add("UIB010330_04.INITSELECT"); ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = dt; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); Init_ComboControl(this.ultraComboEditor1, ref dt); dt = new DataTable(); al = new ArrayList(); al.Add("UIB010330_03.INITSELECT"); ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = dt; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); Init_ComboControl(this.ultraComboEditor2, ref dt); } public static void Init_ComboControl(System.Windows.Forms.Control ComboControl, ref System.Data.DataTable dt) { System.Data.DataView dtview = new System.Data.DataView(dt); ((Infragistics.Win.UltraWinEditors.UltraComboEditor)ComboControl).DataSource = dtview; ((Infragistics.Win.UltraWinEditors.UltraComboEditor)ComboControl).DisplayMember = "SM_CFNM"; ((Infragistics.Win.UltraWinEditors.UltraComboEditor)ComboControl).ValueMember = "SM_CD"; } public void DoQuery() { try { this.dataSet1.Tables[0].Clear(); ArrayList al = new ArrayList(); al.Add("UIB010330_02.SELECT"); if (this.SPECABBSYM_comboBox.Value == null) { al.Add(""); al.Add(""); } else { al.Add(this.SPECABBSYM_comboBox.Value.ToString()); al.Add(this.SPECABBSYM_comboBox.Value.ToString()); } if (this.SPECSTLGRD_comboBox.Value == null) { al.Add(""); al.Add(""); } else { al.Add(this.SPECSTLGRD_comboBox.Value.ToString()); al.Add(this.SPECSTLGRD_comboBox.Value.ToString()); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } public void DoSave() { try { if (MessageBox.Show("确定保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; if (this.ultraGrid1.ActiveRow == null) return; string p_cd = this.ultraGrid1.ActiveRow.Cells["PRDNM_CD"].Text.ToString(); string sp_abbsym = this.ultraGrid1.ActiveRow.Cells["SPEC_ABBSYM"].Text.ToString(); string sp_stlgrd = this.ultraGrid1.ActiveRow.Cells["SPEC_STL_GRD"].Text.ToString(); CoreClientParam ccp = null; ArrayList al = new ArrayList(); ArrayList list = null; foreach (UltraGridRow ugr in this.ultraGrid3.Rows) { list = new ArrayList(); if (ugr.Cells["PROD_VAL"].Text.ToString() != "") { ccp = new CoreClientParam(); ArrayList als = new ArrayList(); //判断是否存在该项目值 als.Add("UIB010330_11.SELECT"); als.Add(p_cd); als.Add(sp_abbsym); als.Add(sp_stlgrd); als.Add(ugr.Cells["PROD_CD"].Text.ToString()); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { als }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); int num = 0; if (null != ccp.SourceDataTable) num = ccp.SourceDataTable.Rows.Count; if (num <= 0) //不存在则为插入 { list.Add("UIB010330_01.INSERT"); list.Add(p_cd); list.Add(sp_abbsym); list.Add(sp_stlgrd); list.Add(ugr.Cells["PROD_CD"].Text.ToString()); list.Add(ugr.Cells["PROD_TYPE"].Text.ToString()); list.Add(ugr.Cells["DCS_SYM"].Text.ToString()); list.Add(ugr.Cells["PROD_VAL"].Text.ToString()); list.Add(ugr.Cells["MEMO"].Text.ToString()); list.Add(this.UserInfo.GetUserName()); } else //否则则为修改 { list.Add("UIB010330_02.UPDATE"); list.Add(ugr.Cells["PROD_VAL"].Text.ToString()); list.Add(ugr.Cells["MEMO"].Text.ToString()); list.Add(this.UserInfo.GetUserName()); list.Add(p_cd); list.Add(sp_abbsym); list.Add(sp_stlgrd); list.Add(ugr.Cells["PROD_CD"].Text.ToString()); } } else //若值为空则删除对应项目 { list.Add("UIB010330_02.DELETE"); list.Add(p_cd); list.Add(sp_abbsym); list.Add(sp_stlgrd); list.Add(ugr.Cells["PROD_CD"].Text.ToString()); } al.Add(list); } if (al.Count == 0) return; ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { al }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } public void DoDelete() { try { if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; if (this.ultraGrid1.ActiveRow == null) return; ArrayList al = new ArrayList(); al.Add("UIB010330_01.DELETE"); al.Add(this.ultraGrid1.ActiveRow.Cells["PRDNM_CD"].Text.ToString()); al.Add(this.ultraGrid1.ActiveRow.Cells["SPEC_ABBSYM"].Text.ToString()); al.Add(this.ultraGrid1.ActiveRow.Cells["SPEC_STL_GRD"].Text.ToString()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { al }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void UIB010330_Load(object sender, EventArgs e) { init(); } //点击某行查询右边规范标准信息 private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { if (this.ultraGrid1.ActiveRow == null) return; //if (this.ultraGrid1.ActiveRow.Selected == false) return; this.dataSet2.Tables[0].Clear(); CoreClientParam ccp = new CoreClientParam(); ArrayList al = new ArrayList(); al.Add("UIB010330_12.SELECT"); al.Add(this.ultraGrid1.ActiveRow.Cells["PRDNM_CD"].Text.ToString()); al.Add(this.ultraGrid1.ActiveRow.Cells["SPEC_ABBSYM"].Text.ToString()); al.Add(this.ultraGrid1.ActiveRow.Cells["SPEC_STL_GRD"].Text.ToString()); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } //private void ultraGrid1_AfterRowUpdate(object sender, RowEventArgs e) //{ //} //private void ultraGrid1_CellChange(object sender, CellEventArgs e) //{ // if (MessageBox.Show("数据有改动需要保存吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) // return; //} } }