Query_ExeProgress.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Query
  14. {
  15. public partial class Query_ExeProgress : Form
  16. {
  17. DataHelper dh;
  18. LogStringBuilder sql = new LogStringBuilder();
  19. //经过的步骤
  20. string PastStep = "";
  21. //经过的步骤
  22. string nextStepCode = "";
  23. //序列号对应抽检批
  24. string checkno = "";
  25. //拆分后的经过的步骤
  26. Dictionary<int, string> Step;
  27. List<Brush> PaintColor = new List<Brush>();
  28. //屏幕高度
  29. int ScreenWidth;
  30. //屏幕宽度
  31. int ScreenHeight;
  32. DataTable dt;
  33. DataTable ms_id;//记录ms_id
  34. DataTable ListA;//记录数据的当前序列号和之前序列号
  35. AutoSizeFormClass asc = new AutoSizeFormClass();
  36. public Query_ExeProgress()
  37. {
  38. InitializeComponent();
  39. }
  40. private void Query_ExeProgress_Load(object sender, EventArgs e)
  41. {
  42. dh = SystemInf.dh;
  43. ScreenWidth = this.Width;
  44. ScreenHeight = this.Height;
  45. asc.controllInitializeSize(this);
  46. sn_code.Focus();
  47. }
  48. private void Query_ExeProgress_SizeChanged(object sender, EventArgs e)
  49. {
  50. // asc.controlAutoSize(this);
  51. }
  52. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  53. {
  54. if (e.KeyCode == Keys.Enter)
  55. {
  56. ms_id = (DataTable)dh.ExecuteSql("select beforesn,sn from makesnrelation where beforesn='" + sn_code.Text + "' or sn='" + sn_code.Text + "'", "select");
  57. if (ms_id.Rows.Count > 0)
  58. {
  59. //说明有过转号
  60. ms_id = (DataTable)dh.ExecuteSql("select ms_othid1,ms_mac,ms_bt,ms_colorcode,ms_id,ms_makecode,ms_checkno,ms_outboxcode from makeserial where ms_sncode='" + ms_id.Rows[0]["beforesn"].ToString() + "' or ms_sncode='" + ms_id.Rows[0]["sn"].ToString() + "' order by ms_id", "select");
  61. }
  62. else
  63. {
  64. //没有过转号
  65. ms_id = (DataTable)dh.ExecuteSql("select ms_othid1,ms_mac,ms_bt,ms_colorcode,ms_id,ms_makecode,ms_checkno,ms_outboxcode from makeserial where ms_sncode='" + sn_code.Text + "' order by ms_id", "select");
  66. }
  67. if (ms_id.Rows.Count == 0)
  68. {
  69. //无值则提示
  70. MessageBox.Show("序列号" + sn_code.Text + "不存在");
  71. return;
  72. }
  73. StringBuilder ms_ids = new StringBuilder();//存所有的ms_id
  74. //设置界面工单号
  75. ma_code.Text = ms_id.Rows[ms_id.Rows.Count - 1]["ms_makecode"].ToString();
  76. ma_colorcode.Text = ms_id.Rows[ms_id.Rows.Count - 1]["ms_colorcode"].ToString();
  77. ms_checkno.Text = ms_id.Rows[ms_id.Rows.Count - 1]["ms_checkno"].ToString();
  78. ms_othid1.Text = ms_id.Rows[ms_id.Rows.Count - 1]["ms_othid1"].ToString();
  79. ms_mac.Text = ms_id.Rows[ms_id.Rows.Count - 1]["ms_mac"].ToString();
  80. ms_bt.Text = ms_id.Rows[ms_id.Rows.Count - 1]["ms_bt"].ToString();
  81. pallet.Text = dh.getFieldDataByCondition("mes_package_view", "v_outboxcode", "v_barcode = '"+sn_code.Text+"' and v_type = 3").ToString();
  82. ms_outboxcode.Text = ms_id.Rows[ms_id.Rows.Count - 1]["ms_outboxcode"].ToString();
  83. int idCount = ms_id.Rows.Count;
  84. for (int i = 0; i < idCount; i++)
  85. {
  86. ms_ids.Append("'" + ms_id.Rows[i]["ms_id"].ToString() + "',");
  87. }
  88. ListA = (DataTable)dh.ExecuteSql("select ms_beforesn,ms_sncode,ms_firstsn,ms_makecode from makeserial where ms_id in (" + ms_ids.ToString().Substring(0, ms_ids.ToString().Length - 1) + ")", "select");
  89. dt = (DataTable)dh.ExecuteSql("select ms_status,ms_nextstepcode,ms_paststep,ms_stepcode,ms_checkno,ms_outboxcode,NVL(ms_ifrework, 0) ms_ifrework,NVL(ms_reworkstatus, 0) ms_reworkstatus from makeserial where ms_id in (" + ms_ids.ToString().Substring(0, ms_ids.ToString().Length - 1) + ") order by ms_id", "select");
  90. if (dt.Rows.Count > 0)
  91. {
  92. if (Step != null && Step.Count > 0)
  93. {
  94. Step.Clear();
  95. SerialPanel.Controls.Clear();
  96. PaintColor.Clear();
  97. }
  98. string ifRework = dt.Rows[idCount - 1]["ms_ifrework"].ToString();
  99. //执行过的步骤
  100. PastStep = dt.Rows[idCount - 1]["ms_paststep"].ToString();
  101. //下一步骤
  102. nextStepCode = dt.Rows[idCount - 1]["ms_nextstepcode"].ToString();
  103. //序列号所属抽检批
  104. checkno = dt.Rows[idCount - 1]["ms_checkno"].ToString();
  105. //如果为不良的时候
  106. string BadStep = "";
  107. string RejectStep = "";
  108. string currentStep = "";
  109. //先判断是否是返工的
  110. if (ifRework != "0")
  111. {
  112. //是返工的
  113. if (dt.Rows[idCount - 1]["ms_reworkstatus"].ToString() == "3")
  114. {
  115. BadStep = dt.Rows[idCount - 1]["ms_stepcode"].ToString();
  116. }
  117. else if (dt.Rows[idCount - 1]["ms_reworkstatus"].ToString() == "4")
  118. {
  119. RejectStep = dt.Rows[idCount - 1]["ms_stepcode"].ToString();
  120. }
  121. }
  122. else
  123. {
  124. //不是返工的
  125. if (dt.Rows[idCount - 1]["ms_status"].ToString() == "3")
  126. {
  127. BadStep = dt.Rows[idCount - 1]["ms_stepcode"].ToString();
  128. }
  129. else if (dt.Rows[idCount - 1]["ms_status"].ToString() == "4")
  130. {
  131. RejectStep = dt.Rows[idCount - 1]["ms_stepcode"].ToString();
  132. }
  133. }
  134. currentStep = dt.Rows[idCount - 1]["ms_stepcode"].ToString();
  135. bool flag = false;//记录返工单开始就是不良的情况
  136. //如果只有一个单
  137. if (idCount == 1)
  138. {
  139. //添加开始节点绿色,除了返工单
  140. if (BadStep == "" && ((dt.Rows[idCount - 1]["ms_status"].ToString() == "3" && ifRework == "0") || (dt.Rows[idCount - 1]["ms_reworkstatus"].ToString() == "3" && ifRework == "-1")))
  141. {
  142. PaintColor.Add(Brushes.Red);
  143. }
  144. else
  145. {
  146. PaintColor.Add(Brushes.Green);
  147. }
  148. }
  149. else//有至少两个工单,之前的工单肯定是已经完工的
  150. {
  151. PaintColor.Add(Brushes.Green);
  152. if (BadStep == "" && ((dt.Rows[idCount - 1]["ms_status"].ToString() == "3" && ifRework == "0") || (dt.Rows[idCount - 1]["ms_reworkstatus"].ToString() == "3" && ifRework == "-1")))
  153. {
  154. //单独记录返工前oqc判不良
  155. flag = true;
  156. }
  157. }
  158. //查询执行过的步骤
  159. sql.Clear();
  160. sql.Append("select CD_DETNO,CD_STEPCODE,CD_STEPNAME,cd_ifoqc,ms_makecode,ms_id from craft left join craftdetail on cd_crid = cr_id left join makeserial ");
  161. sql.Append("on ms_craftcode=cr_code and ms_prodcode=cr_prodcode where ms_id in (" + ms_ids.ToString().Substring(0, ms_ids.ToString().Length - 1) + ") order by ms_id,cd_detno");
  162. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  163. Step = new Dictionary<int, string>();
  164. for (int i = 0; i < dt.Rows.Count + 2; i++)
  165. {
  166. if (i == 0)
  167. Step.Add(i, "开始");
  168. else if (i == dt.Rows.Count + 1)
  169. Step.Add(i, "结束");
  170. else
  171. Step.Add(i, dt.Rows[i - 1]["CD_STEPNAME"].ToString());
  172. }
  173. //添加中间节点
  174. bool passed = true;
  175. int index = 0;
  176. for (int i = 0; i < dt.Rows.Count; i++)
  177. {
  178. //正在生产的途程才算
  179. if (dt.Rows[i]["ms_id"].ToString() == ms_id.Rows[ms_id.Rows.Count - 1]["ms_id"].ToString())
  180. {
  181. if (nextStepCode == dt.Rows[i]["CD_STEPCODE"].ToString())
  182. {
  183. index = i;
  184. }
  185. }
  186. }
  187. for (int i = 0; i < dt.Rows.Count; i++)
  188. {
  189. //只考虑正在生产的途程,之前工单的途程工序必定为绿色完工
  190. if (dt.Rows[i]["ms_id"].ToString() == ms_id.Rows[ms_id.Rows.Count - 1]["ms_id"].ToString())
  191. {
  192. ////下一步不在途程中,不良或者报废或者完工
  193. if (nextStepCode == "" || nextStepCode == " ")
  194. {
  195. //返工单
  196. if (currentStep == "")
  197. {
  198. passed = false;
  199. }
  200. //找到不良步骤
  201. if (BadStep == dt.Rows[i]["CD_STEPCODE"].ToString())
  202. {
  203. PaintColor.Add(Brushes.Red);
  204. //是不良品,后面就不执行
  205. passed = false;
  206. }
  207. //找到报废步骤
  208. else if (PastStep.Contains(dt.Rows[i]["CD_STEPCODE"].ToString() + "," + RejectStep) && RejectStep != "")
  209. {
  210. PaintColor.Add(Brushes.Black);
  211. //是报废品,后面就不执行
  212. passed = false;
  213. }
  214. else
  215. {
  216. //通过加绿色
  217. if (PastStep.Contains(dt.Rows[i]["CD_STEPCODE"].ToString())&&passed)
  218. {
  219. PaintColor.Add(Brushes.Green);
  220. }
  221. //不通过加白色
  222. else
  223. {
  224. PaintColor.Add(Brushes.White);
  225. }
  226. }
  227. }
  228. ////序列号下一步不为空
  229. else
  230. {
  231. /////SN下一步是否在途程中,是则标记
  232. //找到下一步
  233. if (i < index)
  234. {
  235. //已执行
  236. //判断是否为OQC工序
  237. if (dt.Rows[i]["cd_ifoqc"].ToString() == "-1")
  238. {
  239. string oqcpass = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno = '" + checkno + "'").ToString();
  240. if (oqcpass == "OK")
  241. {
  242. PaintColor.Add(Brushes.Green);
  243. }
  244. else
  245. {
  246. PaintColor.Add(Brushes.White);
  247. }
  248. }
  249. else
  250. PaintColor.Add(Brushes.Green);
  251. }
  252. else
  253. {
  254. //未执行
  255. PaintColor.Add(Brushes.White);
  256. }
  257. }
  258. }
  259. else
  260. {
  261. //就是之前生产的途程,为绿色,除了返工
  262. if (flag && (dt.Rows[i + 1]["ms_id"].ToString() == ms_id.Rows[ms_id.Rows.Count - 1]["ms_id"].ToString()))
  263. {
  264. PaintColor.Add(Brushes.Red);
  265. }
  266. else
  267. {
  268. PaintColor.Add(Brushes.Green);
  269. }
  270. }
  271. }
  272. if (ifRework != "0")
  273. {
  274. //完工添加绿色,未完工添加白色
  275. if (dh.CheckExist("Makeserial", "ms_id='" + ms_id.Rows[ms_id.Rows.Count - 1]["ms_id"] + "' and ms_reworkstatus='2'"))
  276. PaintColor.Add(Brushes.Green);
  277. else
  278. PaintColor.Add(Brushes.White);
  279. }
  280. else
  281. {
  282. //完工添加绿色,未完工添加白色
  283. if (dh.CheckExist("Makeserial", "ms_id='" + ms_id.Rows[ms_id.Rows.Count - 1]["ms_id"] + "' and ms_status='2'"))
  284. PaintColor.Add(Brushes.Green);
  285. else
  286. PaintColor.Add(Brushes.White);
  287. }
  288. Refresh();
  289. SerialPanel.Refresh();
  290. StringBuilder mp_sncodes = new StringBuilder();
  291. StringBuilder makecodes = new StringBuilder();
  292. //拼接序列号的和工单号的
  293. for (int i = 0; i < ListA.Rows.Count; i++)
  294. {
  295. //sql mp_sncode
  296. mp_sncodes.Append("'" + ListA.Rows[i]["ms_sncode"].ToString() + "'," + (ListA.Rows[i]["ms_firstsn"].ToString() == "" ? "" : (" '" + ListA.Rows[i]["ms_firstsn"].ToString() + "',")));
  297. //sql ma_code
  298. makecodes.Append("'" + ListA.Rows[i]["ms_makecode"].ToString() + "',");
  299. }
  300. sql.Clear();
  301. sql.Append("select mp_makecode,ma_prodcode,sc_linecode,ma_craftcode,mp_sourcecode,mp_sncode,mp_stepname,");
  302. sql.Append("mp_indate,mp_inman,em_name from makeprocess left join make on mp_makecode=ma_code left join employee on mp_inman = em_code left join source on ");
  303. sql.Append("mp_sourcecode=sc_code where mp_sncode in (" + mp_sncodes.ToString().Substring(0, mp_sncodes.ToString().Length - 1) + ") and ma_code in (" + makecodes.ToString().Substring(0, makecodes.ToString().Length - 1) + ") order by mp_indate");
  304. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  305. BaseUtil.FillDgvWithDataTable(CraftInfDgv, dt);
  306. sql.Clear();
  307. sql.Append("select cm_makecode,cm_soncode,pr_detail,cm_barcode,cm_stepcode,cm_stepname,cm_status,cm_indate ");
  308. sql.Append("from craftmaterial left join product on pr_code=cm_soncode ");
  309. sql.Append("left join employee on cm_inman = em_code where cm_sncode IN (" + mp_sncodes.ToString().Substring(0, mp_sncodes.ToString().Length - 1) + " ) order by cm_id asc");
  310. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  311. BaseUtil.FillDgvWithDataTable(CraftmaterialData, dt);
  312. }
  313. else MessageBox.Show("序列号" + sn_code.Text + "不存在");
  314. }
  315. }
  316. private void SerialPanel_Paint(object sender, PaintEventArgs e)
  317. {
  318. if (Step != null)
  319. {
  320. //设置一行五个展示数量
  321. int RectangleCountEachRow = 5;
  322. int x = 40;
  323. int y = SerialPanel.Height / 10;
  324. int CurrentIndex = 0;
  325. //根据记录的数量判断行数
  326. int RowCount = (Step.Count % RectangleCountEachRow) == 0 ? (Step.Count / RectangleCountEachRow) : (Step.Count / RectangleCountEachRow) + 1;
  327. //每行的循环
  328. for (int i = 1; i <= RowCount; i++)
  329. {
  330. for (int j = CurrentIndex; j < RectangleCountEachRow * i; j++)
  331. {
  332. //创建画板
  333. Graphics g = e.Graphics;
  334. //途程节点的矩形
  335. Rectangle r;
  336. if (Step[j].Contains("开始") || Step[j].Contains("结束"))
  337. {
  338. r = new Rectangle(0, 0, 40, 40);
  339. }
  340. else
  341. r = new Rectangle();
  342. r.Width = SerialPanel.Width / 10;
  343. r.Height = SerialPanel.Height / 8;
  344. //画箭头的Pen
  345. Pen p = new Pen(Color.CadetBlue, 15);
  346. p.StartCap = LineCap.Round;
  347. p.EndCap = LineCap.ArrowAnchor;
  348. //方块内的信息
  349. Label Param = new Label();
  350. Param.Text = j + " " + Step[j];
  351. Param.Name = j + Step[j] + "_label";
  352. Param.AutoSize = true;
  353. Param.Margin = new Padding(0, 0, 0, 0);
  354. Param.Anchor = AnchorStyles.Left;
  355. Param.Anchor = AnchorStyles.Top;
  356. //获取param的宽度和高度
  357. Graphics graphics = Graphics.FromHwnd(Param.Handle);
  358. SizeF size = graphics.MeasureString(Param.Text, Param.Font);
  359. //设定param文本框的位置
  360. //Param.Location = new Point(x + r.Width / 14 * RectangleCountEachRow, y + r.Height / 10 * 4);
  361. Param.Location = new Point(SerialPanel.AutoScrollPosition.X + x + (int)(r.Width - size.Width) / 2, SerialPanel.AutoScrollPosition.Y + y + (int)(r.Height - size.Height) / 2);
  362. graphics.Dispose();
  363. //如果在奇数行
  364. if (i % 2 != 0)
  365. {
  366. r.Location = new Point(SerialPanel.AutoScrollPosition.X + x, SerialPanel.AutoScrollPosition.Y + y);
  367. g.FillRectangle(PaintColor[j], r);
  368. //填充方块内的信息
  369. if (SerialPanel.Controls[Param.Name] == null)
  370. SerialPanel.Controls.Add(Param);
  371. if (j + 1 == Step.Count)
  372. break;
  373. //画箭头
  374. //如果是一行中的箭头
  375. if (j + 1 < RectangleCountEachRow * i)
  376. {
  377. g.DrawLine(p, SerialPanel.AutoScrollPosition.X + x + r.Width + 10, SerialPanel.AutoScrollPosition.Y + y + r.Height / 2, SerialPanel.AutoScrollPosition.X + x + ScreenWidth / (RectangleCountEachRow), SerialPanel.AutoScrollPosition.Y + y + r.Height / 2);
  378. x += ScreenWidth / RectangleCountEachRow;
  379. }
  380. //如果是行的最后一个的箭头
  381. else if (j + 1 == RectangleCountEachRow * i)
  382. {
  383. g.DrawLine(p, SerialPanel.AutoScrollPosition.X + x + r.Width / 2, SerialPanel.AutoScrollPosition.Y + y + r.Height + 10, SerialPanel.AutoScrollPosition.X + x + r.Width / 2, SerialPanel.AutoScrollPosition.Y + y + r.Height + r.Height);
  384. y = y + r.Height + r.Height;
  385. }
  386. }
  387. //如果在偶数行
  388. else
  389. {
  390. r.Location = new Point(SerialPanel.AutoScrollPosition.X + x, SerialPanel.AutoScrollPosition.Y + y);
  391. g.FillRectangle(PaintColor[j], r);
  392. //填充文字信息
  393. //存在这个名称的则不进行添加
  394. if (SerialPanel.Controls[Param.Name] == null)
  395. {
  396. SerialPanel.Controls.Add(Param);
  397. }
  398. //如果最后一个的画则直接Break,不用画箭头了
  399. if (j + 1 == Step.Count)
  400. {
  401. break;
  402. }
  403. //如果不是本行的最后一个画横向的箭头
  404. if (j + 1 < RectangleCountEachRow * i)
  405. {
  406. g.DrawLine(p, SerialPanel.AutoScrollPosition.X + (x - 10), SerialPanel.AutoScrollPosition.Y + (y + r.Height / 2), SerialPanel.AutoScrollPosition.X + (x - ScreenWidth / RectangleCountEachRow + r.Width), SerialPanel.AutoScrollPosition.Y + (y + r.Height / 2));
  407. x -= ScreenWidth / RectangleCountEachRow;
  408. }
  409. //如果是最后一个画纵向的箭头
  410. else if (j + 1 == RectangleCountEachRow * i)
  411. {
  412. g.DrawLine(p, SerialPanel.AutoScrollPosition.X + (x + r.Width / 2), SerialPanel.AutoScrollPosition.Y + (y + r.Height + 10), SerialPanel.AutoScrollPosition.X + (x + r.Width / 2), SerialPanel.AutoScrollPosition.Y + (y + r.Height + r.Height));
  413. y = y + r.Height + r.Height;
  414. }
  415. }
  416. CurrentIndex = CurrentIndex + 1;
  417. }
  418. }
  419. }
  420. }
  421. private void SerialPanel_Scroll(object sender, ScrollEventArgs e)
  422. {
  423. Graphics g = this.SerialPanel.CreateGraphics();
  424. g.Clear(this.BackColor);
  425. SerialPanel.Refresh();
  426. }
  427. private void barcode_KeyDown(object sender, KeyEventArgs e)
  428. {
  429. if (e.KeyCode == Keys.Enter)
  430. {
  431. dt = (DataTable)dh.ExecuteSql("select cm_sncode from craftmaterial where cm_barcode = '"+barcode.Text+ "' and cm_status =0 order by cm_id desc", "select");
  432. if (dt.Rows.Count == 0)
  433. {
  434. MessageBox.Show("未找到此零部件对应成品SN号");
  435. }
  436. else if (dt.Rows.Count > 1)
  437. {
  438. MessageBox.Show("此零部件为可重复件");
  439. }
  440. else
  441. {
  442. sn_code.Text = dt.Rows[0]["cm_sncode"].ToString();
  443. sn_code_KeyDown(this, new KeyEventArgs(Keys.Enter));
  444. }
  445. }
  446. }
  447. private void ms_othid1_KeyDown(object sender, KeyEventArgs e)
  448. {
  449. if (e.KeyCode == Keys.Enter&& ms_othid1.Text!="")
  450. {
  451. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_othid1 = '" + ms_othid1.Text + "' order by ms_id desc", "select");
  452. if (dt.Rows.Count == 0)
  453. {
  454. MessageBox.Show("未找到此相框ID对应成品SN号");
  455. }
  456. else
  457. {
  458. sn_code.Text = dt.Rows[0]["ms_sncode"].ToString();
  459. sn_code_KeyDown(this, new KeyEventArgs(Keys.Enter));
  460. }
  461. }
  462. }
  463. private void ms_mac_KeyDown(object sender, KeyEventArgs e)
  464. {
  465. if (e.KeyCode == Keys.Enter && ms_mac.Text != "")
  466. {
  467. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_mac = '" + ms_mac.Text + "' order by ms_id desc", "select");
  468. if (dt.Rows.Count == 0)
  469. {
  470. MessageBox.Show("未找到此WIFI对应成品SN号");
  471. }
  472. else
  473. {
  474. sn_code.Text = dt.Rows[0]["ms_sncode"].ToString();
  475. sn_code_KeyDown(this, new KeyEventArgs(Keys.Enter));
  476. }
  477. }
  478. }
  479. private void ms_bt_KeyDown(object sender, KeyEventArgs e)
  480. {
  481. if (e.KeyCode == Keys.Enter && ms_bt.Text != "")
  482. {
  483. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_bt = '" + ms_bt.Text + "' order by ms_id desc", "select");
  484. if (dt.Rows.Count == 0)
  485. {
  486. MessageBox.Show("未找到此BT对应成品SN号");
  487. }
  488. else
  489. {
  490. sn_code.Text = dt.Rows[0]["ms_sncode"].ToString();
  491. sn_code_KeyDown(this, new KeyEventArgs(Keys.Enter));
  492. }
  493. }
  494. }
  495. }
  496. }