Make_CollectLcd.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using UAS_MES_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. using UAS_MES_NEW.PublicMethod;
  12. namespace UAS_MES_NEW.Make
  13. {
  14. public partial class Make_CollectLcd : Form
  15. {
  16. DataHelper dh;
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. LogStringBuilder sql = new LogStringBuilder();
  19. DataTable dt;
  20. //当前序列号记录
  21. string sn_code;
  22. //制造单号
  23. string macode;
  24. //采集网标号
  25. string net_code;
  26. //网标查询条件ms_id
  27. string oMsID;
  28. //判断是否输入网标
  29. Boolean isnetcode = false;
  30. //打印计数
  31. int printcount = 0;
  32. int ma_unlimitin;
  33. DataTable Dbfind;
  34. public Make_CollectLcd()
  35. {
  36. InitializeComponent();
  37. }
  38. private void Make_CollectNetCode_Load(object sender, EventArgs e)
  39. {
  40. //设置锁定工单
  41. LockMakeCode.GetMakeCodeCtl(ma_code);
  42. ma_code.SetLockCheckBox(LockMakeCode);
  43. asc.controllInitializeSize(this);
  44. //工单号放大镜配置
  45. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  46. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
  47. ma_code.FormName = Name;
  48. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
  49. ma_code.Condition = "ma_statuscode='STARTED'";
  50. ma_code.DbChange += Ma_code_DbChange;
  51. sncode.Focus();
  52. dh = SystemInf.dh;
  53. }
  54. private void Ma_code_DbChange(object sender, EventArgs e)
  55. {
  56. Dbfind = ma_code.ReturnData;
  57. BaseUtil.SetFormValue(this.Controls, Dbfind);
  58. }
  59. private void sncode_KeyDown(object sender, KeyEventArgs e)
  60. {
  61. if (e.KeyCode == Keys.Enter)
  62. {
  63. if (ma_code.Text == "")
  64. {
  65. OperateResult.AppendText(">>工单号不可为空\n", Color.Red);
  66. return ;
  67. }
  68. if (!checkBox1.Checked && dh.CheckExist("lcdcheck", "lc_sncode = '" + sncode.Text + "' and lc_status = 0"))
  69. {
  70. OperateResult.AppendText(">>SN:"+sncode.Text+"已存在良品检验记录\n", Color.Red,sncode);
  71. return;
  72. }
  73. String status = radioButton1.Checked ? "0" : "-1";
  74. String statuscode = radioButton1.Checked ? "良品" : "不良";
  75. dh.ExecuteSql(" insert into lcdcheck(LC_ID,LC_SNCODE,LC_STATUS,LC_INDATE,LC_INMAN,LC_MAKECODE) values" +
  76. " (lcdcheck_seq.nextval,'" + sncode.Text+"','"+ status + "',sysdate,'"+User.UserCode+"','"+ma_code.Text+"') ", "insert");
  77. OperateResult.AppendText(">>SN:" + sncode.Text + "全捡采集"+ statuscode + "成功\n", Color.Green, sncode);
  78. }
  79. }
  80. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  81. {
  82. asc.controlAutoSize(this);
  83. }
  84. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  85. {
  86. sncode.Focus();
  87. }
  88. /// <summary>
  89. /// 检验长度或者前缀是否合法
  90. /// </summary>
  91. /// <param name="checkbox"></param>
  92. /// <param name="c"></param>
  93. /// <param name="info"></param>
  94. private bool checkLengthOrPre(int psr_length, string psr_prefix, string TSNorSN)
  95. {
  96. //则判断输入转换前的序列号长度是否合法,不合法则提示
  97. if (sncode.Text.Trim().Length != psr_length && psr_length != 0)
  98. {
  99. //序列号校验错误,长度错误
  100. OperateResult.AppendText("<<" + TSNorSN + ":" + sncode.Text + "校验错误,长度错误\n", Color.Red, sncode);
  101. OperateResult.AppendText(">>请重新输入" + TSNorSN + "\n", Color.Black);
  102. return false;
  103. }
  104. string[] pres = psr_prefix.Split('|');
  105. bool f = false;
  106. for (int i = 0; i < pres.Length; i++)
  107. {
  108. if (pres[i] == "" ? true : sncode.Text.StartsWith(pres[i]))
  109. {
  110. //满足其中一条即可
  111. f = true;
  112. break;
  113. }
  114. }
  115. //则判断输入转换前的序列号前缀是否合法,不合法则提示
  116. if (!f)
  117. {
  118. //序列号校验错误,前缀错误
  119. OperateResult.AppendText("<<" + TSNorSN + ":" + sncode.Text + "校验错误,前缀错误\n", Color.Red, sncode);
  120. OperateResult.AppendText(">>请重新输入" + TSNorSN + "\n", Color.Black);
  121. return false;
  122. }
  123. return true;
  124. }
  125. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  126. {
  127. sncode.Focus();
  128. sncode.SelectAll();
  129. }
  130. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  131. {
  132. sncode.Focus();
  133. sncode.SelectAll();
  134. }
  135. }
  136. }