Special_CancelMaekBad.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using UAS_MES_NEW.DataOperate;
  6. using UAS_MES_NEW.Entity;
  7. using UAS_MES_NEW.PublicMethod;
  8. namespace UAS_MES_NEW.Special
  9. {
  10. public partial class Special_CancelMaekBad : Form
  11. {
  12. DataHelper dh = SystemInf.dh;
  13. LogStringBuilder sql = new LogStringBuilder();
  14. AutoSizeFormClass asc = new AutoSizeFormClass();
  15. public Special_CancelMaekBad()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Special_CancelProdinout_Load(object sender, EventArgs e)
  20. {
  21. ma_code.TableName = "make left join product on pr_code=ma_prodcode";
  22. ma_code.DBTitle = "工单号查询";
  23. ma_code.SelectField = "ma_code # 工单号,ma_qty # 工单数量,pr_detail # 产品名称,pr_code # 产品编号";
  24. ma_code.SetValueField = new string[] { "ma_code", "pr_detail", "pr_code" };
  25. ma_code.FormName = Name;
  26. asc.controllInitializeSize(this);
  27. }
  28. private void LoadGridData()
  29. {
  30. DataTable dt = (DataTable)dh.ExecuteSql("select mb_id,mb_sncode,mb_badcode,mb_badname,mbr_dutycode,mbr_brname,mbr_solutionname,mb_stepcode,st_name from makebad left join MAKEBADREASON on mbr_mbid=mb_id left join step on mb_stepcode=st_code where mb_makecode='" + ma_code.Text + "'", "select");
  31. BaseUtil.FillDgvWithDataTable(Info, dt);
  32. }
  33. private void Special_AfterSaleIn_SizeChanged(object sender, EventArgs e)
  34. {
  35. asc.controlAutoSize(this);
  36. }
  37. private void ma_code_UserControlTextChanged(object sender, EventArgs e)
  38. {
  39. LoadGridData();
  40. }
  41. private void Search_Click(object sender, EventArgs e)
  42. {
  43. string sql = "select mb_id,mb_sncode,mb_badcode,mb_badname,mbr_dutycode,mbr_brname,mbr_solutionname,mb_stepcode,st_name from makebad left join MAKEBADREASON on mbr_mbid=mb_id left join step on mb_stepcode=st_code where mb_makecode='" + ma_code.Text + "' ";
  44. if (badname.Text != "")
  45. {
  46. sql += " and mb_badname like '%" + badname.Text + "%'";
  47. }
  48. if (badreason.Text != "")
  49. {
  50. sql += " and mbr_brname like '%" + badreason.Text + "%'";
  51. }
  52. DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
  53. BaseUtil.FillDgvWithDataTable(Info, dt);
  54. }
  55. private void Delete_Click(object sender, EventArgs e)
  56. {
  57. for (int i = 0; i < Info.Rows.Count; i++)
  58. {
  59. if (Info.Rows[i].Cells["Choose"].FormattedValue != null && Info.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  60. {
  61. string mb_id = Info.Rows[i].Cells["mb_id"].Value.ToString();
  62. string mb_sncode = Info.Rows[i].Cells["mb_sncode"].Value.ToString();
  63. string mb_stepcode = Info.Rows[i].Cells["mb_stepcode"].Value.ToString();
  64. dh.ExecuteSql("delete from makebadreason where mbr_mbid='" + mb_id + "'", "delete");
  65. dh.ExecuteSql("delete from makebad where mb_id='" + mb_id + "'", "delete");
  66. dh.ExecuteSql("update steppassed set sp_ifng=0,sp_result='良品' where sp_id= (select max(sp_id) from steppassed where sp_sncode='" + mb_sncode + "' and sp_stepcode='" + mb_stepcode + "' and sp_ifng=-1)", "update");
  67. }
  68. }
  69. LoadGridData();
  70. }
  71. }
  72. }