Make_CollectElec.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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_CollectElec : Form
  15. {
  16. DataHelper dh;
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. LogStringBuilder sql = new LogStringBuilder();
  19. DataTable dt;
  20. //当前序列号记录
  21. string sn_code;
  22. //制造单号
  23. string macode;
  24. //采集网标号
  25. float net_code;
  26. //网标查询条件ms_id
  27. string oMsID;
  28. //判断是否输入网标
  29. Boolean isnetcode = false;
  30. //打印计数
  31. int printcount = 0;
  32. int ma_unlimitin;
  33. public Make_CollectElec()
  34. {
  35. InitializeComponent();
  36. }
  37. private void Make_CollectNetCode_Load(object sender, EventArgs e)
  38. {
  39. asc.controllInitializeSize(this);
  40. sncode.Focus();
  41. dh = SystemInf.dh;
  42. StepCount.StepCode = User.CurrentStepCode;
  43. StepCount.Source = User.UserSourceCode;
  44. StepCount.LineCode = User.UserLineCode;
  45. StepCount.Dh = dh;
  46. StepCount.Start();
  47. }
  48. private void sncode_KeyDown(object sender, KeyEventArgs e)
  49. {
  50. if (e.KeyCode == Keys.Enter)
  51. {
  52. string ErrorMessage2;
  53. string oMakeCode;
  54. //采集序列号
  55. if (!isnetcode)
  56. {
  57. string[] arr = sncode.Text.Split(',');
  58. if (arr.Length != 6)
  59. {
  60. OperateResult.AppendText(">>数据长度错误,无法解析\n", Color.Red);
  61. return;
  62. }
  63. TSN.Text = arr[0];
  64. PSN.Text = arr[1];
  65. PKID.Text = arr[2];
  66. KEY.Text = arr[3];
  67. MAC.Text = arr[4];
  68. IMEI.Text = arr[5];
  69. if (CheckPSN.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_PSN='" + PSN.Text + "')"))
  70. {
  71. OperateResult.AppendText(">>PSN重复信息\n", Color.Red);
  72. return;
  73. }
  74. if (CheckMac.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_MAC='" + MAC.Text + "' )"))
  75. {
  76. OperateResult.AppendText(">>MAC重复信息\n", Color.Red);
  77. return;
  78. }
  79. if (CheckPKID.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_PKID='" + PKID.Text + "')") && PKID.Text != "NONE")
  80. {
  81. OperateResult.AppendText(">>PKID重复信息\n", Color.Red);
  82. return;
  83. }
  84. if (CheckKey.Checked&& dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_KEY='" + KEY.Text + "')") && KEY.Text != "NONE")
  85. {
  86. OperateResult.AppendText(">>KEY重复信息\n", Color.Red);
  87. return;
  88. }
  89. if (CheckImei.Checked&&dh.CheckExist("wincheck", "WC_SNCODE<>'" + TSN.Text + "' and (WC_IMEI='" + IMEI.Text + "')"))
  90. {
  91. OperateResult.AppendText(">>IMEI重复信息\n", Color.Red);
  92. return;
  93. }
  94. sncode.Text = TSN.Text;
  95. if (sncode.Text == "")
  96. {
  97. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  98. return;
  99. }
  100. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage2))
  101. {
  102. //判断界面工单是否为空时的序列号是否自动归属工单
  103. string oStatus = "";
  104. string sn_code = "";
  105. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_sncode ='" + TSN.Text + "' or ms_firstsn='" + TSN.Text + "' order by ms_id desc", "select");
  106. if (dt.Rows.Count > 0)
  107. {
  108. sn_code = dt.Rows[0]["ms_sncode"].ToString();
  109. }
  110. if (!LogicHandler.GetMakeInfo(sn_code, out oMakeCode, out oStatus, out ErrorMessage2))
  111. {
  112. if (ms_makecode.Text == "")
  113. {
  114. OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  115. return;
  116. }
  117. }
  118. OperateResult.AppendText("<<" + sn_code + "\n", Color.Black);
  119. // 获取工单归属工单下一工序是否正确
  120. if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text == "" ? oMakeCode : ms_makecode.Text, User.UserSourceCode, sn_code, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2))
  121. {
  122. sql.Clear();
  123. sql.Append("select ms_makecode,ms_prodcode,pr_detail,nvl(pr_electricmax,0)pr_electricmax,nvl(pr_electricmin,0)pr_electricmin from makeserial left join product on ");
  124. sql.Append(" ms_prodcode = pr_code where ms_id = '" + oMsID + "'");
  125. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  126. BaseUtil.SetFormValue(this.Controls, dt);
  127. OperateResult.AppendText(">>请输入核对参数\n", Color.Black);
  128. sn_code = sncode.Text;
  129. sncode.Text = "";
  130. isnetcode = true;
  131. return;
  132. }
  133. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  134. }
  135. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  136. }
  137. //采集netcode
  138. else
  139. {
  140. if (CheckTSN.Checked)
  141. {
  142. if (TSN_CHECK.Text == "")
  143. {
  144. if (TSN.Text == sncode.Text)
  145. {
  146. TSN_CHECK.Text = sncode.Text;
  147. {
  148. OperateResult.AppendText(">>TSN核对成功\n", Color.Green);
  149. if (CheckInfoPass())
  150. {
  151. dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
  152. isnetcode = false;
  153. sncode.Text = "";
  154. sncode.Focus();
  155. CleanData();
  156. return;
  157. }
  158. return;
  159. }
  160. }
  161. else
  162. {
  163. OperateResult.AppendText(">>TSN核对错误,请重新输入\n", Color.Red);
  164. return;
  165. }
  166. }
  167. }
  168. if (CheckPSN.Checked)
  169. {
  170. if ((!CheckTSN.Checked || TSN_CHECK.Text != "") && PSN_CHECK.Text == "")
  171. {
  172. if (PSN.Text == sncode.Text)
  173. {
  174. PSN_CHECK.Text = sncode.Text;
  175. {
  176. OperateResult.AppendText(">>PSN核对成功\n", Color.Green);
  177. if (CheckInfoPass())
  178. {
  179. dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
  180. isnetcode = false;
  181. sncode.Text = "";
  182. sncode.Focus();
  183. CleanData();
  184. return;
  185. }
  186. return;
  187. }
  188. }
  189. else
  190. {
  191. OperateResult.AppendText(">>PSN核对错误,请重新输入\n", Color.Red);
  192. return;
  193. }
  194. }
  195. }
  196. if (CheckPKID.Checked)
  197. {
  198. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "") && PKID_CHECK.Text == "")
  199. {
  200. if (PKID.Text == sncode.Text)
  201. {
  202. PKID_CHECK.Text = sncode.Text;
  203. {
  204. OperateResult.AppendText(">>PKID核对成功\n", Color.Green);
  205. if (CheckInfoPass())
  206. {
  207. dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
  208. isnetcode = false;
  209. sncode.Text = "";
  210. sncode.Focus();
  211. CleanData();
  212. return;
  213. }
  214. return;
  215. }
  216. }
  217. else
  218. {
  219. OperateResult.AppendText(">>PKID核对错误,请重新输入\n", Color.Red);
  220. return;
  221. }
  222. }
  223. }
  224. if (CheckKey.Checked)
  225. {
  226. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "") && KEY_CHECK.Text == "")
  227. {
  228. if (KEY.Text == sncode.Text)
  229. {
  230. KEY_CHECK.Text = sncode.Text;
  231. {
  232. OperateResult.AppendText(">>KEY核对成功\n", Color.Green);
  233. if (CheckInfoPass())
  234. {
  235. dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
  236. isnetcode = false;
  237. sncode.Text = "";
  238. sncode.Focus();
  239. CleanData();
  240. return;
  241. }
  242. return;
  243. }
  244. }
  245. else
  246. {
  247. OperateResult.AppendText(">>KEY核对错误,请重新输入\n", Color.Red);
  248. return;
  249. }
  250. }
  251. }
  252. if (CheckMac.Checked)
  253. {
  254. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "" || !CheckKey.Checked || KEY_CHECK.Text != "") && MAC_CHECK.Text == "")
  255. {
  256. if (MAC.Text == sncode.Text)
  257. {
  258. MAC_CHECK.Text = sncode.Text;
  259. {
  260. OperateResult.AppendText(">>MAC核对成功\n", Color.Green);
  261. if (CheckInfoPass())
  262. {
  263. dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
  264. isnetcode = false;
  265. sncode.Text = "";
  266. sncode.Focus();
  267. CleanData();
  268. return;
  269. }
  270. return;
  271. }
  272. }
  273. else
  274. {
  275. OperateResult.AppendText(">>MAC核对错误,请重新输入\n", Color.Red);
  276. return;
  277. }
  278. }
  279. }
  280. if (CheckImei.Checked)
  281. {
  282. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "" || !CheckKey.Checked || KEY_CHECK.Text != "" || !CheckMac.Checked || MAC_CHECK.Text != "") && IMEI_CHECK.Text == "")
  283. {
  284. if (IMEI.Text == sncode.Text)
  285. {
  286. IMEI_CHECK.Text = sncode.Text;
  287. {
  288. OperateResult.AppendText(">>IMEI核对成功\n", Color.Green);
  289. if (CheckInfoPass())
  290. {
  291. dh.ExecuteSql("insert into wincheck(WC_ID, WC_SNCODE, WC_PSN, WC_PKID, WC_KEY, WC_MAC, WC_IMEI) values(wincheck_seq.nextval,'" + TSN.Text + "','" + PSN.Text + "','" + PKID.Text + "','" + KEY.Text + "','" + MAC.Text + "','" + IMEI.Text + "')", "insert");
  292. isnetcode = false;
  293. sncode.Text = "";
  294. sncode.Focus();
  295. CleanData();
  296. return;
  297. }
  298. return;
  299. }
  300. }
  301. else
  302. {
  303. OperateResult.AppendText(">>IMEI核对错误,请重新输入\n", Color.Red);
  304. return;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. private void CleanData()
  312. {
  313. TSN.Clear();
  314. PSN.Clear();
  315. PKID.Clear();
  316. IMEI.Clear();
  317. MAC.Clear();
  318. KEY.Clear();
  319. TSN_CHECK.Clear();
  320. PSN_CHECK.Clear();
  321. PKID.Clear();
  322. IMEI.Clear();
  323. MAC.Clear();
  324. KEY.Clear();
  325. OperateResult.AppendText(">>核对完成,请重新输入SN号\n", Color.Green);
  326. }
  327. private bool CheckInfoPass()
  328. {
  329. if (CheckTSN.Checked)
  330. {
  331. if (TSN.Text != TSN_CHECK.Text)
  332. {
  333. return false;
  334. }
  335. }
  336. if (CheckPSN.Checked)
  337. {
  338. if (PSN.Text != PSN_CHECK.Text)
  339. return false;
  340. }
  341. if (CheckPKID.Checked)
  342. {
  343. if (PKID.Text != PKID_CHECK.Text)
  344. return false;
  345. }
  346. if (CheckKey.Checked)
  347. {
  348. if (KEY.Text != KEY_CHECK.Text)
  349. return false;
  350. }
  351. if (CheckMac.Checked)
  352. {
  353. if (MAC.Text != MAC_CHECK.Text)
  354. return false;
  355. }
  356. if (CheckImei.Checked)
  357. {
  358. if (IMEI.Text != IMEI_CHECK.Text)
  359. return false;
  360. }
  361. string ErrorMessage2;
  362. string sn_code = "";
  363. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_sncode ='" + TSN.Text + "' or ms_firstsn='" + TSN.Text + "' order by ms_id desc", "select");
  364. if (dt.Rows.Count > 0)
  365. {
  366. sn_code = dt.Rows[0]["ms_sncode"].ToString();
  367. }
  368. if (!LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, sn_code, "核对标签信息", "核对成功", User.UserCode, out ErrorMessage2))
  369. {
  370. OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red);
  371. }
  372. else
  373. {
  374. }
  375. return true;
  376. }
  377. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  378. {
  379. asc.controlAutoSize(this);
  380. }
  381. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  382. {
  383. sncode.Focus();
  384. }
  385. private void deleteButton1_Click(object sender, EventArgs e)
  386. {
  387. CleanData();
  388. }
  389. private void StepCount_Load(object sender, EventArgs e)
  390. {
  391. }
  392. }
  393. }