暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

預告訂單轉量產訂單.vb 45KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 預告訂單轉量產訂單
  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 ds3 As New DataSet : Dim ds4 As New DataSet
  8. Dim dr As SqlDataReader
  9. Dim DTP As String : Dim DTP1 As String
  10. Private Sub Set_DGV1載入前設定()
  11. DataGridView1.DataSource = Nothing : ds.Clear()
  12. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  13. DataGridView1.ColumnHeadersHeight = 25
  14. DataGridView1.AllowUserToAddRows = False
  15. DataGridView1.RowTemplate.Height = 50
  16. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  17. End Sub
  18. Private Sub Set_DGV1載入後設定()
  19. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  20. End Sub
  21. Private Sub Set_清單()
  22. Set_DGV1載入前設定()
  23. If PA = "" Then
  24. SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次, 訂單屬性
  25. FROM 預告訂單控制表 ORDER BY ConstructionName, PAO DESC, 版次 DESC"
  26. Else
  27. SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次, 訂單屬性 FROM 預告訂單控制表 " &
  28. "WHERE (SO LIKE N'%" & PA & "%') OR (季節 LIKE N'%" & PA & "%') OR (客戶 LIKE N'%" & PA & "%') OR (型體號碼 LIKE N'%" & PA & "%') OR (型體名稱 LIKE N'%" & PA & "%') " &
  29. "OR (ISSUE_DATE LIKE N'%" & PA & "%') OR (ETD LIKE N'%" & PA & "%') OR (FOB LIKE N'%" & PA & "%') OR (ConstructionName LIKE N'%" & PA & "%') OR (PS LIKE N'%" & PA & "%') " &
  30. "OR (制單人 LIKE N'%" & PA & "%') ORDER BY ConstructionName, PAO DESC, 版次 DESC"
  31. End If
  32. Set_DGV1載入後設定()
  33. End Sub
  34. Private Sub Set_grid()
  35. If CheckBox1.Checked = False Then
  36. DataGridView1.Size = New Size(475, 453)
  37. DataGridView1.Columns(0).FillWeight = 85 : DataGridView1.Columns(1).FillWeight = 70 : DataGridView1.Columns(2).FillWeight = 60 : DataGridView1.Columns(4).FillWeight = 95
  38. DataGridView1.Columns(6).FillWeight = 95 : DataGridView1.Columns(7).Visible = False
  39. Else
  40. DataGridView1.Size = New Size(745, 453)
  41. DataGridView1.Columns(0).FillWeight = 85 : DataGridView1.Columns(1).FillWeight = 55 : DataGridView1.Columns(2).FillWeight = 65 : DataGridView1.Columns(4).FillWeight = 170
  42. DataGridView1.Columns(6).FillWeight = 150 : DataGridView1.Columns(7).Visible = True : DataGridView1.Columns(7).FillWeight = 150
  43. End If
  44. DataGridView1.Columns(3).Visible = False : DataGridView1.Columns(5).Visible = False : DataGridView1.Columns(8).Visible = False : DataGridView1.Columns(9).Visible = False
  45. DataGridView1.Columns(10).Visible = False : DataGridView1.Columns(11).Visible = False : DataGridView1.Columns(12).Visible = False : DataGridView1.Columns(13).Visible = False
  46. DataGridView1.Columns(14).Visible = False : DataGridView1.Columns(15).Visible = False : DataGridView1.Columns(16).FillWeight = 45 : DataGridView1.Columns(17).Visible = False
  47. End Sub
  48. Private Sub Set_DGV2載入前設定()
  49. DataGridView2.DataSource = Nothing : ds1.Clear()
  50. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  51. DataGridView2.ColumnHeadersHeight = 25
  52. DataGridView2.AllowUserToAddRows = False
  53. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  54. End Sub
  55. Private Sub Set_DGV2載入後設定()
  56. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close() : Set_grid1()
  57. End Sub
  58. Private Sub Set_清單1()
  59. Set_DGV2載入前設定()
  60. SQL1 = "SELECT 預告訂單清單.顏色, METOO選擇按鈕.選擇
  61. FROM METOO選擇按鈕 RIGHT OUTER JOIN 預告訂單清單 ON METOO選擇按鈕.對應 = 預告訂單清單.顏色 LEFT OUTER JOIN 預告訂單控制表 ON 預告訂單清單.PAO = 預告訂單控制表.PAO AND
  62. 預告訂單清單.版次 = 預告訂單控制表.版次
  63. WHERE (預告訂單控制表.PAO LIKE '" & TextBox1.Text & "') AND (預告訂單控制表.版次 LIKE '" & TextBox2.Text & "') GROUP BY 預告訂單清單.顏色, METOO選擇按鈕.選擇"
  64. Set_DGV2載入後設定()
  65. End Sub
  66. Private Sub Set_grid1()
  67. DataGridView2.Columns(0).FillWeight = 110 : DataGridView2.Columns(1).FillWeight = 40
  68. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  69. DataGridView2.Rows(i).Cells("選擇").Value = False
  70. Next i
  71. End Sub
  72. Private Sub Set_DGV4載入前設定()
  73. DataGridView4.DataSource = Nothing : ds2.Clear()
  74. DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  75. DataGridView4.ColumnHeadersHeight = 25
  76. DataGridView4.AllowUserToAddRows = False
  77. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  78. End Sub
  79. Private Sub Set_DGV4載入後設定()
  80. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView4.DataSource = ds2.Tables(0) : conn.Close() : Set_grid3()
  81. End Sub
  82. Private Sub Set_清單2()
  83. Set_DGV4載入前設定()
  84. SQL1 = "SELECT 訂單流水號, 客戶訂單號, ConstructionName, ModeOfDelivery, DeliveryTerms, OrgShipDate, FromPort, ToPort,
  85. ShippingCarrier, VendorReference, ModifiedDate, CustomerName, ShipDate, SalesOrder, DeliveryAddress, 下單日,
  86. 交期, ETADate, CreatedDate, Brand, CustomerRequisition, 工廠
  87. FROM 訂單明細表抬頭 ORDER BY 訂單流水號 DESC"
  88. Set_DGV4載入後設定()
  89. End Sub
  90. Private Sub Set_grid3()
  91. DataGridView4.Columns(0).FillWeight = 120 : DataGridView4.Columns(1).FillWeight = 150 : DataGridView4.Columns(2).Visible = False : DataGridView4.Columns(3).Visible = False
  92. DataGridView4.Columns(4).Visible = False : DataGridView4.Columns(5).Visible = False : DataGridView4.Columns(6).Visible = False : DataGridView4.Columns(7).Visible = False
  93. DataGridView4.Columns(8).Visible = False : DataGridView4.Columns(9).Visible = False : DataGridView4.Columns(10).Visible = False : DataGridView4.Columns(11).Visible = False
  94. DataGridView4.Columns(12).Visible = False : DataGridView4.Columns(13).Visible = False : DataGridView4.Columns(14).Visible = False : DataGridView4.Columns(15).FillWeight = 90
  95. DataGridView4.Columns(16).FillWeight = 90 : DataGridView4.Columns(17).Visible = False : DataGridView4.Columns(18).Visible = False : DataGridView4.Columns(19).Visible = False
  96. DataGridView4.Columns(20).Visible = False : DataGridView4.Columns(21).Visible = False
  97. TextBox14.Text = "0.00"
  98. For i As Integer = 0 To DataGridView5.Rows.Count - 1
  99. DataGridView3.Rows(i).Cells("訂單數量").Value = DataGridView5.Rows(i).Cells("4").Value + DataGridView5.Rows(i).Cells("4.5").Value + DataGridView5.Rows(i).Cells("5").Value +
  100. DataGridView5.Rows(i).Cells("5.5").Value + DataGridView5.Rows(i).Cells("6").Value + DataGridView5.Rows(i).Cells("6.5").Value + DataGridView5.Rows(i).Cells("7").Value +
  101. DataGridView5.Rows(i).Cells("7.5").Value + DataGridView5.Rows(i).Cells("8").Value + DataGridView5.Rows(i).Cells("8.5").Value + DataGridView5.Rows(i).Cells("9").Value +
  102. DataGridView5.Rows(i).Cells("9.5").Value + DataGridView5.Rows(i).Cells("10").Value + DataGridView5.Rows(i).Cells("10.5").Value + DataGridView5.Rows(i).Cells("11").Value +
  103. DataGridView5.Rows(i).Cells("11.5").Value + DataGridView5.Rows(i).Cells("12").Value + DataGridView5.Rows(i).Cells("12.5").Value + DataGridView5.Rows(i).Cells("13").Value +
  104. DataGridView5.Rows(i).Cells("14").Value
  105. Next i
  106. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  107. TextBox14.Text = Val(TextBox14.Text) + DataGridView3.Rows(i).Cells("訂單數量").Value
  108. Next i
  109. TextBox14.Text = Format(Val(TextBox14.Text), "#,##0.00")
  110. End Sub
  111. Private Sub Set_DGV3載入前設定()
  112. DataGridView3.DataSource = Nothing : ds3.Clear()
  113. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  114. DataGridView3.ColumnHeadersHeight = 40
  115. DataGridView3.AllowUserToAddRows = False
  116. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  117. End Sub
  118. Private Sub Set_DGV3載入後設定()
  119. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds3) : DataGridView3.DataSource = ds3.Tables(0) : conn.Close() : Set_grid4()
  120. End Sub
  121. Private Sub Set_清單3()
  122. Set_DGV3載入前設定()
  123. SQL1 = "SELECT 資料流水號, 年份季度, 客戶訂單號, 型體號碼, GOODBOX AS 型體名稱, APMA確認 AS 顏色, TVW AS 楦型, 訂單數量, 工廠回復交期 AS 工廠交期, 客戶交期 AS 交期開始, 客戶交期1 AS 交期結束,
  124. 單價, 總金額, 備註, 生產工廠, 訂單種類, BUYER, CFMSPEC, CFMSAMPLE, TRIAL1, TRIAL2, TRIAL3, TRIAL4, 包裝確認時間, 貼標時間, 裁斷時間, 針車時間, 成型時間, 驗貨時間,
  125. 實際離廠日, 訂單流水號, 明細建檔, LEATHER, LEA_Note, CXL, CXLTime, 出貨數量, PO_S_Date, Requested_XF, Confirm_XF, Revised_XF, Special_Packaging, Remarks, 出貨地,
  126. 楦頭號, 材質, 長期試穿, 面料, 副料, 中底, 鞋墊, 大底, 跟, 工廠進度表備註1, 七號模具, 工廠進度表備註2, 國標測試, 客戶包裝確認, 東莞業務備註, 驗貨報告圖片
  127. FROM 訂單控制表 WHERE 訂單流水號 LIKE N'" & TextBox12.Text & "' ORDER BY GOODBOX, APMA確認, TVW"
  128. Set_DGV3載入後設定()
  129. End Sub
  130. Private Sub Set_grid4()
  131. DataGridView3.Columns(0).FillWeight = 85 : DataGridView3.Columns(1).FillWeight = 70 : DataGridView3.Columns(2).FillWeight = 130 : DataGridView3.Columns(3).FillWeight = 120
  132. DataGridView3.Columns(4).FillWeight = 130 : DataGridView3.Columns(5).FillWeight = 80 : DataGridView3.Columns(6).FillWeight = 50 : DataGridView3.Columns(7).FillWeight = 80
  133. DataGridView3.Columns(8).FillWeight = 90 : DataGridView3.Columns(9).FillWeight = 90 : DataGridView3.Columns(10).FillWeight = 90
  134. DataGridView3.Columns(11).Visible = False : DataGridView3.Columns(12).Visible = False
  135. DataGridView3.Columns(13).FillWeight = 130 : DataGridView3.Columns(14).FillWeight = 80 : DataGridView3.Columns(15).FillWeight = 120 : DataGridView3.Columns(16).FillWeight = 130
  136. DataGridView3.Columns(17).Visible = False : DataGridView3.Columns(18).Visible = False : DataGridView3.Columns(19).Visible = False : DataGridView3.Columns(20).Visible = False
  137. DataGridView3.Columns(21).Visible = False : DataGridView3.Columns(22).Visible = False : DataGridView3.Columns(23).Visible = False : DataGridView3.Columns(24).Visible = False
  138. DataGridView3.Columns(25).Visible = False : DataGridView3.Columns(26).Visible = False : DataGridView3.Columns(27).Visible = False : DataGridView3.Columns(28).Visible = False
  139. DataGridView3.Columns(29).Visible = False : DataGridView3.Columns(30).Visible = False : DataGridView3.Columns(31).Visible = False : DataGridView3.Columns(32).Visible = False
  140. DataGridView3.Columns(33).Visible = False : DataGridView3.Columns(34).Visible = False : DataGridView3.Columns(35).Visible = False : DataGridView3.Columns(36).Visible = False
  141. DataGridView3.Columns(37).Visible = False : DataGridView3.Columns(38).Visible = False : DataGridView3.Columns(39).Visible = False : DataGridView3.Columns(40).Visible = False
  142. DataGridView3.Columns(41).Visible = False : DataGridView3.Columns(42).Visible = False : DataGridView3.Columns(43).Visible = False : DataGridView3.Columns(44).Visible = False
  143. DataGridView3.Columns(45).Visible = False : DataGridView3.Columns(46).Visible = False : DataGridView3.Columns(47).Visible = False : DataGridView3.Columns(48).Visible = False
  144. DataGridView3.Columns(49).Visible = False : DataGridView3.Columns(50).Visible = False : DataGridView3.Columns(51).Visible = False : DataGridView3.Columns(52).Visible = False
  145. DataGridView3.Columns(53).Visible = False : DataGridView3.Columns(54).Visible = False : DataGridView3.Columns(55).Visible = False : DataGridView3.Columns(56).Visible = False
  146. DataGridView3.Columns(57).Visible = False : DataGridView3.Columns(58).Visible = False : DataGridView3.Columns(59).Visible = False
  147. DataGridView3.Columns(7).DefaultCellStyle.Format = "#,##0"
  148. DataGridView3.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  149. DataGridView3.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  150. DataGridView3.EditMode = DataGridViewEditMode.EditOnEnter
  151. End Sub
  152. Private Sub Set_DGV5載入前設定()
  153. DataGridView5.DataSource = Nothing : ds4.Clear()
  154. DataGridView5.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  155. DataGridView5.ColumnHeadersHeight = 25
  156. DataGridView5.AllowUserToAddRows = False
  157. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  158. End Sub
  159. Private Sub Set_DGV5載入後設定()
  160. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds4) : DataGridView5.DataSource = ds4.Tables(0) : conn.Close() : Set_grid5()
  161. End Sub
  162. Private Sub Set_清單4()
  163. Set_DGV5載入前設定()
  164. SQL1 = "SELECT 資料流水號, 客戶訂單號, ItemNumber, ProductName, Color, DM, [4], [4.5], [5], [5.5], [6], [6.5], [7], [7.5], [8], [8.5], [9], [9.5], [10], [10.5], [11], [11.5], [12], [12.5],
  165. [13], [14], 訂單流水號
  166. FROM 訂單明細表 WHERE 訂單流水號 LIKE N'" & TextBox12.Text & "' ORDER BY ProductName, Color, DM"
  167. Set_DGV5載入後設定()
  168. End Sub
  169. Private Sub Set_grid5()
  170. DataGridView5.Columns(0).FillWeight = 85 : DataGridView5.Columns(1).FillWeight = 150 : DataGridView5.Columns(2).FillWeight = 120 : DataGridView5.Columns(3).FillWeight = 150
  171. DataGridView5.Columns(4).FillWeight = 80 : DataGridView5.Columns(5).FillWeight = 50 : DataGridView5.Columns(6).FillWeight = 38 : DataGridView5.Columns(7).FillWeight = 37
  172. DataGridView5.Columns(8).FillWeight = 38 : DataGridView5.Columns(9).FillWeight = 37 : DataGridView5.Columns(10).FillWeight = 38 : DataGridView5.Columns(11).FillWeight = 37
  173. DataGridView5.Columns(12).FillWeight = 38 : DataGridView5.Columns(13).FillWeight = 37 : DataGridView5.Columns(14).FillWeight = 38 : DataGridView5.Columns(15).FillWeight = 37
  174. DataGridView5.Columns(16).FillWeight = 38 : DataGridView5.Columns(17).FillWeight = 37 : DataGridView5.Columns(18).FillWeight = 38 : DataGridView5.Columns(19).FillWeight = 37
  175. DataGridView5.Columns(20).FillWeight = 38 : DataGridView5.Columns(21).FillWeight = 37 : DataGridView5.Columns(22).FillWeight = 38 : DataGridView5.Columns(23).FillWeight = 37
  176. DataGridView5.Columns(24).FillWeight = 38 : DataGridView5.Columns(25).FillWeight = 37 : DataGridView5.Columns(26).Visible = False
  177. DataGridView5.EditMode = DataGridViewEditMode.EditOnEnter
  178. End Sub
  179. Private Sub ComboBox1下拉表單資料載入()
  180. conn.Close()
  181. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  182. SQL1 = "SELECT 楦型 FROM 訂單控制表楦型清單 ORDER BY 楦型"
  183. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox1.Items.Clear()
  184. While (dr.Read()) : ComboBox1.Items.Add(dr("楦型")) : End While : conn.Close()
  185. End Sub
  186. Private Sub ComboBox2下拉表單資料載入()
  187. conn.Close()
  188. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  189. SQL1 = "SELECT BUYER FROM 預告訂單控制表 GROUP BY BUYER ORDER BY BUYER DESC"
  190. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox2.Items.Clear()
  191. While (dr.Read()) : ComboBox2.Items.Add(dr("BUYER")) : End While : conn.Close()
  192. End Sub
  193. Private Sub ComboBox4下拉表單資料載入()
  194. conn.Close()
  195. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  196. SQL1 = "SELECT MODEOFDELIVERY FROM MODEOFDELIVERY"
  197. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox4.Items.Clear()
  198. While (dr.Read()) : ComboBox4.Items.Add(dr("MODEOFDELIVERY")) : End While : conn.Close()
  199. End Sub
  200. Private Sub ComboBox5下拉表單資料載入()
  201. conn.Close()
  202. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  203. SQL1 = "SELECT DELIVERYTERMS FROM DELIVERYTERMS"
  204. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox5.Items.Clear()
  205. While (dr.Read()) : ComboBox5.Items.Add(dr("DELIVERYTERMS")) : End While : conn.Close()
  206. End Sub
  207. Private Sub ComboBox6下拉表單資料載入()
  208. conn.Close()
  209. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  210. SQL1 = "SELECT FOB FROM 港口清單"
  211. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox6.Items.Clear()
  212. While (dr.Read()) : ComboBox6.Items.Add(dr("FOB")) : End While : conn.Close()
  213. End Sub
  214. Private Sub ComboBox7下拉表單資料載入()
  215. conn.Close()
  216. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  217. SQL1 = "SELECT TOPORT FROM TOPORT ORDER BY TOPORT"
  218. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox7.Items.Clear()
  219. While (dr.Read()) : ComboBox7.Items.Add(dr("TOPORT")) : End While : conn.Close()
  220. End Sub
  221. Private Sub ComboBox8下拉表單資料載入()
  222. conn.Close()
  223. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  224. SQL1 = "SELECT REMARK FROM DELIVERYADDRESS ORDER BY REMARK"
  225. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox8.Items.Clear()
  226. While (dr.Read()) : ComboBox8.Items.Add(dr("REMARK")) : End While : conn.Close()
  227. End Sub
  228. Private Sub ComboBox9下拉表單資料載入()
  229. conn.Close()
  230. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  231. SQL1 = "SELECT 工廠 FROM 工廠控制表 GROUP BY 工廠 ORDER BY 工廠"
  232. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox9.Items.Clear()
  233. While (dr.Read()) : ComboBox9.Items.Add(dr("工廠")) : End While : conn.Close()
  234. End Sub
  235. Private Sub 預告訂單轉量產訂單_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  236. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  237. TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox4.Enabled = False : TextBox6.Enabled = False : TextBox7.Enabled = False : TextBox5.Enabled = False
  238. TextBox8.Enabled = False : TextBox9.Enabled = False : TextBox11.Enabled = False : TextBox12.Enabled = False : TextBox14.Enabled = False : TextBox15.Enabled = False
  239. Button4.Enabled = False : Button3.Enabled = False : Button17.Enabled = False : Button12.Enabled = False : DateTimePicker1.Visible = False
  240. ComboBox4下拉表單資料載入() : ComboBox5下拉表單資料載入() : ComboBox6下拉表單資料載入() : ComboBox7下拉表單資料載入() : ComboBox8下拉表單資料載入() : ComboBox9下拉表單資料載入()
  241. ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入()
  242. Set_清單() : Set_清單2()
  243. End Sub
  244. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  245. If e.RowIndex = -1 Then : Else
  246. TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("PAO").Value : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("版次").Value
  247. ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("BUYER").Value : TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("季節").Value
  248. ComboBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("工廠").Value : TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value
  249. TextBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("型體名稱").Value : TextBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("ETD").Value
  250. TextBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("ISSUE_DATE").Value : ComboBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("FOB").Value
  251. TextBox11.Text = DataGridView1.Rows(e.RowIndex).Cells("ConstructionName").Value : TextBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("訂單屬性").Value
  252. Set_清單1()
  253. End If
  254. End Sub
  255. Private Sub DataGridView4_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView4.CellClick
  256. If e.RowIndex = -1 Then : Else
  257. ComboBox7.Text = DataGridView4.Rows(e.RowIndex).Cells("ToPort").Value : ComboBox4.Text = DataGridView4.Rows(e.RowIndex).Cells("ModeOfDelivery").Value
  258. ComboBox5.Text = DataGridView4.Rows(e.RowIndex).Cells("DeliveryTerms").Value : ComboBox6.Text = DataGridView4.Rows(e.RowIndex).Cells("FromPort").Value
  259. TextBox13.Text = DataGridView4.Rows(e.RowIndex).Cells("客戶訂單號").Value : TextBox16.Text = DataGridView4.Rows(e.RowIndex).Cells("DeliveryAddress").Value
  260. TextBox11.Text = DataGridView4.Rows(e.RowIndex).Cells("CustomerName").Value : ComboBox9.Text = DataGridView4.Rows(e.RowIndex).Cells("工廠").Value
  261. TextBox8.Text = DataGridView4.Rows(e.RowIndex).Cells("交期").Value : TextBox9.Text = DataGridView4.Rows(e.RowIndex).Cells("下單日").Value
  262. ComboBox6.Text = DataGridView4.Rows(e.RowIndex).Cells("FromPort").Value : TextBox11.Text = DataGridView4.Rows(e.RowIndex).Cells("ConstructionName").Value
  263. TextBox12.Text = DataGridView4.Rows(e.RowIndex).Cells("訂單流水號").Value : ComboBox2.Text = DataGridView4.Rows(e.RowIndex).Cells("Brand").Value
  264. conn.Close()
  265. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  266. SQL1 = "SELECT REMARK FROM DELIVERYADDRESS WHERE DELIVERYADDRESS LIKE '" & TextBox16.Text & "'"
  267. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  268. If dr.Read() Then : ComboBox8.Text = dr("REMARK").ToString : End If : conn.Close()
  269. Set_清單3() : Set_清單4()
  270. End If
  271. End Sub
  272. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
  273. If e.RowIndex = -1 Then : Else
  274. TextBox15.Text = DataGridView3.Rows(e.RowIndex).Cells("資料流水號").Value
  275. TextBox5.Text = DataGridView3.Rows(e.RowIndex).Cells("CFMSPEC").Value
  276. End If
  277. End Sub
  278. Private Sub DataGridView5_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView5.CellClick
  279. If e.RowIndex = -1 Then : Else
  280. TextBox15.Text = DataGridView5.Rows(e.RowIndex).Cells("資料流水號").Value
  281. End If
  282. End Sub
  283. Private Sub DataGridView3_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellEndEdit
  284. Dim EU(2) As String
  285. EU(0) = DataGridView3("交期開始", e.RowIndex).Value.ToString
  286. If EU(0) = "" Then
  287. Else
  288. DateTimePicker1.Text = EU(0)
  289. DataGridView3.Rows(e.RowIndex).Cells("交期開始").Value = Format(DateTimePicker1.Value, "yyyy/MM/dd")
  290. End If
  291. EU(1) = DataGridView3("交期結束", e.RowIndex).Value.ToString
  292. If EU(1) = "" Then
  293. Else
  294. DateTimePicker1.Text = EU(1)
  295. DataGridView3.Rows(e.RowIndex).Cells("交期結束").Value = Format(DateTimePicker1.Value, "yyyy/MM/dd")
  296. End If
  297. EU(2) = DataGridView3("工廠交期", e.RowIndex).Value.ToString
  298. If EU(2) = "" Then
  299. Else
  300. DateTimePicker1.Text = EU(2)
  301. DataGridView3.Rows(e.RowIndex).Cells("工廠交期").Value = Format(DateTimePicker1.Value, "yyyy/MM/dd")
  302. End If
  303. End Sub
  304. Private Sub DataGridView5_CellContentClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView5.CellEndEdit
  305. TextBox14.Text = "0"
  306. For i As Integer = 0 To DataGridView5.Rows.Count - 1
  307. DataGridView3.Rows(i).Cells("訂單數量").Value = DataGridView5.Rows(i).Cells("4").Value + DataGridView5.Rows(i).Cells("4.5").Value + DataGridView5.Rows(i).Cells("5").Value +
  308. DataGridView5.Rows(i).Cells("5.5").Value + DataGridView5.Rows(i).Cells("6").Value + DataGridView5.Rows(i).Cells("6.5").Value + DataGridView5.Rows(i).Cells("7").Value +
  309. DataGridView5.Rows(i).Cells("7.5").Value + DataGridView5.Rows(i).Cells("8").Value + DataGridView5.Rows(i).Cells("8.5").Value + DataGridView5.Rows(i).Cells("9").Value +
  310. DataGridView5.Rows(i).Cells("9.5").Value + DataGridView5.Rows(i).Cells("10").Value + DataGridView5.Rows(i).Cells("10.5").Value + DataGridView5.Rows(i).Cells("11").Value +
  311. DataGridView5.Rows(i).Cells("11.5").Value + DataGridView5.Rows(i).Cells("12").Value + DataGridView5.Rows(i).Cells("12.5").Value + DataGridView5.Rows(i).Cells("13").Value +
  312. DataGridView5.Rows(i).Cells("14").Value
  313. Next i
  314. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  315. TextBox14.Text = Val(TextBox14.Text) + DataGridView3.Rows(i).Cells("訂單數量").Value
  316. Next i
  317. TextBox14.Text = Format(Val(TextBox14.Text), "#,##0")
  318. End Sub
  319. Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox8.TextChanged
  320. conn.Close()
  321. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  322. SQL1 = "SELECT DELIVERYADDRESS FROM DELIVERYADDRESS WHERE REMARK LIKE '" & ComboBox8.Text & "'"
  323. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  324. If dr.Read() Then : TextBox16.Text = dr("DELIVERYADDRESS").ToString : End If : conn.Close()
  325. End Sub
  326. Private Sub ComboBox9_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox9.TextChanged
  327. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  328. SQL1 = "SELECT 工廠, 供應商資料, 供應商地址 FROM 工廠控制表 WHERE 工廠 LIKE '" & ComboBox9.Text & "'"
  329. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  330. If dr.Read() Then : TextBox18.Text = dr("供應商資料").ToString : TextBox17.Text = dr("供應商地址").ToString : End If : conn.Close()
  331. End Sub
  332. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
  333. Set_grid()
  334. End Sub
  335. Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
  336. FACTORY_資料管理.Show() : FACTORY_資料管理.BringToFront() : ComboBox9下拉表單資料載入()
  337. End Sub
  338. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
  339. DELIVERY_ADDRESS__資料管理.Show() : DELIVERY_ADDRESS__資料管理.BringToFront() : ComboBox8下拉表單資料載入()
  340. End Sub
  341. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  342. 清單修改.Close() : 交貨條件修改 = True : 清單修改.ShowDialog() : ComboBox5下拉表單資料載入() : 交貨條件修改 = False
  343. End Sub
  344. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  345. 清單修改.Close() : 港口清單修改 = True : 清單修改.ShowDialog() : ComboBox6下拉表單資料載入() : 港口清單修改 = False
  346. End Sub
  347. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  348. 清單修改.Close() : 到港清單修改 = True : 清單修改.ShowDialog() : ComboBox7下拉表單資料載入() : 到港清單修改 = False
  349. End Sub
  350. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  351. 清單修改.Close() : 交貨管道修改 = True : 清單修改.ShowDialog() : ComboBox4下拉表單資料載入() : 交貨管道修改 = False
  352. End Sub
  353. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  354. PA = InputBox("請輸入要查詢的關鍵字") : Set_清單() : PA = ""
  355. End Sub
  356. Private Sub Button32_Click(sender As Object, e As EventArgs) Handles Button32.Click
  357. PA = "" : Set_清單()
  358. End Sub
  359. Private Sub Set_日期格式轉換()
  360. DTP = Format(Today(), "yyyy/MM/dd") & "-" & Format(TimeOfDay(), "HH:mm:ss") : DTP1 = Format(Today(), "yyyyMMdd")
  361. End Sub
  362. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  363. Dim aa1 As MsgBoxResult
  364. aa1 = MsgBox("確定要生成--新的--量產訂單號碼?", MsgBoxStyle.OkCancel)
  365. If aa1 = MsgBoxResult.Ok Then
  366. Button1.Enabled = False : Button11.Enabled = False : Button4.Enabled = True : Button3.Enabled = False : Button17.Enabled = False
  367. Dim NUM0 As Integer
  368. Set_日期格式轉換()
  369. For i As Integer = 1 To 999
  370. NUM0 = 0 + i
  371. If NUM0 < 10 Then : TextBox12.Text = "WP-" & DTP1 & "-00" & NUM0
  372. ElseIf NUM0 > 9 And NUM0 < 100 Then : TextBox12.Text = "WP-" & DTP1 & "-0" & NUM0
  373. ElseIf NUM0 > 99 Then : TextBox12.Text = "WP-" & DTP1 & "-" & NUM0
  374. End If
  375. conn.Close()
  376. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  377. SQL1 = "SELECT TOP (1) 訂單流水號 FROM 訂單控制表 WHERE ( 訂單流水號 LIKE '" & TextBox12.Text & "')"
  378. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  379. If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
  380. Next
  381. End If
  382. End Sub
  383. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  384. If TextBox12.Text = "" Then
  385. MsgBox("請先選擇量產訂單號")
  386. Else
  387. Set_DGV1載入前設定()
  388. SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次
  389. FROM 預告訂單控制表
  390. WHERE (BUYER LIKE N'%" & ComboBox2.Text & "%') AND (ConstructionName LIKE N'%" & TextBox11.Text & "%')
  391. ORDER BY ConstructionName, PAO DESC, 版次 DESC"
  392. Set_DGV1載入後設定()
  393. Button1.Enabled = False : Button11.Enabled = False : Button12.Enabled = True : Button3.Enabled = True : Button17.Enabled = True
  394. End If
  395. End Sub
  396. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  397. If TextBox11.Text = "" Or TextBox9.Text = "" Or ComboBox2.Text = "" Or TextBox8.Text = "" Or TextBox13.Text = "" Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or
  398. ComboBox7.Text = "" Or ComboBox8.Text = "" Or ComboBox9.Text = "" Then
  399. MsgBox("生成量產訂單抬頭之前,請注意紅色字體部分資料不可有誤。")
  400. Else
  401. Set_DGV1載入前設定()
  402. SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次
  403. FROM 預告訂單控制表
  404. WHERE (BUYER LIKE N'%" & ComboBox2.Text & "%') AND (ConstructionName LIKE N'%" & TextBox11.Text & "%')
  405. ORDER BY ConstructionName, PAO DESC, 版次 DESC"
  406. Set_DGV1載入後設定()
  407. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  408. SQL1 = "INSERT INTO 訂單明細表抬頭 (客戶訂單號, 訂單流水號, ConstructionName, ModeOfDelivery, DeliveryTerms, OrgShipDate, FromPort, ToPort,
  409. ShippingCarrier, VendorReference, ModifiedDate, CustomerName, ShipDate, SalesOrder, DeliveryAddress, 下單日,
  410. 交期, ETADate, CreatedDate, Brand, CustomerRequisition, 工廠)
  411. VALUES (N'" & TextBox13.Text & "', N'" & TextBox12.Text & "', N'" & TextBox11.Text & "', N'" & ComboBox4.Text & "', N'" & ComboBox5.Text & "', N'" & TextBox8.Text &
  412. "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text & "', N'', N'', N'" & TextBox9.Text & "', N'" & TextBox11.Text & "', N'" & TextBox8.Text & "', N'', N'" & TextBox16.Text &
  413. "', N'" & TextBox9.Text & "', N'" & TextBox8.Text & "', N'', N'" & TextBox9.Text & "', N'" & ComboBox2.Text & "', N'', N'" & ComboBox9.Text & "')"
  414. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  415. Button1.Enabled = False : Button11.Enabled = False : Button4.Enabled = False : Button12.Enabled = True : Button9.Enabled = False : Button32.Enabled = False
  416. End If
  417. End Sub
  418. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  419. If ComboBox1.Text = "" Then
  420. MsgBox("沒有選擇楦型。")
  421. Else
  422. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  423. 資料數 = DataGridView2.Rows.Count : MyModule1.進度條()
  424. If DataGridView2.Rows(i).Cells("選擇").Value = True Then
  425. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  426. SQL1 = "SELECT TOP (1) 資料流水號 FROM 訂單控制表 GROUP BY 資料流水號 ORDER BY 資料流水號 DESC"
  427. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  428. If dr.Read() Then : TextBox15.Text = dr("資料流水號").ToString : Else : TextBox15.Text = "PO00000000" : End If
  429. conn.Close()
  430. Dim NUM1 As Integer
  431. NUM1 = Double.Parse(Strings.Right(TextBox15.Text, 8)) + 1
  432. If NUM1 < 10 Then : TextBox15.Text = "PO" & "0000000" & NUM1
  433. ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox15.Text = "PO" & "000000" & NUM1
  434. ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox15.Text = "PO" & "00000" & NUM1
  435. ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox15.Text = "PO" & "0000" & NUM1
  436. ElseIf NUM1 > 9999 And NUM1 < 100000 Then : TextBox15.Text = "PO" & "000" & NUM1
  437. ElseIf NUM1 > 99999 And NUM1 < 100000 Then : TextBox15.Text = "PO" & "00" & NUM1
  438. ElseIf NUM1 > 999999 And NUM1 < 1000000 Then : TextBox15.Text = "PO" & "0" & NUM1
  439. ElseIf NUM1 > 9999999 Then : TextBox15.Text = "PO" & NUM1 + 1
  440. End If
  441. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  442. SQL1 = "INSERT INTO 訂單控制表 (訂單流水號, 年份季度, 客戶訂單號, 型體號碼, GOODBOX, 訂單數量, 客戶交期, 客戶交期1, 單價, 總金額, 備註, 生產工廠, 訂單種類, BUYER, CFMSPEC, CFMSAMPLE, TRIAL1,
  443. TRIAL2, TRIAL3, TRIAL4, 包裝確認時間, 貼標時間, 裁斷時間, 針車時間, 成型時間, 驗貨時間, 實際離廠日, 資料流水號, 明細建檔, LEATHER, LEA_Note, CXL, CXLTime,
  444. 出貨數量, PO_S_Date, Requested_XF, Confirm_XF, Revised_XF, Special_Packaging, Remarks, 出貨地, TVW, 楦頭號, 材質, 長期試穿, 面料, 副料, 中底, 鞋墊, 大底, 跟,
  445. 工廠進度表備註1, 七號模具, 工廠進度表備註2, 國標測試, 客戶包裝確認, 東莞業務備註, APMA確認, 驗貨報告圖片)
  446. VALUES (N'" & TextBox12.Text & "', N'" & TextBox4.Text & "', N'" & TextBox13.Text & "', N'" & TextBox6.Text & "', N'" & TextBox7.Text & "', N'0', N'" & TextBox8.Text &
  447. "', N'" & TextBox8.Text & "', N'0', N'0', N'', N'" & ComboBox9.Text & "', N'" & TextBox1.Text & "-" & TextBox2.Text & "', N'" & ComboBox2.Text & "', N'" & TextBox5.Text &
  448. "', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'" & TextBox15.Text & "', N'0', N'', N'', N'0', N'', N'0', N'', N'', N'', N'', N'', N'', N'', N'" & ComboBox1.Text &
  449. "', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'0', N'', N'', N'" & DataGridView2.Rows(i).Cells("顏色").Value & "', N'')"
  450. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  451. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  452. SQL1 = "INSERT INTO 訂單明細表 (訂單流水號, 客戶訂單號, ItemNumber, ProductName, Color, DM, [4], [4.5], [5], [5.5], [6], [6.5], [7], [7.5], [8], [8.5], [9],
  453. [9.5], [10], [10.5], [11], [11.5], [12], [12.5], [13], [14], 資料流水號)
  454. VALUES (N'" & TextBox12.Text & "', N'" & TextBox13.Text & "', N'" & TextBox6.Text & "', N'" & TextBox7.Text & "', N'" & DataGridView2.Rows(i).Cells("顏色").Value &
  455. "', N'" & ComboBox1.Text & "', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'0', N'" & TextBox15.Text & "')"
  456. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  457. End If
  458. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  459. Set_清單3() : Set_清單4() : ComboBox1下拉表單資料載入()
  460. Button3.Enabled = True : Button17.Enabled = True
  461. End If
  462. End Sub
  463. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  464. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  465. SQL1 = "UPDATE 訂單明細表抬頭 SET ModeOfDelivery = N'" & ComboBox4.Text & "', DeliveryTerms = N'" & ComboBox5.Text & "', FromPort = N'" & ComboBox6.Text & "', ToPort = N'" & ComboBox7.Text & "',
  466. 工廠 = N'" & ComboBox9.Text & "', DeliveryAddress = N'" & TextBox16.Text & "' WHERE (訂單流水號 LIKE N'" & TextBox12.Text & "')"
  467. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  468. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  469. 資料數 = DataGridView3.Rows.Count : MyModule1.進度條()
  470. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  471. SQL1 = "UPDATE 訂單控制表 SET 訂單數量 = N'" & DataGridView3.Rows(i).Cells("訂單數量").Value & "', 客戶交期 = N'" & DataGridView3.Rows(i).Cells("交期開始").Value &
  472. "', 客戶交期1 = N'" & DataGridView3.Rows(i).Cells("交期結束").Value & "', 備註 = N'" & DataGridView3.Rows(i).Cells("備註").Value &
  473. "', 工廠回復交期 = N'" & DataGridView3.Rows(i).Cells("工廠交期").Value & "', BUYER = N'" & DataGridView3.Rows(i).Cells("BUYER").Value & "'
  474. WHERE (資料流水號 LIKE N'" & DataGridView3.Rows(i).Cells("資料流水號").Value & "')"
  475. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  476. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  477. For i As Integer = 0 To DataGridView5.Rows.Count - 1
  478. 資料數 = DataGridView5.Rows.Count : MyModule1.進度條()
  479. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  480. SQL1 = "UPDATE 訂單明細表 SET [4] = N'" & DataGridView5.Rows(i).Cells("4").Value & "', [4.5] = N'" & DataGridView5.Rows(i).Cells("4.5").Value &
  481. "', [5] = N'" & DataGridView5.Rows(i).Cells("5").Value & "', [5.5] = N'" & DataGridView5.Rows(i).Cells("5.5").Value &
  482. "', [6] = N'" & DataGridView5.Rows(i).Cells("6").Value & "', [6.5] = N'" & DataGridView5.Rows(i).Cells("6.5").Value &
  483. "', [7] = N'" & DataGridView5.Rows(i).Cells("7").Value & "', [7.5] = N'" & DataGridView5.Rows(i).Cells("7.5").Value &
  484. "', [8] = N'" & DataGridView5.Rows(i).Cells("8").Value & "', [8.5] = N'" & DataGridView5.Rows(i).Cells("8.5").Value &
  485. "', [9] = N'" & DataGridView5.Rows(i).Cells("9").Value & "', [9.5] = N'" & DataGridView5.Rows(i).Cells("9.5").Value &
  486. "', [10] = N'" & DataGridView5.Rows(i).Cells("10").Value & "', [10.5] = N'" & DataGridView5.Rows(i).Cells("10.5").Value &
  487. "', [11] = N'" & DataGridView5.Rows(i).Cells("11").Value & "', [11.5] = N'" & DataGridView5.Rows(i).Cells("11.5").Value &
  488. "', [12] = N'" & DataGridView5.Rows(i).Cells("12").Value & "', [12.5] = N'" & DataGridView5.Rows(i).Cells("12.5").Value &
  489. "', [13] = N'" & DataGridView5.Rows(i).Cells("13").Value & "', [14] = N'" & DataGridView5.Rows(i).Cells("14").Value & "'
  490. WHERE (資料流水號 LIKE N'" & DataGridView5.Rows(i).Cells("資料流水號").Value & "')"
  491. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  492. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  493. MsgBox("存檔完成。") : Set_清單() : Set_清單2() : Set_清單2()
  494. Button1.Enabled = True : Button11.Enabled = True : Button4.Enabled = False : Button12.Enabled = False : Button3.Enabled = False : Button17.Enabled = False
  495. Button9.Enabled = True : Button32.Enabled = True
  496. End Sub
  497. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  498. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  499. DataGridView2.Rows(i).Cells("選擇").Value = False
  500. Next i
  501. End Sub
  502. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  503. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  504. DataGridView2.Rows(i).Cells("選擇").Value = True
  505. Next i
  506. End Sub
  507. Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
  508. If TextBox15.Text = "" Then
  509. MsgBox("未選擇需要刪除的資料")
  510. Else
  511. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  512. SQL1 = "DELETE FROM 訂單控制表 WHERE (資料流水號 LIKE N'" & TextBox15.Text & "')"
  513. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()
  514. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  515. SQL1 = "DELETE FROM 訂單明細表 WHERE (資料流水號 LIKE N'" & TextBox15.Text & "')"
  516. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()
  517. Set_清單3() : Set_清單4()
  518. End If
  519. End Sub
  520. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  521. Set_清單2()
  522. End Sub
  523. Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
  524. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  525. DataGridView3.Rows(i).Cells("BUYER").Value = ComboBox2.Text
  526. Next
  527. MsgBox("注意還未存檔喔")
  528. End Sub
  529. End Class