Make_CollectElec.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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 (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 (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 (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 (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 (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. if (!LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out oStatus, out ErrorMessage2))
  105. {
  106. if (ms_makecode.Text == "")
  107. {
  108. OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  109. return;
  110. }
  111. }
  112. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  113. // 获取工单归属工单下一工序是否正确
  114. if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text == "" ? oMakeCode : ms_makecode.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2))
  115. {
  116. sql.Clear();
  117. 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 ");
  118. sql.Append(" ms_prodcode = pr_code where ms_id = '" + oMsID + "'");
  119. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  120. BaseUtil.SetFormValue(this.Controls, dt);
  121. OperateResult.AppendText(">>请输入核对参数\n", Color.Black);
  122. sn_code = sncode.Text;
  123. sncode.Text = "";
  124. isnetcode = true;
  125. return;
  126. }
  127. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  128. }
  129. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  130. }
  131. //采集netcode
  132. else
  133. {
  134. if (CheckTSN.Checked)
  135. {
  136. if (TSN_CHECK.Text == "")
  137. {
  138. if (TSN.Text == sncode.Text)
  139. {
  140. TSN_CHECK.Text = sncode.Text;
  141. {
  142. OperateResult.AppendText(">>TSN核对成功\n", Color.Green);
  143. if (CheckInfoPass())
  144. {
  145. 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");
  146. isnetcode = false;
  147. sncode.Text = "";
  148. sncode.Focus();
  149. CleanData();
  150. return;
  151. }
  152. return;
  153. }
  154. }
  155. else
  156. {
  157. OperateResult.AppendText(">>TSN核对错误,请重新输入\n", Color.Red);
  158. return;
  159. }
  160. }
  161. }
  162. if (CheckPSN.Checked)
  163. {
  164. if ((!CheckTSN.Checked || TSN_CHECK.Text != "") && PSN_CHECK.Text == "")
  165. {
  166. if (PSN.Text == sncode.Text)
  167. {
  168. PSN_CHECK.Text = sncode.Text;
  169. {
  170. OperateResult.AppendText(">>PSN核对成功\n", Color.Green);
  171. if (CheckInfoPass())
  172. {
  173. 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");
  174. isnetcode = false;
  175. sncode.Text = "";
  176. sncode.Focus();
  177. CleanData();
  178. return;
  179. }
  180. return;
  181. }
  182. }
  183. else
  184. {
  185. OperateResult.AppendText(">>PSN核对错误,请重新输入\n", Color.Red);
  186. return;
  187. }
  188. }
  189. }
  190. if (CheckPKID.Checked)
  191. {
  192. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "") && PKID_CHECK.Text == "")
  193. {
  194. if (PKID.Text == sncode.Text)
  195. {
  196. PKID_CHECK.Text = sncode.Text;
  197. {
  198. OperateResult.AppendText(">>PKID核对成功\n", Color.Green);
  199. if (CheckInfoPass())
  200. {
  201. 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");
  202. isnetcode = false;
  203. sncode.Text = "";
  204. sncode.Focus();
  205. CleanData();
  206. return;
  207. }
  208. return;
  209. }
  210. }
  211. else
  212. {
  213. OperateResult.AppendText(">>PKID核对错误,请重新输入\n", Color.Red);
  214. return;
  215. }
  216. }
  217. }
  218. if (CheckKey.Checked)
  219. {
  220. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "") && KEY_CHECK.Text == "")
  221. {
  222. if (KEY.Text == sncode.Text)
  223. {
  224. KEY_CHECK.Text = sncode.Text;
  225. {
  226. OperateResult.AppendText(">>KEY核对成功\n", Color.Green);
  227. if (CheckInfoPass())
  228. {
  229. 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");
  230. isnetcode = false;
  231. sncode.Text = "";
  232. sncode.Focus();
  233. CleanData();
  234. return;
  235. }
  236. return;
  237. }
  238. }
  239. else
  240. {
  241. OperateResult.AppendText(">>KEY核对错误,请重新输入\n", Color.Red);
  242. return;
  243. }
  244. }
  245. }
  246. if (CheckMac.Checked)
  247. {
  248. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "" || !CheckKey.Checked || KEY_CHECK.Text != "") && MAC_CHECK.Text == "")
  249. {
  250. if (MAC.Text == sncode.Text)
  251. {
  252. MAC_CHECK.Text = sncode.Text;
  253. {
  254. OperateResult.AppendText(">>MAC核对成功\n", Color.Green);
  255. if (CheckInfoPass())
  256. {
  257. 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");
  258. isnetcode = false;
  259. sncode.Text = "";
  260. sncode.Focus();
  261. CleanData();
  262. return;
  263. }
  264. return;
  265. }
  266. }
  267. else
  268. {
  269. OperateResult.AppendText(">>MAC核对错误,请重新输入\n", Color.Red);
  270. return;
  271. }
  272. }
  273. }
  274. if (CheckImei.Checked)
  275. {
  276. 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 == "")
  277. {
  278. if (IMEI.Text == sncode.Text)
  279. {
  280. IMEI_CHECK.Text = sncode.Text;
  281. {
  282. OperateResult.AppendText(">>IMEI核对成功\n", Color.Green);
  283. if (CheckInfoPass())
  284. {
  285. 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");
  286. isnetcode = false;
  287. sncode.Text = "";
  288. sncode.Focus();
  289. CleanData();
  290. return;
  291. }
  292. return;
  293. }
  294. }
  295. else
  296. {
  297. OperateResult.AppendText(">>IMEI核对错误,请重新输入\n", Color.Red);
  298. return;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. private void CleanData()
  306. {
  307. TSN.Clear();
  308. PSN.Clear();
  309. PKID.Clear();
  310. IMEI.Clear();
  311. MAC.Clear();
  312. KEY.Clear();
  313. TSN_CHECK.Clear();
  314. PSN_CHECK.Clear();
  315. PKID.Clear();
  316. IMEI.Clear();
  317. MAC.Clear();
  318. KEY.Clear();
  319. OperateResult.AppendText(">>核对完成,请重新输入SN号\n", Color.Green);
  320. }
  321. private bool CheckInfoPass()
  322. {
  323. if (CheckTSN.Checked)
  324. {
  325. if (TSN.Text != TSN_CHECK.Text)
  326. {
  327. return false;
  328. }
  329. }
  330. if (CheckPSN.Checked)
  331. {
  332. if (PSN.Text != PSN_CHECK.Text)
  333. return false;
  334. }
  335. if (CheckPKID.Checked)
  336. {
  337. if (PKID.Text != PKID_CHECK.Text)
  338. return false;
  339. }
  340. if (CheckKey.Checked)
  341. {
  342. if (KEY.Text != KEY_CHECK.Text)
  343. return false;
  344. }
  345. if (CheckMac.Checked)
  346. {
  347. if (MAC.Text != MAC_CHECK.Text)
  348. return false;
  349. }
  350. if (CheckImei.Checked)
  351. {
  352. if (IMEI.Text != IMEI_CHECK.Text)
  353. return false;
  354. }
  355. string ErrorMessage2;
  356. if (!LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, TSN.Text, "核对标签信息", "核对成功", User.UserCode, out ErrorMessage2))
  357. {
  358. OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red);
  359. }
  360. else
  361. {
  362. }
  363. return true;
  364. }
  365. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  366. {
  367. asc.controlAutoSize(this);
  368. }
  369. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  370. {
  371. sncode.Focus();
  372. }
  373. private void deleteButton1_Click(object sender, EventArgs e)
  374. {
  375. CleanData();
  376. }
  377. private void StepCount_Load(object sender, EventArgs e)
  378. {
  379. }
  380. }
  381. }