Make_BarcodeDetail.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_BarcodeDetail : 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 piinoutno;
  32. public Make_BarcodeDetail(string piinoutno)
  33. {
  34. dh = SystemInf.dh;
  35. InitializeComponent();
  36. this.piinoutno = piinoutno;
  37. }
  38. private void Warehouse_ProdDetail_Load(object sender, EventArgs e)
  39. {
  40. pi_inoutno.Text = piinoutno;
  41. FillDataGridView();
  42. }
  43. private void headBar1_MouseDown(object sender, MouseEventArgs e)
  44. {
  45. ReleaseCapture();
  46. SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
  47. }
  48. private void BatchProductDGV_CellContentClick66(object sender, DataGridViewCellEventArgs e)
  49. {
  50. if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow")
  51. {
  52. if (e.RowIndex >= 0)
  53. {
  54. string id = BatchProductDGV.Rows[e.RowIndex].Cells["bi_id"].Value.ToString();
  55. if (id != "0")
  56. {
  57. dh.ExecuteSql("delete barcodeio where bi_id='" + id + "'", "delete");
  58. FillDataGridView();
  59. }
  60. }
  61. }
  62. }
  63. private void FillDataGridView()
  64. {
  65. sql.Clear();
  66. sql.Append("select bi_id,bi_piid,bi_barcode,bi_inqty,pr_code,pr_detail,pr_spec from barcodeio left join product on bi_prodcode = pr_code ");
  67. sql.Append("where bi_inoutno = '" + pi_inoutno.Text + "' and bi_pdid is null order by bi_id asc " +
  68. "" +
  69. " ");
  70. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  71. BaseUtil.FillDgvWithDataTable(BatchProductDGV, dt);
  72. }
  73. private void button1_Click(object sender, EventArgs e)
  74. {
  75. }
  76. private void BatchProductDGV_CellFormatting12(object sender, DataGridViewCellFormattingEventArgs e)
  77. {
  78. if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow")
  79. {
  80. if (BatchProductDGV.Rows[e.RowIndex].Cells["bi_id"].Value.ToString() == "0")
  81. e.Value = Properties.Resources.WhiteImage;
  82. else
  83. e.Value = Properties.Resources.bindingNavigatorDeleteItem_Image;
  84. }
  85. }
  86. private void button1_Click_1(object sender, EventArgs e)
  87. {
  88. }
  89. private void BatchProductDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  90. {
  91. bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
  92. if (e.ColumnIndex > 0)
  93. {
  94. if (BatchProductDGV.Columns[e.ColumnIndex].Name == "bi_inqty")
  95. {
  96. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  97. e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
  98. Rectangle border = e.CellBounds;
  99. border.Width -= 1;
  100. e.Graphics.DrawRectangle(Pens.White, border);
  101. e.PaintContent(e.CellBounds);
  102. e.Handled = true;
  103. }
  104. }
  105. }
  106. }
  107. }