Make_SeqTransformPrint.cs 35 KB

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