Option Strict Off Public Class 預告訂單轉量產訂單 Private ReadOnly ds, ds1, ds2, ds3, ds4 As New DataSet Dim DTP, DTP1 As String Private Sub Set_DGV1載入前設定() DataGridView1.DataSource = Nothing : ds.Clear() DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView1.ColumnHeadersHeight = 25 DataGridView1.AllowUserToAddRows = False DataGridView1.RowTemplate.Height = 50 ConnOpen() End Sub Private Sub Set_DGV1載入後設定() CmdSet_For_DGV() : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid() End Sub Private Sub Set_清單() Set_DGV1載入前設定() If PA = "" Then SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次, 訂單屬性 FROM 預告訂單控制表 ORDER BY ConstructionName, PAO DESC, 版次 DESC" Else SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次, 訂單屬性 FROM 預告訂單控制表 " & "WHERE (SO LIKE N'%" & PA & "%') OR (季節 LIKE N'%" & PA & "%') OR (客戶 LIKE N'%" & PA & "%') OR (型體號碼 LIKE N'%" & PA & "%') OR (型體名稱 LIKE N'%" & PA & "%') " & "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 & "%') " & "OR (制單人 LIKE N'%" & PA & "%') ORDER BY ConstructionName, PAO DESC, 版次 DESC" End If Set_DGV1載入後設定() End Sub Private Sub Set_grid() If CheckBox1.Checked = False Then DataGridView1.Size = New Size(475, 453) DataGridView1.Columns(0).FillWeight = 85 : DataGridView1.Columns(1).FillWeight = 70 : DataGridView1.Columns(2).FillWeight = 60 : DataGridView1.Columns(4).FillWeight = 95 DataGridView1.Columns(6).FillWeight = 95 : DataGridView1.Columns(7).Visible = False Else DataGridView1.Size = New Size(745, 453) DataGridView1.Columns(0).FillWeight = 85 : DataGridView1.Columns(1).FillWeight = 55 : DataGridView1.Columns(2).FillWeight = 65 : DataGridView1.Columns(4).FillWeight = 170 DataGridView1.Columns(6).FillWeight = 150 : DataGridView1.Columns(7).Visible = True : DataGridView1.Columns(7).FillWeight = 150 End If DataGridView1.Columns(3).Visible = False : DataGridView1.Columns(5).Visible = False : DataGridView1.Columns(8).Visible = False : DataGridView1.Columns(9).Visible = False DataGridView1.Columns(10).Visible = False : DataGridView1.Columns(11).Visible = False : DataGridView1.Columns(12).Visible = False : DataGridView1.Columns(13).Visible = False DataGridView1.Columns(14).Visible = False : DataGridView1.Columns(15).Visible = False : DataGridView1.Columns(16).FillWeight = 45 : DataGridView1.Columns(17).Visible = False End Sub Private Sub Set_清單1() DataGridView2.DataSource = Nothing : ds1.Clear() DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView2.ColumnHeadersHeight = 25 DataGridView2.AllowUserToAddRows = False ConnOpen() SQL1 = "SELECT 預告訂單清單.顏色, METOO選擇按鈕.選擇 FROM METOO選擇按鈕 RIGHT OUTER JOIN 預告訂單清單 ON METOO選擇按鈕.對應 = 預告訂單清單.顏色 LEFT OUTER JOIN 預告訂單控制表 ON 預告訂單清單.PAO = 預告訂單控制表.PAO AND 預告訂單清單.版次 = 預告訂單控制表.版次 WHERE (預告訂單控制表.PAO LIKE '" & TextBox1.Text & "') AND (預告訂單控制表.版次 LIKE '" & TextBox2.Text & "') GROUP BY 預告訂單清單.顏色, METOO選擇按鈕.選擇" CmdSet_For_DGV() da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close() DataGridView2.Columns(0).FillWeight = 110 : DataGridView2.Columns(1).FillWeight = 40 For i As Integer = 0 To DataGridView2.Rows.Count - 1 DataGridView2.Rows(i).Cells("選擇").Value = False Next i End Sub Private Sub Set_清單2() DataGridView4.DataSource = Nothing : ds2.Clear() DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView4.ColumnHeadersHeight = 25 DataGridView4.AllowUserToAddRows = False ConnOpen() SQL1 = "SELECT 訂單流水號, 客戶訂單號, ConstructionName, ModeOfDelivery, DeliveryTerms, OrgShipDate, FromPort, ToPort, ShippingCarrier, VendorReference, ModifiedDate, CustomerName, ShipDate, SalesOrder, DeliveryAddress, 下單日, 交期, ETADate, CreatedDate, Brand, CustomerRequisition, 工廠 FROM 訂單明細表抬頭 ORDER BY 訂單流水號 DESC" CmdSet_For_DGV() da.Fill(ds2) : DataGridView4.DataSource = ds2.Tables(0) : conn.Close() DataGridView4.Columns(0).FillWeight = 120 : DataGridView4.Columns(1).FillWeight = 150 : DataGridView4.Columns(2).Visible = False : DataGridView4.Columns(3).Visible = False DataGridView4.Columns(4).Visible = False : DataGridView4.Columns(5).Visible = False : DataGridView4.Columns(6).Visible = False : DataGridView4.Columns(7).Visible = False DataGridView4.Columns(8).Visible = False : DataGridView4.Columns(9).Visible = False : DataGridView4.Columns(10).Visible = False : DataGridView4.Columns(11).Visible = False DataGridView4.Columns(12).Visible = False : DataGridView4.Columns(13).Visible = False : DataGridView4.Columns(14).Visible = False : DataGridView4.Columns(15).FillWeight = 90 DataGridView4.Columns(16).FillWeight = 90 : DataGridView4.Columns(17).Visible = False : DataGridView4.Columns(18).Visible = False : DataGridView4.Columns(19).Visible = False DataGridView4.Columns(20).Visible = False : DataGridView4.Columns(21).Visible = False TextBox14.Text = "0.00" For i As Integer = 0 To DataGridView5.Rows.Count - 1 DataGridView3.Rows(i).Cells("訂單數量").Value = DataGridView5.Rows(i).Cells("4").Value + DataGridView5.Rows(i).Cells("4.5").Value + DataGridView5.Rows(i).Cells("5").Value + 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 + 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 + 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 + 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 + DataGridView5.Rows(i).Cells("14").Value Next i For i As Integer = 0 To DataGridView3.Rows.Count - 1 TextBox14.Text = Val(TextBox14.Text) + DataGridView3.Rows(i).Cells("訂單數量").Value Next i TextBox14.Text = Format(Val(TextBox14.Text), "#,##0.00") End Sub Private Sub Set_清單3() DataGridView3.DataSource = Nothing : ds3.Clear() DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView3.ColumnHeadersHeight = 40 DataGridView3.AllowUserToAddRows = False ConnOpen() SQL1 = "SELECT 資料流水號, 年份季度, 客戶訂單號, 型體號碼, GOODBOX AS 型體名稱, APMA確認 AS 顏色, TVW AS 楦型, 訂單數量, 工廠回復交期 AS 工廠交期, 客戶交期 AS 交期開始, 客戶交期1 AS 交期結束, 單價, 總金額, 備註, 生產工廠, 訂單種類, BUYER, CFMSPEC, CFMSAMPLE, TRIAL1, TRIAL2, TRIAL3, TRIAL4, 包裝確認時間, 貼標時間, 裁斷時間, 針車時間, 成型時間, 驗貨時間, 實際離廠日, 訂單流水號, 明細建檔, LEATHER, LEA_Note, CXL, CXLTime, 出貨數量, PO_S_Date, Requested_XF, Confirm_XF, Revised_XF, Special_Packaging, Remarks, 出貨地, 楦頭號, 材質, 長期試穿, 面料, 副料, 中底, 鞋墊, 大底, 跟, 工廠進度表備註1, 七號模具, 工廠進度表備註2, 國標測試, 客戶包裝確認, 東莞業務備註, 驗貨報告圖片 FROM 訂單控制表 WHERE 訂單流水號 LIKE N'" & TextBox12.Text & "' ORDER BY GOODBOX, APMA確認, TVW" CmdSet_For_DGV() da.Fill(ds3) : DataGridView3.DataSource = ds3.Tables(0) : conn.Close() DataGridView3.Columns(0).FillWeight = 85 : DataGridView3.Columns(1).FillWeight = 70 : DataGridView3.Columns(2).FillWeight = 130 : DataGridView3.Columns(3).FillWeight = 120 DataGridView3.Columns(4).FillWeight = 130 : DataGridView3.Columns(5).FillWeight = 80 : DataGridView3.Columns(6).FillWeight = 50 : DataGridView3.Columns(7).FillWeight = 80 DataGridView3.Columns(8).FillWeight = 90 : DataGridView3.Columns(9).FillWeight = 90 : DataGridView3.Columns(10).FillWeight = 90 DataGridView3.Columns(11).Visible = False : DataGridView3.Columns(12).Visible = False DataGridView3.Columns(13).FillWeight = 130 : DataGridView3.Columns(14).FillWeight = 80 : DataGridView3.Columns(15).FillWeight = 120 : DataGridView3.Columns(16).FillWeight = 130 DataGridView3.Columns(17).Visible = False : DataGridView3.Columns(18).Visible = False : DataGridView3.Columns(19).Visible = False : DataGridView3.Columns(20).Visible = False DataGridView3.Columns(21).Visible = False : DataGridView3.Columns(22).Visible = False : DataGridView3.Columns(23).Visible = False : DataGridView3.Columns(24).Visible = False DataGridView3.Columns(25).Visible = False : DataGridView3.Columns(26).Visible = False : DataGridView3.Columns(27).Visible = False : DataGridView3.Columns(28).Visible = False DataGridView3.Columns(29).Visible = False : DataGridView3.Columns(30).Visible = False : DataGridView3.Columns(31).Visible = False : DataGridView3.Columns(32).Visible = False DataGridView3.Columns(33).Visible = False : DataGridView3.Columns(34).Visible = False : DataGridView3.Columns(35).Visible = False : DataGridView3.Columns(36).Visible = False DataGridView3.Columns(37).Visible = False : DataGridView3.Columns(38).Visible = False : DataGridView3.Columns(39).Visible = False : DataGridView3.Columns(40).Visible = False DataGridView3.Columns(41).Visible = False : DataGridView3.Columns(42).Visible = False : DataGridView3.Columns(43).Visible = False : DataGridView3.Columns(44).Visible = False DataGridView3.Columns(45).Visible = False : DataGridView3.Columns(46).Visible = False : DataGridView3.Columns(47).Visible = False : DataGridView3.Columns(48).Visible = False DataGridView3.Columns(49).Visible = False : DataGridView3.Columns(50).Visible = False : DataGridView3.Columns(51).Visible = False : DataGridView3.Columns(52).Visible = False DataGridView3.Columns(53).Visible = False : DataGridView3.Columns(54).Visible = False : DataGridView3.Columns(55).Visible = False : DataGridView3.Columns(56).Visible = False DataGridView3.Columns(57).Visible = False : DataGridView3.Columns(58).Visible = False : DataGridView3.Columns(59).Visible = False DataGridView3.Columns(7).DefaultCellStyle.Format = "#,##0" DataGridView3.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight DataGridView3.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight DataGridView3.EditMode = DataGridViewEditMode.EditOnEnter End Sub Private Sub Set_清單4() DataGridView5.DataSource = Nothing : ds4.Clear() DataGridView5.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing DataGridView5.ColumnHeadersHeight = 25 DataGridView5.AllowUserToAddRows = False ConnOpen() 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], [13], [14], 訂單流水號 FROM 訂單明細表 WHERE 訂單流水號 LIKE N'" & TextBox12.Text & "' ORDER BY ProductName, Color, DM" CmdSet_For_DGV() da.Fill(ds4) : DataGridView5.DataSource = ds4.Tables(0) : conn.Close() DataGridView5.Columns(0).FillWeight = 85 : DataGridView5.Columns(1).FillWeight = 150 : DataGridView5.Columns(2).FillWeight = 120 : DataGridView5.Columns(3).FillWeight = 150 DataGridView5.Columns(4).FillWeight = 80 : DataGridView5.Columns(5).FillWeight = 50 : DataGridView5.Columns(6).FillWeight = 38 : DataGridView5.Columns(7).FillWeight = 37 DataGridView5.Columns(8).FillWeight = 38 : DataGridView5.Columns(9).FillWeight = 37 : DataGridView5.Columns(10).FillWeight = 38 : DataGridView5.Columns(11).FillWeight = 37 DataGridView5.Columns(12).FillWeight = 38 : DataGridView5.Columns(13).FillWeight = 37 : DataGridView5.Columns(14).FillWeight = 38 : DataGridView5.Columns(15).FillWeight = 37 DataGridView5.Columns(16).FillWeight = 38 : DataGridView5.Columns(17).FillWeight = 37 : DataGridView5.Columns(18).FillWeight = 38 : DataGridView5.Columns(19).FillWeight = 37 DataGridView5.Columns(20).FillWeight = 38 : DataGridView5.Columns(21).FillWeight = 37 : DataGridView5.Columns(22).FillWeight = 38 : DataGridView5.Columns(23).FillWeight = 37 DataGridView5.Columns(24).FillWeight = 38 : DataGridView5.Columns(25).FillWeight = 37 : DataGridView5.Columns(26).Visible = False DataGridView5.EditMode = DataGridViewEditMode.EditOnEnter End Sub Private Sub ComboBox1下拉表單資料載入() ConnOpen() SQL1 = "SELECT 楦型 FROM 訂單控制表楦型清單 ORDER BY 楦型" CmdSet_For_dr() : ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("楦型")) : End While : conn.Close() End Sub Private Sub ComboBox2下拉表單資料載入() ConnOpen() SQL1 = "SELECT BUYER FROM 預告訂單控制表 GROUP BY BUYER ORDER BY BUYER DESC" CmdSet_For_dr() : ComboBox2.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("BUYER")) : End While : conn.Close() End Sub Private Sub ComboBox4下拉表單資料載入() ConnOpen() SQL1 = "SELECT MODEOFDELIVERY FROM MODEOFDELIVERY" CmdSet_For_dr() : ComboBox4.Items.Clear() : While (dr.Read()) : ComboBox4.Items.Add(dr("MODEOFDELIVERY")) : End While : conn.Close() End Sub Private Sub ComboBox5下拉表單資料載入() ConnOpen() SQL1 = "SELECT DELIVERYTERMS FROM DELIVERYTERMS" CmdSet_For_dr() : ComboBox5.Items.Clear() : While (dr.Read()) : ComboBox5.Items.Add(dr("DELIVERYTERMS")) : End While : conn.Close() End Sub Private Sub ComboBox6下拉表單資料載入() ConnOpen() SQL1 = "SELECT FOB FROM 港口清單" CmdSet_For_dr() : ComboBox6.Items.Clear() : While (dr.Read()) : ComboBox6.Items.Add(dr("FOB")) : End While : conn.Close() End Sub Private Sub ComboBox7下拉表單資料載入() ConnOpen() SQL1 = "SELECT TOPORT FROM TOPORT ORDER BY TOPORT" CmdSet_For_dr() : ComboBox7.Items.Clear() : While (dr.Read()) : ComboBox7.Items.Add(dr("TOPORT")) : End While : conn.Close() End Sub Private Sub ComboBox8下拉表單資料載入() ConnOpen() SQL1 = "SELECT REMARK FROM DELIVERYADDRESS ORDER BY REMARK" CmdSet_For_dr() : ComboBox8.Items.Clear() : While (dr.Read()) : ComboBox8.Items.Add(dr("REMARK")) : End While : conn.Close() End Sub Private Sub ComboBox9下拉表單資料載入() ConnOpen() SQL1 = "SELECT 工廠 FROM 工廠控制表 GROUP BY 工廠 ORDER BY 工廠" CmdSet_For_dr() : ComboBox9.Items.Clear() : While (dr.Read()) : ComboBox9.Items.Add(dr("工廠")) : End While : conn.Close() End Sub Private Sub 預告訂單轉量產訂單_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox4.Enabled = False : TextBox6.Enabled = False : TextBox7.Enabled = False : TextBox5.Enabled = False TextBox8.Enabled = False : TextBox9.Enabled = False : TextBox11.Enabled = False : TextBox12.Enabled = False : TextBox14.Enabled = False : TextBox15.Enabled = False Button4.Enabled = False : Button3.Enabled = False : Button17.Enabled = False : Button12.Enabled = False : DateTimePicker1.Visible = False ComboBox4下拉表單資料載入() : ComboBox5下拉表單資料載入() : ComboBox6下拉表單資料載入() : ComboBox7下拉表單資料載入() : ComboBox8下拉表單資料載入() : ComboBox9下拉表單資料載入() ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入() Set_清單() : Set_清單2() End Sub Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick If e.RowIndex = -1 Then : Else TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("PAO").Value : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("版次").Value ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("BUYER").Value : TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("季節").Value ComboBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("工廠").Value : TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("型體號碼").Value TextBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("型體名稱").Value : TextBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("ETD").Value TextBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("ISSUE_DATE").Value : ComboBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("FOB").Value TextBox11.Text = DataGridView1.Rows(e.RowIndex).Cells("ConstructionName").Value : TextBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("訂單屬性").Value Set_清單1() End If End Sub Private Sub DataGridView4_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView4.CellClick If e.RowIndex = -1 Then : Else ComboBox7.Text = DataGridView4.Rows(e.RowIndex).Cells("ToPort").Value : ComboBox4.Text = DataGridView4.Rows(e.RowIndex).Cells("ModeOfDelivery").Value ComboBox5.Text = DataGridView4.Rows(e.RowIndex).Cells("DeliveryTerms").Value : ComboBox6.Text = DataGridView4.Rows(e.RowIndex).Cells("FromPort").Value TextBox13.Text = DataGridView4.Rows(e.RowIndex).Cells("客戶訂單號").Value : TextBox16.Text = DataGridView4.Rows(e.RowIndex).Cells("DeliveryAddress").Value TextBox11.Text = DataGridView4.Rows(e.RowIndex).Cells("CustomerName").Value : ComboBox9.Text = DataGridView4.Rows(e.RowIndex).Cells("工廠").Value TextBox8.Text = DataGridView4.Rows(e.RowIndex).Cells("交期").Value : TextBox9.Text = DataGridView4.Rows(e.RowIndex).Cells("下單日").Value ComboBox6.Text = DataGridView4.Rows(e.RowIndex).Cells("FromPort").Value : TextBox11.Text = DataGridView4.Rows(e.RowIndex).Cells("ConstructionName").Value TextBox12.Text = DataGridView4.Rows(e.RowIndex).Cells("訂單流水號").Value : ComboBox2.Text = DataGridView4.Rows(e.RowIndex).Cells("Brand").Value ConnOpen() SQL1 = "SELECT REMARK FROM DELIVERYADDRESS WHERE DELIVERYADDRESS LIKE '" & TextBox16.Text & "'" CmdSet_For_dr() If dr.Read() Then : ComboBox8.Text = dr("REMARK").ToString : End If : conn.Close() Set_清單3() : Set_清單4() End If End Sub Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick If e.RowIndex = -1 Then : Else TextBox15.Text = DataGridView3.Rows(e.RowIndex).Cells("資料流水號").Value TextBox5.Text = DataGridView3.Rows(e.RowIndex).Cells("CFMSPEC").Value End If End Sub Private Sub DataGridView5_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView5.CellClick If e.RowIndex = -1 Then : Else TextBox15.Text = DataGridView5.Rows(e.RowIndex).Cells("資料流水號").Value End If End Sub Private Sub DataGridView3_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellEndEdit Dim EU(2) As String EU(0) = DataGridView3("交期開始", e.RowIndex).Value.ToString If EU(0) = "" Then Else DateTimePicker1.Text = EU(0) DataGridView3.Rows(e.RowIndex).Cells("交期開始").Value = Format(DateTimePicker1.Value, "yyyy/MM/dd") End If EU(1) = DataGridView3("交期結束", e.RowIndex).Value.ToString If EU(1) = "" Then Else DateTimePicker1.Text = EU(1) DataGridView3.Rows(e.RowIndex).Cells("交期結束").Value = Format(DateTimePicker1.Value, "yyyy/MM/dd") End If EU(2) = DataGridView3("工廠交期", e.RowIndex).Value.ToString If EU(2) = "" Then Else DateTimePicker1.Text = EU(2) DataGridView3.Rows(e.RowIndex).Cells("工廠交期").Value = Format(DateTimePicker1.Value, "yyyy/MM/dd") End If End Sub Private Sub DataGridView5_CellContentClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView5.CellEndEdit TextBox14.Text = "0" For i As Integer = 0 To DataGridView5.Rows.Count - 1 DataGridView3.Rows(i).Cells("訂單數量").Value = DataGridView5.Rows(i).Cells("4").Value + DataGridView5.Rows(i).Cells("4.5").Value + DataGridView5.Rows(i).Cells("5").Value + 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 + 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 + 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 + 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 + DataGridView5.Rows(i).Cells("14").Value Next i For i As Integer = 0 To DataGridView3.Rows.Count - 1 TextBox14.Text = Val(TextBox14.Text) + DataGridView3.Rows(i).Cells("訂單數量").Value Next i TextBox14.Text = Format(Val(TextBox14.Text), "#,##0") End Sub Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox8.TextChanged ConnOpen() SQL1 = "SELECT DELIVERYADDRESS FROM DELIVERYADDRESS WHERE REMARK LIKE '" & ComboBox8.Text & "'" CmdSet_For_dr() If dr.Read() Then : TextBox16.Text = dr("DELIVERYADDRESS").ToString : End If : conn.Close() End Sub Private Sub ComboBox9_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox9.TextChanged ConnOpen() SQL1 = "SELECT 工廠, 供應商資料, 供應商地址 FROM 工廠控制表 WHERE 工廠 LIKE '" & ComboBox9.Text & "'" CmdSet_For_dr() If dr.Read() Then : TextBox18.Text = dr("供應商資料").ToString : TextBox17.Text = dr("供應商地址").ToString : End If : conn.Close() End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged Set_grid() End Sub Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click FACTORY_資料管理.Show() : FACTORY_資料管理.BringToFront() : ComboBox9下拉表單資料載入() End Sub Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click DELIVERY_ADDRESS__資料管理.Show() : DELIVERY_ADDRESS__資料管理.BringToFront() : ComboBox8下拉表單資料載入() End Sub Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click 清單修改.Close() : 交貨條件修改 = True : 清單修改.ShowDialog() : ComboBox5下拉表單資料載入() : 交貨條件修改 = False End Sub Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click 清單修改.Close() : 港口清單修改 = True : 清單修改.ShowDialog() : ComboBox6下拉表單資料載入() : 港口清單修改 = False End Sub Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click 清單修改.Close() : 到港清單修改 = True : 清單修改.ShowDialog() : ComboBox7下拉表單資料載入() : 到港清單修改 = False End Sub Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click 清單修改.Close() : 交貨管道修改 = True : 清單修改.ShowDialog() : ComboBox4下拉表單資料載入() : 交貨管道修改 = False End Sub Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click PA = InputBox("請輸入要查詢的關鍵字") : Set_清單() : PA = "" End Sub Private Sub Button32_Click(sender As Object, e As EventArgs) Handles Button32.Click PA = "" : Set_清單() End Sub Private Sub Set_日期格式轉換() DTP = Format(Today(), "yyyy/MM/dd") & "-" & Format(TimeOfDay(), "HH:mm:ss") : DTP1 = Format(Today(), "yyyyMMdd") End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim aa1 As MsgBoxResult aa1 = MsgBox("確定要生成--新的--量產訂單號碼?", MsgBoxStyle.OkCancel) If aa1 = MsgBoxResult.Ok Then Button1.Enabled = False : Button11.Enabled = False : Button4.Enabled = True : Button3.Enabled = False : Button17.Enabled = False Dim NUM0 As Integer Set_日期格式轉換() For i As Integer = 1 To 999 NUM0 = 0 + i If NUM0 < 10 Then : TextBox12.Text = "WP-" & DTP1 & "-00" & NUM0 ElseIf NUM0 > 9 And NUM0 < 100 Then : TextBox12.Text = "WP-" & DTP1 & "-0" & NUM0 ElseIf NUM0 > 99 Then : TextBox12.Text = "WP-" & DTP1 & "-" & NUM0 End If ConnOpen() SQL1 = "SELECT TOP (1) 訂單流水號 FROM 訂單控制表 WHERE ( 訂單流水號 LIKE '" & TextBox12.Text & "')" CmdSet_For_dr() If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close() Next End If End Sub Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click If TextBox12.Text = "" Then MsgBox("請先選擇量產訂單號") Else Set_DGV1載入前設定() SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次 FROM 預告訂單控制表 WHERE (BUYER LIKE N'%" & ComboBox2.Text & "%') AND (ConstructionName LIKE N'%" & TextBox11.Text & "%') ORDER BY ConstructionName, PAO DESC, 版次 DESC" Set_DGV1載入後設定() Button1.Enabled = False : Button11.Enabled = False : Button12.Enabled = True : Button3.Enabled = True : Button17.Enabled = True End If End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click 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 ComboBox7.Text = "" Or ComboBox8.Text = "" Or ComboBox9.Text = "" Then MsgBox("生成量產訂單抬頭之前,請注意紅色字體部分資料不可有誤。") Else Set_DGV1載入前設定() SQL1 = "SELECT PAO, ConstructionName AS C_N, 季節, 客戶, BUYER, 工廠, 型體號碼, 型體名稱, 總數量, ETD, ISSUE_DATE, FOB, ConstructionName, PS, 制單人, 制單時間, 版次 FROM 預告訂單控制表 WHERE (BUYER LIKE N'%" & ComboBox2.Text & "%') AND (ConstructionName LIKE N'%" & TextBox11.Text & "%') ORDER BY ConstructionName, PAO DESC, 版次 DESC" Set_DGV1載入後設定() ConnOpen() SQL1 = "INSERT INTO 訂單明細表抬頭 (客戶訂單號, 訂單流水號, ConstructionName, ModeOfDelivery, DeliveryTerms, OrgShipDate, FromPort, ToPort, ShippingCarrier, VendorReference, ModifiedDate, CustomerName, ShipDate, SalesOrder, DeliveryAddress, 下單日, 交期, ETADate, CreatedDate, Brand, CustomerRequisition, 工廠) VALUES (N'" & TextBox13.Text & "', N'" & TextBox12.Text & "', N'" & TextBox11.Text & "', N'" & ComboBox4.Text & "', N'" & ComboBox5.Text & "', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text & "', N'', N'', N'" & TextBox9.Text & "', N'" & TextBox11.Text & "', N'" & TextBox8.Text & "', N'', N'" & TextBox16.Text & "', N'" & TextBox9.Text & "', N'" & TextBox8.Text & "', N'', N'" & TextBox9.Text & "', N'" & ComboBox2.Text & "', N'', N'" & ComboBox9.Text & "')" cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() Button1.Enabled = False : Button11.Enabled = False : Button4.Enabled = False : Button12.Enabled = True : Button9.Enabled = False : Button32.Enabled = False End If End Sub Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click If ComboBox1.Text = "" Then MsgBox("沒有選擇楦型。") Else For i As Integer = 0 To DataGridView2.Rows.Count - 1 資料數 = DataGridView2.Rows.Count : MyModule1.進度條() If DataGridView2.Rows(i).Cells("選擇").Value = True Then ConnOpen() SQL1 = "SELECT TOP (1) 資料流水號 FROM 訂單控制表 GROUP BY 資料流水號 ORDER BY 資料流水號 DESC" CmdSet_For_dr() If dr.Read() Then : TextBox15.Text = dr("資料流水號").ToString : Else : TextBox15.Text = "PO00000000" : End If conn.Close() Dim NUM1 As Integer NUM1 = Double.Parse(Strings.Right(TextBox15.Text, 8)) + 1 If NUM1 < 10 Then : TextBox15.Text = "PO" & "0000000" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox15.Text = "PO" & "000000" & NUM1 ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox15.Text = "PO" & "00000" & NUM1 ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox15.Text = "PO" & "0000" & NUM1 ElseIf NUM1 > 9999 And NUM1 < 100000 Then : TextBox15.Text = "PO" & "000" & NUM1 ElseIf NUM1 > 99999 And NUM1 < 100000 Then : TextBox15.Text = "PO" & "00" & NUM1 ElseIf NUM1 > 999999 And NUM1 < 1000000 Then : TextBox15.Text = "PO" & "0" & NUM1 ElseIf NUM1 > 9999999 Then : TextBox15.Text = "PO" & NUM1 + 1 End If ConnOpen() SQL1 = "INSERT INTO 訂單控制表 (訂單流水號, 年份季度, 客戶訂單號, 型體號碼, GOODBOX, 訂單數量, 客戶交期, 客戶交期1, 單價, 總金額, 備註, 生產工廠, 訂單種類, BUYER, CFMSPEC, CFMSAMPLE, TRIAL1, TRIAL2, TRIAL3, TRIAL4, 包裝確認時間, 貼標時間, 裁斷時間, 針車時間, 成型時間, 驗貨時間, 實際離廠日, 資料流水號, 明細建檔, LEATHER, LEA_Note, CXL, CXLTime, 出貨數量, PO_S_Date, Requested_XF, Confirm_XF, Revised_XF, Special_Packaging, Remarks, 出貨地, TVW, 楦頭號, 材質, 長期試穿, 面料, 副料, 中底, 鞋墊, 大底, 跟, 工廠進度表備註1, 七號模具, 工廠進度表備註2, 國標測試, 客戶包裝確認, 東莞業務備註, APMA確認, 驗貨報告圖片) VALUES (N'" & TextBox12.Text & "', N'" & TextBox4.Text & "', N'" & TextBox13.Text & "', N'" & TextBox6.Text & "', N'" & TextBox7.Text & "', N'0', N'" & TextBox8.Text & "', N'" & TextBox8.Text & "', N'0', N'0', N'', N'" & ComboBox9.Text & "', N'" & TextBox1.Text & "-" & TextBox2.Text & "', N'" & ComboBox2.Text & "', N'" & TextBox5.Text & "', 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 & "', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'0', N'', N'', N'" & DataGridView2.Rows(i).Cells("顏色").Value & "', N'')" cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() ConnOpen() SQL1 = "INSERT INTO 訂單明細表 (訂單流水號, 客戶訂單號, 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], [13], [14], 資料流水號) VALUES (N'" & TextBox12.Text & "', N'" & TextBox13.Text & "', N'" & TextBox6.Text & "', N'" & TextBox7.Text & "', N'" & DataGridView2.Rows(i).Cells("顏色").Value & "', 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 & "')" cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() End If Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 Set_清單3() : Set_清單4() : ComboBox1下拉表單資料載入() Button3.Enabled = True : Button17.Enabled = True End If End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click ConnOpen() SQL1 = "UPDATE 訂單明細表抬頭 SET ModeOfDelivery = N'" & ComboBox4.Text & "', DeliveryTerms = N'" & ComboBox5.Text & "', FromPort = N'" & ComboBox6.Text & "', ToPort = N'" & ComboBox7.Text & "', 工廠 = N'" & ComboBox9.Text & "', DeliveryAddress = N'" & TextBox16.Text & "' WHERE (訂單流水號 LIKE N'" & TextBox12.Text & "')" cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() For i As Integer = 0 To DataGridView3.Rows.Count - 1 資料數 = DataGridView3.Rows.Count : MyModule1.進度條() ConnOpen() SQL1 = "UPDATE 訂單控制表 SET 訂單數量 = N'" & DataGridView3.Rows(i).Cells("訂單數量").Value & "', 客戶交期 = N'" & DataGridView3.Rows(i).Cells("交期開始").Value & "', 客戶交期1 = N'" & DataGridView3.Rows(i).Cells("交期結束").Value & "', 備註 = N'" & DataGridView3.Rows(i).Cells("備註").Value & "', 工廠回復交期 = N'" & DataGridView3.Rows(i).Cells("工廠交期").Value & "', BUYER = N'" & DataGridView3.Rows(i).Cells("BUYER").Value & "' WHERE (資料流水號 LIKE N'" & DataGridView3.Rows(i).Cells("資料流水號").Value & "')" cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 For i As Integer = 0 To DataGridView5.Rows.Count - 1 資料數 = DataGridView5.Rows.Count : MyModule1.進度條() ConnOpen() SQL1 = "UPDATE 訂單明細表 SET [4] = N'" & DataGridView5.Rows(i).Cells("4").Value & "', [4.5] = N'" & DataGridView5.Rows(i).Cells("4.5").Value & "', [5] = N'" & DataGridView5.Rows(i).Cells("5").Value & "', [5.5] = N'" & DataGridView5.Rows(i).Cells("5.5").Value & "', [6] = N'" & DataGridView5.Rows(i).Cells("6").Value & "', [6.5] = N'" & DataGridView5.Rows(i).Cells("6.5").Value & "', [7] = N'" & DataGridView5.Rows(i).Cells("7").Value & "', [7.5] = N'" & DataGridView5.Rows(i).Cells("7.5").Value & "', [8] = N'" & DataGridView5.Rows(i).Cells("8").Value & "', [8.5] = N'" & DataGridView5.Rows(i).Cells("8.5").Value & "', [9] = N'" & DataGridView5.Rows(i).Cells("9").Value & "', [9.5] = N'" & DataGridView5.Rows(i).Cells("9.5").Value & "', [10] = N'" & DataGridView5.Rows(i).Cells("10").Value & "', [10.5] = N'" & DataGridView5.Rows(i).Cells("10.5").Value & "', [11] = N'" & DataGridView5.Rows(i).Cells("11").Value & "', [11.5] = N'" & DataGridView5.Rows(i).Cells("11.5").Value & "', [12] = N'" & DataGridView5.Rows(i).Cells("12").Value & "', [12.5] = N'" & DataGridView5.Rows(i).Cells("12.5").Value & "', [13] = N'" & DataGridView5.Rows(i).Cells("13").Value & "', [14] = N'" & DataGridView5.Rows(i).Cells("14").Value & "' WHERE (資料流水號 LIKE N'" & DataGridView5.Rows(i).Cells("資料流水號").Value & "')" cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 MsgBox("存檔完成。") : Set_清單() : Set_清單2() : Set_清單2() Button1.Enabled = True : Button11.Enabled = True : Button4.Enabled = False : Button12.Enabled = False : Button3.Enabled = False : Button17.Enabled = False Button9.Enabled = True : Button32.Enabled = True End Sub Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click For i As Integer = 0 To DataGridView2.Rows.Count - 1 DataGridView2.Rows(i).Cells("選擇").Value = False Next i End Sub Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click For i As Integer = 0 To DataGridView2.Rows.Count - 1 DataGridView2.Rows(i).Cells("選擇").Value = True Next i End Sub Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click If TextBox15.Text = "" Then MsgBox("未選擇需要刪除的資料") Else ConnOpen() SQL1 = "DELETE FROM 訂單控制表 WHERE (資料流水號 LIKE N'" & TextBox15.Text & "')" cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close() ConnOpen() SQL1 = "DELETE FROM 訂單明細表 WHERE (資料流水號 LIKE N'" & TextBox15.Text & "')" cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close() Set_清單3() : Set_清單4() End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Set_清單2() End Sub Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click For i As Integer = 0 To DataGridView3.Rows.Count - 1 DataGridView3.Rows(i).Cells("BUYER").Value = ComboBox2.Text Next MsgBox("注意還未存檔喔") End Sub End Class