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 System.Collections; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Core.LZMes.Client.QCM { public partial class QCM0206 : FrmBase { #region 初始变量 public string specimenNo;//取样编号 public string smpNo;//试样号 public string batchNo;//轧批号 public string designKey;//订单号 public string steelCode;//牌号 public string thick;//规格 #endregion public QCM0206() { InitializeComponent(); } private void QCM0206_Load(object sender, EventArgs e) { this.MinimumSize = new Size(1300, 650); // this.MaximumSize = new Size(2000, 1000); this.textBox1.Text = batchNo;//轧批号 this.DoQuery();//查询被引用项目 this.DoQueryNew();//引用项目 this.QueryDesignKey();//订单号 牌号 规格 } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "InExport": break; } } #region 查询按钮 private void button1_Click(object sender, EventArgs e) { this.DoQuery(); } #endregion #region 全选 private void checkBox2_CheckedChanged(object sender, EventArgs e) { foreach (UltraGridRow ugr in this.ultraGrid2.Rows.Where(p => p.IsFilteredOut == false).ToList()) { if (checkBox2.Checked) { ugr.Cells["check"].Value = "True"; } else { ugr.Cells["check"].Value = "False"; } } } #endregion #region 查询当前取样编号项目 private void DoQueryNew() { try { Hashtable ht = new Hashtable(); ht.Add("SPECIMEN_NO", specimenNo); CoreClientParam ccp = new CoreClientParam(); this.dataSet1.Clear(); ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly"; ccp.MethodName = "getRgYitem"; ccp.SourceDataTable = this.dataSet1.Tables[0]; ccp.ServerParams = new object[] { ht }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); ClsControlPack.RefreshAndAutoSize(ultraGrid1); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("查询异常!","警告"); } } #endregion #region 被引用项目 private void DoQuery() { try { String B_DESIGN_KEY = ""; String B_STEEL_CODE = ""; String B_THICK = ""; if (!String.IsNullOrEmpty(this.txt_design_key.Text.ToString())) { B_DESIGN_KEY = this.txt_design_key.Text.ToString(); } else { B_DESIGN_KEY = "全部"; } if (!String.IsNullOrEmpty(this.txt_steel_code.Text.ToString())) { B_STEEL_CODE = this.txt_steel_code.Text.ToString(); } else { B_STEEL_CODE = "全部"; } if (!String.IsNullOrEmpty(this.txt_thick.Text.ToString())) { B_THICK = this.txt_thick.Text.ToString(); } else { B_THICK = "全部"; } Hashtable ht = new Hashtable(); ht.Add("SPECIMEN_NO", specimenNo);//引用取样编号 ht.Add("THICK", thick);//规格 ht.Add("BATCH_NO", batchNo);//轧批号 ht.Add("B_DESIGN_KEY", B_DESIGN_KEY);//被引用订单号 ht.Add("B_STEEL_CODE", B_STEEL_CODE);//被引用牌号 ht.Add("B_THICK", B_THICK);//被引用规格 CoreClientParam ccp = new CoreClientParam(); this.dataSet2.Clear(); ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly"; ccp.MethodName = "getRgBYitem"; ccp.SourceDataTable = this.dataSet2.Tables[0]; ccp.ServerParams = new object[] { ht }; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); ClsControlPack.RefreshAndAutoSize(ultraGrid2); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("查询异常!", "警告"); } } #endregion #region 订单号 牌号 规格 public void QueryDesignKey() { this.dataSet3.Clear(); Hashtable ht = new Hashtable(); ht.Add("BATCH_NO", batchNo);//轧批号 ht.Add("THICK", thick);//规格 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly";//调用java地址 ccp.MethodName = "getQueryDesignKey";//调用的方法 ccp.ServerParams = new object[] { ht }; ccp.SourceDataTable = this.dataSet3.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); ValueList VDEFECT_DESC = new ValueList(); ValueList VDEFECT_DESC2 = new ValueList(); ValueList VDEFECT_DESC3 = new ValueList(); VDEFECT_DESC.ValueListItems.Add("全部", "全部"); VDEFECT_DESC2.ValueListItems.Add("全部", "全部"); VDEFECT_DESC3.ValueListItems.Add("全部", "全部"); for (int i = 0; i < ccp.SourceDataTable.Rows.Count; i++) { VDEFECT_DESC.ValueListItems.Add(ccp.SourceDataTable.Rows[i]["DESIGN_KEY"].ToString(), ccp.SourceDataTable.Rows[i]["DESIGN_KEY"].ToString()); VDEFECT_DESC2.ValueListItems.Add(ccp.SourceDataTable.Rows[i]["STEEL_CODE"].ToString(), ccp.SourceDataTable.Rows[i]["STEEL_CODE"].ToString()); VDEFECT_DESC3.ValueListItems.Add(ccp.SourceDataTable.Rows[i]["THICK"].ToString(), ccp.SourceDataTable.Rows[i]["THICK"].ToString()); } txt_design_key.ValueList = VDEFECT_DESC; txt_steel_code.ValueList = VDEFECT_DESC2; txt_thick.ValueList = VDEFECT_DESC3; } #endregion #region 引用已选实绩 取样编号:SPECIMEN_NO 材质项目项:PHY_CODE_S GUID 判定记录号:PHY_ID private void button2_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder("["); Dictionary openWith = new Dictionary(); int tf = 0; foreach (UltraGridRow row in this.ultraGrid2.Rows) { if (row.Cells["check"].Value.ToString().ToLower() == "true") { if (tf == 0) { openWith.Add("SPECIMEN_NO", row.Cells["SPECIMEN_NO"].Value.ToString());//取样编号 openWith.Add("PHY_CODE_S", row.Cells["PHY_CODE_S"].Value.ToString());//材质项目项 openWith.Add("PHY_NAME_S", row.Cells["PHY_NAME_S"].Value.ToString());//材质项目项 openWith.Add("THICK", row.Cells["THICK"].Value.ToString());//规格 openWith.Add("GUID", row.Cells["GUID"].Value.ToString());//GUID openWith.Add("PHY_ID", row.Cells["PHY_ID"].Value.ToString());//判定记录号 openWith.Add("CREATE_NAME", this.UserInfo.GetUserName().ToString());//操作人 openWith.Add("SEND_ID", this.UserInfo.GetUserID().ToString());//操作人 sb.Append(JsonConvert.SerializeObject(openWith)); } if (tf != 0) { sb.Append(","); openWith["SPECIMEN_NO"] = row.Cells["SPECIMEN_NO"].Value.ToString(); openWith["PHY_CODE_S"] = row.Cells["PHY_CODE_S"].Value.ToString(); openWith["PHY_NAME_S"] = row.Cells["PHY_NAME_S"].Value.ToString(); openWith["THICK"] = row.Cells["THICK"].Value.ToString(); openWith["GUID"] = row.Cells["GUID"].Value.ToString(); openWith["PHY_ID"] = row.Cells["PHY_ID"].Value.ToString(); openWith["CREATE_NAME"] = this.UserInfo.GetUserName().ToString(); openWith["SEND_ID"] = this.UserInfo.GetUserID().ToString(); sb.Append(JsonConvert.SerializeObject(openWith)); } tf = tf + 1; } } sb.Append("]"); string sbb = sb.ToString(); if (tf==0) { this.alert("未选择被引用项目!!!"); return; } UltraGridRow row1 = this.ultraGrid1.ActiveRow; if (row1 == null) { this.alert("没有找到引用项目!!!"); return; } String num1 = row1.Cells["NUMB"].Value.ToString();//引用项目数 int num2=int.Parse(num1); //被引用数 大于 引用数 if (tf > num2) { this.alert("勾选的被引用项目数[" + tf + "]大于引用项目数[" + num2 + "]"); return; } //查询数据库里的数据 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly"; ccp.MethodName = "getBYITEM"; ccp.ServerParams = new object[] { sbb, specimenNo }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageBox.Show("引用成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None); this.Close(); } } #endregion private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e) { //不合格显示颜色 if (e.Row.Cells["IS_PASS"].Value.ToString().Equals("不合格")) { e.Row.Appearance.BackColor = Color.Red;//红色 } } } }