QCM0205YT.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. using Newtonsoft.Json;
  13. using Newtonsoft.Json.Linq;
  14. using Infragistics.Win;
  15. using System.Diagnostics;
  16. namespace Core.LZMes.Client.QCM
  17. {
  18. public partial class QCM0205YT : FrmBase
  19. {
  20. #region 初始变量
  21. public string specimenNo = "";//取样编号
  22. public string smpNo = "";//试样号
  23. public string plineCode="";//产线
  24. public Hashtable hashTable = new Hashtable();
  25. #endregion
  26. #region 初始化
  27. public QCM0205YT()
  28. {
  29. InitializeComponent();
  30. }
  31. //初始化的时候加载列
  32. private void QCM0205YT_Load(object sender, EventArgs e)
  33. {
  34. this.sel_BATCH_NO.Focus();
  35. }
  36. #endregion
  37. #region 功能
  38. public override void ToolBar_Click(object sender, string ToolbarKey)
  39. {
  40. switch (ToolbarKey)
  41. {
  42. case "Query":
  43. //this.DoQuery();
  44. break;
  45. case "Add":
  46. //this.DoAdd();
  47. break;
  48. }
  49. }
  50. #region 查询
  51. private void button1_Click(object sender, EventArgs e)
  52. {
  53. this.DoKchTurnofFlist();//优特钢
  54. }
  55. #region 优特钢
  56. private void DoKchTurnofFlist()
  57. {
  58. try
  59. {
  60. this.dataSet1.Clear();
  61. string selDesignKey = this.sel_DESIGN_KEY.Text.Trim(); //销售订单号
  62. string selHeatNo = this.sel_HEAT_NO.Text.Trim(); //子板号
  63. string selBatchNo = this.sel_BATCH_NO.Text.Trim(); //轧批号
  64. //查询数据库里的数据
  65. CoreClientParam ccp = new CoreClientParam();
  66. DataTable datatable = new DataTable();
  67. ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample";
  68. ccp.MethodName = "getTurnofFlistYT";
  69. ccp.SourceDataTable = this.dataSet1.Tables[0];
  70. ccp.ServerParams = new object[] { selDesignKey, selHeatNo, selBatchNo };
  71. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  72. }
  73. catch (Exception ex)
  74. {
  75. System.Diagnostics.Debug.WriteLine(ex.ToString());
  76. MessageBox.Show("系统出错,请联系管理人员", "警告");
  77. }
  78. }
  79. #endregion
  80. #endregion
  81. #region 新增
  82. private void button2_Click(object sender, EventArgs e)
  83. {
  84. this.DoAdd();
  85. }
  86. private void DoAdd()
  87. {
  88. try
  89. {
  90. String tabname = "优特钢";
  91. UltraGrid ug = this.ultraGrid1;
  92. String CAstr = "";
  93. if (this.radioButton1.Checked)
  94. {
  95. CAstr = "【按子板取样,生成的委托只代表当前勾选的子板】";
  96. }
  97. else if (this.radioButton2.Checked)
  98. {
  99. CAstr = "【按批取样,生成的委托代表这一个轧批】";
  100. }
  101. if (MessageBox.Show("是否确认" + CAstr + "?请谨慎操作!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
  102. {
  103. return;
  104. }
  105. StringBuilder sb = new StringBuilder("[");
  106. Dictionary<string, string> openWith = new Dictionary<string, string>();
  107. int tf = 0;
  108. foreach (UltraGridRow row in ug.Rows)
  109. {
  110. if (row.Cells["check"].Value.ToString().ToLower() == "true")
  111. {
  112. if (tf == 0)
  113. {
  114. openWith.Add("INSPECTION_LOT", row.Cells["INSPECTION_LOT"].Value.ToString());//检验号
  115. openWith.Add("DESIGN_KEY", row.Cells["DESIGN_KEY"].Value.ToString());//销售订单号
  116. openWith.Add("PSC", row.Cells["PSC"].Value.ToString());//产品码
  117. openWith.Add("HEAT_NO", row.Cells["HEAT_NO"].Value.ToString());//炉号
  118. openWith.Add("BATCH_NO", row.Cells["BATCH_NO"].Value.ToString());//轧批号
  119. openWith.Add("BOARD_NO", row.Cells["BOARD_NO"].Value.ToString());//母板号
  120. openWith.Add("GRADE_CODE", row.Cells["GRADE_CODE"].Value.ToString());//炼钢牌号代码
  121. openWith.Add("GRADE_NAME", row.Cells["GRADE_NAME"].Value.ToString());//炼钢牌号名称
  122. openWith.Add("MATERIAL_NO", row.Cells["MATERIAL_NO"].Value.ToString());//产品序号
  123. openWith.Add("MSC_PLINE", row.Cells["MSC_PLINE"].Value.ToString());//全程产线号
  124. openWith.Add("PLINE_CODE", row.Cells["PLINE_CODE"].Value.ToString());//产线代码
  125. openWith.Add("PLINE_NAME", row.Cells["PLINE_NAME"].Value.ToString());//产线名称
  126. openWith.Add("DELIVERY_STATE_CODE", row.Cells["DELIVERY_STATE_CODE"].Value.ToString());//交货状态代码
  127. openWith.Add("DELIVERY_STATE_DESC", row.Cells["DELIVERY_STATE_DESC"].Value.ToString());//交货状态描述
  128. openWith.Add("PROCESS_CODE", row.Cells["PROCESS_CODE"].Value.ToString());//工序代码
  129. openWith.Add("THICK", row.Cells["THICK"].Value.ToString());
  130. openWith.Add("WIDTH", row.Cells["WIDTH"].Value.ToString());//
  131. openWith.Add("LENGTH", row.Cells["LENGTH"].Value.ToString());
  132. openWith.Add("IS_QTLY", row.Cells["IS_QTLY"].Value.ToString());//是否需要材质检验
  133. openWith.Add("IS_CHEM", row.Cells["IS_CHEM"].Value.ToString());//是否需要成品成分检验
  134. openWith.Add("TYPE", row.Cells["TYPE"].Value.ToString());//请求类型
  135. openWith.Add("MEMO", row.Cells["MEMO"].Value.ToString());//备注信息
  136. openWith.Add("USER_NAME", this.UserInfo.GetUserName());
  137. openWith.Add("CASTR", CAstr);
  138. sb.Append(JsonConvert.SerializeObject(openWith));
  139. }
  140. if (tf != 0)
  141. {
  142. sb.Append(",");
  143. openWith["INSPECTION_LOT"] = row.Cells["INSPECTION_LOT"].Value.ToString();//检验号
  144. openWith["DESIGN_KEY"] = row.Cells["DESIGN_KEY"].Value.ToString();//销售订单号
  145. openWith["PSC"] = row.Cells["PSC"].Value.ToString();//产品码
  146. openWith["HEAT_NO"] = row.Cells["HEAT_NO"].Value.ToString();//炉号
  147. openWith["BATCH_NO"] = row.Cells["BATCH_NO"].Value.ToString();//轧批号
  148. openWith["BOARD_NO"] = row.Cells["BOARD_NO"].Value.ToString();//母板号
  149. openWith["GRADE_CODE"] = row.Cells["GRADE_CODE"].Value.ToString();//炼钢牌号代码
  150. openWith["GRADE_NAME"] = row.Cells["GRADE_NAME"].Value.ToString();//炼钢牌号名称
  151. openWith["MATERIAL_NO"] = row.Cells["MATERIAL_NO"].Value.ToString();//产品序号
  152. openWith["MSC_PLINE"] = row.Cells["MSC_PLINE"].Value.ToString();//全程产线号
  153. openWith["PLINE_CODE"] = row.Cells["PLINE_CODE"].Value.ToString();//产线代码
  154. openWith["PLINE_NAME"] = row.Cells["PLINE_NAME"].Value.ToString();//产线名称
  155. openWith["DELIVERY_STATE_CODE"] = row.Cells["DELIVERY_STATE_CODE"].Value.ToString();//交货状态代码
  156. openWith["DELIVERY_STATE_DESC"] = row.Cells["DELIVERY_STATE_DESC"].Value.ToString();//交货状态描述
  157. openWith["PROCESS_CODE"] = row.Cells["PROCESS_CODE"].Value.ToString();//工序代码
  158. openWith["THICK"] = row.Cells["THICK"].Value.ToString();
  159. openWith["WIDTH"] = row.Cells["WIDTH"].Value.ToString();//
  160. openWith["LENGTH"] = row.Cells["LENGTH"].Value.ToString();
  161. openWith["IS_QTLY"] = row.Cells["IS_QTLY"].Value.ToString();//是否需要材质检验
  162. openWith["IS_CHEM"] = row.Cells["IS_CHEM"].Value.ToString();//是否需要成品成分检验
  163. openWith["TYPE"] = row.Cells["TYPE"].Value.ToString();//请求类型
  164. openWith["MEMO"] = row.Cells["MEMO"].Value.ToString();//备注信息
  165. openWith["USER_NAME"] = this.UserInfo.GetUserName();
  166. openWith["CASTR"] = CAstr;
  167. sb.Append(JsonConvert.SerializeObject(openWith));
  168. }
  169. tf = tf + 1;
  170. }
  171. }
  172. sb.Append("]");
  173. string sbb = sb.ToString();
  174. if (this.radioButton2.Checked)
  175. {
  176. if (tf >= 2)
  177. {
  178. this.alert("您选择的是按批取样,按批取样只要选择一个产品序号生成一条委托!请正确操作!");
  179. return;
  180. }
  181. }
  182. //查询是否已经委托
  183. String retun ="0";
  184. retun = selEntrust(sbb);
  185. if (retun.Equals("1"))
  186. {
  187. if (MessageBox.Show("选择的数据当中有已经委托并且未发送,您确实要从新生成委托吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  188. {
  189. return;
  190. }
  191. }
  192. //JArray jo = (JArray)JsonConvert.DeserializeObject(sbb);
  193. //查询数据库里的数据
  194. CoreClientParam ccp = new CoreClientParam();
  195. DataTable datatable = new DataTable();
  196. ccp.ServerName = "QCM.JHY01.JHY0101.AddAutoSample";
  197. ccp.MethodName = "doGenerationSampleInfoYT";
  198. ccp.ServerParams = new object[] { sbb, tabname };
  199. ccp.SourceDataTable = this.dataSet2.Tables[0];
  200. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  201. if (ccp.ReturnCode != -1)
  202. {
  203. MessageBox.Show("委托成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
  204. this.Close();
  205. }
  206. }
  207. catch (Exception ex)
  208. {
  209. System.Diagnostics.Debug.WriteLine(ex.ToString());
  210. MessageBox.Show("系统出错,请联系管理人员", "警告");
  211. }
  212. }
  213. #endregion
  214. #endregion
  215. #region 其它事件
  216. #region 查询人工委托中是否已经有委托了
  217. public String selEntrust(String date)
  218. {
  219. String returnnum = "0";
  220. //查询数据库里的数据
  221. CoreClientParam ccp = new CoreClientParam();
  222. DataTable datatable = new DataTable();
  223. ccp.ServerName = "QCM.JHY01.JHY0101.QuerryQltySample";
  224. ccp.MethodName = "selEntrust";
  225. ccp.ServerParams = new object[] { date };
  226. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  227. if (ccp.ReturnCode != 0)
  228. {
  229. returnnum = "1";//1代表已经有委托 并且没有下发
  230. }
  231. return returnnum;
  232. }
  233. #endregion
  234. #region 更新事件
  235. private void ultraGrid1_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
  236. {
  237. ultraGrid1.UpdateData();
  238. }
  239. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  240. {
  241. ultraGrid1.UpdateData();
  242. }
  243. #endregion
  244. #endregion
  245. }
  246. }