| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- 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 QCM0205YT : FrmBase
- {
- #region 初始变量
- public string specimenNo = "";//取样编号
- public string smpNo = "";//试样号
- public string plineCode="";//产线
- public Hashtable hashTable = new Hashtable();
- #endregion
- #region 初始化
- public QCM0205YT()
- {
- InitializeComponent();
- }
- //初始化的时候加载列
- private void QCM0205YT_Load(object sender, EventArgs e)
- {
- this.sel_BATCH_NO.Focus();
- }
- #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)
- {
- this.DoKchTurnofFlist();//优特钢
- }
- #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(); //轧批号
- //查询数据库里的数据
- CoreClientParam ccp = new CoreClientParam();
- DataTable datatable = new DataTable();
- ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample";
- ccp.MethodName = "getTurnofFlistYT";
- 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
- #endregion
- #region 新增
- private void button2_Click(object sender, EventArgs e)
- {
- this.DoAdd();
-
- }
- private void DoAdd()
- {
- try
- {
- String tabname = "优特钢";
- UltraGrid ug = this.ultraGrid1;
- String CAstr = "";
- 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<string, string> openWith = new Dictionary<string, string>();
- 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());
- openWith.Add("CASTR", CAstr);
-
- 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();
- openWith["CASTR"] = CAstr;
-
- sb.Append(JsonConvert.SerializeObject(openWith));
- }
- tf = tf + 1;
- }
- }
- sb.Append("]");
- string sbb = sb.ToString();
- if (this.radioButton2.Checked)
- {
- 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 = "doGenerationSampleInfoYT";
- 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();
- }
- #endregion
-
- #endregion
-
- }
- }
|