using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using Infragistics.Win.UltraWinGrid; using System.Collections; using System.Windows.Forms; using CoreFS.CA06; namespace Core.LZMes.Client.UIB { public partial class UIB010320 : FrmBase { public UIB010320() { 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("UIB010320_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.ultraComboEditor1, ref dt); DoQuery(); //DataTable dt = new DataTable(); //CoreClientParam ccp = new CoreClientParam(); //dt = new DataTable(); //ccp = new CoreClientParam(); //ccp.ServerName = "UIB.COM.ComDBQuery"; //ccp.MethodName = "doSimpleQuery"; //paramArray = new ArrayList(); //paramArray.Add("UIECOMM00_SELECT.C_STL_GRD"); //ccp.ServerParams = new object[] { paramArray }; //ccp.SourceDataTable = dt; //this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //Core.LZMes.Client.UIE.UIE041.UIEBase.Init_ComboControl(this.ComboColdStlGrd, ref dt, "C_STL_GRD"); //dt = new DataTable(); //ccp = new CoreClientParam(); //ccp.ServerName = "UIB.COM.ComDBQuery"; //ccp.MethodName = "doSimpleQuery"; //paramArray = new ArrayList(); //paramArray.Add("UIECOMM00_SELECT.H_STL_GRD"); //ccp.ServerParams = new object[] { paramArray }; //ccp.SourceDataTable = dt; //this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //Core.LZMes.Client.UIE.UIE041.UIEBase.Init_ComboControl(this.ComboHotStlGrd, ref dt, "H_STL_GRD"); } public void DoQuery() { try { this.dataSet1.Tables[0].Clear(); ArrayList al = new ArrayList(); al.Add("UIB010320_01.SELECT"); 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 DoInsert() //{ // try // { // int num = this.ultraGrid1.Rows.Count; // this.ultraGrid1.Rows[num - 1].Cells["DISPLAY_SEQ"].Value.ToString(); // this.ultraGrid1.Rows[num - 1].Cells["PROD_TYPE"].Text.ToString(); // this.ultraGrid1.Rows[num - 1].Cells["PROD_CD_CFNM"].Text.ToString(); // this.ultraGrid1.Rows[num - 1].Cells["DCS_SYM"].Text.ToString(); // } // catch (Exception ex) // { // MessageBox.Show(ex.ToString()); // } //} public void DoSave() { try { if (MessageBox.Show("确定保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); ArrayList list = null; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { if (ugr.Cells["PROD_CD"].Text.ToString() == "") { MessageBox.Show("生产规范代码不允许为空!", "提示"); return; } list = new ArrayList(); if (ugr.Cells["EDIT_PROD"].Text == "")//插入 { list.Add("UIB010320_01.INSERT"); list.Add(ugr.Cells["PROD_CD"].Text.ToString()); list.Add(ugr.Cells["DISPLAY_SEQ"].Text.ToString()); list.Add(ugr.Cells["PROD_TYPE"].Text.ToString()); list.Add(ugr.Cells["PROD_CD_CFNM"].Text.ToString()); list.Add(ugr.Cells["DCS_SYM"].Text.ToString()); list.Add(this.UserInfo.GetUserName()); } else//更新 { list.Add("UIB010320_01.UPDATE"); list.Add(ugr.Cells["PROD_CD"].Text.ToString()); list.Add(ugr.Cells["DISPLAY_SEQ"].Text.ToString()); list.Add(ugr.Cells["PROD_TYPE"].Text.ToString()); list.Add(ugr.Cells["PROD_CD_CFNM"].Text.ToString()); list.Add(ugr.Cells["DCS_SYM"].Text.ToString()); list.Add(this.UserInfo.GetUserName()); list.Add(ugr.Cells["EDIT_PROD"].Text.ToString()); } al.Add(list); } } if (al.Count == 0) { MessageBox.Show("请勾选数据再做保存操作!", "提示"); return; } 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()); } } public void DoDelete() { try { if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); ArrayList list = null; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { list = new ArrayList(); list.Add("UIB010320_01.DELETE"); list.Add(ugr.Cells["PROD_CD"].Text.ToString()); al.Add(list); } } 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()); } } 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"; //try //{ // switch (ComboControl.GetType().ToString()) // { // case "Infragistics.Win.UltraWinEditors.UltraComboEditor": // break; // } //} //catch (System.Exception ex) //{ // System.Diagnostics.Debug.WriteLine(ex.ToString()); //} } private void UIB010320_Load(object sender, EventArgs e) { init(); } //自定义单元格数据错误提示框 private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e) { e.RaiseErrorEvent = false; e.StayInEditMode = true; MessageBox.Show("输入数据的格式不正确,请校验"); } } }