Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

樣品進度表FOR METOO PAG導入.vb 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 樣品進度表FOR_METOO_PAG導入
  4. Dim conn As New SqlConnection
  5. Dim da As New SqlDataAdapter
  6. Dim cmd As New SqlCommand
  7. Dim ds As New DataSet : Dim ds1 As New DataSet : Dim ds2 As New DataSet : Dim ds4 As New DataSet : Dim ds5 As New DataSet : Dim ds6 As New DataSet
  8. Dim dr As SqlDataReader
  9. Dim N1 As Integer = 0
  10. Private Sub Set_清單()
  11. DataGridView1.DataSource = Nothing : ds.Clear()
  12. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  13. DataGridView1.ColumnHeadersHeight = 25
  14. DataGridView1.AllowUserToAddRows = False
  15. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  16. SQL1 = "SELECT 流水號 AS 序號, 流水號, 季節, 客戶, S_N AS Style, C_N, COLOR_NO AS Col_No, COLOR, LOTS, 檔案名稱
  17. FROM 樣品進度控制表METOO專用 WHERE 季節 LIKE N'" & ComboBox7.Text & "' AND 客戶 LIKE N'" & ComboBox2.Text & "' ORDER BY S_N, COLOR_NO"
  18. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  19. End Sub
  20. Private Sub Set_grid()
  21. DataGridView1.Columns(0).Width = 40 : DataGridView1.Columns(1).Visible = False : DataGridView1.Columns(2).Visible = False : DataGridView1.Columns(3).Visible = False
  22. DataGridView1.Columns(4).Width = 150 : DataGridView1.Columns(5).Width = 80 : DataGridView1.Columns(6).Width = 70 : DataGridView1.Columns(7).Width = 320
  23. DataGridView1.Columns(8).Width = 320
  24. DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
  25. N1 = 1
  26. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  27. If i = DataGridView1.Rows.Count - 1 Then
  28. DataGridView1.Rows(i).Cells("序號").Value = N1.ToString
  29. Exit For
  30. Else
  31. If DataGridView1(4, i).Value.ToString <> DataGridView1(4, i + 1).Value.ToString Then
  32. DataGridView1.Rows(i).Cells("序號").Value = N1.ToString
  33. N1 = N1 + 1
  34. Else
  35. DataGridView1.Rows(i).Cells("序號").Value = N1.ToString
  36. End If
  37. End If
  38. Next
  39. End Sub
  40. Private Sub ComboBox7下拉表單資料載入()
  41. conn.Close()
  42. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  43. SQL1 = "SELECT SEASON FROM 季節清單 ORDER BY SEASON"
  44. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  45. ComboBox7.Items.Clear() : While (dr.Read()) : ComboBox7.Items.Add(dr("SEASON")) : End While : conn.Close()
  46. End Sub
  47. Private Sub ComboBox2下拉表單資料載入()
  48. conn.Close()
  49. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  50. SQL1 = "SELECT 客戶簡稱 FROM 客戶控制表 ORDER BY 客戶簡稱"
  51. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  52. ComboBox2.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
  53. End Sub
  54. Private Sub 樣品進度表FOR_METOO_PAG導入_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  55. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  56. ComboBox7下拉表單資料載入() : ComboBox2下拉表單資料載入()
  57. End Sub
  58. Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
  59. Dim linePen As New Pen(Color.Blue, 2)
  60. If e.RowIndex = DataGridView1.Rows.Count - 1 Then
  61. Exit Sub
  62. Else
  63. If DataGridView1(4, e.RowIndex).Value.ToString <> DataGridView1(4, e.RowIndex + 1).Value.ToString Then
  64. Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  65. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  66. Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
  67. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  68. Exit Sub
  69. End If
  70. End If
  71. End Sub
  72. Private Sub ComboBox7_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
  73. If ComboBox7.Text = "" Or ComboBox2.Text = "" Then : Else : Set_清單() : End If
  74. End Sub
  75. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
  76. If ComboBox7.Text = "" Or ComboBox2.Text = "" Then : Else : Set_清單() : End If
  77. End Sub
  78. End Class