Make_StepReportDetail.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  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.Make
  14. {
  15. public partial class Make_StepReportDetail : CustomControl.BaseForm.BaseForm
  16. {
  17. //所有用到了headBar的部分都需要这段代码
  18. [DllImport("user32.dll")]
  19. public static extern bool ReleaseCapture();
  20. [DllImport("user32.dll")]
  21. public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
  22. [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
  23. public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
  24. [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
  25. public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);
  26. public const int WM_SYSCOMMAND = 0x0112;
  27. public const int SC_MOVE = 0xF010;
  28. public const int HTCAPTION = 0x0002;
  29. DataHelper dh;
  30. LogStringBuilder sql = new LogStringBuilder();
  31. string msid;
  32. double badqty;
  33. string macode;
  34. public Make_StepReportDetail(string msid, double badqty, string macode)
  35. {
  36. dh = SystemInf.dh;
  37. InitializeComponent();
  38. this.msid = msid;
  39. this.badqty = badqty;
  40. this.macode = macode;
  41. }
  42. private void Warehouse_ProdDetail_Load(object sender, EventArgs e)
  43. {
  44. ngsum.Text = badqty.ToString();
  45. ma_code.Text = macode;
  46. stepcode.Text = User.CurrentStepCode;
  47. comBoxWithFocus1.Items.Add("1234");
  48. FillDataGridView();
  49. }
  50. private void headBar1_MouseDown(object sender, MouseEventArgs e)
  51. {
  52. ReleaseCapture();
  53. SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
  54. }
  55. private void BatchProductDGV_CellContentClick66(object sender, DataGridViewCellEventArgs e)
  56. {
  57. if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow")
  58. {
  59. if (e.RowIndex >= 0)
  60. {
  61. string id = BatchProductDGV.Rows[e.RowIndex].Cells["msd_id"].Value.ToString();
  62. if (id != "0")
  63. {
  64. dh.ExecuteSql("update MES_STEPREPORTdet set msd_status =-1 where msd_id='" + id + "'", "delete");
  65. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "工序不良报工", "删除记录" + id, "", "");
  66. FillDataGridView();
  67. }
  68. }
  69. }
  70. }
  71. private void FillDataGridView()
  72. {
  73. sql.Clear();
  74. sql.Append("select msd_id,msd_msid,msd_badname,msd_qty,msd_indate,msd_status,msd_stepcode from MES_STEPREPORTdet ");
  75. sql.Append("where msd_msid = '" + msid + "' and msd_stepcode = '" + User.CurrentStepCode + "' and msd_status = 0");
  76. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  77. BaseUtil.FillDgvWithDataTable(BatchProductDGV, dt);
  78. }
  79. private void button1_Click(object sender, EventArgs e)
  80. {
  81. }
  82. private void BatchProductDGV_CellFormatting12(object sender, DataGridViewCellFormattingEventArgs e)
  83. {
  84. if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow")
  85. {
  86. if (BatchProductDGV.Rows[e.RowIndex].Cells["msd_id"].Value.ToString() == "0")
  87. e.Value = Properties.Resources.WhiteImage;
  88. else
  89. e.Value = Properties.Resources.bindingNavigatorDeleteItem_Image;
  90. }
  91. }
  92. //try
  93. //{
  94. // if (comBoxWithFocus1.Text == "" || ngqty.Text == "")
  95. // {
  96. // MessageBox.Show("必填项为空");
  97. // return;
  98. // }
  99. // double ng = double.Parse(ngqty.Text);
  100. // double nowng = double.Parse(dh.getFieldDataByCondition("MES_STEPREPORTdet", "nvl(sum(msd_qty),0)", " msd_msid = '" + msid + "' and msd_stepcode = '" + User.CurrentStepCode + "' and msd_status = 0 ").ToString());
  101. // if (nowng + double.Parse(ngqty.Text) > badqty)
  102. // {
  103. // MessageBox.Show("已录入不良" + nowng + "+待录入不良" + ng + "大于不良总数" + badqty + "");
  104. // return;
  105. // }
  106. // else
  107. // {
  108. // string msdid = dh.GetSEQ("MES_STEPREPORTDET_seq");
  109. // sql.Clear();
  110. // sql.Append("insert into MES_STEPREPORTdet (MSD_ID,MSD_MSID,MSD_BADNAME ,MSD_QTY,");
  111. // sql.Append("MSD_INDATE,MSD_STATUS,MSD_STEPCODE");
  112. // sql.Append(") values(" + msdid + "," + msd_id + ",'" + comBoxWithFocus1.Text + "',");
  113. // sql.Append("'" + ng + "',sysdate,'0','" + User.CurrentStepCode + "')");
  114. // dh.ExecuteSql(sql.GetString(), "insert");
  115. // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "工序不良报工", "现象:" + comBoxWithFocus1.Text + ",数量:" + ng + "", "", "");
  116. // FillDataGridView();
  117. // comBoxWithFocus1.Text = "";
  118. // ngqty.Text = "";
  119. // }
  120. //}
  121. //catch (Exception ex)
  122. //{
  123. // Console.WriteLine(ex.Message);
  124. //}
  125. }
  126. }