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 Infragistics.Win; using Newtonsoft.Json; namespace Core.LZMes.Client.QCM { public partial class QCM0401 : FrmBase { #region 窗体初始化 public QCM0401() { InitializeComponent(); } private void QCM0401_Load(object sender, EventArgs e) { ValueList v2 = new ValueList(); v2.ValueListItems.Add("00", "待提报"); v2.ValueListItems.Add("10", "待确认"); v2.ValueListItems.Add("20", "审批中"); v2.ValueListItems.Add("30", "审批拒绝"); v2.ValueListItems.Add("40", "审批退回"); v2.ValueListItems.Add("50", "审批通过"); ultraGrid2.DisplayLayout.Bands[0].Columns["CERT_STATUS"].ValueList = v2.Clone(); } #endregion #region 申报记录 #region 查询申报记录 private void button2_Click(object sender, EventArgs e) { Query(); } private void Query() { try { String STARTTIME = this.dateTimePicker4.Value.ToString("yyyy-MM-dd"); String ENDTIME = this.dateTimePicker3.Value.ToString("yyyy-MM-dd"); String CERT_INST_NAME = this.textBox6.Text.Trim();//认证机构 String BATCH_NO = this.textBox5.Text.Trim();//轧批号 String shordh = this.textBox4.Text.Trim();//销售订单号 this.dataSet2.Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0103.QuerryThirdInfo"; ccp.MethodName = "QueryMainInfo"; ccp.ServerParams = new object[] { STARTTIME, ENDTIME, CERT_INST_NAME, BATCH_NO, shordh }; ccp.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataTable table = this.dataTable2; if (table == null) { this.dataSet3.Clear(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 申报记录事件 private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { ultraGrid2AfterRowActivate(); } public void ultraGrid2AfterRowActivate() { try { UltraGridRow row = ultraGrid2.ActiveRow; if (row == null) { this.dataSet3.Clear(); } String CERT_NO = row.Cells["CERT_NO"].Value.ToString();//认证申报编号 String BATCH_NO = "";//轧批号 String design_key = "";//design_key this.dataSet3.Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0103.QuerryThirdInfo"; ccp.MethodName = "QueryDetailInfo"; ccp.ServerParams = new object[] { CERT_NO, BATCH_NO, design_key }; ccp.SourceDataTable = this.dataSet3.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 剔除子板 private void button3_Click(object sender, EventArgs e) { try { if (MessageBox.Show("确认剔除子板?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } UltraGridRow row = ultraGrid3.ActiveRow; String CERT_NO = row.Cells["CERT_NO"].Value.ToString();//认证申报编号 String MATERIAL_NO = row.Cells["MATERIAL_NO"].Value.ToString();//产品序号 Hashtable columnMap = new Hashtable(); string cm = CERT_NO + "," + MATERIAL_NO; this.dataSet3.Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0103.DeleteMaterialInfo"; ccp.MethodName = "delete2"; ccp.ServerParams = new object[] { cm }; ccp.SourceDataTable = this.dataSet3.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); ultraGrid2AfterRowActivate(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 撤销申报 private void button4_Click(object sender, EventArgs e) { try { if (MessageBox.Show("确认撤销申报?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } UltraGridRow row = ultraGrid2.ActiveRow; String CERT_NO = row.Cells["CERT_NO"].Value.ToString();//认证申报编号 String CERT_STATUS = row.Cells["CERT_STATUS"].Value.ToString();//确认状态 if (CERT_STATUS.Equals("50")) { MessageBox.Show("已申报确认!不可撤销!!","提示",MessageBoxButtons.OK); return; } this.dataSet2.Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0103.DeleteMaterialInfo"; ccp.MethodName = "deleteMD"; ccp.ServerParams = new object[] { CERT_NO }; ccp.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); Query(); UltraGridRow row1 = ultraGrid2.ActiveRow; if (row1 == null) { this.dataSet3.Clear(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #endregion #region 库存信息 #region 认证申报 private void button5_Click(object sender, EventArgs e) { // DoAdd1();//认证申报 调用接口方法1 DoAdd2();//认证申报 调用接口方法2 } private void DoAdd1() { ultraGrid1.UpdateData(); if (ultraGrid1.Rows.Count == 0) { MessageBox.Show("库存信息为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } ArrayList CERT_INST_CODE = new ArrayList(); ArrayList CERT_INST_NAME = new ArrayList(); ArrayList MEMO = new ArrayList(); ArrayList CREATE_ID = new ArrayList(); ArrayList CREATE_NAME = new ArrayList(); ArrayList CERT_NO = new ArrayList(); //认证申报编号 ArrayList CERT_STATUS = new ArrayList(); ArrayList APPLY_ORG_NO = new ArrayList(); ArrayList APPLY_ORG_DESC = new ArrayList(); ArrayList DEP_TYPE_CODE = new ArrayList(); ArrayList DUTY_ID = new ArrayList(); ArrayList INSTANCE_ID = new ArrayList(); ArrayList material_no = new ArrayList(); //产品序号 ArrayList design_key = new ArrayList(); //DESIGN_KEY ArrayList psc = new ArrayList(); //产品规范代码 ArrayList prod_code = new ArrayList(); //产品名称代码 ArrayList prod_name = new ArrayList(); //产品名称描述 ArrayList steel_code = new ArrayList(); //产品牌号代码 ArrayList steel_name = new ArrayList(); //产品牌号名称 ArrayList std_code = new ArrayList(); //执行标准代码 ArrayList std_name = new ArrayList(); //执行标准名称 ArrayList delivery_state_code = new ArrayList(); //交货状态代码 ArrayList delivery_state_desc = new ArrayList(); //交货状态描述 ArrayList delivery_date = new ArrayList(); //交货日期 ArrayList cut_type = new ArrayList(); //切边状态 ArrayList heat_no = new ArrayList(); //炉号 ArrayList batch_no = new ArrayList(); //轧批号 ArrayList inspection_lot = new ArrayList(); //检验号 ArrayList board_no = new ArrayList(); //母板号 ArrayList thick = new ArrayList(); //厚度(mm) ArrayList width = new ArrayList(); //宽度(mm) ArrayList length = new ArrayList(); //长度 ArrayList mat_weight = new ArrayList(); //重量 ArrayList pline_code = new ArrayList(); //产线代码 ArrayList pline_name = new ArrayList(); //产线名称 for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["check"].Value.ToString() == "True") { CERT_INST_CODE.Add(ultraGrid1.Rows[i].Cells["CERT_INST_CODE"].Value.ToString()); CERT_INST_NAME.Add(ultraGrid1.Rows[i].Cells["CERT_INST_NAME"].Value.ToString()); MEMO.Add(ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString()); CREATE_ID.Add(ultraGrid1.Rows[i].Cells["CREATE_ID"].Value.ToString()); CREATE_NAME.Add(ultraGrid1.Rows[i].Cells["CREATE_NAME"].Value.ToString()); CERT_NO.Add(ultraGrid1.Rows[i].Cells["CERT_NO"].Value.ToString()); CERT_STATUS.Add(ultraGrid1.Rows[i].Cells["CERT_STATUS"].Value.ToString()); APPLY_ORG_NO.Add(ultraGrid1.Rows[i].Cells["APPLY_ORG_NO"].Value.ToString()); APPLY_ORG_DESC.Add(ultraGrid1.Rows[i].Cells["APPLY_ORG_DESC"].Value.ToString()); DEP_TYPE_CODE.Add(ultraGrid1.Rows[i].Cells["DEP_TYPE_CODE"].Value.ToString()); DUTY_ID.Add(ultraGrid1.Rows[i].Cells["DUTY_ID"].Value.ToString()); INSTANCE_ID.Add(ultraGrid1.Rows[i].Cells["INSTANCE_ID"].Value.ToString()); material_no.Add(ultraGrid1.Rows[i].Cells["MATERIAL_NO"].Value.ToString()); design_key.Add(ultraGrid1.Rows[i].Cells["DESIGN_KEY"].Value.ToString()); psc.Add(ultraGrid1.Rows[i].Cells["PSC"].Value.ToString()); prod_code.Add(ultraGrid1.Rows[i].Cells["PROD_CODE"].Value.ToString()); prod_name.Add(ultraGrid1.Rows[i].Cells["PROD_NAME"].Value.ToString()); steel_code.Add(ultraGrid1.Rows[i].Cells["STEEL_CODE"].Value.ToString()); steel_name.Add(ultraGrid1.Rows[i].Cells["STEEL_NAME"].Value.ToString()); std_code.Add(ultraGrid1.Rows[i].Cells["STD_CODE"].Value.ToString()); std_name.Add(ultraGrid1.Rows[i].Cells["STD_NAME"].Value.ToString()); delivery_state_code.Add(ultraGrid1.Rows[i].Cells["DELIVERY_STATE_CODE"].Value.ToString()); delivery_state_desc.Add(ultraGrid1.Rows[i].Cells["DELIVERY_STATE_DESC"].Value.ToString()); delivery_date.Add(ultraGrid1.Rows[i].Cells["DELIVERY_DATE"].Value.ToString()); cut_type.Add(ultraGrid1.Rows[i].Cells["CUT_TYPE"].Value.ToString()); heat_no.Add(ultraGrid1.Rows[i].Cells["HEAT_NO"].Value.ToString()); batch_no.Add(ultraGrid1.Rows[i].Cells["BATCH_NO"].Value.ToString()); inspection_lot.Add(ultraGrid1.Rows[i].Cells["INSPECTION_LOT"].Value.ToString()); board_no.Add(ultraGrid1.Rows[i].Cells["BOARD_NO"].Value.ToString()); thick.Add(ultraGrid1.Rows[i].Cells["THICK"].Value.ToString()); width.Add(ultraGrid1.Rows[i].Cells["WIDTH"].Value.ToString()); length.Add(ultraGrid1.Rows[i].Cells["LENGTH"].Value.ToString()); mat_weight.Add(ultraGrid1.Rows[i].Cells["MAT_WEIGHT"].Value.ToString()); pline_code.Add(ultraGrid1.Rows[i].Cells["PLINE_CODE"].Value.ToString()); pline_name.Add(ultraGrid1.Rows[i].Cells["PLINE_NAME"].Value.ToString()); } } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0103.AddThirdInfo"; ccp.MethodName = "addList"; ccp.ServerParams = new object[] { CERT_INST_CODE, CERT_INST_NAME, MEMO, CREATE_ID, CREATE_NAME, CERT_NO, CERT_STATUS, APPLY_ORG_NO, APPLY_ORG_DESC,DEP_TYPE_CODE,DUTY_ID,INSTANCE_ID, material_no, design_key, psc, prod_code, prod_name, steel_code, steel_name, std_code, std_name, delivery_state_code, delivery_state_desc, delivery_date, cut_type, heat_no, batch_no, inspection_lot, board_no, thick, width, length, mat_weight, pline_code, pline_name,this.UserInfo.GetUserID(),this.UserInfo.GetUserName() }; ccp.SourceDataTable = this.dataSet1.Tables[0]; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageBox.Show("认证申报成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); } QueryKs(); } private void DoAdd2() { try { ultraGrid1.UpdateData(); if (ultraGrid1.Rows.Count == 0) { MessageBox.Show("库存信息为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } StringBuilder sb = new StringBuilder("["); Dictionary openWith = new Dictionary(); int tf = 0; foreach (UltraGridRow row in this.ultraGrid1.Rows) { if (row.Cells["check"].Value.ToString().ToLower() == "true") { if (tf == 0) { openWith.Add("CERT_INST_CODE", row.Cells["CERT_INST_CODE"].Value.ToString()); openWith.Add("CERT_INST_NAME", row.Cells["CERT_INST_NAME"].Value.ToString()); openWith.Add("MEMO", row.Cells["MEMO"].Value.ToString()); openWith.Add("CREATE_ID", row.Cells["CREATE_ID"].Value.ToString()); openWith.Add("CREATE_NAME", row.Cells["CREATE_NAME"].Value.ToString()); openWith.Add("CERT_NO", row.Cells["CERT_NO"].Value.ToString()); openWith.Add("CERT_STATUS", row.Cells["CERT_STATUS"].Value.ToString()); openWith.Add("APPLY_ORG_NO", row.Cells["APPLY_ORG_NO"].Value.ToString()); openWith.Add("APPLY_ORG_DESC", row.Cells["APPLY_ORG_DESC"].Value.ToString()); openWith.Add("DEP_TYPE_CODE", row.Cells["DEP_TYPE_CODE"].Value.ToString()); openWith.Add("DUTY_ID", row.Cells["DUTY_ID"].Value.ToString()); openWith.Add("INSTANCE_ID", row.Cells["INSTANCE_ID"].Value.ToString()); openWith.Add("MATERIAL_NO", row.Cells["MATERIAL_NO"].Value.ToString()); openWith.Add("DESIGN_KEY", row.Cells["DESIGN_KEY"].Value.ToString()); openWith.Add("PSC", row.Cells["PSC"].Value.ToString()); openWith.Add("PROD_CODE", row.Cells["PROD_CODE"].Value.ToString()); openWith.Add("PROD_NAME", row.Cells["PROD_NAME"].Value.ToString()); openWith.Add("STEEL_CODE", row.Cells["STEEL_CODE"].Value.ToString()); openWith.Add("STEEL_NAME", row.Cells["STEEL_NAME"].Value.ToString()); openWith.Add("STD_CODE", row.Cells["STD_CODE"].Value.ToString()); openWith.Add("STD_NAME", row.Cells["STD_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("DELIVERY_DATE", row.Cells["DELIVERY_DATE"].Value.ToString()); openWith.Add("CUT_TYPE", row.Cells["CUT_TYPE"].Value.ToString()); openWith.Add("HEAT_NO", row.Cells["HEAT_NO"].Value.ToString()); openWith.Add("BATCH_NO", row.Cells["BATCH_NO"].Value.ToString()); openWith.Add("INSPECTION_LOT", row.Cells["INSPECTION_LOT"].Value.ToString()); openWith.Add("BOARD_NO", row.Cells["BOARD_NO"].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("MAT_WEIGHT", row.Cells["MAT_WEIGHT"].Value.ToString()); openWith.Add("PLINE_CODE", row.Cells["PLINE_CODE"].Value.ToString()); openWith.Add("PLINE_NAME", row.Cells["PLINE_NAME"].Value.ToString()); sb.Append(JsonConvert.SerializeObject(openWith)); } if (tf != 0) { sb.Append(","); openWith["CERT_INST_CODE"] = row.Cells["CERT_INST_CODE"].Value.ToString(); openWith["CERT_INST_NAME"] = row.Cells["CERT_INST_NAME"].Value.ToString(); openWith["MEMO"] = row.Cells["MEMO"].Value.ToString(); openWith["CREATE_ID"] = row.Cells["CREATE_ID"].Value.ToString(); openWith["CREATE_NAME"] = row.Cells["CREATE_NAME"].Value.ToString(); openWith["CERT_NO"] = row.Cells["CERT_NO"].Value.ToString(); openWith["CERT_STATUS"] = row.Cells["CERT_STATUS"].Value.ToString(); openWith["APPLY_ORG_NO"] = row.Cells["APPLY_ORG_NO"].Value.ToString(); openWith["APPLY_ORG_DESC"] = row.Cells["APPLY_ORG_DESC"].Value.ToString(); openWith["DEP_TYPE_CODE"] = row.Cells["DEP_TYPE_CODE"].Value.ToString(); openWith["DUTY_ID"] = row.Cells["DUTY_ID"].Value.ToString(); openWith["INSTANCE_ID"] = row.Cells["INSTANCE_ID"].Value.ToString(); openWith["MATERIAL_NO"] = row.Cells["MATERIAL_NO"].Value.ToString(); openWith["DESIGN_KEY"] = row.Cells["DESIGN_KEY"].Value.ToString(); openWith["PSC"] = row.Cells["PSC"].Value.ToString(); openWith["PROD_CODE"] = row.Cells["PROD_CODE"].Value.ToString(); openWith["PROD_NAME"] = row.Cells["PROD_NAME"].Value.ToString(); openWith["STEEL_CODE"] = row.Cells["STEEL_CODE"].Value.ToString(); openWith["STEEL_NAME"] = row.Cells["STEEL_NAME"].Value.ToString(); openWith["STD_CODE"] = row.Cells["STD_CODE"].Value.ToString(); openWith["STD_NAME"] = row.Cells["STD_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["DELIVERY_DATE"] = row.Cells["DELIVERY_DATE"].Value.ToString(); openWith["CUT_TYPE"] = row.Cells["CUT_TYPE"].Value.ToString(); openWith["HEAT_NO"] = row.Cells["HEAT_NO"].Value.ToString(); openWith["BATCH_NO"] = row.Cells["BATCH_NO"].Value.ToString(); openWith["INSPECTION_LOT"] = row.Cells["INSPECTION_LOT"].Value.ToString(); openWith["BOARD_NO"] = row.Cells["BOARD_NO"].Value.ToString(); openWith["THICK"] = row.Cells["THICK"].Value.ToString(); openWith["WIDTH"] = row.Cells["WIDTH"].Value.ToString(); openWith["LENGTH"] = row.Cells["LENGTH"].Value.ToString(); openWith["MAT_WEIGHT"] = row.Cells["MAT_WEIGHT"].Value.ToString(); openWith["PLINE_CODE"] = row.Cells["PLINE_CODE"].Value.ToString(); openWith["PLINE_NAME"] = row.Cells["PLINE_NAME"].Value.ToString(); sb.Append(JsonConvert.SerializeObject(openWith)); } tf = tf + 1; } } sb.Append("]"); string sbb = sb.ToString(); //JArray jo = (JArray)JsonConvert.DeserializeObject(sbb); //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); DataTable datatable = new DataTable(); ccp.ServerName = "QCM.JHY01.JHY0103.AddThirdInfo"; ccp.MethodName = "addList2"; ccp.ServerParams = new object[] { sbb, this.UserInfo.GetUserID(), this.UserInfo.GetUserName() }; ccp.SourceDataTable = this.dataSet1.Tables[0]; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageBox.Show("认证申报成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); } this.QueryKs(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #region 查询 private void button1_Click(object sender, EventArgs e) { QueryKs(); } private void QueryKs() { try { String STARTTIME = this.dateTimePicker1.Value.ToString("yyyy-MM-dd"); String ENDTIME = this.dateTimePicker2.Value.ToString("yyyy-MM-dd"); String BATCH_NO1 = this.textBox1.Text.Trim();//轧批号1 String ORG_NAME = this.textBox2.Text.Trim();//认证机构 String PROD_NAMEMOME = this.textBox3.Text.Trim();//产品规范描述 this.dataSet1.Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0103.QuerryThirdInfo"; ccp.MethodName = "QueryKSInfo"; ccp.ServerParams = new object[] { STARTTIME, ENDTIME, BATCH_NO1, ORG_NAME, PROD_NAMEMOME }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统出错,请联系管理人员", "警告"); } } #endregion #endregion #region 其它事件 private void ultraGrid1_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e) { ultraGrid1.UpdateData(); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); } #endregion } }