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 System.Diagnostics; namespace Core.LZMes.Client.UIK { public partial class UIK010080 : FrmBase { public UIK010080() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query"://查询 this.DoQuery(); break; case "Insert"://添加反射率检验记录 this.DoInsert(); break; case "Update"://修改反射率检验记录 this.DoUpdate(); break; case "Export": this.DoExport(); break; case "Delete"://删除反射率检验记录 this.DoDelete(); break; } } private void UIK010080_Load(object sender, EventArgs e) { this.ultraDateTimeEditor1.Enabled = this.checkBox1.Checked; this.ultraDateTimeEditor2.Enabled = this.checkBox1.Checked; } private void DoQuery() { try { ArrayList al = new ArrayList(); al.Add("UIK010080_01.SELECT"); //al.Add(this.textBox9_coilNo.Text.Trim());//钢卷号 //al.Add(this.textBox3_stl_grd.Text.Trim());//牌号 if (this.checkBox1.Checked) { al.Add(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"));//日期 al.Add(this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd"));//日期 } else { al.Add(""); al.Add(""); } this.dataSet2.Tables[0].Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataRowCollection drc1 = this.dataSet2.Tables[0].Rows; if (drc1.Count <= 0) { MessageBox.Show("暂无记录!"); } this.clearTextBoxData(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void DoUpdate() { if (MessageBox.Show("您确认要修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { try { Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid2.ActiveRow; if (ugr.Cells["SELECT_ITEM"].Text.ToString() == "True") { if (this.ultraTextEditor_no.Text == "") { MessageBox.Show("该记录不存在,不能修改!", "提示"); return; } ArrayList list = new ArrayList(); list.Add("UIK010080_01.UPDATE"); list.Add(this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd")); list.Add(this.ultraTextsmptime.Text.ToString());//取样时间 list.Add(this.smplocat.Text.ToString());//取样地点 list.Add(this.ultraTextsmpcunt.Text.ToString());//取样百分比 list.Add(this.ultraTextEditor1.Text.ToString());//取样人 list.Add(ugr.Cells["dateno"].Text); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); this.clearTextBoxData(); } else { MessageBox.Show("请选择修改行!"); } } catch (Exception Ex) { MessageBox.Show(Ex.ToString()); } } } private void DoInsert() { if (MessageBox.Show("您确认要添加数据吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { try { if (this.ultraTextEditor_no.Text.ToString() != "") { MessageBox.Show("请不要勾选行记录!", "提示"); return; } ArrayList list = new ArrayList(); list.Add("UIK010080_01.INSERT"); list.Add(this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd")); list.Add(this.smplocat.Text.ToString()); list.Add(this.ultraTextsmptime.Text.ToString()); list.Add(this.ultraTextsmpcunt.Text.ToString()); list.Add(this.ultraTextEditor1.Text.ToString()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); this.clearTextBoxData(); } catch (Exception Ex) { MessageBox.Show(Ex.ToString()); } } } public void DoDelete() { try { if (MessageBox.Show("确定删除选中的记录?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid2.ActiveRow; if (ugr.Cells["SELECT_ITEM"].Text.ToString() == "True") { if (ugr.Cells["DATENO"].Text.ToString() == "") { MessageBox.Show("该记录不存在!", "提示"); return; } ArrayList list = new ArrayList(); list.Add("UIK010080_01.delete"); list.Add(ugr.Cells["DATENO"].Text.ToString()); //list.Add(ugr.Cells["REG_DTIME"].Text.ToString()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); this.clearTextBoxData(); } else { MessageBox.Show("请选择需要删除的记录!"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } public void DoExport() { try { if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fName = this.saveFileDialog1.FileName; this.ultraGridExcelExporter1.Export(this.ultraGrid2, fName); Process.Start(fName); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } //清空编辑区域的数据 private void clearTextBoxData() { this.ultraTextEditor_no.Clear(); this.smplocat.Clear(); this.ultraTextsmptime.Clear(); this.ultraTextsmpcunt.Clear(); this.ultraTextEditor1.Clear(); //this.ultraTextEditor_no.Text = edit_no; //this.smplocat.Text = e.Cell.Row.Cells["smp_locat"].Text; //this.ultraTextsmptime.Text = e.Cell.Row.Cells["smp_dtime"].Text; //this.ultraTextsmpcunt.Text = e.Cell.Row.Cells["smp_cont"].Text; //this.ultraTextEditor1.Text = e.Cell.Row.Cells["regman"].Text; } //时间查询参数选择事件 private void checkBox1_Click(object sender, EventArgs e) { this.ultraDateTimeEditor1.Enabled = this.checkBox1.Checked; this.ultraDateTimeEditor2.Enabled = this.checkBox1.Checked; } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { } private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (e.Cell.Column.Key == "SELECT_ITEM") { if (e.Cell.Text == "True") { string edit_no = e.Cell.Row.Cells["DATENO"].Text; //string edit_REG_DTIME = e.Cell.Row.Cells["REG_DTIME"].Text; /*for循环控制单选*/ int i = this.ultraGrid2.Rows.Count; for (int j = 0; j < i; j++) { if (this.ultraGrid2.Rows[j].Cells["DATENO"].Value.ToString() != edit_no ) { this.ultraGrid2.Rows[j].Cells["SELECT_ITEM"].Value = false; } } this.ultraTextEditor_no.Text = edit_no; this.smplocat.Text = e.Cell.Row.Cells["smp_locat"].Text; this.ultraTextsmptime.Text = e.Cell.Row.Cells["smp_dtime"].Text; this.ultraTextsmpcunt.Text = e.Cell.Row.Cells["smp_cont"].Text; this.ultraTextEditor1.Text = e.Cell.Row.Cells["regman"].Text; DateTime dt = DateTime.ParseExact(e.Cell.Row.Cells["smp_date"].Text, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); this.ultraDateTimeEditor3.Value = dt; } else { this.clearTextBoxData(); } } } } }