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.Text.RegularExpressions; namespace Core.LZMes.Client.UIC { public partial class UIC020111 : FrmBase { public UIC020111() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Save": this.DoSave(); break; case "Export": this.DoExport(); break; case "Close": this.Close(); break; } } private void DoQuery() { try { CoreClientParam ccp = new CoreClientParam(); //查询 this.dataSet1.Tables[0].Clear(); ArrayList al = new ArrayList(); al.Add("UIC020111_01.SELECT"); al.Add(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") ); ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.IfShowErrMsg = false; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void DoExport() { try { if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fileName = this.saveFileDialog1.FileName; ultraGridExcelExporter1.Export(ultraGrid1, fileName); System.Diagnostics.Process.Start(fileName); } } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } private class TT { public bool b(string s) { string pattern = "^([0-9]{1,}[.][0-9]*)$"; Regex rx = new Regex(pattern); return rx.IsMatch(s); } public bool b2(string s) { string pattern = "^([0-9]{1,})$"; Regex rx = new Regex(pattern); return rx.IsMatch(s); } } private void DoSave() { try { if (MessageBox.Show("确认保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); ArrayList list = null; int num2 ;//停轧时间 string strTime = ""; string strProdLine = ""; TT t =new TT(); foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["MODIFY_FLAG"].Text == "Y") { strTime = ugr.Cells["TJ_DTIME"].Text.Trim(); strProdLine = ugr.Cells["PROD_LINE"].Text.Trim(); list = new ArrayList(); list.Add("UIC020111_01.UPDATE"); list.Add(ugr.Cells["TJ_RESULT"].Text.Trim()); list.Add(ugr.Cells["TJ_DEMO"].Text.Trim()); list.Add(this.UserInfo.GetUserName()); list.Add(ugr.Cells["TJ_DTIME"].Text.Trim()); list.Add(ugr.Cells["TJ_NAME"].Text.Trim()); if (!t.b(ugr.Cells["TJ_RESULT"].Text.Trim()) && !t.b2(ugr.Cells["TJ_RESULT"].Text.Trim()))//如果转换失败(为false)时输出括号内容 { MessageBox.Show("请正确输入数字"); return; } 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.IfShowErrMsg = false; ccp =this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统发生异常,请与管理员联系", "提示"); } } //private string checkSJZYSJ(string date) // private void checkSJZYSJ() // { // CoreClientParam ccp = new CoreClientParam(); // Hashtable ht = new Hashtable(); // ht.Add("i1", this.ComboProdLine.Text);//产线 // ht.Add("i2", this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd"));//录入时间 // ht.Add("i3",this.ultraComboEditor2.Value.ToString());//班组 // ht.Add("o4", ""); // ccp.ServerName = "UIB.COM.ComDBProcedure"; // ccp.MethodName = "doXmlProcedure"; // ccp.ServerParams = new object[] { "UIC020111_02.CALL", ht }; // CoreClientParam ccpResult = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); // } private void DoInsertRow() { try { if (this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") == "" ) { MessageBox.Show("请在编辑区域选择正确的日期"); return; } if (MessageBox.Show("确认增加【" + this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") + "】的日志数据?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; CoreClientParam ccp = new CoreClientParam(); Hashtable ht = new Hashtable(); ht.Add("i1", "");//产线 ht.Add("i2", this.UserInfo.GetUserName());//用户名 ht.Add("i3", this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") ); ht.Add("o4", ""); ccp.ServerName = "UIB.COM.ComDBProcedure"; ccp.MethodName = "doXmlProcedure"; ccp.ServerParams = new object[] { "UIC020111_01.CALL", ht }; CoreClientParam ccpResult = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); ArrayList al = ccpResult.ReturnObject as ArrayList; if (al[0].ToString() != "YY") { //ugr.Cells["CHEM_CD"].Appearance.BackColor = Color.Blue; MessageBox.Show(al[0].ToString(), "提示"); return; } this.ultraDateTimeEditor1.Value = this.ultraDateTimeEditor3.Value.ToString(); this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } string strBC = "";//班组 private void UIC020111_Load(object sender, EventArgs e) { try { if (this.UserInfo.GetUserGroup() == 0 + "") strBC = "常白班"; else if (this.UserInfo.GetUserGroup() == 1 + "") strBC = "甲班"; else if (this.UserInfo.GetUserGroup() == 2 + "") strBC = "乙班"; else if (this.UserInfo.GetUserGroup() == 3 + "") strBC = "丙班"; else if (this.UserInfo.GetUserGroup() == 4 + "") strBC = "丁班"; //this.labelBC.Text = "提醒:当前登录班组为" + strBC + ",非" + strBC + "人员禁止增加该班的数据。"; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { try { this.ultraGrid1.ActiveRow.Appearance.ForeColor = Color.Red;//红色 this.ultraGrid1.ActiveRow.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;//设置为粗体 this.ultraGrid1.ActiveRow.Cells["MODIFY_FLAG"].Value = "Y"; this.ultraGrid1.Update(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void ultraGrid1_KeyUp(object sender, KeyEventArgs e) { try { if(e.KeyCode != Keys.Enter) return; if (this.ultraGrid1.ActiveCell == null) return; string keyName = this.ultraGrid1.ActiveCell.Column.Key; this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow); this.ultraGrid1.ActiveRow.Cells[keyName].Activated = true; this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void button1_Click(object sender, EventArgs e) { this.DoInsertRow(); } } }