Make_SeqTransform.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
  6. using UAS_MES_NEW.DataOperate;
  7. using UAS_MES_NEW.Entity;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Make
  10. {
  11. public partial class Make_SeqTransform : Form
  12. {
  13. AutoSizeFormClass asc = new AutoSizeFormClass();
  14. DataHelper dh;
  15. DataTable dt;
  16. DataTable rules;
  17. LogStringBuilder sql = new LogStringBuilder();
  18. string bsncode = "";//转换前序列号
  19. string errorMessage = "";
  20. DataTable ListA;
  21. //存放工单中数量
  22. int ma_qty;
  23. string oMakeCode = "";
  24. string oMsId = "";
  25. bool onlyPass = false;
  26. bool hasSnList = false;//记录是否有转换后SN清单
  27. bool hasMakeRule = false;//记录是否有工单防呆规则
  28. bool hasSaleRule = false;//记录是否有合同防呆规则
  29. public Make_SeqTransform()
  30. {
  31. InitializeComponent();
  32. }
  33. private void sncode_KeyDown(object sender, KeyEventArgs e)
  34. {
  35. if (e.KeyCode == Keys.Enter)
  36. {
  37. if (sncode.Text != "")
  38. {
  39. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out errorMessage))
  40. {
  41. if (sncode.Text.Length < 10)
  42. {
  43. OperateResult.AppendText(">>" + sncode.Text + "长度不足无法采集\n", Color.Red);
  44. ReCall_Click(this, e);
  45. return;
  46. }
  47. if (sncode.Text.Length > 100)
  48. {
  49. OperateResult.AppendText(">>" + sncode.Text + "长度超过50无法采集\n", Color.Red);
  50. ReCall_Click(this, e);
  51. return;
  52. }
  53. OperateResult.AppendText(">>" + sncode.Text + "\n", Color.Black);
  54. //如果用户没有输入工单号自行去后台查询
  55. //通过工单序列号关系验证
  56. //bsncode为空,就说明是输入转换之前的序列号
  57. if (bsncode == "")
  58. {
  59. if (!ChangeResult.Checked)
  60. {
  61. //用户填写了工单号,那么序列号必须要是该工单的,否则提示错误
  62. if (!LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsId, out errorMessage))
  63. {
  64. OperateResult.AppendText("<<" + errorMessage + "\n", Color.Red, sncode);
  65. return;
  66. }
  67. if (dh.CheckExist("packagedetail", "pd_barcode = '" + sncode.Text + "' and pd_makecode = '" + oMakeCode + "'"))
  68. {
  69. OperateResult.AppendText("<<SN:" + sncode.Text + "已装箱,不可操作\n", Color.Red, sncode);
  70. return;
  71. }
  72. }
  73. else//勾选
  74. {
  75. oMsId = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode in (select '" + sncode.Text + "' from dual union select sn from makesnrelation where beforesn='" + sncode.Text + "' and sn<>' ' union select beforesn from makesnrelation where sn='" + sncode.Text + "' and beforesn<>' ')").ToString();
  76. if (oMsId == "")
  77. {
  78. OperateResult.AppendText("<<TSN号错误\n", Color.Red, sncode);
  79. return;
  80. }
  81. //根据ms_id查询
  82. sql.Clear();
  83. sql.Append("select ms_stepcode,nvl(ms_downstatus,'0') ms_downstatus from makeserial where ms_id='" + oMsId + "' and ms_beforesn='" + sncode.Text + "' and ms_nextmacode is null and ms_outboxcode is null");
  84. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  85. //如果行数大于0则允许转号
  86. if (dt.Rows.Count > 0)
  87. {
  88. if (dt.Rows[0]["ms_downstatus"].ToString() != "0")
  89. {
  90. OperateResult.AppendText("<<当前TSN号处于下地状态不允许操作\n", Color.Red, sncode);
  91. return;
  92. }
  93. bsncode = sncode.Text;
  94. //显示序列号
  95. show_sncode.Text = bsncode;
  96. ChangeResult.Enabled = false;
  97. //if (dt.Rows[0]["ms_stepcode"].ToString() == User.CurrentStepCode)
  98. //{
  99. // bsncode = sncode.Text;
  100. // //显示序列号
  101. // show_sncode.Text = bsncode;
  102. // ChangeResult.Enabled = false;
  103. //}
  104. //else
  105. //{
  106. // OperateResult.AppendText("<<当前工序不允许重新转号\n", Color.Red, sncode);
  107. // return;
  108. //}
  109. }
  110. else
  111. {
  112. OperateResult.AppendText("<<TSN号" + sncode.Text + "未转号不允许重新转号\n", Color.Red, sncode);
  113. return;
  114. }
  115. }
  116. //如果用户没有选择工单号
  117. if (ma_code.Text == "" || ma_code.Text != oMakeCode || ChangeResult.Checked)
  118. {
  119. //按照out出的工单号查出工单相关信息,并赋值到相关控件
  120. sql.Clear();
  121. sql.Append("select ma_code,ma_softversion,ma_prodcode,pr_orispeccode pr_detail,ma_endremark,ma_salecode,ma_qty,ma_qty-mcd_inqty as remain_qty ");
  122. sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on ");
  123. sql.Append("ms_prodcode=pr_code left join makecraftdetail_view on ms_makecode=mcd_macode where ms_id='" + oMsId + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  124. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  125. if (dt.Rows.Count > 0)
  126. {
  127. //记录数量
  128. ma_qty = int.Parse(dt.Rows[0]["ma_qty"].ToString());
  129. BaseUtil.SetFormValue(this.Controls, dt);
  130. }
  131. }
  132. //获取需要关联采集的信息,以及校验规则
  133. ListA = (DataTable)dh.ExecuteSql("select * from productsnrelation where psr_prodcode='" + ma_prodcode.Text + "' order by psr_detno", "select");
  134. //没有获取到就提示错误请维护产品对应的关联采集信息
  135. if (ListA.Rows.Count > 0)
  136. {
  137. OperateResult.AppendText("<<产品已维护关联采集信息,不允许只做转号\n", Color.Red, sncode);
  138. OperateResult.AppendText(">>请输入TSN\n", Color.Black);
  139. if (ChangeResult.Checked)
  140. {
  141. bsncode = "";
  142. ChangeResult.Enabled = true;
  143. show_sncode.Text = "";
  144. }
  145. return;
  146. }
  147. if (ChangeResult.Checked)
  148. {
  149. OperateResult.AppendText(">>请输入SN号\n", Color.Green, sncode);
  150. }
  151. switch (ChangeResult.CheckState)
  152. {
  153. //勾选是修改已转换的序列,矫正修改错了的序列号
  154. case CheckState.Checked:
  155. break;
  156. case CheckState.Unchecked:
  157. //string beforesn = dh.getFieldDataByCondition("makeserial", "ms_beforesn", "ms_sncode='" + sncode.Text + "'").ToString().Trim();
  158. //为空,就说明,没有进行过序列号的转换
  159. if (dh.CheckExist("makeserial", "ms_id='" + oMsId + "' and ms_sncode='" + sncode.Text + "' and ms_beforesn is null"))
  160. {
  161. //记录转换前的序列号
  162. bsncode = sncode.Text;
  163. //显示序列号
  164. show_sncode.Text = bsncode;
  165. OperateResult.AppendText(">>请输入SN号\n", Color.Green, sncode);
  166. ChangeResult.Enabled = false;
  167. }
  168. else
  169. //不为空,进行过转换。不勾选修改结果,就不能再修改
  170. {
  171. //修改转换结果时,输入两次SN直接过站
  172. if (dh.CheckExist("MakeSerial", "ms_id='" + oMsId + "' and ms_sncode='" + sncode.Text + "' and ms_beforesn is not null"))
  173. {
  174. string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsId + "'").ToString();
  175. if (nextstepcode == User.CurrentStepCode)
  176. {
  177. bsncode = sncode.Text;
  178. //显示序列号
  179. show_sncode.Text = bsncode;
  180. OperateResult.AppendText(">>请输入SN号\n", Color.Green, sncode);
  181. ChangeResult.Enabled = false;
  182. onlyPass = true;
  183. }
  184. else
  185. {
  186. nextstepcode = dh.getFieldDataByCondition("step", "st_name", "st_code='" + nextstepcode + "'").ToString();
  187. OperateResult.AppendText("<<序列号:" + sncode.Text + "下一工序是" + nextstepcode + ",不是当前岗位的工序\n", Color.Red, sncode);
  188. OperateResult.AppendText(">>请重新输入TSN号\n", Color.Black);
  189. }
  190. }
  191. else
  192. {
  193. OperateResult.AppendText("<<序列号:" + sncode.Text + "已转换过\n", Color.Red, sncode);
  194. OperateResult.AppendText(">>请重新输入TSN号\n", Color.Black);
  195. }
  196. }
  197. break;
  198. default:
  199. break;
  200. }
  201. }
  202. //bsncode不为空,说明输入的是转换后的序列号
  203. else
  204. {
  205. ////判断工单是否导入了序列号清单
  206. //if (hasSnList)
  207. //{
  208. // if (!dh.CheckExist("makesnlist", "msl_sncode='" + sncode.Text + "' and msl_makecode='" + ma_code.Text + "' and msl_type='after'"))
  209. // {
  210. // //有序列号清单,输入的序列号却不在范围内
  211. // OperateResult.AppendText("<<SN号" + sncode.Text + "错误,不在工单设定的转换后序列号清单中\n", Color.Red, sncode);
  212. // return;
  213. // }
  214. //}
  215. //else if (hasMakeRule)//判断工单防呆
  216. //{
  217. // if (!dh.CheckExist("makesnruledetail", "msd_sncode='" + sncode.Text + "' and msd_makecode='" + ma_code.Text + "' and msd_type='after'"))
  218. // {
  219. // OperateResult.AppendText("<<SN号" + sncode.Text + "校验错误,不在工单防呆规则指定范围内!\n", Color.Red, sncode);
  220. // return;
  221. // }
  222. //}
  223. //else if (hasSaleRule)//判断合同防呆
  224. //{
  225. // if (!dh.CheckExist("makesnruledetail", "msd_sncode='" + sncode.Text + "' and msd_salecode='" + ma_salecode.Text + "' and msd_type='after'"))
  226. // {
  227. // OperateResult.AppendText("<<SN号" + sncode.Text + "校验错误,不在合同防呆规则指定范围内!\n", Color.Red, sncode);
  228. // return;
  229. // }
  230. //}
  231. //else//判断产品防呆
  232. //{
  233. //判断用户是否锁定输入转换后序列号长度,
  234. //if (!checkLengthOrPre(afterTransSNLength_checkBox, afterTransSNLength, "长度"))
  235. // return;
  236. //判断用户是否锁定输入转换后序列号前缀,
  237. if (!checkLengthOrPre(afterTransSNPre_checkBox, afterTransSNPre, "前缀"))
  238. return;
  239. //}
  240. //防呆验证完成
  241. if ((!ChangeResult.Checked && (!dh.CheckExist("makeserial", "ms_sncode='" + sncode.Text + "'")&& (!dh.CheckExist("makeserial", "ms_code='" + sncode.Text + "' ")) && !onlyPass )) || (ChangeResult.Checked && !dh.CheckExist("makeserial", "ms_sncode='" + sncode.Text + "' ")))
  242. {
  243. //if (CollectRemark.Checked || SameReamrk.Checked)
  244. //{
  245. // if (Remark.Text == "")
  246. // {
  247. // OperateResult.AppendText(">>备注栏信息为空,录入备注信息\n", Color.Black);
  248. // Remark.SelectAll();
  249. // Remark.Focus();
  250. // return;
  251. // }
  252. // if (IFONLY.Checked)
  253. // {
  254. // if (!CheckPre())
  255. // {
  256. // return;
  257. // }
  258. // string UsedSncode = dh.getFieldDataByCondition("SNRELATIONINFORECORD", "SIR_SNCODE", "sir_remark = '" + Remark.Text + "'").ToString();
  259. // if (UsedSncode != "")
  260. // {
  261. // OperateResult.AppendText(">>备注信息" + Remark.Text + "已被" + UsedSncode + "采集,不可重复采集\n", Color.Red);
  262. // Remark.SelectAll();
  263. // Remark.Focus();
  264. // return;
  265. // }
  266. // LogicHandler.CollectRemarkInf(show_sncode.Text, "", "", oMakeCode, ma_prodcode.Text, Remark.Text);
  267. // OperateResult.AppendText(">>备注:" + Remark.Text + "\n", Color.Black);
  268. // if (CollectRemark.Checked)
  269. // {
  270. // Remark.Text = "";
  271. // }
  272. // }
  273. // else
  274. // {
  275. // if (!CheckPre())
  276. // {
  277. // return;
  278. // }
  279. // LogicHandler.CollectRemarkInf(show_sncode.Text, "", "", oMakeCode, ma_prodcode.Text, Remark.Text);
  280. // OperateResult.AppendText(">>备注:" + Remark.Text + "\n", Color.Black);
  281. // if (CollectRemark.Checked)
  282. // {
  283. // Remark.Text = "";
  284. // }
  285. // }
  286. //}
  287. if (/*!ChangeResult.Checked && */!onlyPass)
  288. {
  289. string firstsn = "";
  290. string updateSql = "";
  291. //勾选了修改转换结果
  292. if (ChangeResult.Checked)
  293. {
  294. //查询ms_firstsn
  295. firstsn = dh.getFieldDataByCondition("makeserial", "ms_firstsn", "ms_id='" + oMsId + "' and ms_beforesn='" + bsncode + "'").ToString();
  296. //记录本次修改,存入makesnrelation表中
  297. updateSql = "update makeserial set ms_sncode='" + sncode.Text + "' where ms_id='" + oMsId + "' and ms_beforesn='" + bsncode + "'";
  298. //删除最近一条转换记录
  299. dh.ExecuteSql("delete from makesnrelation where BEFORESN='" + bsncode + "' and makecode='" + ma_code.Text + "'", "delete");
  300. }
  301. //未勾选修改转换结果
  302. else
  303. {
  304. //查询ms_firstsn
  305. firstsn = dh.getFieldDataByCondition("makeserial", "ms_firstsn", "ms_id='" + oMsId + "' and ms_sncode='" + bsncode + "'").ToString();
  306. //记录本次修改,存入makesnrelation表中
  307. updateSql = "update makeserial set ms_sncode='" + sncode.Text + "', ms_beforesn='" + bsncode + "' where ms_id='" + oMsId + "' and ms_sncode='" + bsncode + "'";
  308. }
  309. string insertSql = "insert into makesnrelation (BEFORESN,SN,FIRSTSN,MAKECODE,msr_indate, msr_inman)values('" + bsncode + "','" + sncode.Text + "','" + firstsn + "','" + ma_code.Text + "', sysdate ,'" + User.UserCode + "')";
  310. dh.ExecuteSQLTran(updateSql, insertSql);
  311. }
  312. onlyPass = false;
  313. OperateResult.AppendText("<<序列号" + bsncode + "成功转换为" + sncode.Text + "\n", Color.LawnGreen);
  314. //记录日志
  315. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "序列转换", bsncode + "转换为" + sncode.Text, sncode.Text, "");
  316. //if (CollectRemark.Checked && Remark.Text != "")
  317. //{
  318. // LogicHandler.CollectRemarkInf(sncode.Text, "", "", oMakeCode, ma_prodcode.Text, Remark.Text);
  319. //}
  320. LogManager.DoLog("修改序列号:" + bsncode + "为" + sncode.Text + "成功!" + "操作人:" + User.UserCode);
  321. //写入日志
  322. if (!LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, sncode.Text, "序列转换", "序列转换成功", User.UserCode, out errorMessage))
  323. {
  324. OperateResult.AppendText(">>" + errorMessage + "\n", Color.Red, sncode);
  325. }
  326. OperateResult.AppendText(">>请输入TSN号\n", Color.Black);
  327. //置空
  328. bsncode = "";
  329. show_sncode.Text = "";
  330. //获取剩余数,刷新页面
  331. sql.Clear();
  332. sql.Append("select mcd_inqty from makecraftdetail_view where mcd_macode='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  333. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  334. if (dt.Rows.Count > 0)
  335. {
  336. BaseUtil.SetFormValue(this.Controls, dt);
  337. remain_qty.Text = ma_qty - int.Parse(dt.Rows[0]["mcd_inqty"].ToString()) + "";
  338. }
  339. //更新数量
  340. changenum.Text = int.Parse(changenum.Text) + 1 + "";
  341. ChangeResult.Enabled = true;
  342. }
  343. else
  344. {
  345. if (onlyPass)
  346. {
  347. OperateResult.AppendText("<<SN号" + sncode.Text + "错误,已完成转号只允许SN转SN\n", Color.Red);
  348. }
  349. else
  350. {
  351. OperateResult.AppendText("<<SN号" + sncode.Text + "已存在,请输入其他序列号\n", Color.Red);
  352. }
  353. ReCall_Click(this,e);
  354. }
  355. sncode.Text = "";
  356. }
  357. }
  358. else
  359. {
  360. OperateResult.AppendText("<<" + errorMessage + "\n", Color.Red, sncode);
  361. }
  362. }
  363. else
  364. {
  365. OperateResult.AppendText("<<序列号不能为空\n", Color.Red);
  366. }
  367. sncode.Text = "";
  368. }
  369. }
  370. private void Confirm_Click(object sender, EventArgs e)
  371. {
  372. KeyEventArgs ky = new KeyEventArgs(Keys.Enter);
  373. sncode_KeyDown(sender, ky);
  374. }
  375. private void ReCall_Click(object sender, EventArgs e)
  376. {
  377. bsncode = "";
  378. OperateResult.AppendText(">>请输入TSN号\n", Color.Black, show_sncode);
  379. ChangeResult.Enabled = true;
  380. onlyPass = false;
  381. }
  382. /// <summary>
  383. /// 工单号keydown
  384. /// </summary>
  385. /// <param name="sender"></param>
  386. /// <param name="e"></param>
  387. private void ms_makecode_KeyDown(object sender, KeyEventArgs e)
  388. {
  389. }
  390. /// <summary>
  391. /// 如果清空了工单号,或者更换了工单号则将 : 转换前序列号长度,转换前序列号前缀
  392. ///转换后序列号长度,转换后序列号前缀 四个字段值清空。
  393. /// </summary>
  394. /// <param name="sender"></param>
  395. /// <param name="e"></param>
  396. private void ms_makecode_UserControlTextChanged(object sender, EventArgs e)
  397. {
  398. hasSnList = false;
  399. hasMakeRule = false;
  400. hasSaleRule = false;
  401. //清空
  402. beforeTransSNPre.Text = "";
  403. beforeTransSNLength.Text = "";
  404. afterTransSNPre.Text = "";
  405. afterTransSNLength.Text = "";
  406. //取消勾选
  407. beforeTransSNPre_checkBox.Checked = false;
  408. beforeTransSNLength_checkBox.Checked = false;
  409. afterTransSNPre_checkBox.Checked = false;
  410. afterTransSNLength_checkBox.Checked = false;
  411. //设置可编辑
  412. beforeTransSNLength.Enabled = true;
  413. beforeTransSNPre.Enabled = true;
  414. afterTransSNLength.Enabled = true;
  415. afterTransSNPre.Enabled = true;
  416. beforeTransSNPre_checkBox.Enabled = true;
  417. beforeTransSNLength_checkBox.Enabled = true;
  418. afterTransSNPre_checkBox.Enabled = true;
  419. afterTransSNLength_checkBox.Enabled = true;
  420. //判断工单是否导入了序列号清单
  421. if (dh.CheckExist("makesnlist", "msl_makecode='" + ma_code.Text + "' and msl_type='after'"))
  422. {
  423. hasSnList = true;
  424. return;
  425. }
  426. //查询表工单序列号防呆规则表
  427. rules = (DataTable)dh.ExecuteSql("select msr_startno from makesnrule where msr_makecode='" + ma_code.Text + "' and msr_type='after'", "select");
  428. if (rules.Rows.Count > 0)
  429. {
  430. hasMakeRule = true;
  431. }
  432. else
  433. {
  434. ma_salecode.Text = dh.getFieldDataByCondition("make", "ma_salecode", "ma_code='" + ma_code.Text + "'").ToString();
  435. //查询表合同序列号防呆规则表
  436. rules = (DataTable)dh.ExecuteSql("select msr_startno from makesnrule where msr_salecode='" + ma_salecode.Text + "' and msr_type='after'", "select");
  437. if (rules.Rows.Count > 0)
  438. {
  439. hasSaleRule = true;
  440. }
  441. else
  442. {
  443. /* 如果转换前没有值,则取 select productsnrule where psr_prodcode=? 产品编号,
  444. * 有值则赋值到 转换前,并且自动勾选不可编辑。*/
  445. rules = (DataTable)dh.ExecuteSql("select psr_prefix ,psr_length from productsnrule where psr_prodcode = '" + dt.Rows[0]["ma_prodcode"].ToString() + "' and psr_type='after'", "select");
  446. if (rules.Rows.Count > 0)
  447. {
  448. //将产品序列号防呆规则查出的数据填充
  449. if (rules.Rows[0]["psr_prefix"].ToString() != "")
  450. {
  451. afterTransSNPre.Text = rules.Rows[0]["psr_prefix"].ToString();
  452. afterTransSNPre.Enabled = false;
  453. afterTransSNPre_checkBox.Checked = true;
  454. afterTransSNPre_checkBox.Enabled = false;
  455. }
  456. //if (rules.Rows[0]["psr_length"].ToString() != "")
  457. //{
  458. // afterTransSNLength.Text = rules.Rows[0]["psr_length"].ToString();
  459. // afterTransSNLength.Enabled = false;
  460. // afterTransSNLength_checkBox.Checked = true;
  461. // afterTransSNLength_checkBox.Enabled = false;
  462. //}
  463. }
  464. }
  465. }
  466. }
  467. /// <summary>
  468. /// 检验长度或者前缀是否合法
  469. /// </summary>
  470. /// <param name="checkbox"></param>
  471. /// <param name="c"></param>
  472. /// <param name="info"></param>
  473. private bool checkLengthOrPre(CheckBox checkbox, TextBox textbox, string type)
  474. {
  475. if (checkbox.Checked == true)
  476. {
  477. //如果勾选没有填值
  478. if (textbox.Text == "")
  479. {
  480. OperateResult.AppendText("<<勾选长度或者前缀需要填写内容\n", Color.Red);
  481. return false;
  482. }
  483. if (type == "长度")
  484. {
  485. //则判断输入转换前的序列号长度是否合法,不合法则提示
  486. if (sncode.Text.Trim().Length != int.Parse(textbox.Text))
  487. {
  488. //序列号校验错误,长度错误
  489. OperateResult.AppendText("<<序列号" + sncode.Text + "校验错误,长度错误\n", Color.Red, sncode);
  490. OperateResult.AppendText(">>请重新输入SN号\n", Color.Black);
  491. return false;
  492. }
  493. }
  494. else if (type == "前缀")
  495. {
  496. string[] pres = textbox.Text.Split('|');
  497. bool f = false;
  498. for (int i = 0; i < pres.Length; i++)
  499. {
  500. if (pres[i] == "" ? true : sncode.Text.Contains(pres[i]))
  501. {
  502. //满足其中一条即可
  503. f = true;
  504. break;
  505. }
  506. }
  507. //则判断输入转换前的序列号前缀是否合法,不合法则提示
  508. if (!f)
  509. {
  510. //序列号校验错误,前缀错误
  511. OperateResult.AppendText("<<序列号" + sncode.Text + "校验错误,前缀错误\n", Color.Red, sncode);
  512. OperateResult.AppendText(">>请重新输入SN号\n", Color.Black);
  513. return false;
  514. }
  515. }
  516. return true;
  517. }
  518. return true;
  519. }
  520. private void ChangeResult_CheckedChanged(object sender, EventArgs e)
  521. {
  522. if (ChangeResult.Checked)
  523. {
  524. //勾选的时候提示输入TSN
  525. OperateResult.AppendText(">>请输入TSN号\n", Color.Black);
  526. }
  527. }
  528. private void Make_SeqTransform_Load(object sender, EventArgs e)
  529. {
  530. asc.controllInitializeSize(this);
  531. dh = SystemInf.dh;
  532. sncode.Focus();
  533. OperateResult.AppendText(">>请输入TSN号\n", Color.Black);
  534. StepCount.StepCode = User.CurrentStepCode;
  535. StepCount.Source = User.UserSourceCode;
  536. StepCount.LineCode = User.UserLineCode;
  537. StepCount.Dh = dh;
  538. StepCount.Start();
  539. Seq_Remark_PreFix.Text = BaseUtil.GetCacheData("Seq_Remark_PreFix").ToString();
  540. }
  541. private void Make_SeqTransform_SizeChanged(object sender, EventArgs e)
  542. {
  543. asc.controlAutoSize(this);
  544. }
  545. private void Remark_KeyDown(object sender, KeyEventArgs e)
  546. {
  547. if (e.KeyCode == Keys.Enter)
  548. {
  549. try
  550. {
  551. if ((CollectRemark.Checked || SameReamrk.Checked) && Remark.Text != "")
  552. {
  553. sncode.Enabled = true;
  554. sncode.Focus();
  555. sncode_KeyDown(this, new KeyEventArgs(Keys.Enter));
  556. }
  557. else
  558. {
  559. sncode.Enabled = true;
  560. sncode.Focus();
  561. }
  562. }
  563. catch
  564. {
  565. sncode.Enabled = true;
  566. sncode.Focus();
  567. }
  568. }
  569. }
  570. private void IFONLY_CheckedChanged(object sender, EventArgs e)
  571. {
  572. if (IFONLY.Checked)
  573. {
  574. SameReamrk.Checked = false;
  575. CollectRemark.Checked = true;
  576. }
  577. }
  578. private void SameReamrk_CheckedChanged(object sender, EventArgs e)
  579. {
  580. if (SameReamrk.Checked)
  581. {
  582. IFONLY.Checked = false;
  583. CollectRemark.Checked = false;
  584. }
  585. }
  586. private void Seq_Remark_PreFix_KeyDown(object sender, KeyEventArgs e)
  587. {
  588. if (e.KeyCode == Keys.Enter)
  589. {
  590. BaseUtil.SetCacheData("Seq_Remark_PreFix", Seq_Remark_PreFix.Text);
  591. if (CollectRemark.Checked || SameReamrk.Checked)
  592. {
  593. Remark.SelectAll();
  594. Remark.Focus();
  595. }
  596. }
  597. }
  598. //校验备注前缀
  599. private Boolean CheckPre()
  600. {
  601. try
  602. {
  603. if (Remark.Text.Substring(0, Seq_Remark_PreFix.Text.Length) != Seq_Remark_PreFix.Text)
  604. {
  605. OperateResult.AppendText(">>备注前缀不匹配,请重新输入备注信息\n", Color.Red);
  606. Remark.SelectAll();
  607. Remark.Focus();
  608. return false;
  609. }
  610. }
  611. catch (Exception)
  612. {
  613. OperateResult.AppendText(">>备注前缀不匹配,请重新输入备注信息\n", Color.Red);
  614. Remark.SelectAll();
  615. Remark.Focus();
  616. return false;
  617. }
  618. return true;
  619. }
  620. private void CollectRemark_CheckedChanged(object sender, EventArgs e)
  621. {
  622. if (CollectRemark.Checked)
  623. {
  624. SameReamrk.Checked = false;
  625. }
  626. }
  627. private void Remark_Leave(object sender, EventArgs e)
  628. {
  629. sncode.Enabled = true;
  630. }
  631. private void Remark_Enter(object sender, EventArgs e)
  632. {
  633. sncode.Enabled = false;
  634. }
  635. }
  636. }