Make_TestCollectionSku.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Threading;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. using UAS_MES_NEW.DataOperate;
  8. using UAS_MES_NEW.Entity;
  9. using UAS_MES_NEW.PublicMethod;
  10. using System.Collections.Generic;
  11. using UAS_MES_NEW.CustomControl.PowerControlForm;
  12. using UAS_MES_NEW.PublicForm;
  13. using LabelManager2;
  14. using System.IO;
  15. using System.Text.RegularExpressions;
  16. namespace UAS_MES_NEW.Make
  17. {
  18. public partial class Make_TestCollectionSku : Form
  19. {
  20. DataHelper dh = null;
  21. DataTable dt = null;
  22. //当前工序的名称
  23. string ErrorMessage = "";
  24. //用于保存是否之前输入的ms_sncode
  25. string LastSncode;
  26. string oMakeCode = "";
  27. string oMSID = "";
  28. string ifrework = "";
  29. string reworkstatus = "";
  30. LogStringBuilder sql = new LogStringBuilder();
  31. AutoSizeFormClass asc = new AutoSizeFormClass();
  32. /// <summary>
  33. /// 已选的不良
  34. /// </summary>
  35. List<string> ChoosedList = new List<string>();
  36. /// <summary>
  37. /// 待选的不良
  38. /// </summary>
  39. List<string> WaitList = new List<string>();
  40. bool AutoCut = false;
  41. bool LockSn = false;
  42. string labelname;
  43. DataTable Dbfind;
  44. ApplicationClass lbl;
  45. Thread thread;
  46. // Document doc;
  47. public Make_TestCollectionSku()
  48. {
  49. InitializeComponent();
  50. }
  51. private void TestCollection_Load(object sender, EventArgs e)
  52. {
  53. GoodProduct.Checked = true;
  54. asc.controllInitializeSize(this);
  55. ms_sncode.Focus();
  56. //设置锁定工单
  57. LockMakeCode.GetMakeCodeCtl(ma_code);
  58. ma_code.SetLockCheckBox(LockMakeCode);
  59. ControlLockTimer.Tick += ControlLockTimer_Tick;
  60. ControlLockTimer.Interval = 100;
  61. labelname = System.Windows.Forms.Application.StartupPath + @"\badsn.lab";
  62. //thread = new Thread(NewPrint);
  63. // SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
  64. //BaseUtil.SetFormCenter(stw);
  65. // stw.ShowDialog();
  66. //工单号放大镜配置
  67. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  68. ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_spec # 产品规格,ma_softversion # 软件版本,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式";
  69. ma_code.FormName = Name;
  70. ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_spec", "ma_softversion", "ma_salecode", "nvl(pr_sendchecktype,'LineCode')pr_sendchecktype" };
  71. ma_code.Condition = "ma_statuscode='STARTED'";
  72. ma_code.DbChange += Ma_code_DbChange;
  73. dh = SystemInf.dh;
  74. StepCount.StepCode = User.CurrentStepCode;
  75. StepCount.Source = User.UserSourceCode;
  76. StepCount.LineCode = User.UserLineCode;
  77. StepCount.Dh = dh;
  78. StepCount.Start();
  79. }
  80. private void ControlLockTimer_Tick(object sender, EventArgs e)
  81. {
  82. this.Activate();
  83. ms_sncode.Focus();
  84. }
  85. private void Ma_code_DbChange(object sender, EventArgs e)
  86. {
  87. Dbfind = ma_code.ReturnData;
  88. BaseUtil.SetFormValue(this.Controls, Dbfind);
  89. LoadBadGroupData();
  90. LoadCollectedNum();
  91. LoadCheckQTY();
  92. }
  93. /// <summary>
  94. /// 将已选不良移动到待选不良
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void WaitReject_Click(object sender, EventArgs e)
  99. {
  100. int CheckedNum = 0;
  101. //已存在在ListView中的Item是不能添加到其他ListView中的,需要调用其克隆的方法
  102. for (int i = ChoosedRejectList.Items.Count - 1; i >= 0; i--)
  103. {
  104. if (ChoosedRejectList.Items[i].Checked)
  105. {
  106. ChoosedRejectList.Items[i].Checked = false;
  107. WaitRejectList.Items.Add((ListViewItem)ChoosedRejectList.Items[i].Clone());
  108. ChoosedRejectList.Items[i].Remove();
  109. CheckedNum++;
  110. }
  111. }
  112. if (CheckedNum == 0)
  113. {
  114. for (int i = ChoosedRejectList.Items.Count - 1; i >= 0; i--)
  115. {
  116. WaitRejectList.Items.Add((ListViewItem)ChoosedRejectList.Items[i].Clone());
  117. ChoosedRejectList.Items[i].Remove();
  118. }
  119. }
  120. }
  121. /// <summary>
  122. /// 将不良信息移动到已选不良
  123. /// </summary>
  124. /// <param name="sender"></param>
  125. /// <param name="e"></param>
  126. private void ChooseedReject_Click(object sender, EventArgs e)
  127. {
  128. if (ms_sncode.Text == "")
  129. {
  130. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  131. ms_sncode.Focus();
  132. return;
  133. }
  134. int CheckedNum = 0;
  135. //是否已经添加到不良
  136. bool AddToReject = false;
  137. for (int i = WaitRejectList.Items.Count - 1; i >= 0; i--)
  138. {
  139. if (WaitRejectList.Items[i].Checked)
  140. {
  141. AddToReject = false;
  142. for (int j = 0; j < ChoosedRejectList.Items.Count; j++)
  143. {
  144. if ((ChoosedRejectList.Items[j].SubItems[2].Text == WaitRejectList.Items[i].SubItems[2].Text))
  145. {
  146. AddToReject = true;
  147. OperateResult.AppendText(">>已存在" + ChoosedRejectList.Items[j].SubItems[2].Text + "不良\n", Color.Red);
  148. break;
  149. }
  150. }
  151. //未添加则进行添加
  152. if (!AddToReject)
  153. {
  154. WaitRejectList.Items[i].Checked = false;
  155. ChoosedRejectList.Items.Add((ListViewItem)WaitRejectList.Items[i].Clone());
  156. WaitRejectList.Items[i].Remove();
  157. CheckedNum++;
  158. }
  159. }
  160. }
  161. if (CheckedNum == 0)
  162. {
  163. OperateResult.AppendText(">>请勾选不良代码\n", Color.Red);
  164. }
  165. }
  166. private void CleanInfo_Click(object sender, EventArgs e)
  167. {
  168. OperateResult.Clear();
  169. }
  170. private void ms_code_KeyDown(object sender, KeyEventArgs e)
  171. {
  172. if (e.KeyCode == Keys.Enter)
  173. {
  174. ChoosedRejectList.Items.Clear();
  175. WaitList.Clear();
  176. ChoosedList.Clear();
  177. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  178. {
  179. bool NoteAlready = LogicHandler.CheckDiffMakeCodeBeforeStepCheck(ms_sncode.Text, ma_code.Text, NoteForChange.Checked, out oMakeCode, out ErrorMessage);
  180. if (!NoteAlready)
  181. {
  182. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  183. return;
  184. }
  185. if (LogicHandler.CheckStepSNAndMacode(oMakeCode, User.UserSourceCode, ms_sncode.Text, User.UserCode, out oMakeCode, out oMSID, out ErrorMessage))
  186. {
  187. //是否提示过工单切换框,检测前后执行
  188. if (!LogicHandler.CheckDiffMakeCodeAfterStepCheck(ms_sncode.Text, oMakeCode, NoteForChange.Checked, NoteAlready, ma_code, out ErrorMessage))
  189. {
  190. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  191. return;
  192. }
  193. if (ma_code.Text != oMakeCode && oMakeCode != null)
  194. {
  195. dt = (DataTable)dh.ExecuteSql("select ma_code,ma_prodcode,ma_softversion,ma_salecode,pr_spec,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype,ma_qty from make left join product on ma_prodcode=pr_code where ma_code='" + oMakeCode + "'", "select");
  196. if (dt.Rows.Count > 0)
  197. {
  198. BaseUtil.SetFormValue(this.Controls, dt);
  199. LockMakeCode.Checked = true;
  200. }
  201. }
  202. dt = (DataTable)dh.ExecuteSql("select ma_qdz,ms_nextstepcode,ms_sncode,ms_reworkstatus,nvl(ms_ifrework,0)ms_ifrework,ms_stepcode,ms_status,nvl(st_ifrepair,0) st_ifrepair from makeserial left join step on ms_stepcode=st_code left join make on ma_code = ms_makecode where ms_id='" + oMSID + "'", "select");
  203. string status = dt.Rows[0]["ms_status"].ToString();
  204. string ma_sku = dt.Rows[0]["ma_qdz"].ToString();
  205. reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
  206. string stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  207. string ifrepair = dt.Rows[0]["st_ifrepair"].ToString();
  208. string sncode = dt.Rows[0]["ms_sncode"].ToString();
  209. if (bidui.Checked && ma_sku!=""&&biduisn.Text != ma_sku)
  210. {
  211. OperateResult.AppendText(">>SN对应SKU"+ ma_sku + "与录入"+ biduisn.Text + "不一致\n", Color.Red);
  212. biduisn.Focus();
  213. biduisn.SelectAll();
  214. return;
  215. }
  216. if (sncode != ms_sncode.Text)
  217. {
  218. OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过转号,不允许使用TSN采集\n", Color.Red, ms_sncode);
  219. return;
  220. }
  221. ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  222. if (GoodProduct.Checked)
  223. {
  224. if (ifrework != "0")
  225. {
  226. if (stepcode == User.CurrentStepCode && (reworkstatus == "1" || reworkstatus == "2") && ifrepair == "0")
  227. {
  228. OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过" + User.CurrentStepName + "工序,采集结果为良品\n", Color.Red, ms_sncode);
  229. return;
  230. }
  231. }
  232. else
  233. {
  234. if (stepcode == User.CurrentStepCode && (status == "1" || status == "2") && ifrepair == "0")
  235. {
  236. OperateResult.AppendText(">>" + ms_sncode.Text + " 序列号已执行过" + User.CurrentStepName + "工序,采集结果为良品\n", Color.Red, ms_sncode);
  237. return;
  238. }
  239. }
  240. }
  241. SetCollectResult();
  242. }
  243. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode,biduisn);
  244. }
  245. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode, biduisn);
  246. }
  247. }
  248. private void bc_groupcode_SelectedIndexChanged(object sender, EventArgs e)
  249. {
  250. LoadBadCodeListView();
  251. }
  252. /// <summary>
  253. /// 填充不良组别信息
  254. /// </summary>
  255. private void LoadBadGroupData()
  256. {
  257. //如果ms_makecode的值修改过再去查询
  258. sql.Clear();
  259. sql.Append("select bg_code||':'||bg_name bg_name,bg_code from badgroup left join (select pb_badgroup,pr_kind ");
  260. sql.Append("from product left join productkind on pk_name=pr_kind ");
  261. sql.Append("left join productbadgroup on pk_code=PB_KINDCODE where pr_code='" + ma_prodcode.Text + "')");
  262. sql.Append("on pb_badgroup=bg_code where bg_statuscode='AUDITED' order by case when bg_code='" + User.DefaultBadGroup + "' then 0 else 1 end");
  263. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  264. bc_groupcode.DisplayMember = "bg_name";
  265. bc_groupcode.ValueMember = "bg_code";
  266. bc_groupcode.DataSource = dt;
  267. }
  268. /// <summary>
  269. /// 加载不良代码的ListView的信息
  270. /// </summary>
  271. private void LoadBadCodeListView()
  272. {
  273. object bg_code = bc_groupcode.SelectedValue;
  274. sql.Clear();
  275. sql.Append("select bg_code||':'||bg_name bg_code,bc_code,bc_name,'' bc_remark from badgroupdetail ");
  276. sql.Append("left join badgroup on bg_id=bgd_bgid left join badcode on bgd_badcode=bc_code where ");
  277. sql.Append("bg_code='" + (bg_code != null ? bg_code.ToString() : "") + "' and bg_code is not null order by bgd_detno");
  278. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  279. BadInfSource.DataSource = dt;
  280. //往listview中添加数据
  281. WaitRejectList.Items.Clear();
  282. WaitRejectList.BeginUpdate();
  283. for (int i = 0; i < dt.Rows.Count; i++)
  284. {
  285. if (!ChoosedList.Contains(dt.Rows[i]["bc_code"].ToString()))
  286. {
  287. ListViewItem lvi = new ListViewItem();
  288. //第一列是勾选列,设置列头文本为空
  289. lvi.Text = "";
  290. WaitList.Add(dt.Rows[i]["bc_code"].ToString());
  291. for (int j = 0; j < dt.Columns.Count; j++)
  292. lvi.SubItems.Add(dt.Rows[i][j].ToString());
  293. WaitRejectList.Items.Add(lvi);
  294. }
  295. }
  296. WaitRejectList.EndUpdate();
  297. }
  298. /// <summary>
  299. /// 加载已选不良的ListView
  300. /// </summary>
  301. private void LoadChoosedBadListView()
  302. {
  303. sql.Clear();
  304. sql.Append("select nvl(bg_code,mb_bgcode)||':'||nvl(bg_name,mb_badcode) bg_code,nvl(mb_badcode,bc_code) bc_code,bc_name,mb_badremark from makebad ");
  305. sql.Append("left join badgroup on mb_bgcode=bg_code left join badcode on mb_badcode=bc_code ");
  306. sql.Append(" where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and mb_status=0");
  307. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  308. ChoosedRejectList.Items.Clear();
  309. ChoosedRejectList.BeginUpdate();
  310. for (int i = 0; i < dt.Rows.Count; i++)
  311. {
  312. ListViewItem lvi = new ListViewItem();
  313. //第一列是勾选列,设置列头文本为空
  314. lvi.Text = "";
  315. ChoosedList.Add(dt.Rows[i]["bc_code"].ToString());
  316. for (int j = 0; j < dt.Columns.Count; j++)
  317. lvi.SubItems.Add(dt.Rows[i][j].ToString());
  318. ChoosedRejectList.Items.Add(lvi);
  319. }
  320. ChoosedRejectList.EndUpdate();
  321. }
  322. /// <summary>
  323. /// 设置良品或者不良品的采集结果
  324. /// </summary>
  325. private void SetCollectResult()
  326. {
  327. string ErrorMessage = "";
  328. //如果勾选的是不良品
  329. if (Reject.Checked)
  330. {
  331. LoadBadCodeListView();
  332. LoadChoosedBadListView();
  333. OperateResult.AppendText(">>请采集不良代码\n", Color.Green);
  334. bc_code.Focus();
  335. }
  336. else if (GoodProduct.Checked)
  337. {
  338. //如果不是返修的
  339. if (ifrework == "0")
  340. {
  341. dt = (DataTable)dh.ExecuteSql("select mb_id,bc_name,mbr_mbid from makebad left join makebadreason on mbr_mbid=mb_id left join badcode on mb_badcode=bc_code where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and mb_status=0", "select");
  342. for (int i = 0; i < dt.Rows.Count; i++)
  343. {
  344. if (dt.Rows[i]["mb_id"].ToString() != dt.Rows[i]["mbr_mbid"].ToString())
  345. ErrorMessage += "【" + dt.Rows[i]["bc_name"].ToString() + "】";
  346. }
  347. //存在不良记录
  348. if (ErrorMessage != "")
  349. {
  350. OperateResult.AppendText(">>序列号:" + ms_sncode.Text + " 已经判为不良品,不允许修改!\n", Color.Red);
  351. return;
  352. }
  353. else
  354. {
  355. if (AutoBadCode.Checked)
  356. {
  357. string str = BaseUtil.GetDataFromDevice("DEVICES");
  358. str = str.Replace("LIST OF DEVICES ATTACHED", "").Replace("\n", "");
  359. if (!(str.Length == 0))
  360. {
  361. Console.WriteLine("有链接");
  362. BaseUtil.GetDataFromDevice("RESET");
  363. }
  364. else
  365. {
  366. OperateResult.AppendText(">>无设备链接,无法恢复出厂设置,采集失败\n", Color.Red, ms_sncode);
  367. return;
  368. }
  369. }
  370. //良品信息采集
  371. if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", User.UserCode, out ErrorMessage))
  372. {
  373. //if (WriteSoftWare.Checked)
  374. //{
  375. // string Message = BaseUtil.GetDataFromDevice("INSTALL", SoftWarePath.Text);
  376. // OperateResult.AppendText(">>" + Message + "\n");
  377. //}
  378. //提示正确返回时传递的信息
  379. if (ErrorMessage.Contains("AFTERSUCCESS"))
  380. OperateResult.AppendText(">>" + ErrorMessage + "\n");
  381. ////恢复出厂设置
  382. //if (AutoBadCode.Checked)
  383. // BaseUtil.GetDataFromDevice("RESET");
  384. LastSncode = ms_sncode.Text;
  385. OperateResult.AppendText(">>" + ms_sncode.Text + "良品采集成功\n", Color.Green, ms_sncode, biduisn);
  386. if (bidui.Checked)
  387. biduisn.Focus();
  388. //记录操作日志
  389. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
  390. }
  391. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode, biduisn);
  392. }
  393. }
  394. else
  395. {
  396. if (reworkstatus != "3")
  397. {
  398. if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "良品采集", "检测合格", User.UserCode, out ErrorMessage))
  399. {
  400. //提示正确返回时传递的信息
  401. if (ErrorMessage.Contains("AFTERSUCCESS"))
  402. OperateResult.AppendText(">>" + ErrorMessage + "\n");
  403. LastSncode = ms_sncode.Text;
  404. OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为良品\n", Color.Green, ms_sncode, biduisn);
  405. if (bidui.Checked)
  406. biduisn.Focus();
  407. //记录操作日志
  408. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
  409. }
  410. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode, biduisn);
  411. }
  412. else
  413. {
  414. OperateResult.AppendText(">>返修的不良序列号必须先进行维修\n", Color.Red);
  415. }
  416. }
  417. }
  418. //加载页面信息
  419. LoadCollectedNum();
  420. LoadCheckQTY();
  421. }
  422. private void 测试采集_SizeChanged(object sender, EventArgs e)
  423. {
  424. asc.controlAutoSize(this);
  425. }
  426. private void LoadCollectedNum()
  427. {
  428. dt = (DataTable)dh.ExecuteSql("select mcd_inqty,ma_qty-mcd_inqty mcd_remainqty,mcd_ngqty,mcd_okqty,mcd_totalng from make left join makecraftdetail_view on mcd_macode=ma_code where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'", "select");
  429. BaseUtil.SetFormValue(Controls, dt);
  430. }
  431. private void Save_Click(object sender, EventArgs e)
  432. {
  433. if (ms_sncode.Text == "")
  434. {
  435. OperateResult.AppendText(">>序列号不允许为空\n", Color.Red);
  436. return;
  437. }
  438. if (GoodProduct.Checked)
  439. ms_code_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  440. else if (Reject.Checked)
  441. {
  442. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  443. {
  444. //判断界面工单是否为空时的序列号是否自动归属工单
  445. string oStatus = "";
  446. if (!LogicHandler.GetMakeInfo(ms_sncode.Text, out oMakeCode, out oStatus, out ErrorMessage))
  447. {
  448. if (ma_code.Text == "")
  449. {
  450. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  451. return;
  452. }
  453. }
  454. if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? oMakeCode : ma_code.Text, User.UserSourceCode, ms_sncode.Text, User.UserCode, out oMakeCode, out oMSID, out ErrorMessage))
  455. {
  456. dt = (DataTable)dh.ExecuteSql("select ma_code,ma_prodcode,ma_softversion,pr_spec,ma_qty from make left join product on ma_prodcode=pr_code where ma_code='" + oMakeCode + "'", "select");
  457. if (dt.Rows.Count > 0)
  458. {
  459. BaseUtil.SetFormValue(this.Controls, dt);
  460. LockMakeCode.Checked = true;
  461. }
  462. }
  463. else
  464. {
  465. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  466. return;
  467. }
  468. }
  469. else
  470. {
  471. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, ms_sncode);
  472. return;
  473. }
  474. int RejectCount = ChoosedRejectList.Items.Count;
  475. string[] bccode = new string[RejectCount];
  476. string[] bcremark = new string[RejectCount];
  477. string[] bgcode = new string[RejectCount];
  478. string[] bgname = new string[RejectCount];
  479. string[] bcname = new string[RejectCount];
  480. if (ChoosedRejectList.Items.Count == 0)
  481. {
  482. OperateResult.AppendText(">>不良品必须选择不良原因和不良代码!\n", Color.Red);
  483. return;
  484. }
  485. else
  486. {
  487. for (int i = 0; i < RejectCount; i++)
  488. {
  489. //获取不良代码组
  490. bgcode[i] = ChoosedRejectList.Items[i].SubItems[1].Text.Split(':')[0];
  491. //获取不良代码组名称
  492. bgname[i] = ChoosedRejectList.Items[i].SubItems[1].Text.Split(':')[1];
  493. //获取所有的不良代码
  494. bccode[i] = ChoosedRejectList.Items[i].SubItems[2].Text;
  495. //获取不良名称
  496. bcname[i] = ChoosedRejectList.Items[i].SubItems[3].Text;
  497. //获取所有的不良备注
  498. bcremark[i] = bc_remark.Text;
  499. }
  500. }
  501. //如果之前是良品的
  502. dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_status", "ms_checkno", "ms_outboxcode" }, "ms_id='" + oMSID + "' and ms_stepcode='" + User.CurrentStepCode + "'");
  503. if (dt.Rows.Count > 0)
  504. {
  505. string status = dt.Rows[0]["ms_status"].ToString();
  506. string outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
  507. if (outboxcode != "")
  508. {
  509. OperateResult.AppendText(">>序列号:" + ms_sncode.Text + "已装箱,请先进行拆箱\n", Color.Red);
  510. BaseUtil.CleanForm(this);
  511. return;
  512. }
  513. if (status == "1" || status == "2")
  514. {
  515. dh.UpdateByCondition("steppassed", "sp_result='不良品',sp_ifng=-1,sp_ymd=to_char(sysdate,'yyyymmdd'),sp_hm=to_char(sysdate,'hh24miss')", "sp_id=(select max(sp_id) from steppassed where sp_sncode='" + ms_sncode.Text + "')");
  516. dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty-1", "mcd_macode='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  517. dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_badtimes=nvl(ms_badtimes,0)+1", "ms_id='" + oMSID + "'");
  518. LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "良品采集成不良", "测试不良", User.UserCode);
  519. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "测试不良", "良品采集成不良", ms_sncode.Text, ob_checkno.Text);
  520. }
  521. string checkno = dt.Rows[0]["ms_checkno"].ToString();
  522. //存在抽检批次更新为空
  523. if (checkno != "")
  524. dh.UpdateByCondition("makeserial", "ms_checkno=''", "ms_id='" + oMSID + "'");
  525. }
  526. else
  527. {
  528. LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "采集成不良", "测试不良", User.UserCode);
  529. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集成不良", "测试不良", ms_sncode.Text, ob_checkno.Text);
  530. }
  531. //不良信息采集,mb_status<>0的是之前维修保存的,不能删除
  532. dh.ExecuteSql("delete from makebad where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and nvl(mb_status,0)=0", "delete");
  533. //normalButton1_Click(this, e);
  534. if (LogicHandler.SetTestNGDetail(ms_sncode.Text, ma_code.Text, User.UserCode, User.UserSourceCode, "检查未通过", bgcode, bccode, bgname, bcname, bcremark, out ErrorMessage))
  535. {
  536. //存在的不良代码和
  537. dt = (DataTable)dh.ExecuteSql("select sr_badcode from STEPRETURN where sr_stepcode='" + User.CurrentStepCode + "'", "select");
  538. if (dt.Rows.Count > 0)
  539. {
  540. int BadCodeInStep = 0;
  541. string badname = "";
  542. for (int i = 0; i < dt.Rows.Count; i++)
  543. {
  544. for (int j = 0; j < bccode.Length; j++)
  545. {
  546. if (dt.Rows[i]["sr_badcode"].ToString() == bccode[j])
  547. {
  548. badname += "[" + bcname[j] + "]";
  549. BadCodeInStep += 1;
  550. }
  551. }
  552. }
  553. //选中的不良代码必须全在工序默认的不良代码中才通过判断
  554. if (BadCodeInStep == bccode.Length)
  555. {
  556. dh.UpdateByCondition("makebad", "mb_status=-1", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and mb_stepcode='" + User.CurrentStepCode + "'");
  557. dh.UpdateByCondition("makeserial", "ms_stepcode='',ms_status=1,ms_nextstepcode='" + User.CurrentStepCode + "'", "ms_id='" + oMSID + "'");
  558. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "快速维修成功", "快速维修", "", ob_checkno.Text);
  559. OperateResult.AppendText(">>本次采集不良代码" + badname + "存在于本工序" + User.CurrentStepCode + "中,请解除故障后重新测试本站\n", Color.Black);
  560. }
  561. else OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
  562. }
  563. else OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
  564. LastSncode = ms_sncode.Text;
  565. //采集完不良,聚焦序列号
  566. ms_sncode.Focus();
  567. //记录操作日志
  568. ms_sncode.Text = "";
  569. //清除不良信息
  570. bc_code.Text = "";
  571. ChoosedRejectList.Items.Clear();
  572. LoadCollectedNum();
  573. WaitList.Clear();
  574. ChoosedList.Clear();
  575. }
  576. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  577. }
  578. }
  579. private void bc_code_KeyDown(object sender, KeyEventArgs e)
  580. {
  581. if (e.KeyCode == Keys.Enter)
  582. {
  583. sql.Clear();
  584. sql.Append("select bg_code||':'||bg_name bg_code,bc_code,bc_name,'' bc_remark from badgroupdetail left join ");
  585. sql.Append("badgroup on bg_id=bgd_bgid left join badcode on bgd_badcode = bc_code where bc_code='" + bc_code.Text + "' and rownum=1 ");
  586. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  587. if (dt.Rows.Count > 0)
  588. {
  589. for (int i = 0; i < ChoosedRejectList.Items.Count; i++)
  590. {
  591. if (ChoosedRejectList.Items[i].ListView.Items[i].SubItems[2].Text == bc_code.Text)
  592. {
  593. OperateResult.AppendText(">>已添加过不良代码" + bc_code.Text + "\n", Color.Red, bc_code);
  594. return;
  595. }
  596. }
  597. ListViewItem lvi = new ListViewItem();
  598. lvi.Text = "";
  599. for (int j = 0; j < dt.Columns.Count; j++)
  600. lvi.SubItems.Add(dt.Rows[0][j].ToString());
  601. ChoosedRejectList.Items.Add(lvi);
  602. bc_code.Clear();
  603. }
  604. else OperateResult.AppendText(">>" + bc_code.Text + "不良代码不存在\n", Color.Red, bc_code);
  605. }
  606. }
  607. private void LoadCheckQTY()
  608. {
  609. sql.Clear();
  610. string condition = "";
  611. int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  612. int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  613. if (nowcheckqty + 1 == batchqty && AutoCut)
  614. {
  615. condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
  616. }
  617. else
  618. {
  619. condition = "and ob_status='ENTERING' ";
  620. }
  621. if (pr_sendchecktype.Text == "SaleCode")
  622. {
  623. condition += " and ob_salecode='" + ma_salecode.Text + "'";
  624. }
  625. sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
  626. sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_prodcode='" + ma_prodcode.Text + "' and ");
  627. sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
  628. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  629. if (dt.Rows.Count > 0)
  630. {
  631. ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatch", "sum(ob_nowcheckqty)", "ob_makecode='" + ma_code.Text + "' and ob_status<>'ENTERING'").ToString();
  632. ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
  633. ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
  634. ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
  635. nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  636. batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  637. if (nowcheckqty == batchqty)
  638. {
  639. ob_nowcheckqty.ForeColor = Color.Red;
  640. OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
  641. if (AutoCut)
  642. {
  643. OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动断批\n", Color.Blue);
  644. }
  645. }
  646. }
  647. else
  648. {
  649. BaseUtil.CleanControlsText(ob_batchqty, ob_nowcheckqty, ob_checkno);
  650. SendCheck.Enabled = false;
  651. }
  652. if (ob_batchqty.Text != "")
  653. {
  654. SendCheck.Enabled = true;
  655. }
  656. else
  657. {
  658. SendCheck.Enabled = false;
  659. }
  660. }
  661. private void GoodProduct_CheckedChanged(object sender, EventArgs e)
  662. {
  663. if (GoodProduct.Checked)
  664. {
  665. bc_code.Enabled = false;
  666. WaitReject.Enabled = false;
  667. ChooseedReject.Enabled = false;
  668. Save.Visible = false;
  669. }
  670. else
  671. {
  672. bc_code.Enabled = true;
  673. WaitReject.Enabled = true;
  674. ChooseedReject.Enabled = true;
  675. Save.Visible = true;
  676. }
  677. if (ms_sncode.Text == "")
  678. {
  679. ms_sncode.Focus();
  680. }
  681. }
  682. private void SendCheck_Click(object sender, EventArgs e)
  683. {
  684. sql.Clear();
  685. sql.Append("update oqcbatch set ob_status='UNCHECK' where ob_checkno ='" + ob_checkno.Text + "'");
  686. dh.ExecuteSql(sql.GetString(), "select");
  687. ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatch", "sum(ob_nowcheckqty)", "ob_makecode='" + ma_code.Text + "' and ob_status<>'ENTERING'").ToString();
  688. ob_nowcheckqty.Text = "";
  689. ob_batchqty.Text = "";
  690. ob_nowcheckqty.ForeColor = Color.Black;
  691. SendCheck.Enabled = false;
  692. OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Blue);
  693. ms_sncode.Focus();
  694. LogicHandler.InsertMakeProcess(LastSncode, ma_code.Text, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
  695. //记录操作日志
  696. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
  697. ob_checkno.Text = "";
  698. }
  699. private void ob_checkno_TextChanged(object sender, EventArgs e)
  700. {
  701. if (ob_checkno.Text != "")
  702. {
  703. string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
  704. if (Cut == "" || Cut == "0")
  705. AutoCut = false;
  706. else
  707. AutoCut = true;
  708. SendCheck.Enabled = true;
  709. }
  710. }
  711. /// <summary>
  712. /// 工单变化修改数量
  713. /// </summary>
  714. /// <param name="sender"></param>
  715. /// <param name="e"></param>
  716. private void ma_code_UserControlTextChanged(object sender, EventArgs e)
  717. {
  718. if (ma_code.Text.Length > 4)
  719. {
  720. BaseUtil.CleanControlsText(mcd_inqty, mcd_remainqty, ob_batchqty, ob_nowcheckqty, ob_sendqty);
  721. LoadCollectedNum();
  722. LoadCheckQTY();
  723. }
  724. }
  725. private void Make_TestCollection_FormClosing(object sender, FormClosingEventArgs e)
  726. {
  727. BaseUtil.ClosePrint(lbl);
  728. //if (engine != null)
  729. // engine.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
  730. dh.Dispose();
  731. }
  732. private void ma_prodcode_TextChanged(object sender, EventArgs e)
  733. {
  734. LoadBadGroupData();
  735. }
  736. private void Filter_UserControlTextChanged(object sender, EventArgs e)
  737. {
  738. try
  739. {
  740. DataRow[] dr = (BadInfSource.DataSource as DataTable).Select("bc_code like '%" + Filter.Text + "%' or bc_name like '%" + Filter.Text + "%'");
  741. DataTable dt = (BadInfSource.DataSource as DataTable).Clone();
  742. for (int i = 0; i < dr.Length; i++)
  743. {
  744. dt.Rows.Add(dr[i].ItemArray);
  745. }
  746. WaitRejectList.Items.Clear();
  747. WaitRejectList.BeginUpdate();
  748. for (int i = 0; i < dt.Rows.Count; i++)
  749. {
  750. if (!ChoosedList.Contains(dt.Rows[i]["bc_code"].ToString()))
  751. {
  752. ListViewItem lvi = new ListViewItem();
  753. //第一列是勾选列,设置列头文本为空
  754. lvi.Text = "";
  755. WaitList.Add(dt.Rows[i]["bc_code"].ToString());
  756. for (int j = 0; j < dt.Columns.Count; j++)
  757. lvi.SubItems.Add(dt.Rows[i][j].ToString());
  758. WaitRejectList.Items.Add(lvi);
  759. }
  760. }
  761. WaitRejectList.EndUpdate();
  762. }
  763. catch (Exception)
  764. {
  765. }
  766. }
  767. private void WaitRejectList_DoubleClick(object sender, EventArgs e)
  768. {
  769. for (int i = WaitRejectList.Items.Count - 1; i >= 0; i--)
  770. {
  771. if (WaitRejectList.Items[i].Checked)
  772. {
  773. //双击右移
  774. ChooseedReject.PerformClick();
  775. }
  776. }
  777. }
  778. private void Make_TestCollection_KeyDown(object sender, KeyEventArgs e)
  779. {
  780. if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Q)
  781. {
  782. if (!LockSn)
  783. {
  784. ControlLockTimer.Start();
  785. LockSn = true;
  786. Lock_label.Visible = true;
  787. }
  788. else
  789. {
  790. ControlLockTimer.Stop();
  791. LockSn = false;
  792. Lock_label.Visible = false;
  793. }
  794. }
  795. }
  796. //创建打印进程
  797. private void NewPrint()
  798. {
  799. try
  800. {
  801. // engine = new BarTender.Application();
  802. lbl = new ApplicationClass();
  803. BaseUtil.WriteLbl();
  804. }
  805. catch (Exception ex)
  806. {
  807. OperateResult.AppendText("未正确安装CodeSoft软件\n" + ex.Message, Color.Red);
  808. }
  809. }
  810. private void normalButton1_Click(object sender, EventArgs e)
  811. {
  812. //if (ChoosedRejectList.Items.Count == 0 || ms_sncode.Text == "")
  813. //{
  814. // MessageBox.Show("未录入不良或SN为空");
  815. //}
  816. //string BADINFO = "";
  817. //for (int i = 0; i < ChoosedRejectList.Items.Count; i++)
  818. //{
  819. // BADINFO = BADINFO + ChoosedRejectList.Items[i].ListView.Items[i].SubItems[3].Text + " ";
  820. //}
  821. //BADINFO = BADINFO.Substring(0, BADINFO.Length - 1);
  822. //FileInfo PrintFile = new FileInfo(labelname);
  823. //if (!PrintFile.Exists)
  824. //{
  825. // MessageBox.Show("打印文件不存在");
  826. // return ;
  827. //}
  828. //doc = lbl.Documents.Open(labelname, true);
  829. //if (doc == null)
  830. //{
  831. // MessageBox.Show("标签文件打开失败");
  832. // return ;
  833. //}
  834. //for (int j = 1; j < doc.Variables.FormVariables.Count+1; j++)
  835. //{
  836. // switch (doc.Variables.FormVariables.Item(j).Name)
  837. // {
  838. // case "SN":
  839. // doc.Variables.FormVariables.Item(j).Value = ms_sncode.Text;
  840. // break;
  841. // case "BAD":
  842. // doc.Variables.FormVariables.Item(j).Value = BADINFO;
  843. // break;
  844. // }
  845. // // doc.Variables.FormVariables.Item(1).Value = (Prefix.Text + Date.Value.ToString("yyMMdd") + lpad(4, (i).ToString()));
  846. //}
  847. ////保存本次赋值进行打印
  848. //doc.Printer.SwitchTo(PrintList.Text);
  849. //doc.PrintDocument(1);
  850. }
  851. private void StartWatch_Click(object sender, EventArgs e)
  852. {
  853. if (FolderPath.Text == "")
  854. {
  855. OperateResult.AppendText("请选择监控文件夹\n");
  856. return;
  857. }
  858. else
  859. {
  860. if (!Directory.Exists(FolderPath.Text))
  861. {
  862. OperateResult.AppendText("监控文件夹不存在\n");
  863. return;
  864. }
  865. }
  866. XmlWatcher.Path = FolderPath.Text;
  867. XmlWatcher.Filter = "SN Writer.log";
  868. XmlWatcher.EnableRaisingEvents = true;
  869. //设置缓存数据
  870. BaseUtil.SetCacheData("FolderPath", FolderPath.Text);
  871. //设置按钮不可点击
  872. StartWatch.Enabled = false;
  873. ChooseFolder.Enabled = false;
  874. StopWatch.Enabled = true;
  875. OperateResult.AppendText("开始执行监控\n");
  876. }
  877. private void StopWatch_Click(object sender, EventArgs e)
  878. {
  879. XmlWatcher.EnableRaisingEvents = false;
  880. StartWatch.Enabled = true;
  881. ChooseFolder.Enabled = true;
  882. StopWatch.Enabled = false;
  883. OperateResult.AppendText("停止执行监控\n");
  884. }
  885. private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
  886. {
  887. while (true)
  888. {
  889. try
  890. {
  891. using (Stream stream = File.Open(e.FullPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
  892. {
  893. if (stream != null)
  894. break;
  895. }
  896. }
  897. catch (Exception ex)
  898. {
  899. Console.WriteLine(ex.Message);
  900. }
  901. }
  902. StreamReader _Sr = new StreamReader(FolderPath.Text + @"\" + e.Name, Encoding.UTF8);
  903. String[] strData;
  904. string line;
  905. string ssn = "";
  906. string imei = "";
  907. string imei1 = "";
  908. string bt = "";
  909. string mac = "";
  910. try
  911. {
  912. while ((line = _Sr.ReadLine()) != null)
  913. {
  914. if (line.Contains("Barcode[0]"))
  915. {
  916. Regex regex = new Regex("\"[^\"]*\"");
  917. ssn = regex.Match(line).Value.Replace("\"", "");
  918. }
  919. else if (line.Contains("Prod_Info->IMEI[0]"))
  920. {
  921. strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
  922. Regex regex = new Regex("\\[[^*]+\\]");
  923. imei = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
  924. }
  925. else if (line.Contains("Prod_Info->IMEI[1]"))
  926. {
  927. strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
  928. Regex regex = new Regex("\\[[^*]+\\]");
  929. imei1 = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
  930. }
  931. else if (line.Contains("Prod_Info->BtAddress"))
  932. {
  933. strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
  934. Regex regex = new Regex("\\[[^*]+\\]");
  935. bt = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
  936. }
  937. else if (line.Contains("Prod_Info->WiFiAddress"))
  938. {
  939. strData = line.Replace("\r", "").Replace("\n", "").Replace("\t", "").Split('=');
  940. Regex regex = new Regex("\\[[^*]+\\]");
  941. mac = regex.Match(strData[1]).Value.Replace("[", "").Replace("]", "");
  942. }
  943. }
  944. if (ssn != "")
  945. {
  946. ms_sncode.Text = ssn;
  947. ms_code_KeyDown(this, new KeyEventArgs(Keys.Enter));
  948. if (imei!="")
  949. {
  950. dh.ExecuteSql("update makeserial set ms_imei = '"+imei+"' where ms_sncode = '"+ ssn + "' and ms_makecode = '"+ma_code.Text+"'", "update");
  951. }
  952. if (imei1 != "")
  953. {
  954. dh.ExecuteSql("update makeserial set ms_imei1 = '" + imei1 + "' where ms_sncode = '" + ssn + "' and ms_makecode = '" + ma_code.Text + "'", "update");
  955. }
  956. if (bt != "")
  957. {
  958. dh.ExecuteSql("update makeserial set ms_bt = '" + bt + "' where ms_sncode = '" + ssn + "' and ms_makecode = '" + ma_code.Text + "'", "update");
  959. }
  960. if (mac != "")
  961. {
  962. dh.ExecuteSql("update makeserial set ms_mac = '" + mac + "' where ms_sncode = '" + ssn + "' and ms_makecode = '" + ma_code.Text + "'", "update");
  963. }
  964. }
  965. }
  966. catch (Exception ex)
  967. {
  968. MessageBox.Show(ex.Message);
  969. _Sr.Close();
  970. }
  971. _Sr.Close();
  972. }
  973. private void ChooseFolder_Click(object sender, EventArgs e)
  974. {
  975. FolderBrowserDialog folder = new FolderBrowserDialog();
  976. folder.Description = "选择监控文件夹";
  977. DialogResult result = folder.ShowDialog();
  978. if (result == DialogResult.OK)
  979. {
  980. FolderPath.Text = folder.SelectedPath;
  981. }
  982. }
  983. private void biduisn_KeyDown(object sender, KeyEventArgs e)
  984. {
  985. if (e.KeyCode == Keys.Enter)
  986. {
  987. if (bidui.Checked&&biduisn.Text!="")
  988. {
  989. ms_sncode.Focus();
  990. ms_sncode.SelectAll();
  991. }
  992. }
  993. }
  994. }
  995. }