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.Collections; using Infragistics.Win.UltraWinGrid; using System.Reflection; namespace Core.LZMes.Client.QCM { public partial class EGIS : FrmBase { public EGIS() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Add": this.DoAdd(); break; case "Update": this.DoUpdate(); break; case "Delete": this.DoDelete(); break; } } //查询 private void DoQuery() { try { this.dataSet1.Clear(); string forName = this.textBox1.Text.Trim(); string proLine = this.textBox2.Text.Trim(); CoreClientParam ccp = new CoreClientParam(); ccp.MethodName = "Query"; ccp.ServerName = "EGIS.QueryEgis"; ccp.ServerParams = new object[]{ forName , proLine }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } //新增 private void DoAdd() { try { ArrayList list = new ArrayList(); foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text.ToString() == "True") { if (ugr.Cells["EGIS_ID"].Text == "") //没有id才加 { list = new ArrayList(); list.Add(ugr.Cells["FOR_NAME"].Text.ToString()); list.Add(ugr.Cells["PRODUCTION_LINE"].Text.ToString()); list.Add(ugr.Cells["NORM"].Text.ToString()); list.Add(ugr.Cells["UNIT_PRICE"].Text.ToString()); } }// if end }//foreach end if (list.Count == 0) return; if (list.Contains("")) { MessageBox.Show("请输入完整信息!", "警告"); return; } CoreClientParam ccp = new CoreClientParam(); ccp.MethodName = "add"; ccp.ServerName = "EGIS.addEgis"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } //更新 private void DoUpdate() { try { ArrayList al = new ArrayList(); foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text.ToString() == "True") { if (ugr.Cells["EGIS_ID"].Text != "")//有id 即数据库有数据 才更新 { al.Add(ugr.Cells["FOR_NAME"].Text.ToString()); al.Add(ugr.Cells["PRODUCTION_LINE"].Text.ToString()); al.Add(ugr.Cells["NORM"].Text.ToString()); al.Add(ugr.Cells["UNIT_PRICE"].Text.ToString()); al.Add(ugr.Cells["EGIS_ID"].Text.ToString()); } }// if end }//foreach end if (al.Count == 0) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "EGIS.SaveEgis"; ccp.MethodName = "Save"; ccp.ServerParams = new object[] { al }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } //删除 public void DoDelete() { try { if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text.ToString() == "True") { if (ugr.Cells["EGIS_ID"].Text != "") //有id才能删 { al.Add(ugr.Cells["EGIS_ID"].Text.ToString()); } }//if end }//for end if (al.Count == 0) return; //没有选择数据 返回 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "EGIS.removeEgis"; ccp.MethodName = "remove"; ccp.ServerParams = new object[] { al[0] }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } } }