Make_SeqTransform.cs 33 KB

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