Option Strict Off Imports System.IO Imports System.Net Public Class 量產訂單明細表 Private ReadOnly ds, ds2, ds3 As New DataSet Dim 已超出 As Boolean Dim Date1, Date2, Date3, Date4, Date5, Date6, Date7 As String Dim 新流水號3 As String Private m_Leftx As Integer = 152 Private m_Lefty As Integer = 0 Dim m_MousePosX, m_MousePosY, m_DeltaX, m_DeltaY As Integer Private Sub 基本資料載入() SQL_基本資料載入() If dr.Read() Then Number_tb.Text = dr("客戶訂單號").ToString : Vendor_tb.Text = dr("供應商資料").ToString : 備註_tb.Text = dr("供應商地址").ToString 工廠_tb.Text = dr("生產工廠").ToString : TotalNumber_tb.Text = Format(Val(dr("訂單數量").ToString), "#,##0") Else : Number_tb.Text = "" : End If : conn.Close() End Sub Private Sub Set_訂單清單() 表單3_dgv.DataSource = Nothing : ds.Clear() 表單3_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 表單3_dgv.ColumnHeadersHeight = 25 表單3_dgv.AllowUserToAddRows = False SQL_訂單清單() da.Fill(ds) : 表單3_dgv.DataSource = ds.Tables(0) : conn.Close() 表單3_dgv.Columns(0).Visible = False : 表單3_dgv.Columns(1).Visible = False 表單3_dgv.Columns(2).FillWeight = 120 : 表單3_dgv.Columns(3).FillWeight = 150 : 表單3_dgv.Columns(4).FillWeight = 100 : 表單3_dgv.Columns(5).FillWeight = 70 表單3_dgv.Columns(6).FillWeight = 40 : 表單3_dgv.Columns(7).FillWeight = 40 : 表單3_dgv.Columns(8).FillWeight = 40 : 表單3_dgv.Columns(9).FillWeight = 40 表單3_dgv.Columns(10).FillWeight = 40 : 表單3_dgv.Columns(11).FillWeight = 40 : 表單3_dgv.Columns(12).FillWeight = 40 : 表單3_dgv.Columns(13).FillWeight = 40 表單3_dgv.Columns(14).FillWeight = 40 : 表單3_dgv.Columns(15).FillWeight = 40 : 表單3_dgv.Columns(16).FillWeight = 40 : 表單3_dgv.Columns(17).FillWeight = 40 表單3_dgv.Columns(18).FillWeight = 40 : 表單3_dgv.Columns(19).FillWeight = 40 : 表單3_dgv.Columns(20).FillWeight = 40 : 表單3_dgv.Columns(21).FillWeight = 40 表單3_dgv.Columns(22).FillWeight = 40 : 表單3_dgv.Columns(23).FillWeight = 40 : 表單3_dgv.Columns(24).FillWeight = 40 : 表單3_dgv.Columns(25).FillWeight = 40 表單3_dgv.Columns(26).FillWeight = 60 : 表單3_dgv.Columns(27).Visible = False 表單3_dgv.Columns(7).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(9).DefaultCellStyle.Format = "#,##0" 表單3_dgv.Columns(10).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(11).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(12).DefaultCellStyle.Format = "#,##0" 表單3_dgv.Columns(13).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(14).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(15).DefaultCellStyle.Format = "#,##0" 表單3_dgv.Columns(16).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(17).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(18).DefaultCellStyle.Format = "#,##0" 表單3_dgv.Columns(19).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(20).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(21).DefaultCellStyle.Format = "#,##0" 表單3_dgv.Columns(22).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(23).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(24).DefaultCellStyle.Format = "#,##0" 表單3_dgv.Columns(25).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(26).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(6).DefaultCellStyle.Format = "#,##0" 表單3_dgv.EditMode = DataGridViewEditMode.EditOnEnter End Sub Private Sub Set_清單2() 表單1_dgv.DataSource = Nothing : ds2.Clear() 表單1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 表單1_dgv.ColumnHeadersHeight = 25 表單1_dgv.AllowUserToAddRows = False SQL_訂單附件資料() da.Fill(ds2) : 表單1_dgv.DataSource = ds2.Tables(0) : conn.Close() 表單1_dgv.Columns(0).FillWeight = 120 : 表單1_dgv.Columns(1).FillWeight = 45 End Sub Private Sub Set_清單3() 表單2_dgv.DataSource = Nothing : ds3.Clear() 表單2_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 表單2_dgv.ColumnHeadersHeight = 25 表單2_dgv.AllowUserToAddRows = False SQL_訂單控制表1() da.Fill(ds3) : 表單2_dgv.DataSource = ds3.Tables(0) : conn.Close() 表單2_dgv.Columns(0).FillWeight = 85 : 表單2_dgv.Columns(1).FillWeight = 70 : 表單2_dgv.Columns(2).FillWeight = 130 : 表單2_dgv.Columns(3).FillWeight = 120 表單2_dgv.Columns(4).FillWeight = 130 : 表單2_dgv.Columns(5).FillWeight = 80 : 表單2_dgv.Columns(6).FillWeight = 50 : 表單2_dgv.Columns(7).FillWeight = 80 表單2_dgv.Columns(8).FillWeight = 90 : 表單2_dgv.Columns(9).FillWeight = 90 : 表單2_dgv.Columns(10).FillWeight = 90 表單2_dgv.Columns(11).Visible = False : 表單2_dgv.Columns(12).Visible = False 表單2_dgv.Columns(13).FillWeight = 62 : 表單2_dgv.Columns(14).FillWeight = 80 : 表單2_dgv.Columns(15).FillWeight = 120 : 表單2_dgv.Columns(16).FillWeight = 130 表單2_dgv.Columns(17).Visible = False : 表單2_dgv.Columns(18).Visible = False : 表單2_dgv.Columns(19).Visible = False : 表單2_dgv.Columns(20).Visible = False 表單2_dgv.Columns(21).Visible = False : 表單2_dgv.Columns(22).Visible = False : 表單2_dgv.Columns(23).Visible = False : 表單2_dgv.Columns(24).Visible = False 表單2_dgv.Columns(25).Visible = False : 表單2_dgv.Columns(26).Visible = False : 表單2_dgv.Columns(27).Visible = False : 表單2_dgv.Columns(28).Visible = False 表單2_dgv.Columns(29).Visible = False : 表單2_dgv.Columns(30).Visible = False : 表單2_dgv.Columns(31).Visible = False : 表單2_dgv.Columns(32).Visible = False 表單2_dgv.Columns(33).Visible = False : 表單2_dgv.Columns(34).Visible = False : 表單2_dgv.Columns(35).Visible = False : 表單2_dgv.Columns(36).Visible = False 表單2_dgv.Columns(37).Visible = False : 表單2_dgv.Columns(38).Visible = False : 表單2_dgv.Columns(39).Visible = False : 表單2_dgv.Columns(40).Visible = False 表單2_dgv.Columns(41).Visible = False : 表單2_dgv.Columns(42).Visible = False : 表單2_dgv.Columns(43).Visible = False : 表單2_dgv.Columns(44).Visible = False 表單2_dgv.Columns(45).Visible = False : 表單2_dgv.Columns(46).Visible = False : 表單2_dgv.Columns(47).Visible = False : 表單2_dgv.Columns(48).Visible = False 表單2_dgv.Columns(49).Visible = False : 表單2_dgv.Columns(50).Visible = False : 表單2_dgv.Columns(51).Visible = False : 表單2_dgv.Columns(52).Visible = False 表單2_dgv.Columns(53).Visible = False : 表單2_dgv.Columns(54).Visible = False : 表單2_dgv.Columns(55).Visible = False : 表單2_dgv.Columns(56).Visible = False 表單2_dgv.Columns(57).Visible = False : 表單2_dgv.Columns(58).Visible = False : 表單2_dgv.Columns(59).Visible = False 表單2_dgv.Columns(7).DefaultCellStyle.Format = "#,##0" 表單2_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 表單2_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight 表單2_dgv.EditMode = DataGridViewEditMode.EditOnEnter End Sub Private Sub Set_格式設定1() Number_tb.Enabled = False : TextBox3.Enabled = False : 訂單號_tb.Enabled = False : 工廠_tb.Enabled = False : TotalNumber_tb.Enabled = False : TextBox7.Visible = False 日期_dtp.Format = DateTimePickerFormat.Custom : 日期_dtp.CustomFormat = " " 日期1_dtp.Format = DateTimePickerFormat.Custom : 日期1_dtp.CustomFormat = " " 日期3_dtp.Format = DateTimePickerFormat.Custom : 日期3_dtp.CustomFormat = " " 日期4_dtp.Format = DateTimePickerFormat.Custom : 日期4_dtp.CustomFormat = " " 日期6_dtp.Format = DateTimePickerFormat.Custom : 日期6_dtp.CustomFormat = " " 日期7_dtp.Format = DateTimePickerFormat.Custom : 日期7_dtp.CustomFormat = " " 日期5_dtp.Format = DateTimePickerFormat.Custom : 日期5_dtp.CustomFormat = " " ShippingCarrier_tb.Text = "" : VendorReference_tb.Text = "" CustomerName_tb.Text = "" : SalesOrder_tb.Text = "" : DeliveryAddress_tb.Text = "" End Sub Private Sub Set_自動彙總1() Dim 加總(20) As Double 加總(0) = 0 : 加總(1) = 0 : 加總(2) = 0 : 加總(3) = 0 : 加總(4) = 0 : 加總(5) = 0 : 加總(6) = 0 : 加總(7) = 0 : 加總(8) = 0 加總(9) = 0 : 加總(10) = 0 : 加總(11) = 0 : 加總(12) = 0 : 加總(13) = 0 : 加總(14) = 0 : 加總(15) = 0 : 加總(16) = 0 : 加總(17) = 0 : 加總(18) = 0 : 加總(19) = 0 : 加總(20) = 0 For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計_tb.Text = "0" : Else : 加總(19) += 表單3_dgv.Rows(i).Cells("4").Value : End If Next i : 合計_tb.Text = Format(Val(加總(19)), "#,##0") : If 合計_tb.Text = "0" Then : 合計_tb.ForeColor = Color.Black : Else : 合計_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計1_tb.Text = "0" : Else : 加總(20) += 表單3_dgv.Rows(i).Cells("4.5").Value : End If Next i : 合計1_tb.Text = Format(Val(加總(20)), "#,##0") : If 合計1_tb.Text = "0" Then : 合計1_tb.ForeColor = Color.Black : Else : 合計1_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計2_tb.Text = "0" : Else : 加總(0) += 表單3_dgv.Rows(i).Cells("5").Value : End If Next i : 合計2_tb.Text = Format(Val(加總(0)), "#,##0") : If 合計2_tb.Text = "0" Then : 合計2_tb.ForeColor = Color.Black : Else : 合計2_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計3_tb.Text = "0" : Else : 加總(1) += 表單3_dgv.Rows(i).Cells("5.5").Value : End If Next i : 合計3_tb.Text = Format(Val(加總(1)), "#,##0") : If 合計3_tb.Text = "0" Then : 合計3_tb.ForeColor = Color.Black : Else : 合計3_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計4_tb.Text = "0" : Else : 加總(2) += 表單3_dgv.Rows(i).Cells("6").Value : End If Next i : 合計4_tb.Text = Format(Val(加總(2)), "#,##0") : If 合計4_tb.Text = "0" Then : 合計4_tb.ForeColor = Color.Black : Else : 合計4_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計5_tb.Text = "0" : Else : 加總(3) += 表單3_dgv.Rows(i).Cells("6.5").Value : End If Next i : 合計5_tb.Text = Format(Val(加總(3)), "#,##0") : If 合計5_tb.Text = "0" Then : 合計5_tb.ForeColor = Color.Black : Else : 合計5_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計6_tb.Text = "0" : Else : 加總(4) += 表單3_dgv.Rows(i).Cells("7").Value : End If Next i : 合計6_tb.Text = Format(Val(加總(4)), "#,##0") : If 合計6_tb.Text = "0" Then : 合計6_tb.ForeColor = Color.Black : Else : 合計6_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計7_tb.Text = "0" : Else : 加總(5) += 表單3_dgv.Rows(i).Cells("7.5").Value : End If Next i : 合計7_tb.Text = Format(Val(加總(5)), "#,##0") : If 合計7_tb.Text = "0" Then : 合計7_tb.ForeColor = Color.Black : Else : 合計7_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計8_tb.Text = "0" : Else : 加總(6) += 表單3_dgv.Rows(i).Cells("8").Value : End If Next i : 合計8_tb.Text = Format(Val(加總(6)), "#,##0") : If 合計8_tb.Text = "0" Then : 合計8_tb.ForeColor = Color.Black : Else : 合計8_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計9_tb.Text = "0" : Else : 加總(7) += 表單3_dgv.Rows(i).Cells("8.5").Value : End If Next i : 合計9_tb.Text = Format(Val(加總(7)), "#,##0") : If 合計9_tb.Text = "0" Then : 合計9_tb.ForeColor = Color.Black : Else : 合計9_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計10_tb.Text = "0" : Else : 加總(8) += 表單3_dgv.Rows(i).Cells("9").Value : End If Next i : 合計10_tb.Text = Format(Val(加總(8)), "#,##0") : If 合計10_tb.Text = "0" Then : 合計10_tb.ForeColor = Color.Black : Else : 合計10_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計11_tb.Text = "0" : Else : 加總(9) += 表單3_dgv.Rows(i).Cells("9.5").Value : End If Next i : 合計11_tb.Text = Format(Val(加總(9)), "#,##0") : If 合計11_tb.Text = "0" Then : 合計11_tb.ForeColor = Color.Black : Else : 合計11_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計12_tb.Text = "0" : Else : 加總(10) += 表單3_dgv.Rows(i).Cells("10").Value : End If Next i : 合計12_tb.Text = Format(Val(加總(10)), "#,##0") : If 合計12_tb.Text = "0" Then : 合計12_tb.ForeColor = Color.Black : Else : 合計12_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計13_tb.Text = "0" : Else : 加總(11) += 表單3_dgv.Rows(i).Cells("10.5").Value : End If Next i : 合計13_tb.Text = Format(Val(加總(11)), "#,##0") : If 合計13_tb.Text = "0" Then : 合計13_tb.ForeColor = Color.Black : Else : 合計13_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計14_tb.Text = "0" : Else : 加總(12) += 表單3_dgv.Rows(i).Cells("11").Value : End If Next i : 合計14_tb.Text = Format(Val(加總(12)), "#,##0") : If 合計14_tb.Text = "0" Then : 合計14_tb.ForeColor = Color.Black : Else : 合計14_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計15_tb.Text = "0" : Else : 加總(17) += 表單3_dgv.Rows(i).Cells("11.5").Value : End If Next i : 合計15_tb.Text = Format(Val(加總(17)), "#,##0") : If 合計15_tb.Text = "0" Then : 合計15_tb.ForeColor = Color.Black : Else : 合計15_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計16_tb.Text = "0" : Else : 加總(13) += 表單3_dgv.Rows(i).Cells("12").Value : End If Next i : 合計16_tb.Text = Format(Val(加總(13)), "#,##0") : If 合計16_tb.Text = "0" Then : 合計16_tb.ForeColor = Color.Black : Else : 合計16_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計17_tb.Text = "0" : Else : 加總(18) += 表單3_dgv.Rows(i).Cells("12.5").Value : End If Next i : 合計17_tb.Text = Format(Val(加總(18)), "#,##0") : If 合計17_tb.Text = "0" Then : 合計17_tb.ForeColor = Color.Black : Else : 合計17_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計18_tb.Text = "0" : Else : 加總(14) += 表單3_dgv.Rows(i).Cells("13").Value : End If Next i : 合計18_tb.Text = Format(Val(加總(14)), "#,##0") : If 合計18_tb.Text = "0" Then : 合計18_tb.ForeColor = Color.Black : Else : 合計18_tb.ForeColor = Color.Red : End If For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 : If 表單3_dgv.RowCount = 0 Then : 合計19_tb.Text = "0" : Else : 加總(15) += 表單3_dgv.Rows(i).Cells("14").Value : End If Next i : 合計19_tb.Text = Format(Val(加總(15)), "#,##0") : If 合計19_tb.Text = "0" Then : 合計19_tb.ForeColor = Color.Black : Else : 合計19_tb.ForeColor = Color.Red : End If 加總(16) = 加總(0) + 加總(1) + 加總(2) + 加總(3) + 加總(4) + 加總(5) + 加總(6) + 加總(7) + 加總(8) + 加總(9) + 加總(10) + 加總(11) + 加總(12) + 加總(13) + 加總(14) + 加總(15) + 加總(17) + 加總(18) + 加總(19) + 加總(20) 合計20_tb.Text = Format(Val(加總(16)), "#,##0") 加總(16) = 0 If 合計20_tb.Text = "0" Then : 合計20_tb.ForeColor = Color.Black : Else : 合計20_tb.ForeColor = Color.Blue : End If End Sub Private Sub 下拉表單資料載入1() SQL_客戶控制表() : Brand_cb.Items.Clear() While (dr.Read()) : Brand_cb.Items.Add(dr("客戶簡稱")) : End While : conn.Close() '------------------------------------------------------------------------------------------------------------------ SQL_MODEOFDELIVERY() : Delivery_cb.Items.Clear() While (dr.Read()) : Delivery_cb.Items.Add(dr("MODEOFDELIVERY")) : End While : conn.Close() '------------------------------------------------------------------------------------------------------------------- SQL_DELIVERYTERMS() : Terms_cb.Items.Clear() While (dr.Read()) : Terms_cb.Items.Add(dr("DELIVERYTERMS")) : End While : conn.Close() '------------------------------------------------------------------------------------------------------------------- SQL_港口清單() : FromPort_cb.Items.Clear() While (dr.Read()) : FromPort_cb.Items.Add(dr("FOB")) : End While : conn.Close() '------------------------------------------------------------------------------------------------------------------- SQL_TOPORT() : ToPort_cb.Items.Clear() While (dr.Read()) : ToPort_cb.Items.Add(dr("TOPORT")) : End While : conn.Close() '------------------------------------------------------------------------------------------------------------------- SQL_REMARK() : Remark_cb.Items.Clear() While (dr.Read()) : Remark_cb.Items.Add(dr("REMARK")) : End While : conn.Close() End Sub Private Sub 量產訂單明細表_Load(sender As Object, e As EventArgs) Handles MyBase.Load WINPROFIT_ERP_SYS.WindowState = 2 : Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True : Set_格式設定1() : 資料刪除_bt.Enabled = False GroupBox1.Visible = False : 日期2_dtp.Visible = False If PA = "" Then : Else 訂單號_tb.Text = PA 下拉表單資料載入1() : 基本資料載入() : SQL_查詢資料() If dr.Read() Then Delivery_cb.Text = dr("ModeOfDelivery").ToString : Terms_cb.Text = dr("DeliveryTerms").ToString : FromPort_cb.Text = dr("FromPort").ToString ToPort_cb.Text = dr("ToPort").ToString : ShippingCarrier_tb.Text = dr("ShippingCarrier").ToString : VendorReference_tb.Text = dr("VendorReference").ToString CustomerName_tb.Text = dr("CustomerName").ToString : SalesOrder_tb.Text = dr("SalesOrder").ToString : DeliveryAddress_tb.Text = dr("DeliveryAddress").ToString Brand_cb.Text = dr("Brand").ToString : CustomerRequisition_tb.Text = dr("CustomerRequisition").ToString Date1 = dr("CreatedDate").ToString : Date2 = dr("OrgShipDate").ToString : Date3 = dr("ModifiedDate").ToString Date4 = dr("ShipDate").ToString : Date5 = dr("下單日").ToString : Date6 = dr("交期").ToString : Date7 = dr("ETADate").ToString If Date1 = " " Or Date1 = "" Then : Else : 日期_dtp.Format = DateTimePickerFormat.Short : 日期_dtp.Text = dr("CreatedDate").ToString : End If If Date2 = " " Or Date2 = "" Then : Else : 日期1_dtp.Format = DateTimePickerFormat.Short : 日期1_dtp.Text = dr("OrgShipDate").ToString : End If If Date3 = " " Or Date3 = "" Then : Else : 日期3_dtp.Format = DateTimePickerFormat.Short : 日期3_dtp.Text = dr("ModifiedDate").ToString : End If If Date4 = " " Or Date4 = "" Then : Else : 日期4_dtp.Format = DateTimePickerFormat.Short : 日期4_dtp.Text = dr("ShipDate").ToString : End If If Date5 = " " Or Date5 = "" Then : Else : 日期6_dtp.Format = DateTimePickerFormat.Short : 日期6_dtp.Text = dr("下單日").ToString : End If If Date6 = " " Or Date6 = "" Then : Else : 日期7_dtp.Format = DateTimePickerFormat.Short : 日期7_dtp.Text = dr("交期").ToString : End If If Date7 = " " Or Date7 = "" Then : Else : 日期5_dtp.Format = DateTimePickerFormat.Short : 日期5_dtp.Text = dr("ETADate").ToString : End If Remark_cb.Text = dr("REMARK").ToString End If conn.Close() Set_訂單清單() : Set_自動彙總1() : Set_清單3() : Set_清單2() 訂單屬性_tb.Text = 表單2_dgv.Rows(0).Cells("CFMSPEC").Value PictureBox1.Image = Nothing PA7 = 表單2_dgv.Rows(0).Cells("BUYER").Value : PA8 = 表單2_dgv.Rows(0).Cells("型體號碼").Value PA9 = 表單2_dgv.Rows(0).Cells("型體名稱").Value SQL_第一筆圖片() If dr.Read() Then : PictureBox1.Image = Nothing : SQL_第一筆圖片() While dr.Read() = True Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream) End While : conn.Close() Else : PictureBox1.Image = Nothing : SQL_第一筆圖片1() If dr.Read() Then : PictureBox1.Image = Nothing : SQL_第一筆圖片1() While dr.Read() = True Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream) End While conn.Close() Else : SQL_圖片() : PictureBox1.Image = Nothing If dr.Read() Then : PictureBox1.Image = Nothing : SQL_圖片() While dr.Read() = True Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream) End While : conn.Close() Else : conn.Close() : End If End If End If : PictureBox1.SizeMode = 4 列印用SQL1 = 訂單號_tb.Text End If : PA = "" : PA5 = "" End Sub Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 表單1_dgv.CellClick PictureBox2.Image = Nothing : PA6 = 表單1_dgv.Rows(e.RowIndex).Cells("訂單流水號").Value : PA7 = 表單1_dgv.Rows(e.RowIndex).Cells("附件數").Value SQL_一筆訂單附件資料() While dr.Read() = True Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox2.Image = Bitmap.FromStream(oStream) End While conn.Close() PictureBox2.SizeMode = 4 End Sub Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 表單2_dgv.CellClick If e.RowIndex = -1 Then : Else PictureBox1.Image = Nothing PA7 = 表單2_dgv.Rows(0).Cells("BUYER").Value : PA8 = 表單2_dgv.Rows(0).Cells("型體號碼").Value PA9 = 表單2_dgv.Rows(0).Cells("型體名稱").Value SQL_第一筆圖片() If dr.Read() Then : PictureBox1.Image = Nothing : SQL_第一筆圖片() While dr.Read() = True Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream) End While : conn.Close() Else : PictureBox1.Image = Nothing : SQL_第一筆圖片1() If dr.Read() Then : PictureBox1.Image = Nothing : SQL_第一筆圖片1() While dr.Read() = True Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream) End While conn.Close() Else : SQL_圖片() : PictureBox1.Image = Nothing If dr.Read() Then : PictureBox1.Image = Nothing : SQL_圖片() While dr.Read() = True Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream) End While : conn.Close() Else : conn.Close() : End If End If End If : PictureBox1.SizeMode = 4 End If End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 表單3_dgv.CellEndEdit TotalNumber_tb.Text = "0" For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 表單2_dgv.Rows(i).Cells("訂單數量").Value = 表單3_dgv.Rows(i).Cells("4").Value + 表單3_dgv.Rows(i).Cells("4.5").Value + 表單3_dgv.Rows(i).Cells("5").Value + 表單3_dgv.Rows(i).Cells("5.5").Value + 表單3_dgv.Rows(i).Cells("6").Value + 表單3_dgv.Rows(i).Cells("6.5").Value + 表單3_dgv.Rows(i).Cells("7").Value + 表單3_dgv.Rows(i).Cells("7.5").Value + 表單3_dgv.Rows(i).Cells("8").Value + 表單3_dgv.Rows(i).Cells("8.5").Value + 表單3_dgv.Rows(i).Cells("9").Value + 表單3_dgv.Rows(i).Cells("9.5").Value + 表單3_dgv.Rows(i).Cells("10").Value + 表單3_dgv.Rows(i).Cells("10.5").Value + 表單3_dgv.Rows(i).Cells("11").Value + 表單3_dgv.Rows(i).Cells("11.5").Value + 表單3_dgv.Rows(i).Cells("12").Value + 表單3_dgv.Rows(i).Cells("12.5").Value + 表單3_dgv.Rows(i).Cells("13").Value + 表單3_dgv.Rows(i).Cells("14").Value 表單3_dgv.Rows(i).Cells("TOTAL").Value = 表單2_dgv.Rows(i).Cells("訂單數量").Value Next i For i As Integer = 0 To 表單2_dgv.Rows.Count - 1 TotalNumber_tb.Text = Val(TotalNumber_tb.Text) + 表單2_dgv.Rows(i).Cells("訂單數量").Value Next i TotalNumber_tb.Text = Format(Val(TotalNumber_tb.Text), "#,##0") Set_自動彙總1() End Sub Private Sub DataGridView3_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 表單2_dgv.CellEndEdit Dim EU(2) As String EU(0) = 表單2_dgv("交期開始", e.RowIndex).Value.ToString If EU(0) = "" Then Else 日期2_dtp.Text = EU(0) 表單2_dgv.Rows(e.RowIndex).Cells("交期開始").Value = Format(日期2_dtp.Value, "yyyy/MM/dd") End If EU(1) = 表單2_dgv("交期結束", e.RowIndex).Value.ToString If EU(1) = "" Then Else 日期2_dtp.Text = EU(1) 表單2_dgv.Rows(e.RowIndex).Cells("交期結束").Value = Format(日期2_dtp.Value, "yyyy/MM/dd") End If EU(2) = 表單2_dgv("工廠交期", e.RowIndex).Value.ToString If EU(2) = "" Then Else 日期2_dtp.Text = EU(2) 表單2_dgv.Rows(e.RowIndex).Cells("工廠交期").Value = Format(日期2_dtp.Value, "yyyy/MM/dd") End If End Sub Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Remark_cb.TextChanged SQL_DELIVERYADDRESS2() If dr.Read() Then : DeliveryAddress_tb.Text = dr("DELIVERYADDRESS").ToString : End If : conn.Close() End Sub Private Sub Button30_Click(sender As Object, e As EventArgs) Handles 返回訂單控制表_bt.Click Me.Close() 列印用SQL = "" End Sub Private Sub Button12_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click OD(0) = Number_tb.Text : OD(1) = 日期_dtp.Text : OD(2) = Brand_cb.Text : OD(3) = Vendor_tb.Text : OD(4) = Delivery_cb.Text OD(5) = Terms_cb.Text : OD(6) = 備註_tb.Text OD(7) = 日期1_dtp.Text : OD(8) = FromPort_cb.Text : OD(9) = ToPort_cb.Text : OD(10) = ShippingCarrier_tb.Text : OD(11) = VendorReference_tb.Text OD(12) = 日期3_dtp.Text : OD(13) = CustomerName_tb.Text : OD(14) = 日期4_dtp.Text : OD(15) = SalesOrder_tb.Text OD(16) = 日期5_dtp.Text : OD(17) = DeliveryAddress_tb.Text OD(18) = 訂單號_tb.Text : OD(19) = 工廠_tb.Text : OD(20) = 日期6_dtp.Text : OD(21) = 日期7_dtp.Text OD(40) = Remark_cb.Text OD(22) = 合計2_tb.Text : OD(23) = 合計3_tb.Text : OD(24) = 合計4_tb.Text : OD(25) = 合計5_tb.Text : OD(26) = 合計6_tb.Text OD(27) = 合計7_tb.Text : OD(28) = 合計8_tb.Text : OD(29) = 合計9_tb.Text : OD(30) = 合計10_tb.Text : OD(31) = 合計11_tb.Text OD(32) = 合計12_tb.Text : OD(33) = 合計13_tb.Text : OD(34) = 合計14_tb.Text : OD(35) = 合計16_tb.Text : OD(36) = 合計18_tb.Text OD(37) = 合計19_tb.Text : OD(38) = 合計20_tb.Text : OD(39) = CustomerRequisition_tb.Text : OD(41) = 合計15_tb.Text : OD(42) = 合計17_tb.Text OD(43) = 合計_tb.Text : OD(44) = 合計1_tb.Text : OD(45) = 訂單屬性_tb.Text 列印_訂單明細.Show() End Sub Private Sub Set_日期格式轉換() DTPs(0) = 日期_dtp.Text : DTPs(1) = 日期1_dtp.Text : DTPs(2) = 日期3_dtp.Text : DTPs(3) = 日期4_dtp.Text : DTPs(4) = 日期6_dtp.Text DTPs(5) = 日期7_dtp.Text : DTPs(6) = 日期5_dtp.Text If DTPs(0) = " " Then : DTPs(0) = "" : Else : DTPs(0) = Format(日期_dtp.Value, "yyyy/MM/dd") : End If If DTPs(1) = " " Then : DTPs(1) = "" : Else : DTPs(1) = Format(日期1_dtp.Value, "yyyy/MM/dd") : End If If DTPs(2) = " " Then : DTPs(2) = "" : Else : DTPs(2) = Format(日期3_dtp.Value, "yyyy/MM/dd") : End If If DTPs(3) = " " Then : DTPs(3) = "" : Else : DTPs(3) = Format(日期4_dtp.Value, "yyyy/MM/dd") : End If If DTPs(4) = " " Then : DTPs(4) = "" : Else : DTPs(4) = Format(日期6_dtp.Value, "yyyy/MM/dd") : End If If DTPs(5) = " " Then : DTPs(5) = "" : Else : DTPs(5) = Format(日期7_dtp.Value, "yyyy/MM/dd") : End If If DTPs(6) = " " Then : DTPs(6) = "" : Else : DTPs(6) = Format(日期5_dtp.Value, "yyyy/MM/dd") : End If End Sub Private Sub Button8_Click(sender As Object, e As EventArgs) Handles 資料存檔_bt.Click Set_日期格式轉換() SQL_修改訂單明細表抬頭() : conn.Close() For i As Integer = 0 To 表單2_dgv.Rows.Count - 1 資料數 = 表單2_dgv.Rows.Count : MyModule1.進度條() PA8 = 表單2_dgv.Rows(i).Cells("訂單數量").Value : PA9 = 表單2_dgv.Rows(i).Cells("交期開始").Value PA10 = 表單2_dgv.Rows(i).Cells("交期結束").Value : PA11 = 表單2_dgv.Rows(i).Cells("備註").Value PA12 = 表單2_dgv.Rows(i).Cells("工廠交期").Value : PA13 = 表單2_dgv.Rows(i).Cells("BUYER").Value PA14 = 表單2_dgv.Rows(i).Cells("資料流水號").Value SQL_修改訂單控制表5() : conn.Close() Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 For i As Integer = 0 To 表單3_dgv.Rows.Count - 1 資料數 = 表單3_dgv.Rows.Count : MyModule1.進度條() PA15 = 表單3_dgv.Rows(i).Cells("4").Value : PA16 = 表單3_dgv.Rows(i).Cells("4.5").Value PA17 = 表單3_dgv.Rows(i).Cells("5").Value : PA18 = 表單3_dgv.Rows(i).Cells("5.5").Value PA19 = 表單3_dgv.Rows(i).Cells("6").Value : PA20 = 表單3_dgv.Rows(i).Cells("6.5").Value PA21 = 表單3_dgv.Rows(i).Cells("7").Value : PA22 = 表單3_dgv.Rows(i).Cells("7.5").Value PA23 = 表單3_dgv.Rows(i).Cells("8").Value : PA24 = 表單3_dgv.Rows(i).Cells("8.5").Value PA25 = 表單3_dgv.Rows(i).Cells("9").Value : PA26 = 表單3_dgv.Rows(i).Cells("9.5").Value PA27 = 表單3_dgv.Rows(i).Cells("10").Value : PA28 = 表單3_dgv.Rows(i).Cells("10.5").Value PA29 = 表單3_dgv.Rows(i).Cells("11").Value : PA30 = 表單3_dgv.Rows(i).Cells("11.5").Value PA31 = 表單3_dgv.Rows(i).Cells("12").Value : PA32 = 表單3_dgv.Rows(i).Cells("12.5").Value PA33 = 表單3_dgv.Rows(i).Cells("13").Value : PA7 = 表單3_dgv.Rows(i).Cells("14").Value PA4 = 表單3_dgv.Rows(i).Cells("資料流水號").Value SQL_修改訂單明細表1() : conn.Close() Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 MsgBox("存檔完成。") End Sub Private Sub Button6_Click(sender As Object, e As EventArgs) Handles 訂單附件導入_bt.Click Dim NUM1 As Integer SQL_訂單附件資料1() If dr.Read() Then : 新流水號3 = dr("附件數") : Else : 新流水號3 = "V00" : End If : conn.Close() NUM1 = Double.Parse(Strings.Right(新流水號3, 2)) + 1 If NUM1 < 10 Then : 新流水號3 = "V" & "0" & NUM1 ElseIf NUM1 > 9 Then : 新流水號3 = "V" & NUM1 End If TextBox3.Text = 新流水號3 GroupBox1.Visible = True If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath) End If End Sub Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click GroupBox1.Visible = False End Sub Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath) End If End Sub Private Sub TextBox4_DragEnter(sender As Object, e As DragEventArgs) Handles TextBox4.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop) Then : Dim files As String() Try : files = CType(e.Data.GetData(DataFormats.FileDrop), String()) : TextBox4.Text = files(files.Length - 1) Catch ex As Exception : MessageBox.Show(ex.Message) : Return : End Try End If Dim STR2 As Integer = 0 : TextBox7.Text = TextBox4.Text If TextBox4.Text = "" Then : Else For i As Integer = 0 To 9999 : Dim STR1 As Integer = Strings.Len(TextBox7.Text) If Strings.Right((TextBox7.Text), 1) <> "\" Then : STR1 -= 1 : STR2 += 1 If STR1 = 0 Then : TextBox7.Text = "" : TextBox4.Text = "" : i = 9999 Else : TextBox7.Text = Strings.Left((TextBox7.Text), STR1) : End If Else TextBox7.Text = Strings.Right((TextBox4.Text), STR2) TextBox4.Text = TextBox7.Text : i = 9999 End If Next Dim files As String() : files = CType(e.Data.GetData(DataFormats.FileDrop), String()) TextBox7.Text = files(files.Length - 1) End If End Sub Private Sub TextBox4_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox4.DragDrop Dim files As Array = e.Data.GetData(DataFormats.FileDrop) For Each file As String In files TextBox4.AppendText(file + Environment.NewLine) Next End Sub Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click If TextBox3.Text = "" Or TextBox4.Text = "" Then : MsgBox("請注意圖片檔案已準備完畢") : Else PA49 = TextBox7.Text : SQL_新增訂單附件資料() : conn.Close() PictureBox2.Image = Nothing SQL_訂單附件資料3() While dr.Read() = True Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte()) Dim oStream As New MemoryStream(bytes) : PictureBox2.Image = Bitmap.FromStream(oStream) End While conn.Close() : PictureBox2.SizeMode = 4 : TextBox3.Text = "" : TextBox4.Text = "" : MsgBox("新增完成") : GroupBox1.Visible = False : Set_清單2() End If End Sub Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox2.MouseUp m_DeltaX = m_MousePosX - e.X : m_DeltaY = m_MousePosY - e.Y : m_Leftx -= m_DeltaX : m_Lefty -= m_DeltaY : Picturemove(sender, e) Me.Cursor = Cursors.Arrow End Sub Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox2.MouseDown Me.Cursor = Cursors.Hand : m_MousePosX = e.X : m_MousePosY = e.Y End Sub Private Sub Picturemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim myBit As New Bitmap(PictureBox2.Image) Dim myPicGrh As Graphics = Me.PictureBox2.CreateGraphics myPicGrh.Clear(Me.PictureBox2.BackColor) myPicGrh.DrawImageUnscaled(myBit, m_Leftx - 152, m_Lefty) myBit.Dispose() myPicGrh.Dispose() End Sub Private Sub Button20_Click(sender As Object, e As EventArgs) Handles 放大_bt.Click Dim image = PictureBox2.Image Dim g As Graphics = PictureBox2.CreateGraphics g.DrawImage(image, New Rectangle(0, 0, image.Width * 1.01, image.Height * 1.01)) End Sub Private Sub Button11_Click(sender As Object, e As EventArgs) Handles 復原_bt.Click PictureBox2.Refresh() End Sub Private Sub Button25_Click(sender As Object, e As EventArgs) Handles 順時鐘90度旋轉_bt.Click PictureBox2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4 End Sub Private Sub Button24_Click(sender As Object, e As EventArgs) Handles 逆時鐘90度旋轉_bt.Click PictureBox2.Image.RotateFlip(RotateFlipType.Rotate270FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4 End Sub Private Sub Button23_Click(sender As Object, e As EventArgs) Handles 水平翻轉_bt.Click PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipY) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4 End Sub Private Sub Button21_Click(sender As Object, e As EventArgs) Handles 垂直翻轉_bt.Click PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipX) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4 End Sub Private Sub Button26_Click(sender As Object, e As EventArgs) Handles 更新BUYER_bt.Click For i As Integer = 0 To 表單2_dgv.Rows.Count - 1 表單2_dgv.Rows(i).Cells("BUYER").Value = Brand_cb.Text Next MsgBox("注意還未存檔喔") End Sub Private Sub 表單3_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 表單3_dgv.MouseUp If 表單3_dgv.SelectedCells.Count = 1 Then 已超出 = False End If If 表單3_dgv.SelectedCells.Count > 0 Then If 表單3_dgv.SelectedCells(0).ColumnIndex >= 6 And 表單3_dgv.SelectedCells(0).ColumnIndex <= 25 Then If 已超出 = False Then Dim x As Double = 0 For i As Integer = 0 To 表單3_dgv.SelectedCells.Count - 1 x += Val(表單3_dgv.Rows(表單3_dgv.SelectedCells.Item(i).RowIndex).Cells(表單3_dgv.SelectedCells.Item(i).ColumnIndex).Value) Next i WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(x, "#,##0.0") Else WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.0") End If Else 已超出 = True WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.0") End If End If End Sub End Class