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 Newtonsoft.Json; using Newtonsoft.Json.Linq; using Infragistics.Win; using System.Diagnostics; namespace Core.LZMes.Client.QCM { public partial class QCM0205 : FrmBase { #region 初始变量 public string specimenNo = "";//取样编号 public string smpNo = "";//试样号 public string plineCode="";//产线 public Hashtable hashTable = new Hashtable(); #endregion #region 初始化 public QCM0205() { InitializeComponent(); } //初始化的时候加载列 private void QCM0205_Load(object sender, EventArgs e) { this.sel_BATCH_NO.Focus(); //隐藏中厚板tab tabPage1.Parent = null; tabPage2.Parent = null; if (plineCode.Equals("RZ1")) { tabPage3.Parent = null;//线棒 tabPage5.Parent = null;//连退 if (hashTable.Count>=1) { this.sel_BATCH_NO.Text = hashTable["BATCH_NO"].ToString(); this.DoTbcTurnofFlist();//热轧线 } }else if(plineCode.Equals("LT1")){ tabPage3.Parent = null;//线棒 tabPage4.Parent = null;//热轧 } else { //线棒 this.radioButton1.Parent = null; this.radioButton2.Parent = null; tabPage4.Parent = null; tabPage5.Parent = null; } } #endregion #region 功能 public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": //this.DoQuery(); break; case "Add": //this.DoAdd(); break; } } #region 查询 private void button1_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab.Text.Equals("厚板线")) { this.DoKchTurnofFlist();//厚板线 } else if (tabControl1.SelectedTab.Text.Equals("中板线")) { this.DoKczTurnofFlist();//中板线 } else if (tabControl1.SelectedTab.Text.Equals("高棒线")) { this.DoKcxTurnofFlist();//高棒线 } else if (tabControl1.SelectedTab.Text.Equals("热轧线")) { this.DoTbcTurnofFlist();//热轧线 } else if (tabControl1.SelectedTab.Text.Equals("连退线")) { this.DoCtbcTurnofFlist();//连退线 } } #region 厚板线 private void DoKchTurnofFlist() { try { this.dataSet1.Clear(); string selDesignKey = this.sel_DESIGN_KEY.Text.Trim(); //销售订单号 string selHeatNo = this.sel_HEAT_NO.Text.Trim(); //炉号 string selBatchNo = this.sel_BATCH_NO.Text.Trim(); //轧批号 if (selBatchNo == null || selBatchNo.Equals("")) { this.alert("【厚板线】请输入轧批号"); this.sel_BATCH_NO.Focus(); return; } //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample"; ccp.MethodName = "getKchTurnofFlist"; ccp.SourceDataTable = this.dataSet1.Tables[0]; ccp.ServerParams = new object[] { selDesignKey, selHeatNo, selBatchNo }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 中板线 private void DoKczTurnofFlist() { try { this.dataSet2.Clear(); string selDesignKey = this.sel_DESIGN_KEY.Text.Trim(); //销售订单号 string selHeatNo = this.sel_HEAT_NO.Text.Trim(); //炉号 string selBatchNo = this.sel_BATCH_NO.Text.Trim(); //轧批号 if (selBatchNo == null || selBatchNo.Equals("")) { this.alert("【中板线】请输入轧批号"); this.sel_BATCH_NO.Focus(); return; } //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample"; ccp.MethodName = "getKczTurnofFlist"; ccp.SourceDataTable = this.dataSet2.Tables[0]; ccp.ServerParams = new object[] { selDesignKey, selHeatNo, selBatchNo }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //foreach (UltraGridRow ugr in this.ultraGrid2.Rows) //{ // ugr.Cells["ALLPHYTESTNAMES2"].Value = ugr.Cells["ALLPHYTESTNAMES2"].Value.ToString(); //} } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 高棒线 private void DoKcxTurnofFlist() { try { this.dataSet3.Clear(); string selDesignKey = this.sel_DESIGN_KEY.Text.Trim(); //销售订单号 string selHeatNo = this.sel_HEAT_NO.Text.Trim(); //炉号 string selBatchNo = this.sel_BATCH_NO.Text.Trim(); //轧批号 if (selBatchNo == null || selBatchNo.Equals("")) { this.alert("【高棒线】请输入轧批号8位"); this.sel_BATCH_NO.Focus(); return; } //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample"; ccp.MethodName = "getKcxTurnofFlist"; ccp.SourceDataTable = this.dataSet3.Tables[0]; ccp.ServerParams = new object[] { selDesignKey, selHeatNo, selBatchNo }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 热轧线 private void DoTbcTurnofFlist() { try { this.dataSet4.Clear(); string selDesignKey = this.sel_DESIGN_KEY.Text.Trim(); //销售订单号 string selHeatNo = this.sel_HEAT_NO.Text.Trim(); //炉号 string selBatchNo = this.sel_BATCH_NO.Text.Trim(); //轧批号 if (selBatchNo == null || selBatchNo.Equals("")) { this.alert("【热轧线】请输入正确轧批号!"); this.sel_BATCH_NO.Focus(); return; } //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample"; ccp.MethodName = "getHotRoll"; ccp.SourceDataTable = this.dataSet4.Tables[0]; ccp.ServerParams = new object[] { selDesignKey, selHeatNo, selBatchNo }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 连退线 private void DoCtbcTurnofFlist() { try { this.dataSet5.Clear(); string selDesignKey = this.sel_DESIGN_KEY.Text.Trim(); //销售订单号 string selHeatNo = this.sel_HEAT_NO.Text.Trim(); //炉号 string selBatchNo = this.sel_BATCH_NO.Text.Trim(); //轧批号 if (selBatchNo == null || selBatchNo.Equals("")) { this.alert("【连退线】请输入正确轧批号!"); this.sel_BATCH_NO.Focus(); return; } //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample"; ccp.MethodName = "getRetreat"; ccp.SourceDataTable = this.dataSet5.Tables[0]; ccp.ServerParams = new object[] { selDesignKey, selHeatNo, selBatchNo }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #endregion #region 新增 private void button2_Click(object sender, EventArgs e) { this.DoAdd(); } private void DoAdd() { try { String tabname = "厚板线"; UltraGrid ug = this.ultraGrid1; if (tabControl1.SelectedTab.Text.Equals("厚板线")) { tabname = "厚板线"; ug = this.ultraGrid1; } else if (tabControl1.SelectedTab.Text.Equals("中板线")) { tabname = "中板线"; ug = this.ultraGrid2; } else if (tabControl1.SelectedTab.Text.Equals("高棒线")) { tabname = "高棒线"; ug = this.ultraGrid3; } else if (tabControl1.SelectedTab.Text.Equals("热轧线")) { tabname = "热轧线"; ug = this.ultraGrid4; } else if (tabControl1.SelectedTab.Text.Equals("连退线")) { tabname = "连退线"; ug = this.ultraGrid5; } String CAstr = ""; if (tabControl1.SelectedTab.Text.Equals("热轧线") || tabControl1.SelectedTab.Text.Equals("连退线")) { if(this.radioButton1.Checked){ CAstr = "【按子板取样,生成的委托只代表当前勾选的子板】"; }else if(this.radioButton2.Checked){ CAstr = "【按批取样,生成的委托代表这一个轧批】"; } if (MessageBox.Show("是否确认" + CAstr + "?请谨慎操作!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } } StringBuilder sb = new StringBuilder("["); Dictionary openWith = new Dictionary(); int tf = 0; foreach (UltraGridRow row in ug.Rows) { if (row.Cells["check"].Value.ToString().ToLower() == "true") { if (tf == 0) { openWith.Add("INSPECTION_LOT", row.Cells["INSPECTION_LOT"].Value.ToString());//检验号 openWith.Add("DESIGN_KEY", row.Cells["DESIGN_KEY"].Value.ToString());//销售订单号 openWith.Add("PSC", row.Cells["PSC"].Value.ToString());//产品码 openWith.Add("HEAT_NO", row.Cells["HEAT_NO"].Value.ToString());//炉号 openWith.Add("BATCH_NO", row.Cells["BATCH_NO"].Value.ToString());//轧批号 openWith.Add("BOARD_NO", row.Cells["BOARD_NO"].Value.ToString());//母板号 openWith.Add("GRADE_CODE", row.Cells["GRADE_CODE"].Value.ToString());//炼钢牌号代码 openWith.Add("GRADE_NAME", row.Cells["GRADE_NAME"].Value.ToString());//炼钢牌号名称 openWith.Add("MATERIAL_NO", row.Cells["MATERIAL_NO"].Value.ToString());//产品序号 openWith.Add("MSC_PLINE", row.Cells["MSC_PLINE"].Value.ToString());//全程产线号 openWith.Add("PLINE_CODE", row.Cells["PLINE_CODE"].Value.ToString());//产线代码 openWith.Add("PLINE_NAME", row.Cells["PLINE_NAME"].Value.ToString());//产线名称 openWith.Add("DELIVERY_STATE_CODE", row.Cells["DELIVERY_STATE_CODE"].Value.ToString());//交货状态代码 openWith.Add("DELIVERY_STATE_DESC", row.Cells["DELIVERY_STATE_DESC"].Value.ToString());//交货状态描述 openWith.Add("PROCESS_CODE", row.Cells["PROCESS_CODE"].Value.ToString());//工序代码 openWith.Add("THICK", row.Cells["THICK"].Value.ToString()); openWith.Add("WIDTH", row.Cells["WIDTH"].Value.ToString());// openWith.Add("LENGTH", row.Cells["LENGTH"].Value.ToString()); openWith.Add("IS_QTLY", row.Cells["IS_QTLY"].Value.ToString());//是否需要材质检验 openWith.Add("IS_CHEM", row.Cells["IS_CHEM"].Value.ToString());//是否需要成品成分检验 openWith.Add("TYPE", row.Cells["TYPE"].Value.ToString());//请求类型 openWith.Add("MEMO", row.Cells["MEMO"].Value.ToString());//备注信息 openWith.Add("USER_NAME", this.UserInfo.GetUserName()); if (tabControl1.SelectedTab.Text.Equals("高棒线")) { openWith.Add("WEIGHT", row.Cells["WEIGHT"].Value.ToString());//总重量 openWith.Add("WEIGHT_STD", row.Cells["WEIGHT_STD"].Value.ToString());//上限值 openWith.Add("WEIGHT_SFD", row.Cells["WEIGHT_SFD"].Value.ToString());//浮动值 } if (tabname.Equals("厚板线") || tabname.Equals("中板线")) { if (checkBox1.Checked) { if (tabname.Equals("厚板线")) { openWith.Add("HTPROCESS_CODE", "HB1");//初样 } else { openWith.Add("HTPROCESS_CODE", "ZB1");//初样 } } else if (checkBox2.Checked) { openWith.Add("HTPROCESS_CODE", "FY");//复样 } else { openWith.Add("HTPROCESS_CODE", "HT1");//热处理之后 力学 } } else { if (tabControl1.SelectedTab.Text.Equals("热轧线") || tabControl1.SelectedTab.Text.Equals("连退线")) { openWith.Add("CASTR", CAstr); } openWith.Add("HTPROCESS_CODE", "");//其它产线 } sb.Append(JsonConvert.SerializeObject(openWith)); } if (tf != 0) { sb.Append(","); openWith["INSPECTION_LOT"] = row.Cells["INSPECTION_LOT"].Value.ToString();//检验号 openWith["DESIGN_KEY"] = row.Cells["DESIGN_KEY"].Value.ToString();//销售订单号 openWith["PSC"] = row.Cells["PSC"].Value.ToString();//产品码 openWith["HEAT_NO"] = row.Cells["HEAT_NO"].Value.ToString();//炉号 openWith["BATCH_NO"] = row.Cells["BATCH_NO"].Value.ToString();//轧批号 openWith["BOARD_NO"] = row.Cells["BOARD_NO"].Value.ToString();//母板号 openWith["GRADE_CODE"] = row.Cells["GRADE_CODE"].Value.ToString();//炼钢牌号代码 openWith["GRADE_NAME"] = row.Cells["GRADE_NAME"].Value.ToString();//炼钢牌号名称 openWith["MATERIAL_NO"] = row.Cells["MATERIAL_NO"].Value.ToString();//产品序号 openWith["MSC_PLINE"] = row.Cells["MSC_PLINE"].Value.ToString();//全程产线号 openWith["PLINE_CODE"] = row.Cells["PLINE_CODE"].Value.ToString();//产线代码 openWith["PLINE_NAME"] = row.Cells["PLINE_NAME"].Value.ToString();//产线名称 openWith["DELIVERY_STATE_CODE"] = row.Cells["DELIVERY_STATE_CODE"].Value.ToString();//交货状态代码 openWith["DELIVERY_STATE_DESC"] = row.Cells["DELIVERY_STATE_DESC"].Value.ToString();//交货状态描述 openWith["PROCESS_CODE"] = row.Cells["PROCESS_CODE"].Value.ToString();//工序代码 openWith["THICK"] = row.Cells["THICK"].Value.ToString(); openWith["WIDTH"] = row.Cells["WIDTH"].Value.ToString();// openWith["LENGTH"] = row.Cells["LENGTH"].Value.ToString(); openWith["IS_QTLY"] = row.Cells["IS_QTLY"].Value.ToString();//是否需要材质检验 openWith["IS_CHEM"] = row.Cells["IS_CHEM"].Value.ToString();//是否需要成品成分检验 openWith["TYPE"] = row.Cells["TYPE"].Value.ToString();//请求类型 openWith["MEMO"] = row.Cells["MEMO"].Value.ToString();//备注信息 openWith["USER_NAME"] = this.UserInfo.GetUserName(); if (tabControl1.SelectedTab.Text.Equals("高棒线")) { openWith["WEIGHT"] = row.Cells["WEIGHT"].Value.ToString();//总重量 openWith["WEIGHT_STD"] = row.Cells["WEIGHT_STD"].Value.ToString();//上限值 openWith["WEIGHT_SFD"] = row.Cells["WEIGHT_SFD"].Value.ToString();//浮动值 } if (tabname.Equals("厚板线") || tabname.Equals("中板线")) { if (checkBox1.Checked) { if (tabname.Equals("厚板线")) { openWith["HTPROCESS_CODE"] = "HB1";//初样 } else { openWith["HTPROCESS_CODE"] = "ZB1";//初样 } } else if (checkBox2.Checked) { openWith["HTPROCESS_CODE"] = "FY";//复样 } else { openWith["HTPROCESS_CODE"] = "HT1";//热处理之后 } } else { if (tabControl1.SelectedTab.Text.Equals("热轧线") || tabControl1.SelectedTab.Text.Equals("连退线")) { openWith["CASTR"] = CAstr; } openWith["HTPROCESS_CODE"] = "";//其它产线 } sb.Append(JsonConvert.SerializeObject(openWith)); } tf = tf + 1; } } sb.Append("]"); string sbb = sb.ToString(); if (this.radioButton2.Checked && (tabControl1.SelectedTab.Text.Equals("热轧线") || tabControl1.SelectedTab.Text.Equals("连退线")) ) { if (tf>=2) { this.alert("您选择的是按批取样,按批取样只要选择一个产品序号生成一条委托!请正确操作!"); return; } } //查询是否已经委托 String retun ="0"; retun = selEntrust(sbb); if (retun.Equals("1")) { if (MessageBox.Show("选择的数据当中有已经委托并且未发送,您确实要从新生成委托吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } //JArray jo = (JArray)JsonConvert.DeserializeObject(sbb); //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); // ccp.ServerName = "QCM.JHY01.JHY0101.AddAutoSample"; // ccp.MethodName = "doGenerationSampleInfo"; ccp.ServerName = "QCM.JHY01.JHY0101.AutoSample"; ccp.MethodName = "doGenerationSampleInfo"; ccp.ServerParams = new object[] { sbb, tabname }; ccp.SourceDataTable = this.dataSet2.Tables[0]; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageBox.Show("委托成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); this.Close(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #endregion #region 其它事件 #region 查询人工委托中是否已经有委托了 public String selEntrust(String date) { String returnnum = "0"; //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample"; ccp.MethodName = "selEntrust"; ccp.ServerParams = new object[] { date }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != 0) { returnnum = "1";//1代表已经有委托 并且没有下发 } return returnnum; } #endregion #region 更新事件 private void ultraGrid1_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e) { ultraGrid1.UpdateData(); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); } private void ultraGrid2_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e) { ultraGrid2.UpdateData(); } private void ultraGrid2_CellChange(object sender, CellEventArgs e) { ultraGrid2.UpdateData(); } private void ultraGrid3_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e) { ultraGrid3.UpdateData(); } private void ultraGrid3_CellChange(object sender, CellEventArgs e) { ultraGrid3.UpdateData(); } private void ultraGrid4_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e) { ultraGrid4.UpdateData(); } private void ultraGrid4_CellChange(object sender, CellEventArgs e) { ultraGrid4.UpdateData(); } private void ultraGrid5_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e) { ultraGrid5.UpdateData(); } private void ultraGrid5_CellChange(object sender, CellEventArgs e) { ultraGrid5.UpdateData(); } #endregion #region tab切换点击事件 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { //if (tabControl1.SelectedTab.Text.Equals("厚板线")) //{ // //执行相应的操作 // DoKchTurnofFlist(); //} //else if (tabControl1.SelectedTab.Text.Equals("中板线")) //{ // //执行相应的操作 // DoKczTurnofFlist(); //} //else if (tabControl1.SelectedTab.Text.Equals("高棒线")) //{ // DoKcxTurnofFlist(); //} //else if (tabControl1.SelectedTab.Text.Equals("热轧线")) //{ // this.DoTbcTurnofFlist();//热轧线 //} //else if (tabControl1.SelectedTab.Text.Equals("连退线")) //{ // this.DoCtbcTurnofFlist();//连退线 //} } #endregion private void panel2_Paint(object sender, PaintEventArgs e) { } #endregion } }