Make_SeqTransformPrint.cs 35 KB

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