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; namespace Core.LZMes.Client.UIK { public partial class UIK050010 : FrmBase { public UIK050010() { 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; } } private void UIK050010_Load(object sender, EventArgs e) { } private void DoQuery() { try { string zgNum = ""; string zgAr = ""; string beginTime = ""; string endTime = ""; bool flag = false; CoreClientParam ccp = new CoreClientParam(); CoreClientParam ccp2 = new CoreClientParam(); //if (this.zgNumber.Text == "" && this.zgArea.Text == "" && this.ultraCheckEditor1.Checked == false) //{ // MessageBox.Show("请选择查询条件!"); //} //else //{ if (this.ultraCheckEditor1.Checked) { this.dataSet1.Tables[0].Clear(); this.dataSet2.Tables[0].Clear(); this.zgArea.Clear(); this.zgNumber.Clear(); this.ultraCheckEditor1.Checked = false; ccp.ServerName = "UIK.UIK05.UIK050010"; ccp.MethodName = "DoQueryShang"; ccp.ServerParams = new object[] { zgNum, zgAr, flag ,beginTime,endTime}; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataRowCollection drc1 = this.dataSet1.Tables[0].Rows; ccp2.ServerName = "UIK.UIK05.UIK050010"; ccp2.MethodName = "DoQueryXia"; ccp2.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp2.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal); DataRowCollection drc2 = this.dataSet2.Tables[0].Rows; if (drc1.Count <= 0) { MessageBox.Show("暂无记录!"); } return; } else { flag = true; if (this.zgArea.Text == "" || this.zgNumber.Text == "") { if (this.zgNumber.Text == "") { this.dataSet1.Tables[0].Clear(); this.dataSet2.Tables[0].Clear(); zgAr = this.zgArea.Text; beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd000000") : ""; endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd999999") : ""; this.zgArea.Clear(); this.zgNumber.Clear(); this.ultraCheckEditor1.Checked = false; ccp.ServerName = "UIK.UIK05.UIK050010"; ccp.MethodName = "DoQueryShang"; ccp.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataRowCollection drc1 = this.dataSet1.Tables[0].Rows; ccp2.ServerName = "UIK.UIK05.UIK050010"; ccp2.MethodName = "DoQueryXia"; ccp2.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp2.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal); DataRowCollection drc2 = this.dataSet2.Tables[0].Rows; if (drc1.Count <= 0) { MessageBox.Show("该区域的记录不存在!"); } return; } if (this.zgArea.Text == "") { this.dataSet1.Tables[0].Clear(); this.dataSet2.Tables[0].Clear(); zgNum = this.zgNumber.Text; beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd000000") : ""; endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd999999") : ""; this.zgArea.Clear(); this.zgNumber.Clear(); this.ultraCheckEditor1.Checked = false; ccp.ServerName = "UIK.UIK05.UIK050010"; ccp.MethodName = "DoQueryShang"; ccp.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataRowCollection drc1 = this.dataSet1.Tables[0].Rows; ccp2.ServerName = "UIK.UIK05.UIK050010"; ccp2.MethodName = "DoQueryXia"; ccp2.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp2.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal); DataRowCollection drc2 = this.dataSet2.Tables[0].Rows; if (drc1.Count <= 0) { MessageBox.Show("该换辊计划号记录不存在,请查证后查询!"); } return; } } if (this.zgArea.Text == "" && this.zgNumber.Text == "") { beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd000000") : ""; endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd999999") : ""; this.zgArea.Clear(); this.zgNumber.Clear(); this.ultraCheckEditor1.Checked = false; ccp.ServerName = "UIK.UIK05.UIK050010"; ccp.MethodName = "DoQueryShang"; ccp.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataRowCollection drc1 = this.dataSet1.Tables[0].Rows; ccp2.ServerName = "UIK.UIK05.UIK050010"; ccp2.MethodName = "DoQueryXia"; ccp2.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp2.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal); DataRowCollection drc2 = this.dataSet1.Tables[0].Rows; if (drc1.Count <= 0) { MessageBox.Show("记录不存在,请查证后查询!"); } return; } else { this.dataSet1.Tables[0].Clear(); this.dataSet2.Tables[0].Clear(); zgNum = this.zgNumber.Text; zgAr = this.zgArea.Text; beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd000000") : ""; endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd999999") : ""; this.zgArea.Clear(); this.zgNumber.Clear(); this.ultraCheckEditor1.Checked = false; ccp.ServerName = "UIK.UIK05.UIK050010"; ccp.MethodName = "DoQueryShang"; ccp.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataRowCollection drc1 = this.dataSet1.Tables[0].Rows; ccp2.ServerName = "UIK.UIK05.UIK050010"; ccp2.MethodName = "DoQueryXia"; ccp2.ServerParams = new object[] { zgNum, zgAr, flag, beginTime, endTime }; ccp2.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal); DataRowCollection drc2 = this.dataSet2.Tables[0].Rows; if (drc1.Count <= 0) { MessageBox.Show("记录不存在,请查证后查询!"); } return; } } } // } catch (Exception Ex) { MessageBox.Show(Ex.ToString()); } } private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e) { try { if (this.ultraCheckEditor1.Checked) { this.zgNumber.Enabled = false; this.zgArea.Enabled = false; } if (!this.ultraCheckEditor1.Checked) { this.zgNumber.Enabled = true; this.zgArea.Enabled = true; } } catch (Exception Ex) { MessageBox.Show(Ex.ToString()); } } private void DoInsert() { try { if (this.ultraTextSand_id.Text == "" || this.ultraTextReg_id.Text == "") { MessageBox.Show("机架号和操作人必填!"); } else { string sand_Id = this.ultraTextSand_id.Text; string roll_Type = this.ultraComboRollType.Text; string roll_Area = this.ultraComboArea.Text; string roll_Id_up = this.ultraTextRoll_id_up.Text; string roll_Id_lo = this.ultraTextRoll_id_lo.Text; string reg_Id = this.ultraTextReg_id.Text; string reg_Dtime = System.DateTime.Now.ToString(); string updia = this.ultraTextUpdia.Text; string lodia = this.ultraTextLodia.Text; string xiatu = this.ultraTextXiaTu.Text; string shangtu = this.ultraTextShangTu.Text; string sshap = this.ultraTextSshap.Text; string xshap = this.ultraTextXshap.Text; string scai = this.ultraComboScai.Text; string xcai = this.ultraComboXcai.Text; if (scai == "光辊") { scai = "1"; } if (scai == "毛辊") { scai = "2"; } if (xcai == "光辊") { xcai = "1"; } if (xcai == "毛辊") { xcai = "2"; } System.DateTime dtt = System.DateTime.Now; string spec_No = (string.Format("{0:yyyyMMddHHmmss}", dtt)).Substring(8, 6); string number = reg_Dtime; DataTable dt = new DataTable(); CoreClientParam ccp2 = new CoreClientParam(); ccp2.ServerName = "UIK.UIK05.UIK050010"; ccp2.MethodName = "DoSelect"; ccp2.ServerParams = new object[] { reg_Dtime }; ccp2.SourceDataTable = dt; this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal); if (dt.Rows.Count > 0) { MessageBox.Show("换辊计划已存在,请查证后填写!"); this.ultraTextSand_id.Clear(); this.ultraComboArea.Clear(); this.ultraComboRollType.Clear(); this.ultraTextRoll_id_up.Clear(); this.ultraTextRoll_id_lo.Clear(); this.ultraTextReg_id.Clear(); this.ultraTextUpdia.Clear(); this.ultraTextLodia.Clear(); this.ultraTextXiaTu.Clear(); this.ultraTextShangTu.Clear(); this.ultraTextSshap.Clear(); this.ultraTextXshap.Clear(); this.ultraComboScai.Clear(); this.ultraComboXcai.Clear(); } else { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIK.UIK05.UIK050010"; ccp.MethodName = "PlanAdd"; ccp.ServerParams = new object[] { sand_Id, roll_Type, roll_Area, spec_No, roll_Id_up, roll_Id_lo, reg_Id, reg_Dtime, updia, lodia, shangtu, xiatu, sshap, xshap, scai, xcai }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //if (0 != ccp.ReturnCode) return; if (0 != ccp.ReturnCode) { MessageBox.Show("添加失败"); } else { MessageBox.Show("添加成功"); this.ultraTextSand_id.Clear(); this.ultraComboArea.Clear(); this.ultraComboRollType.Clear(); this.ultraTextRoll_id_up.Clear(); this.ultraTextRoll_id_lo.Clear(); this.ultraTextReg_id.Clear(); this.ultraTextUpdia.Clear(); this.ultraTextLodia.Clear(); this.ultraTextXiaTu.Clear(); this.ultraTextShangTu.Clear(); this.ultraTextSshap.Clear(); this.ultraTextXshap.Clear(); this.ultraComboScai.Clear(); this.ultraComboXcai.Clear(); } } } } catch (Exception Ex) { MessageBox.Show(Ex.ToString()); } } private void DoUpdate() { Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr.Cells["SELECT_ITEM"].Text.ToString() == "True") { if (ugr.Cells["MEG_FLAG"].Value.ToString() == "是") { MessageBox.Show("该计划已下发!"); ugr.Cells["SELECT_ITEM"].Value = false; } else { string reg_Dtime,number, roll_type, roll_id_up, roll_id_lo, up_shape, lo_shape, area, stand_id, up_diameter, lo_diameter, lo_crown, up_crown, up_pro, lo_pro; //long spec_no, area, stand_id, up_diameter, lo_diameter, lo_crown, up_crown, up_pro, lo_pro; //DateTime r_dt; string uid = "Core.LZMes.Client.UIK.UIK050010"; reg_Dtime = ugr.Cells["REG_DTIME"].Value.ToString(); DataTable dt = new DataTable(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIK.UIK05.UIK050010"; ccp.MethodName = "DoSelect"; ccp.ServerParams = new object[] { reg_Dtime }; ccp.SourceDataTable = dt; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); foreach (DataRow dr in dt.Rows) { number = dr["SPEC_NO"].ToString(); area = dr["ROLL_AREA"].ToString(); stand_id = dr["STAND_ID"].ToString(); roll_type = dr["ROLL_TYPE"].ToString(); roll_id_up = dr["ROLL_ID_UP"].ToString(); roll_id_lo = dr["ROLL_ID_LO"].ToString(); up_diameter = dr["ROLL_DIAMETER_UP"].ToString(); lo_diameter = dr["ROLL_DIAMETER_LO"].ToString(); lo_crown = dr["ROLL_CROWN_LO"].ToString(); up_crown = dr["ROLL_CROWN_UP"].ToString(); up_shape = dr["ROLL_SHAPE_UP"].ToString(); lo_shape = dr["ROLL_SHAPE_LO"].ToString(); up_pro = dr["ROLL_PROPERTY_CLASS"].ToString(); lo_pro = dr["ROLL_PROPERTY_CLASS_LO"].ToString();//1为光辊,2为毛辊 CoreClientParam ccp2 = new CoreClientParam(); ccp2.ServerName = "UIK.UIK05.UIK050010"; ccp2.MethodName = "DoSend"; ccp2.ServerParams = new object[] { number, reg_Dtime, area, stand_id, roll_type, roll_id_up, roll_id_lo, up_diameter, lo_diameter, lo_crown, up_crown, up_shape, lo_shape, up_pro, lo_pro, uid }; ccp2 = this.ExecuteNonQuery(ccp2, CoreInvokeType.Internal); if (0 != ccp2.ReturnCode) { MessageBox.Show("下发失败!"); } else { MessageBox.Show("下发成功!"); CoreClientParam ccp3 = new CoreClientParam(); ccp3.ServerName = "UIK.UIK05.UIK050010"; ccp3.MethodName = "DoUpdate"; ccp3.ServerParams = new object[] { reg_Dtime }; ccp3 = this.ExecuteNonQuery(ccp3, CoreInvokeType.Internal); if (0 != ccp3.ReturnCode) { MessageBox.Show("下发计划修改失败!"); } else { MessageBox.Show("下发计划已修改成功!"); } } } } } else { MessageBox.Show("请选择下发行!"); } } //private void A() //{ // Infragistics.Win.UltraWinGrid.UltraGridRow ugr=this.ultraGrid1.ActiveRow; // foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.ultraGrid1.Rows) // { // if (row.Cells["SELECTITEM"].Value.ToString() == "true") // { // } // } //} //在cellchangde事件中去控制 只选中一行 不能选择多行 } }