Make_ColorBoxWeigh.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Data;
  4. using System.IO;
  5. using System.IO.Ports;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading;
  9. using System.Windows.Forms;
  10. using UAS_MES.DataOperate;
  11. using UAS_MES.Entity;
  12. using UAS_MES.PublicMethod;
  13. using System.Drawing;
  14. using LabelManager2;
  15. using UAS_MES.PublicForm;
  16. using DevComponents.DotNetBar.Controls;
  17. namespace UAS_MES.Make
  18. {
  19. public partial class Make_ColorBoxWeigh : Form
  20. {
  21. AutoSizeFormClass asc = new AutoSizeFormClass();
  22. ApplicationClass lbl;
  23. Document doc;
  24. DataHelper dh;
  25. DataTable dt;
  26. LogStringBuilder sql = new LogStringBuilder();
  27. //启用线程进行称重数据读取
  28. Thread thread;
  29. SerialPort serialPort1 = new SerialPort();
  30. //称量的标准重量
  31. Double Weight;
  32. //最大重量
  33. Double MaxWeight;
  34. //最小重量
  35. Double MinWeight;
  36. //是否通过串口获取数据
  37. bool GetData = true;
  38. string LastSncode;
  39. bool WeightChange = false;
  40. Regex re = new Regex("\\d+.\\d+\\w+");
  41. string ErrorMessage;
  42. Thread InitPrint;
  43. System.DateTime[] indate;
  44. private bool AutoCut;
  45. public Make_ColorBoxWeigh()
  46. {
  47. InitializeComponent();
  48. CheckForIllegalCrossThreadCalls = false;
  49. }
  50. private void Make_ColorBoxWeigh_Load(object sender, EventArgs e)
  51. {
  52. asc.controllInitializeSize(this);
  53. ComList.Text = BaseUtil.GetCacheData("PortName").ToString();
  54. BaudRate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
  55. InitPrint = new Thread(InPrint);
  56. SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
  57. BaseUtil.SetFormCenter(stw);
  58. stw.ShowDialog();
  59. StartWeight.PerformClick();
  60. dh = SystemInf.dh;
  61. StepCount.StepCode = User.CurrentStepCode;
  62. StepCount.Source = User.UserSourceCode;
  63. StepCount.LineCode = User.UserLineCode;
  64. StepCount.Dh = dh;
  65. StepCount.Start();
  66. }
  67. private void InPrint()
  68. {
  69. try
  70. {
  71. lbl = new ApplicationClass();
  72. BaseUtil.WriteLbl();
  73. }
  74. catch (Exception ex)
  75. {
  76. OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
  77. }
  78. }
  79. private void sncode_KeyDown(object sender, KeyEventArgs e)
  80. {
  81. if (e.KeyCode == Keys.Enter)
  82. {
  83. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  84. {
  85. sql.Clear();
  86. sql.Append("select ms_makecode,ma_qty,ma_salecode,pr_machinetype,pr_colorboxunit,pr_code,pr_colorboxgw,");
  87. sql.Append("pr_colorboxunit,pr_colorboxmaxw,pr_colorboxminw,nvl(PR_CHECKCOLORBOXW,'0') PR_CHECKCOLORBOXW,nvl(pr_sendchecktype,'LineCode')");
  88. sql.Append("pr_sendchecktype from makeserial left join make on ms_makecode=ma_code left join product on ");
  89. sql.Append("ms_prodcode=pr_code where ms_sncode='" + sncode.Text + "' order by ms_id desc");
  90. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  91. if (dt.Rows.Count > 0)
  92. {
  93. //重量的临时变量
  94. pr_code.Text = dt.Rows[0]["pr_code"].ToString();
  95. string _weight = dt.Rows[0]["pr_colorboxgw"].ToString();
  96. string _maxweight = dt.Rows[0]["pr_colorboxmaxw"].ToString();
  97. string _minweight = dt.Rows[0]["pr_colorboxminw"].ToString();
  98. string pr_colorunit = dt.Rows[0]["pr_colorboxunit"].ToString();
  99. string ma_salecode_text = dt.Rows[0]["ma_salecode"].ToString();
  100. string PR_CHECKCOLORBOXW = dt.Rows[0]["PR_CHECKCOLORBOXW"].ToString();
  101. //赋值重量单位
  102. Weight = double.Parse(_weight == "" ? "0" : _weight);
  103. MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
  104. MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
  105. if (locksalecode.Checked && ma_salecode.Text != "" && ma_salecode.Text != ma_salecode_text)
  106. {
  107. OperateResult.AppendText(">>序列号" + sncode.Text + "所属订单号" + ma_salecode_text + "与界面订单号" + ma_salecode.Text + "不同,无法采集\n", Color.Red, sncode);
  108. return;
  109. }
  110. ma_salecode.Text= dt.Rows[0]["ma_salecode"].ToString();
  111. BaseUtil.SetFormValue(this.Controls, dt);
  112. if (Weight - MinWeight == MaxWeight - Weight)
  113. pr_colorboxgw.Text = Weight + "±" + (MaxWeight - Weight) + dt.Rows[0]["pr_colorboxunit"].ToString();
  114. else
  115. pr_colorboxgw.Text = MinWeight + "-" + MaxWeight + dt.Rows[0]["pr_colorboxunit"].ToString();
  116. string oMakeCode = "";
  117. string oMsID = "";
  118. if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
  119. {
  120. string mscode = dh.getFieldDataByCondition("makeserial LEFT JOIN craft ON ms_craftcode = cr_code and ms_prodcode = cr_prodcode LEFT JOIN craftdetail ON cr_id = cd_crid LEFT JOIN STEP ON CD_NEXTSTEPCODE = ST_CODE", "ms_code", "ms_id = '" + oMsID + "' AND CD_STEPCODE = '" + User.CurrentStepCode + "' AND ST_IFOQC = -1").ToString();
  121. if (mscode != "" && (dh.CheckExist("makeserial", "ms_id = '" + oMsID + "' and NVL(MS_BADTIMES,0)>0 ") || dh.CheckExist("makeserial", "ms_sncode = '" + mscode + "' and NVL(MS_BADTIMES,0)>0 ")))
  122. {
  123. OperateResult.AppendText(">>" + sncode.Text + " 序列号即将送检,此序列号经过维修,提示\n", Color.Purple);
  124. }
  125. string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
  126. if (nextstepcode != User.CurrentStepCode)
  127. {
  128. OperateResult.AppendText("<<序列号:" + sncode.Text + "下一工序是" + nextstepcode + ",不是当前岗位的工序\n", Color.Red, sncode);
  129. return;
  130. }
  131. //if (dh.CheckExist("makeserial LEFT JOIN craft ON ms_craftcode = cr_code and ms_prodcode = cr_prodcode LEFT JOIN craftdetail ON cr_id = cd_crid LEFT JOIN STEP ON CD_NEXTSTEPCODE = ST_CODE ", "ms_id = '" + oMsID + "' AND CD_STEPCODE = '" + User.CurrentStepCode + "' AND NVL(MS_BADTIMES,0)>0 AND ST_IFOQC = -1 "))
  132. //{
  133. // OperateResult.AppendText(">>" + sncode.Text + " 序列号即将送检,此序列号经过维修,提示\n", Color.Purple);
  134. //}
  135. //如果未打开串口设置为0
  136. //if (pr_colorboxunit.Text == "kg" && !WeightChange)
  137. //{
  138. // WeightChange = true;
  139. //}
  140. //重量信息若需要检测则必须符合检测要求才更新
  141. double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Trim());
  142. if (PR_CHECKCOLORBOXW != "0"&&!checkBox1.Checked)
  143. {
  144. if (MinWeight == 0 || MaxWeight == 0)
  145. {
  146. OperateResult.AppendText(">>产品" + pr_code.Text + "未维护彩盒重量范围\n", Color.Red);
  147. return;
  148. }
  149. if ((ActualWeight >= MinWeight) && (ActualWeight <= MaxWeight))
  150. {
  151. OperateResult.AppendText(">>彩盒" + sncode.Text + "重量检测检测合格\n", Color.Green);
  152. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "彩盒称重:" + weight.Text, "称量合格", sncode.Text, "");
  153. LogicHandler.RecordProdWeight(sncode.Text, "SN", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  154. dh.ExecuteSql("update makeserial set ms_grossw='" + ActualWeight + "' where ms_id='" + oMsID + "'", "update");
  155. }
  156. else
  157. {
  158. OperateResult.AppendText(">>彩盒" + sncode.Text + "重量检测未通过\n", Color.Red);
  159. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "彩盒称重:" + weight.Text, "称量不合格", sncode.Text, "");
  160. LogicHandler.RecordProdWeight(sncode.Text, "SN", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  161. return;
  162. }
  163. }
  164. else
  165. {
  166. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "彩盒称重:" + weight.Text, "称量完成", sncode.Text, "");
  167. LogicHandler.RecordProdWeight(sncode.Text, "SN", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  168. dh.ExecuteSql("update makeserial set ms_grossw='" + ActualWeight + "' where ms_id='" + oMsID + "'", "update");
  169. }
  170. ListViewItem lsi = new ListViewItem();
  171. lsi.SubItems.Add(sncode.Text);
  172. lsi.SubItems.Add(ActualWeight.ToString());
  173. lsi.SubItems.Add(System.DateTime.Now.ToString());
  174. WeighRecord.Items.Add(lsi);
  175. OperateResult.AppendText(">>彩盒" + sncode.Text + "称重完成\n", Color.Green);
  176. if (checkBox1.Checked)
  177. {
  178. checkBox1.Checked = false;
  179. }
  180. //显示最近的三个称量记录
  181. if (LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, sncode.Text, "彩盒称量", "称量合格", User.UserCode, out ErrorMessage))
  182. {
  183. //提示正确返回时传递的信息
  184. if (ErrorMessage.Contains("AFTERSUCCESS"))
  185. OperateResult.AppendText(">>" + ErrorMessage + "\n");
  186. LoadCheckQTY();
  187. //记录送检前的最后一个序列号
  188. LastSncode = sncode.Text;
  189. if (AutoPrint.Checked)
  190. {
  191. OperateResult.AppendText(">>打印条码号" + sncode.Text + "\n", Color.Green);
  192. Confirm.PerformClick();
  193. }
  194. }
  195. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  196. if (CollectRemark.Checked && Remark.Text != "")
  197. {
  198. LogicHandler.CollectRemarkInf(sncode.Text, "", "", oMakeCode, pr_code.Text, Remark.Text);
  199. }
  200. LoadCollectedNum();
  201. sncode.Clear();
  202. }
  203. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sncode);
  204. }
  205. else OperateResult.AppendText(">>序列号不存在\n", Color.Red, sncode);
  206. }
  207. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sncode);
  208. }
  209. }
  210. private void getSerialData()
  211. {
  212. if (serialPort1.IsOpen)
  213. {
  214. if (!SystemInf.OpenPort.Contains(serialPort1.PortName))
  215. {
  216. SystemInf.OpenPort.Add(serialPort1.PortName);
  217. try
  218. {
  219. while (GetData)
  220. {
  221. try
  222. {
  223. weight.Text = re.Match(serialPort1.ReadLine().Trim()).Groups[0].Value;
  224. }
  225. catch (Exception)
  226. {
  227. GetData = false;
  228. }
  229. }
  230. }
  231. catch (IOException ex) { MessageBox.Show(ex.Message); }
  232. }
  233. else OperateResult.AppendText(">>端口已被占用,请关闭其他窗口\n", Color.Red);
  234. }
  235. }
  236. private void 彩盒称重_SizeChanged(object sender, EventArgs e)
  237. {
  238. weight.Location = new Point(weight_label.Location.X + weight_label.Size.Width - 10, weight_label.Location.Y - 20);
  239. asc.controlAutoSize(this);
  240. }
  241. protected override void OnVisibleChanged(EventArgs e)
  242. {
  243. base.OnVisibleChanged(e);
  244. if (!IsHandleCreated)
  245. {
  246. this.Close();
  247. }
  248. }
  249. private void Clean_Click(object sender, EventArgs e)
  250. {
  251. OperateResult.Clear();
  252. }
  253. //关闭窗口的时候停止进程读取串口数据
  254. private void 彩盒称重_FormClosing(object sender, FormClosingEventArgs e)
  255. {
  256. BaseUtil.ClosePrint(lbl);
  257. StopWeight.PerformClick();
  258. InitPrint.Abort();
  259. if (serialPort1.IsOpen)
  260. {
  261. GetData = false;
  262. serialPort1.Close();
  263. SystemInf.OpenPort.Remove(serialPort1.PortName);
  264. thread.Interrupt();
  265. }
  266. //thread.Abort();
  267. }
  268. private void Confirm_Click(object sender, EventArgs e)
  269. {
  270. if (PrintLabel.Items.Count != 0)
  271. {
  272. //doc = lbl.Documents.Open(PrintLabel.Text);
  273. string oErrorMessage;
  274. if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, sncode.Text, int.Parse(PrintNum.Text), ms_makecode.Text, pr_code.Text, "彩盒标", "0", out oErrorMessage))
  275. {
  276. OperateResult.AppendText(oErrorMessage + "\n", Color.Red);
  277. }
  278. }
  279. else
  280. {
  281. OperateResult.AppendText(">>产品" + pr_code.Text + "未维护打印标签\n", Color.Red);
  282. }
  283. }
  284. private void StartWeight_Click(object sender, EventArgs e)
  285. {
  286. thread = new Thread(getSerialData);
  287. try
  288. {
  289. serialPort1.PortName = ComList.Text;
  290. serialPort1.BaudRate = int.Parse(BaudRate.Text);
  291. serialPort1.Open();
  292. GetData = true;
  293. thread.Start();
  294. }
  295. catch (Exception mes)
  296. {
  297. if (BaudRate.Text == "" || ComList.Text == "")
  298. OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
  299. else
  300. OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
  301. }
  302. }
  303. private void StopWeight_Click(object sender, EventArgs e)
  304. {
  305. if (serialPort1.IsOpen)
  306. {
  307. GetData = false;
  308. serialPort1.Close();
  309. SystemInf.OpenPort.Remove(serialPort1.PortName);
  310. thread.Abort();
  311. }
  312. }
  313. private void pr_code_TextChanged(object sender, EventArgs e)
  314. {
  315. LoadCheckQTY();
  316. DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='" + pr_code.Text + "' and la_templatetype='彩盒标' and la_statuscode='AUDITED' order by la_isdefault", "select");
  317. PrintLabel.DataSource = _dt;
  318. PrintLabel.DisplayMember = "la_url";
  319. PrintLabel.ValueMember = "la_id";
  320. }
  321. private void SendCheck_Click(object sender, EventArgs e)
  322. {
  323. sql.Clear();
  324. sql.Append("update oqcbatch set ob_status='UNCHECK',ob_breakingdate=sysdate where ob_checkno ='" + ob_checkno.Text + "'");
  325. dh.ExecuteSql(sql.GetString(), "select");
  326. ob_nowcheckqty.Text = "";
  327. ob_batchqty.Text = "";
  328. ob_nowcheckqty.ForeColor = Color.Black;
  329. SendCheck.Enabled = false;
  330. OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Green);
  331. LogicHandler.InsertMakeProcess(LastSncode, ms_makecode.Text, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
  332. //记录操作日志
  333. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
  334. ob_checkno.Text = "";
  335. }
  336. private void LoadCheckQTY()
  337. {
  338. sql.Clear();
  339. string condition = "";
  340. int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  341. int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  342. if (nowcheckqty + 1 == batchqty && AutoCut)
  343. {
  344. condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
  345. }
  346. else
  347. {
  348. condition = "and ob_status='ENTERING' ";
  349. }
  350. if (pr_sendchecktype.Text == "SaleCode")
  351. {
  352. condition += " and ob_salecode='" + ma_salecode.Text + "'";
  353. }
  354. else if (pr_sendchecktype.Text == "MakeCode")
  355. {
  356. condition += " and ob_makecode='" + ms_makecode.Text + "'";
  357. }
  358. sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
  359. sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_prodcode='" + pr_code.Text + "' and ");
  360. sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
  361. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  362. if (dt.Rows.Count > 0)
  363. {
  364. ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
  365. ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
  366. ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
  367. nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  368. batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  369. if (nowcheckqty == batchqty)
  370. {
  371. ob_nowcheckqty.ForeColor = Color.Red;
  372. OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
  373. if (AutoCut)
  374. {
  375. OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动断批\n", Color.Green);
  376. }
  377. }
  378. }
  379. else
  380. {
  381. ob_batchqty.Text = "";
  382. ob_nowcheckqty.Text = "";
  383. ob_checkno.Text = "";
  384. SendCheck.Enabled = false;
  385. }
  386. if (ob_batchqty.Text != "")
  387. {
  388. SendCheck.Enabled = true;
  389. }
  390. else
  391. {
  392. SendCheck.Enabled = false;
  393. }
  394. }
  395. private void ob_checkno_TextChanged(object sender, EventArgs e)
  396. {
  397. if (ob_checkno.Text != "")
  398. {
  399. string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
  400. if (Cut == "" || Cut == "0")
  401. AutoCut = false;
  402. else
  403. AutoCut = true;
  404. SendCheck.Enabled = true;
  405. }
  406. }
  407. private void PrintLabel_SelectedValueChanged(object sender, EventArgs e)
  408. {
  409. if (PrintLabel.SelectedValue != null && PrintLabel.SelectedValue.ToString() != "System.Data.DataRowView")
  410. {
  411. string PrintNums = dh.getFieldDataByCondition("label", "la_printnos", "la_id='" + PrintLabel.SelectedValue.ToString() + "'").ToString();
  412. PrintNum.Text = (PrintNums == "" ? "1" : PrintNums);
  413. }
  414. }
  415. private void RefreshWeigh_Click(object sender, EventArgs e)
  416. {
  417. sql.Clear();
  418. sql.Append("select pr_colorboxgw,pr_colorboxmaxw,pr_colorboxminw,pr_colorboxunit from product where pr_code='" + pr_code.Text + "'");
  419. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  420. if (dt.Rows.Count > 0)
  421. {
  422. //重量的临时变量
  423. string _weight = dt.Rows[0]["pr_colorboxgw"].ToString();
  424. string _maxweight = dt.Rows[0]["pr_colorboxmaxw"].ToString();
  425. string _minweight = dt.Rows[0]["pr_colorboxminw"].ToString();
  426. //赋值重量单位
  427. Weight = double.Parse(_weight == "" ? "0" : _weight);
  428. MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
  429. MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
  430. if (Weight - MinWeight == MaxWeight - Weight)
  431. pr_colorboxgw.Text = Weight + "±" + (MaxWeight - Weight) + dt.Rows[0]["pr_colorboxunit"].ToString();
  432. else
  433. pr_colorboxgw.Text = MinWeight + "-" + MaxWeight + dt.Rows[0]["pr_colorboxunit"].ToString();
  434. }
  435. }
  436. private void LoadCollectedNum()
  437. {
  438. dt = (DataTable)dh.ExecuteSql("select mcd_inqty,ma_qty-mcd_inqty mcd_remainqty from make left join makecraftdetail on mcd_macode=ma_code where ma_code='" + ms_makecode.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'", "select");
  439. BaseUtil.SetFormValue(Controls, dt);
  440. }
  441. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  442. {
  443. if (checkBox1.Checked)
  444. checkBox1.Enabled = true;
  445. else checkBox1.Enabled = false;
  446. }
  447. private void textBox1_KeyDown(object sender, KeyEventArgs e)
  448. {
  449. if (e.KeyCode == Keys.Enter)
  450. {
  451. string password = dh.getFieldDataByCondition("employee", "em_password", "em_code = 'FD001'").ToString();
  452. if (textBox1.Text.Equals(password))
  453. {
  454. checkBox1.Checked = true;
  455. textBox1.Clear();
  456. sncode.Focus();
  457. }
  458. else
  459. {
  460. OperateResult.AppendText(">>密码错误\n", Color.Red,textBox1);
  461. }
  462. }
  463. }
  464. }
  465. }