Make_UpdateDownLine.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  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. namespace UAS_MES_NEW.Make
  13. {
  14. public partial class Make_UpdateDownLine : Form
  15. {
  16. public Make_UpdateDownLine()
  17. {
  18. InitializeComponent();
  19. }
  20. StringBuilder SQL = new StringBuilder();
  21. DataTable dt;
  22. DataHelper dh;
  23. bool authenticate;
  24. private void Make_UpdateDownLine_Load(object sender, EventArgs e)
  25. {
  26. dh = SystemInf.dh;
  27. SQL.Clear();
  28. SQL.Append("SELECT dl_linecode FROM deviceline WHERE dl_type = 'SMT'");
  29. dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
  30. if (dt.Rows.Count > 0)
  31. {
  32. for(int i = dt.Rows.Count - 1; i >= 0; i--)
  33. {
  34. Line.Items.Add(dt.Rows[i]["dl_linecode"]);
  35. }
  36. Down.Enabled = true;
  37. }
  38. SQL.Clear();
  39. SQL.Append("SELECT * FROM deviceline_smt_log ORDER BY dl_indate DESC");
  40. dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
  41. if (dt.Rows.Count > 0)
  42. {
  43. DGV.DataSource = dt;
  44. }
  45. SQL.Clear();
  46. SQL.Append($"select * from employee where em_type = 'admin' and em_name = '{User.UserName}'");
  47. dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
  48. if (dt.Rows.Count > 0)
  49. {
  50. authenticate = true;
  51. Down.Enabled = true;
  52. }
  53. }
  54. private void Down_Click(object sender, EventArgs e)
  55. {
  56. if (!authenticate)
  57. {
  58. return;
  59. }
  60. if (Line.SelectedIndex == -1)
  61. {
  62. return;
  63. }
  64. DialogResult result = MessageBox.Show("确定是否下线在制工单","警告",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
  65. if(result != DialogResult.OK)
  66. {
  67. return;
  68. }
  69. string line = Line.Text;
  70. SQL.Clear();
  71. SQL.Append($"INSERT INTO DEVICELINE_SMT_LOG SELECT * FROM DEVICELINE WHERE DL_LINECODE = '{line}' AND DL_TYPE = 'SMT'");
  72. dh.ExecuteSql(SQL.ToString(), "insert");
  73. SQL.Clear();
  74. SQL.Append($"DELETE DEVICELINE WHERE DL_TYPE = 'SMT' AND DL_LINECODE = '{line}'");
  75. dh.ExecuteSql(SQL.ToString(), "delete");
  76. SQL.Clear();
  77. SQL.Append("SELECT * FROM deviceline_smt_log ORDER BY dl_indate DESC");
  78. dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
  79. if (dt.Rows.Count > 0)
  80. {
  81. DGV.DataSource = dt;
  82. }
  83. }
  84. }
  85. }