Make_BurnInfo.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 UAS_MES_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. using UAS_MES_NEW.PublicMethod;
  12. namespace UAS_MES_NEW.Make
  13. {
  14. public partial class Make_BurnInfo : Form
  15. {
  16. public Make_BurnInfo()
  17. {
  18. InitializeComponent();
  19. }
  20. LogStringBuilder sql = new LogStringBuilder();
  21. DataTable Dbfind;
  22. DataHelper dh;
  23. DataTable dt;
  24. string remainQty;
  25. private void Make_BurnInfo_Load(object sender, EventArgs e)
  26. {
  27. //设置锁定工单
  28. LockMakeCode.GetMakeCodeCtl(ma_code);
  29. ma_code.SetLockCheckBox(LockMakeCode);
  30. //工单号放大镜配置
  31. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  32. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
  33. ma_code.FormName = Name;
  34. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
  35. ma_code.Condition = "ma_statuscode='STARTED'";
  36. ma_code.DbChange += Ma_code_DbChange;
  37. dh = SystemInf.dh;
  38. dt = (DataTable)dh.ExecuteSql("SELECT * FROM line WHERE li_wcname = 'SMT' ORDER BY li_auditdate", "select");
  39. if (dt.Rows.Count > 0)
  40. {
  41. foreach (DataRow item in dt.Rows)
  42. {
  43. LineVal.Items.Add(item["li_code"].ToString());
  44. }
  45. }
  46. }
  47. private void Ma_code_DbChange(object sender, EventArgs e)
  48. {
  49. Dbfind = ma_code.ReturnData;
  50. BaseUtil.SetFormValue(this.Controls, Dbfind);
  51. //获取工单的其他信息
  52. sql.Clear();
  53. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
  54. sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty,ma_qty from make left join makecraftdetail on ");
  55. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "'");
  56. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  57. if (dt.Rows.Count > 0)
  58. {
  59. BaseUtil.SetFormValue(this.Controls, dt);
  60. }
  61. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME,BURN_QTY FROM burn_info WHERE work_order = '{ma_code.Text}'", "select");
  62. if (dt.Rows.Count > 0)
  63. {
  64. DataBox.DataSource = dt;
  65. dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
  66. if (dt.Rows.Count > 0)
  67. {
  68. CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
  69. }
  70. }
  71. ShowMsg(1, $"工单: {ma_code.Text} 已找到{dt.Rows.Count}条烧录记录");
  72. }
  73. private void Confirm_Click(object sender, EventArgs e)
  74. {
  75. if (string.IsNullOrEmpty(ma_code.Text))
  76. {
  77. ShowMsg(0, "请选择归属工单");
  78. ma_code.Focus();
  79. return;
  80. }
  81. /*if (string.IsNullOrEmpty(LineVal.Text))
  82. {
  83. ShowMsg(0, "请选择线体");
  84. LineVal.Focus();
  85. LineVal.SelectAll();
  86. return;
  87. }*/
  88. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  89. {
  90. ShowMsg(0, "请扫描包批次号");
  91. BurnLotnoVal.Focus();
  92. BurnLotnoVal.SelectAll();
  93. return;
  94. }
  95. dt = (DataTable)dh.ExecuteSql($@"select * from burn_info where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  96. if (dt.Rows.Count > 0)
  97. {
  98. ShowMsg(0, $"批号 {BurnLotnoVal.Text}已记录,请勿重复使用");
  99. return;
  100. }
  101. dh.ExecuteSql($@"insert INTO burn_info (burn_id,burn_lotno,burn_software,
  102. check_code,dot_detail,line,burn_qty,
  103. update_name,update_time,work_order) VALUES (BURN_INFO_SEQ.nextval,'{BurnLotnoVal.Text.Trim()}','{BurnSwVal.Text.Trim()}',
  104. '{CheckCodeVal.Text.Trim()}','{DotVal.Text.Trim()}','{LineVal.Text.Trim()}','{remainQty}',
  105. '{User.UserName}',sysdate,'{ma_code.Text.Trim()}')", "insert");
  106. BurnLotnoVal.Focus();
  107. BurnLotnoVal.SelectAll();
  108. BurnSwVal.Text = "";
  109. CheckCodeVal.Text = "";
  110. DotVal.Text = "";
  111. ShowMsg(1, "添加烧录信息成功");
  112. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME FROM burn_info WHERE work_order = '{ma_code.Text}'", "select");
  113. if (dt.Rows.Count > 0)
  114. {
  115. DataBox.DataSource = dt;
  116. }
  117. dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
  118. if (dt.Rows.Count > 0)
  119. {
  120. CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
  121. }
  122. }
  123. private void ShowMsg(int type, string msg)
  124. {
  125. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  126. if (type == 0)
  127. {
  128. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  129. }
  130. else if (type == 1)
  131. {
  132. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
  133. }
  134. }
  135. private void BurnLotnoVal_KeyDown(object sender, KeyEventArgs e)
  136. {
  137. if (e.KeyCode != Keys.Enter) return;
  138. BurnLotnoVal.Text = BurnLotnoVal.Text.Trim();
  139. if (!string.IsNullOrEmpty(BurnLotnoVal.Text))
  140. {
  141. dt = (DataTable)dh.ExecuteSql($"select * from barcode where bar_code = '{BurnLotnoVal.Text}'", "select");
  142. if (dt.Rows.Count == 0)
  143. {
  144. ShowMsg(0, $"条码:{BurnLotnoVal.Text} 不是MES系统中库存条码");
  145. BurnLotnoVal.Text = "";
  146. return;
  147. }
  148. remainQty = dt.Rows[0]["BAR_REMAIN"].ToString();
  149. }
  150. if (string.IsNullOrEmpty(ma_code.Text))
  151. {
  152. ShowMsg(0, "请选择归属工单");
  153. ma_code.Focus();
  154. return;
  155. }
  156. if(Convert.ToInt32(CurrQtyVal.Text) > Convert.ToInt32(ma_qty.Text))
  157. {
  158. ShowMsg(0, "烧录数量已达标,超过工单批量");
  159. ma_code.Focus();
  160. return;
  161. }
  162. if (string.IsNullOrEmpty(EmployeeVal.Text))
  163. {
  164. ShowMsg(0, "请输入操作人员");
  165. ma_code.Focus();
  166. return;
  167. }
  168. /*if (string.IsNullOrEmpty(LineVal.Text))
  169. {
  170. ShowMsg(0, "请选择线体");
  171. LineVal.Focus();
  172. LineVal.SelectAll();
  173. return;
  174. }*/
  175. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  176. {
  177. ShowMsg(0, "请扫描包批次号");
  178. BurnLotnoVal.Focus();
  179. BurnLotnoVal.SelectAll();
  180. return;
  181. }
  182. dt = (DataTable)dh.ExecuteSql($@"select * from burn_info where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  183. if (dt.Rows.Count > 0)
  184. {
  185. ShowMsg(0, $"批号:{BurnLotnoVal.Text} 已记录,请勿重复使用");
  186. return;
  187. }
  188. dh.ExecuteSql($@"insert INTO burn_info (burn_id,burn_lotno,burn_software,
  189. check_code,dot_detail,line,burn_qty,
  190. update_name,update_time,work_order) VALUES (BURN_INFO_SEQ.nextval,'{BurnLotnoVal.Text.Trim()}','{BurnSwVal.Text.Trim()}',
  191. '{CheckCodeVal.Text.Trim()}','{DotVal.Text.Trim()}','{LineVal.Text.Trim()}','{remainQty}',
  192. '{EmployeeVal.Text}',sysdate,'{ma_code.Text.Trim()}')", "insert");
  193. BurnLotnoVal.Focus();
  194. BurnLotnoVal.SelectAll();
  195. BurnLotnoVal.Text = "";
  196. /*BurnSwVal.Text = "";
  197. CheckCodeVal.Text = "";
  198. DotVal.Text = "";*/
  199. ShowMsg(1, $"批号:{BurnLotnoVal.Text} 添加烧录信息成功");
  200. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME FROM burn_info WHERE work_order = '{ma_code.Text}'", "select");
  201. if (dt.Rows.Count > 0)
  202. {
  203. DataBox.DataSource = dt;
  204. }
  205. dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
  206. if (dt.Rows.Count > 0)
  207. {
  208. CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
  209. }
  210. }
  211. private void BurnSwVal_KeyDown(object sender, KeyEventArgs e)
  212. {
  213. if (e.KeyCode != Keys.Enter) return;
  214. CheckCodeVal.Focus();
  215. CheckCodeVal.SelectAll();
  216. }
  217. private void CheckCodeVal_KeyDown(object sender, KeyEventArgs e)
  218. {
  219. if (e.KeyCode != Keys.Enter) return;
  220. DotVal.Focus();
  221. DotVal.SelectAll();
  222. }
  223. private void DotVal_KeyDown(object sender, KeyEventArgs e)
  224. {
  225. if (e.KeyCode != Keys.Enter) return;
  226. Confirm.Focus();
  227. }
  228. private void ClearMsg_Click(object sender, EventArgs e)
  229. {
  230. OperateResult.Clear();
  231. }
  232. }
  233. }