Make_CollectElec.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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 + "' or WC_PKID='" + PKID.Text + "' or WC_KEY='" + KEY.Text + "' or WC_MAC='" + IMEI.Text + "' or WC_IMEI='" + IMEI.Text + "')"))
  70. {
  71. OperateResult.AppendText(">>包含重复信息\n", Color.Red);
  72. return;
  73. }
  74. sncode.Text = TSN.Text;
  75. if (sncode.Text == "")
  76. {
  77. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  78. return;
  79. }
  80. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage2))
  81. {
  82. //判断界面工单是否为空时的序列号是否自动归属工单
  83. string oStatus = "";
  84. if (!LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out oStatus, out ErrorMessage2))
  85. {
  86. if (ms_makecode.Text == "")
  87. {
  88. OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  89. return;
  90. }
  91. }
  92. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  93. // 获取工单归属工单下一工序是否正确
  94. if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text == "" ? oMakeCode : ms_makecode.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2))
  95. {
  96. sql.Clear();
  97. 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 ");
  98. sql.Append(" ms_prodcode = pr_code where ms_id = '" + oMsID + "'");
  99. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  100. BaseUtil.SetFormValue(this.Controls, dt);
  101. OperateResult.AppendText(">>请输入核对参数\n", Color.Black);
  102. sn_code = sncode.Text;
  103. sncode.Text = "";
  104. isnetcode = true;
  105. return;
  106. }
  107. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  108. }
  109. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  110. }
  111. //采集netcode
  112. else
  113. {
  114. if (CheckTSN.Checked)
  115. {
  116. if (TSN_CHECK.Text == "")
  117. {
  118. if (TSN.Text == sncode.Text)
  119. {
  120. TSN_CHECK.Text = sncode.Text;
  121. {
  122. OperateResult.AppendText(">>TSN核对成功\n", Color.Green);
  123. if (CheckInfoPass())
  124. {
  125. 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");
  126. isnetcode = false;
  127. sncode.Text = "";
  128. sncode.Focus();
  129. return;
  130. }
  131. return;
  132. }
  133. }
  134. else
  135. {
  136. OperateResult.AppendText(">>TSN核对错误,请重新输入\n", Color.Red);
  137. return;
  138. }
  139. }
  140. }
  141. if (CheckPSN.Checked)
  142. {
  143. if ((!CheckTSN.Checked || TSN_CHECK.Text != "") && PSN_CHECK.Text == "")
  144. {
  145. if (PSN.Text == sncode.Text)
  146. {
  147. PSN_CHECK.Text = sncode.Text;
  148. {
  149. OperateResult.AppendText(">>PSN核对成功\n", Color.Green);
  150. if (CheckInfoPass())
  151. {
  152. 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");
  153. isnetcode = false;
  154. sncode.Text = "";
  155. sncode.Focus();
  156. return;
  157. }
  158. return;
  159. }
  160. }
  161. else
  162. {
  163. OperateResult.AppendText(">>PSN核对错误,请重新输入\n", Color.Red);
  164. return;
  165. }
  166. }
  167. }
  168. if (CheckPKID.Checked)
  169. {
  170. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "") && PKID_CHECK.Text == "")
  171. {
  172. if (PKID.Text == sncode.Text)
  173. {
  174. PKID_CHECK.Text = sncode.Text;
  175. {
  176. OperateResult.AppendText(">>PKID核对成功\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. return;
  184. }
  185. return;
  186. }
  187. }
  188. else
  189. {
  190. OperateResult.AppendText(">>PKID核对错误,请重新输入\n", Color.Red);
  191. return;
  192. }
  193. }
  194. }
  195. if (CheckKey.Checked)
  196. {
  197. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "") && KEY_CHECK.Text == "")
  198. {
  199. if (KEY.Text == sncode.Text)
  200. {
  201. KEY_CHECK.Text = sncode.Text;
  202. {
  203. OperateResult.AppendText(">>KEY核对成功\n", Color.Green);
  204. if (CheckInfoPass())
  205. {
  206. 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");
  207. isnetcode = false;
  208. sncode.Text = "";
  209. sncode.Focus();
  210. return;
  211. }
  212. return;
  213. }
  214. }
  215. else
  216. {
  217. OperateResult.AppendText(">>KEY核对错误,请重新输入\n", Color.Red);
  218. return;
  219. }
  220. }
  221. }
  222. if (CheckMac.Checked)
  223. {
  224. if ((!CheckTSN.Checked || TSN_CHECK.Text != "" || !CheckPSN.Checked || PSN_CHECK.Text != "" || !CheckPKID.Checked || PKID_CHECK.Text != "" || !CheckKey.Checked || KEY_CHECK.Text != "") && MAC_CHECK.Text == "")
  225. {
  226. if (MAC.Text == sncode.Text)
  227. {
  228. MAC_CHECK.Text = sncode.Text;
  229. {
  230. OperateResult.AppendText(">>MAC核对成功\n", Color.Green);
  231. if (CheckInfoPass())
  232. {
  233. 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");
  234. isnetcode = false;
  235. sncode.Text = "";
  236. sncode.Focus();
  237. return;
  238. }
  239. return;
  240. }
  241. }
  242. else
  243. {
  244. OperateResult.AppendText(">>MAC核对错误,请重新输入\n", Color.Red);
  245. return;
  246. }
  247. }
  248. }
  249. if (CheckImei.Checked)
  250. {
  251. 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 == "")
  252. {
  253. if (IMEI.Text == sncode.Text)
  254. {
  255. IMEI_CHECK.Text = sncode.Text;
  256. {
  257. OperateResult.AppendText(">>IMEI核对成功\n", Color.Green);
  258. if (CheckInfoPass())
  259. {
  260. 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");
  261. isnetcode = false;
  262. sncode.Text = "";
  263. sncode.Focus();
  264. return;
  265. }
  266. return;
  267. }
  268. }
  269. else
  270. {
  271. OperateResult.AppendText(">>IMEI核对错误,请重新输入\n", Color.Red);
  272. return;
  273. }
  274. }
  275. }
  276. }
  277. }
  278. }
  279. private bool CheckInfoPass()
  280. {
  281. if (CheckTSN.Checked)
  282. {
  283. if (TSN.Text != TSN_CHECK.Text)
  284. {
  285. return false;
  286. }
  287. }
  288. if (CheckPSN.Checked)
  289. {
  290. if (PSN.Text != PSN_CHECK.Text)
  291. return false;
  292. }
  293. if (CheckPKID.Checked)
  294. {
  295. if (PKID.Text != PKID_CHECK.Text)
  296. return false;
  297. }
  298. if (CheckKey.Checked)
  299. {
  300. if (KEY.Text != KEY_CHECK.Text)
  301. return false;
  302. }
  303. if (CheckMac.Checked)
  304. {
  305. if (MAC.Text != MAC_CHECK.Text)
  306. return false;
  307. }
  308. if (CheckImei.Checked)
  309. {
  310. if (IMEI.Text != IMEI_CHECK.Text)
  311. return false;
  312. }
  313. string ErrorMessage2;
  314. if (!LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, TSN.Text, "核对标签信息", "核对成功", User.UserCode, out ErrorMessage2))
  315. {
  316. OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red);
  317. }
  318. return true;
  319. }
  320. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  321. {
  322. asc.controlAutoSize(this);
  323. }
  324. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  325. {
  326. sncode.Focus();
  327. }
  328. private void deleteButton1_Click(object sender, EventArgs e)
  329. {
  330. if (isnetcode)
  331. {
  332. BaseUtil.CleanForm(this);
  333. OperateResult.AppendText(">>清除完成,清重新输入SN号\n", Color.Green);
  334. isnetcode = false;
  335. sncode.Focus();
  336. TSN.Clear();
  337. PSN.Clear();
  338. PKID.Clear();
  339. IMEI.Clear();
  340. MAC.Clear();
  341. KEY.Clear();
  342. }
  343. }
  344. }
  345. }