暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

量產訂單明細表.vb 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. Option Strict Off
  2. Imports System.IO
  3. Imports System.Net
  4. Public Class 量產訂單明細表
  5. Private ReadOnly ds, ds2, ds3 As New DataSet
  6. Dim 已超出 As Boolean
  7. Dim Date1, Date2, Date3, Date4, Date5, Date6, Date7 As String
  8. Dim 新流水號3 As String
  9. Private m_Leftx As Integer = 152
  10. Private m_Lefty As Integer = 0
  11. Dim m_MousePosX, m_MousePosY, m_DeltaX, m_DeltaY As Integer
  12. Private Sub 基本資料載入()
  13. SQL_基本資料載入()
  14. If dr.Read() Then
  15. Number_tb.Text = dr("客戶訂單號").ToString : Vendor_tb.Text = dr("供應商資料").ToString : 備註_tb.Text = dr("供應商地址").ToString
  16. 工廠_tb.Text = dr("生產工廠").ToString : TotalNumber_tb.Text = Format(Val(dr("訂單數量").ToString), "#,##0")
  17. Else : Number_tb.Text = "" : End If : conn.Close()
  18. End Sub
  19. Private Sub Set_訂單清單()
  20. 表單3_dgv.DataSource = Nothing : ds.Clear()
  21. 表單3_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  22. 表單3_dgv.ColumnHeadersHeight = 25
  23. 表單3_dgv.AllowUserToAddRows = False
  24. SQL_訂單清單()
  25. da.Fill(ds) : 表單3_dgv.DataSource = ds.Tables(0) : conn.Close()
  26. 表單3_dgv.Columns(0).Visible = False : 表單3_dgv.Columns(1).Visible = False
  27. 表單3_dgv.Columns(2).FillWeight = 120 : 表單3_dgv.Columns(3).FillWeight = 150 : 表單3_dgv.Columns(4).FillWeight = 100 : 表單3_dgv.Columns(5).FillWeight = 70
  28. 表單3_dgv.Columns(6).FillWeight = 40 : 表單3_dgv.Columns(7).FillWeight = 40 : 表單3_dgv.Columns(8).FillWeight = 40 : 表單3_dgv.Columns(9).FillWeight = 40
  29. 表單3_dgv.Columns(10).FillWeight = 40 : 表單3_dgv.Columns(11).FillWeight = 40 : 表單3_dgv.Columns(12).FillWeight = 40 : 表單3_dgv.Columns(13).FillWeight = 40
  30. 表單3_dgv.Columns(14).FillWeight = 40 : 表單3_dgv.Columns(15).FillWeight = 40 : 表單3_dgv.Columns(16).FillWeight = 40 : 表單3_dgv.Columns(17).FillWeight = 40
  31. 表單3_dgv.Columns(18).FillWeight = 40 : 表單3_dgv.Columns(19).FillWeight = 40 : 表單3_dgv.Columns(20).FillWeight = 40 : 表單3_dgv.Columns(21).FillWeight = 40
  32. 表單3_dgv.Columns(22).FillWeight = 40 : 表單3_dgv.Columns(23).FillWeight = 40 : 表單3_dgv.Columns(24).FillWeight = 40 : 表單3_dgv.Columns(25).FillWeight = 40
  33. 表單3_dgv.Columns(26).FillWeight = 60 : 表單3_dgv.Columns(27).Visible = False
  34. 表單3_dgv.Columns(7).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(9).DefaultCellStyle.Format = "#,##0"
  35. 表單3_dgv.Columns(10).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(11).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(12).DefaultCellStyle.Format = "#,##0"
  36. 表單3_dgv.Columns(13).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(14).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(15).DefaultCellStyle.Format = "#,##0"
  37. 表單3_dgv.Columns(16).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(17).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(18).DefaultCellStyle.Format = "#,##0"
  38. 表單3_dgv.Columns(19).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(20).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(21).DefaultCellStyle.Format = "#,##0"
  39. 表單3_dgv.Columns(22).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(23).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(24).DefaultCellStyle.Format = "#,##0"
  40. 表單3_dgv.Columns(25).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(26).DefaultCellStyle.Format = "#,##0" : 表單3_dgv.Columns(6).DefaultCellStyle.Format = "#,##0"
  41. 表單3_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  42. End Sub
  43. Private Sub Set_清單2()
  44. 表單1_dgv.DataSource = Nothing : ds2.Clear()
  45. 表單1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  46. 表單1_dgv.ColumnHeadersHeight = 25
  47. 表單1_dgv.AllowUserToAddRows = False
  48. SQL_訂單附件資料()
  49. da.Fill(ds2) : 表單1_dgv.DataSource = ds2.Tables(0) : conn.Close()
  50. 表單1_dgv.Columns(0).FillWeight = 120 : 表單1_dgv.Columns(1).FillWeight = 45
  51. End Sub
  52. Private Sub Set_清單3()
  53. 表單2_dgv.DataSource = Nothing : ds3.Clear()
  54. 表單2_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  55. 表單2_dgv.ColumnHeadersHeight = 25
  56. 表單2_dgv.AllowUserToAddRows = False
  57. SQL_訂單控制表1()
  58. da.Fill(ds3) : 表單2_dgv.DataSource = ds3.Tables(0) : conn.Close()
  59. 表單2_dgv.Columns(0).FillWeight = 85 : 表單2_dgv.Columns(1).FillWeight = 70 : 表單2_dgv.Columns(2).FillWeight = 130 : 表單2_dgv.Columns(3).FillWeight = 120
  60. 表單2_dgv.Columns(4).FillWeight = 130 : 表單2_dgv.Columns(5).FillWeight = 80 : 表單2_dgv.Columns(6).FillWeight = 50 : 表單2_dgv.Columns(7).FillWeight = 80
  61. 表單2_dgv.Columns(8).FillWeight = 90 : 表單2_dgv.Columns(9).FillWeight = 90 : 表單2_dgv.Columns(10).FillWeight = 90
  62. 表單2_dgv.Columns(11).Visible = False : 表單2_dgv.Columns(12).Visible = False
  63. 表單2_dgv.Columns(13).FillWeight = 62 : 表單2_dgv.Columns(14).FillWeight = 80 : 表單2_dgv.Columns(15).FillWeight = 120 : 表單2_dgv.Columns(16).FillWeight = 130
  64. 表單2_dgv.Columns(17).Visible = False : 表單2_dgv.Columns(18).Visible = False : 表單2_dgv.Columns(19).Visible = False : 表單2_dgv.Columns(20).Visible = False
  65. 表單2_dgv.Columns(21).Visible = False : 表單2_dgv.Columns(22).Visible = False : 表單2_dgv.Columns(23).Visible = False : 表單2_dgv.Columns(24).Visible = False
  66. 表單2_dgv.Columns(25).Visible = False : 表單2_dgv.Columns(26).Visible = False : 表單2_dgv.Columns(27).Visible = False : 表單2_dgv.Columns(28).Visible = False
  67. 表單2_dgv.Columns(29).Visible = False : 表單2_dgv.Columns(30).Visible = False : 表單2_dgv.Columns(31).Visible = False : 表單2_dgv.Columns(32).Visible = False
  68. 表單2_dgv.Columns(33).Visible = False : 表單2_dgv.Columns(34).Visible = False : 表單2_dgv.Columns(35).Visible = False : 表單2_dgv.Columns(36).Visible = False
  69. 表單2_dgv.Columns(37).Visible = False : 表單2_dgv.Columns(38).Visible = False : 表單2_dgv.Columns(39).Visible = False : 表單2_dgv.Columns(40).Visible = False
  70. 表單2_dgv.Columns(41).Visible = False : 表單2_dgv.Columns(42).Visible = False : 表單2_dgv.Columns(43).Visible = False : 表單2_dgv.Columns(44).Visible = False
  71. 表單2_dgv.Columns(45).Visible = False : 表單2_dgv.Columns(46).Visible = False : 表單2_dgv.Columns(47).Visible = False : 表單2_dgv.Columns(48).Visible = False
  72. 表單2_dgv.Columns(49).Visible = False : 表單2_dgv.Columns(50).Visible = False : 表單2_dgv.Columns(51).Visible = False : 表單2_dgv.Columns(52).Visible = False
  73. 表單2_dgv.Columns(53).Visible = False : 表單2_dgv.Columns(54).Visible = False : 表單2_dgv.Columns(55).Visible = False : 表單2_dgv.Columns(56).Visible = False
  74. 表單2_dgv.Columns(57).Visible = False : 表單2_dgv.Columns(58).Visible = False : 表單2_dgv.Columns(59).Visible = False
  75. 表單2_dgv.Columns(7).DefaultCellStyle.Format = "#,##0"
  76. 表單2_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  77. 表單2_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  78. 表單2_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  79. End Sub
  80. Private Sub Set_格式設定1()
  81. Number_tb.Enabled = False : TextBox3.Enabled = False : 訂單號_tb.Enabled = False : 工廠_tb.Enabled = False : TotalNumber_tb.Enabled = False : TextBox7.Visible = False
  82. 日期_dtp.Format = DateTimePickerFormat.Custom : 日期_dtp.CustomFormat = " "
  83. 日期1_dtp.Format = DateTimePickerFormat.Custom : 日期1_dtp.CustomFormat = " "
  84. 日期3_dtp.Format = DateTimePickerFormat.Custom : 日期3_dtp.CustomFormat = " "
  85. 日期4_dtp.Format = DateTimePickerFormat.Custom : 日期4_dtp.CustomFormat = " "
  86. 日期6_dtp.Format = DateTimePickerFormat.Custom : 日期6_dtp.CustomFormat = " "
  87. 日期7_dtp.Format = DateTimePickerFormat.Custom : 日期7_dtp.CustomFormat = " "
  88. 日期5_dtp.Format = DateTimePickerFormat.Custom : 日期5_dtp.CustomFormat = " "
  89. ShippingCarrier_tb.Text = "" : VendorReference_tb.Text = ""
  90. CustomerName_tb.Text = "" : SalesOrder_tb.Text = "" : DeliveryAddress_tb.Text = ""
  91. End Sub
  92. Private Sub Set_自動彙總1()
  93. Dim 加總(20) As Double
  94. 加總(0) = 0 : 加總(1) = 0 : 加總(2) = 0 : 加總(3) = 0 : 加總(4) = 0 : 加總(5) = 0 : 加總(6) = 0 : 加總(7) = 0 : 加總(8) = 0
  95. 加總(9) = 0 : 加總(10) = 0 : 加總(11) = 0 : 加總(12) = 0 : 加總(13) = 0 : 加總(14) = 0 : 加總(15) = 0 : 加總(16) = 0 : 加總(17) = 0 : 加總(18) = 0 : 加總(19) = 0 : 加總(20) = 0
  96. 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
  97. Next i : 合計_tb.Text = Format(Val(加總(19)), "#,##0") : If 合計_tb.Text = "0" Then : 合計_tb.ForeColor = Color.Black : Else : 合計_tb.ForeColor = Color.Red : End If
  98. 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
  99. 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
  100. 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
  101. 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
  102. 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
  103. 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
  104. 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
  105. 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
  106. 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
  107. 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
  108. 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
  109. 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
  110. 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
  111. 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
  112. 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
  113. 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
  114. 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
  115. 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
  116. 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
  117. 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
  118. 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
  119. 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
  120. 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
  121. 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
  122. 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
  123. 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
  124. 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
  125. 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
  126. 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
  127. 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
  128. 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
  129. 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
  130. 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
  131. 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
  132. 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
  133. 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
  134. 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
  135. 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
  136. 加總(16) = 加總(0) + 加總(1) + 加總(2) + 加總(3) + 加總(4) + 加總(5) + 加總(6) + 加總(7) + 加總(8) + 加總(9) + 加總(10) + 加總(11) + 加總(12) + 加總(13) + 加總(14) +
  137. 加總(15) + 加總(17) + 加總(18) + 加總(19) + 加總(20)
  138. 合計20_tb.Text = Format(Val(加總(16)), "#,##0")
  139. 加總(16) = 0
  140. If 合計20_tb.Text = "0" Then : 合計20_tb.ForeColor = Color.Black : Else : 合計20_tb.ForeColor = Color.Blue : End If
  141. End Sub
  142. Private Sub 下拉表單資料載入1()
  143. SQL_客戶控制表() : Brand_cb.Items.Clear()
  144. While (dr.Read()) : Brand_cb.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
  145. '------------------------------------------------------------------------------------------------------------------
  146. SQL_MODEOFDELIVERY() : Delivery_cb.Items.Clear()
  147. While (dr.Read()) : Delivery_cb.Items.Add(dr("MODEOFDELIVERY")) : End While : conn.Close()
  148. '-------------------------------------------------------------------------------------------------------------------
  149. SQL_DELIVERYTERMS() : Terms_cb.Items.Clear()
  150. While (dr.Read()) : Terms_cb.Items.Add(dr("DELIVERYTERMS")) : End While : conn.Close()
  151. '-------------------------------------------------------------------------------------------------------------------
  152. SQL_港口清單() : FromPort_cb.Items.Clear()
  153. While (dr.Read()) : FromPort_cb.Items.Add(dr("FOB")) : End While : conn.Close()
  154. '-------------------------------------------------------------------------------------------------------------------
  155. SQL_TOPORT() : ToPort_cb.Items.Clear()
  156. While (dr.Read()) : ToPort_cb.Items.Add(dr("TOPORT")) : End While : conn.Close()
  157. '-------------------------------------------------------------------------------------------------------------------
  158. SQL_REMARK() : Remark_cb.Items.Clear()
  159. While (dr.Read()) : Remark_cb.Items.Add(dr("REMARK")) : End While : conn.Close()
  160. End Sub
  161. Private Sub 量產訂單明細表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  162. WINPROFIT_ERP_SYS.WindowState = 2 : Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True : Set_格式設定1() : 資料刪除_bt.Enabled = False
  163. Target1 = Target & AA(1) & "/"
  164. WebBrowser1.Url = New Uri(Target1)
  165. GroupBox1.Visible = False : 日期2_dtp.Visible = False
  166. If PA = "" Then : Else
  167. 訂單號_tb.Text = PA
  168. 下拉表單資料載入1() : 基本資料載入() : SQL_查詢資料()
  169. If dr.Read() Then
  170. Delivery_cb.Text = dr("ModeOfDelivery").ToString : Terms_cb.Text = dr("DeliveryTerms").ToString : FromPort_cb.Text = dr("FromPort").ToString
  171. ToPort_cb.Text = dr("ToPort").ToString : ShippingCarrier_tb.Text = dr("ShippingCarrier").ToString : VendorReference_tb.Text = dr("VendorReference").ToString
  172. CustomerName_tb.Text = dr("CustomerName").ToString : SalesOrder_tb.Text = dr("SalesOrder").ToString : DeliveryAddress_tb.Text = dr("DeliveryAddress").ToString
  173. Brand_cb.Text = dr("Brand").ToString : CustomerRequisition_tb.Text = dr("CustomerRequisition").ToString
  174. Date1 = dr("CreatedDate").ToString : Date2 = dr("OrgShipDate").ToString : Date3 = dr("ModifiedDate").ToString
  175. Date4 = dr("ShipDate").ToString : Date5 = dr("下單日").ToString : Date6 = dr("交期").ToString : Date7 = dr("ETADate").ToString
  176. If Date1 = " " Or Date1 = "" Then : Else : 日期_dtp.Format = DateTimePickerFormat.Short : 日期_dtp.Text = dr("CreatedDate").ToString : End If
  177. If Date2 = " " Or Date2 = "" Then : Else : 日期1_dtp.Format = DateTimePickerFormat.Short : 日期1_dtp.Text = dr("OrgShipDate").ToString : End If
  178. If Date3 = " " Or Date3 = "" Then : Else : 日期3_dtp.Format = DateTimePickerFormat.Short : 日期3_dtp.Text = dr("ModifiedDate").ToString : End If
  179. If Date4 = " " Or Date4 = "" Then : Else : 日期4_dtp.Format = DateTimePickerFormat.Short : 日期4_dtp.Text = dr("ShipDate").ToString : End If
  180. If Date5 = " " Or Date5 = "" Then : Else : 日期6_dtp.Format = DateTimePickerFormat.Short : 日期6_dtp.Text = dr("下單日").ToString : End If
  181. If Date6 = " " Or Date6 = "" Then : Else : 日期7_dtp.Format = DateTimePickerFormat.Short : 日期7_dtp.Text = dr("交期").ToString : End If
  182. If Date7 = " " Or Date7 = "" Then : Else : 日期5_dtp.Format = DateTimePickerFormat.Short : 日期5_dtp.Text = dr("ETADate").ToString : End If
  183. Remark_cb.Text = dr("REMARK").ToString
  184. End If
  185. conn.Close()
  186. Set_訂單清單() : Set_自動彙總1() : Set_清單3() : Set_清單2()
  187. 訂單屬性_tb.Text = 表單2_dgv.Rows(0).Cells("CFMSPEC").Value
  188. PictureBox1.Image = Nothing : PA5 = 表單2_dgv.Rows(0).Cells("型體號碼").Value
  189. SQL_一筆鞋型圖片資料庫1()
  190. If dr.Read() Then
  191. PictureBox1.Image = Nothing
  192. SQL_一筆鞋型圖片資料庫1()
  193. While dr.Read() = True
  194. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  195. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  196. End While
  197. conn.Close()
  198. Else
  199. PictureBox1.Image = Nothing
  200. SQL_一筆鞋型圖片資料庫2()
  201. If dr.Read() Then
  202. PictureBox1.Image = Nothing
  203. SQL_一筆鞋型圖片資料庫2()
  204. While dr.Read() = True
  205. Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  206. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  207. End While
  208. conn.Close()
  209. Else
  210. PictureBox1.Image = Nothing
  211. SQL_一筆鞋型圖片資料庫3()
  212. If dr.Read() Then
  213. PictureBox1.Image = Nothing
  214. SQL_一筆鞋型圖片資料庫3()
  215. While dr.Read() = True
  216. Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  217. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  218. End While
  219. conn.Close()
  220. Else
  221. conn.Close()
  222. End If
  223. End If
  224. End If : PictureBox1.SizeMode = 4
  225. 列印用SQL1 = 訂單號_tb.Text
  226. End If : PA = "" : PA5 = ""
  227. End Sub
  228. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 表單1_dgv.CellClick
  229. PictureBox2.Image = Nothing : PA6 = 表單1_dgv.Rows(e.RowIndex).Cells("訂單流水號").Value : PA7 = 表單1_dgv.Rows(e.RowIndex).Cells("附件數").Value
  230. SQL_一筆訂單附件資料()
  231. While dr.Read() = True
  232. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  233. Dim oStream As New MemoryStream(bytes) : PictureBox2.Image = Bitmap.FromStream(oStream)
  234. End While
  235. conn.Close()
  236. PictureBox2.SizeMode = 4
  237. End Sub
  238. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 表單2_dgv.CellClick
  239. If e.RowIndex = -1 Then : Else
  240. PictureBox1.Image = Nothing : PA6 = 表單2_dgv.Rows(0).Cells("型體號碼").Value
  241. SQL_一筆鞋型圖片資料庫4()
  242. If dr.Read() Then
  243. PictureBox1.Image = Nothing
  244. SQL_一筆鞋型圖片資料庫4()
  245. While dr.Read() = True
  246. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  247. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  248. End While
  249. conn.Close()
  250. Else
  251. PictureBox1.Image = Nothing
  252. SQL_一筆鞋型圖片資料庫5()
  253. If dr.Read() Then
  254. PictureBox1.Image = Nothing
  255. SQL_一筆鞋型圖片資料庫5()
  256. While dr.Read() = True
  257. Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  258. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  259. End While
  260. conn.Close()
  261. Else
  262. PictureBox1.Image = Nothing
  263. SQL_一筆鞋型圖片資料庫6()
  264. If dr.Read() Then
  265. PictureBox1.Image = Nothing
  266. SQL_一筆鞋型圖片資料庫6()
  267. While dr.Read() = True
  268. Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  269. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  270. End While
  271. conn.Close()
  272. Else
  273. conn.Close()
  274. End If
  275. End If
  276. End If : PictureBox1.SizeMode = 4
  277. End If
  278. End Sub
  279. Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 表單3_dgv.CellEndEdit
  280. TotalNumber_tb.Text = "0"
  281. For i As Integer = 0 To 表單3_dgv.Rows.Count - 1
  282. 表單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 +
  283. 表單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 +
  284. 表單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 +
  285. 表單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 +
  286. 表單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 +
  287. 表單3_dgv.Rows(i).Cells("14").Value
  288. 表單3_dgv.Rows(i).Cells("TOTAL").Value = 表單2_dgv.Rows(i).Cells("訂單數量").Value
  289. Next i
  290. For i As Integer = 0 To 表單2_dgv.Rows.Count - 1
  291. TotalNumber_tb.Text = Val(TotalNumber_tb.Text) + 表單2_dgv.Rows(i).Cells("訂單數量").Value
  292. Next i
  293. TotalNumber_tb.Text = Format(Val(TotalNumber_tb.Text), "#,##0")
  294. Set_自動彙總1()
  295. End Sub
  296. Private Sub DataGridView3_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 表單2_dgv.CellEndEdit
  297. Dim EU(2) As String
  298. EU(0) = 表單2_dgv("交期開始", e.RowIndex).Value.ToString
  299. If EU(0) = "" Then
  300. Else
  301. 日期2_dtp.Text = EU(0)
  302. 表單2_dgv.Rows(e.RowIndex).Cells("交期開始").Value = Format(日期2_dtp.Value, "yyyy/MM/dd")
  303. End If
  304. EU(1) = 表單2_dgv("交期結束", e.RowIndex).Value.ToString
  305. If EU(1) = "" Then
  306. Else
  307. 日期2_dtp.Text = EU(1)
  308. 表單2_dgv.Rows(e.RowIndex).Cells("交期結束").Value = Format(日期2_dtp.Value, "yyyy/MM/dd")
  309. End If
  310. EU(2) = 表單2_dgv("工廠交期", e.RowIndex).Value.ToString
  311. If EU(2) = "" Then
  312. Else
  313. 日期2_dtp.Text = EU(2)
  314. 表單2_dgv.Rows(e.RowIndex).Cells("工廠交期").Value = Format(日期2_dtp.Value, "yyyy/MM/dd")
  315. End If
  316. End Sub
  317. Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Remark_cb.TextChanged
  318. SQL_DELIVERYADDRESS2()
  319. If dr.Read() Then : DeliveryAddress_tb.Text = dr("DELIVERYADDRESS").ToString : End If : conn.Close()
  320. End Sub
  321. Private Sub Button30_Click(sender As Object, e As EventArgs) Handles 返回訂單控制表_bt.Click
  322. Me.Close()
  323. 列印用SQL = ""
  324. End Sub
  325. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  326. OD(0) = Number_tb.Text : OD(1) = 日期_dtp.Text : OD(2) = Brand_cb.Text : OD(3) = Vendor_tb.Text : OD(4) = Delivery_cb.Text
  327. OD(5) = Terms_cb.Text : OD(6) = 備註_tb.Text
  328. 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
  329. OD(12) = 日期3_dtp.Text : OD(13) = CustomerName_tb.Text : OD(14) = 日期4_dtp.Text : OD(15) = SalesOrder_tb.Text
  330. OD(16) = 日期5_dtp.Text : OD(17) = DeliveryAddress_tb.Text
  331. OD(18) = 訂單號_tb.Text : OD(19) = 工廠_tb.Text : OD(20) = 日期6_dtp.Text : OD(21) = 日期7_dtp.Text
  332. OD(40) = Remark_cb.Text
  333. 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
  334. 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
  335. 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
  336. 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
  337. OD(43) = 合計_tb.Text : OD(44) = 合計1_tb.Text : OD(45) = 訂單屬性_tb.Text
  338. 列印_訂單明細.Show()
  339. End Sub
  340. Private Sub Set_日期格式轉換()
  341. DTPs(0) = 日期_dtp.Text : DTPs(1) = 日期1_dtp.Text : DTPs(2) = 日期3_dtp.Text : DTPs(3) = 日期4_dtp.Text : DTPs(4) = 日期6_dtp.Text
  342. DTPs(5) = 日期7_dtp.Text : DTPs(6) = 日期5_dtp.Text
  343. If DTPs(0) = " " Then : DTPs(0) = "" : Else : DTPs(0) = Format(日期_dtp.Value, "yyyy/MM/dd") : End If
  344. If DTPs(1) = " " Then : DTPs(1) = "" : Else : DTPs(1) = Format(日期1_dtp.Value, "yyyy/MM/dd") : End If
  345. If DTPs(2) = " " Then : DTPs(2) = "" : Else : DTPs(2) = Format(日期3_dtp.Value, "yyyy/MM/dd") : End If
  346. If DTPs(3) = " " Then : DTPs(3) = "" : Else : DTPs(3) = Format(日期4_dtp.Value, "yyyy/MM/dd") : End If
  347. If DTPs(4) = " " Then : DTPs(4) = "" : Else : DTPs(4) = Format(日期6_dtp.Value, "yyyy/MM/dd") : End If
  348. If DTPs(5) = " " Then : DTPs(5) = "" : Else : DTPs(5) = Format(日期7_dtp.Value, "yyyy/MM/dd") : End If
  349. If DTPs(6) = " " Then : DTPs(6) = "" : Else : DTPs(6) = Format(日期5_dtp.Value, "yyyy/MM/dd") : End If
  350. End Sub
  351. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles 資料存檔_bt.Click
  352. Set_日期格式轉換()
  353. SQL_修改訂單明細表抬頭() : conn.Close()
  354. For i As Integer = 0 To 表單2_dgv.Rows.Count - 1
  355. 資料數 = 表單2_dgv.Rows.Count : MyModule1.進度條()
  356. PA8 = 表單2_dgv.Rows(i).Cells("訂單數量").Value : PA9 = 表單2_dgv.Rows(i).Cells("交期開始").Value
  357. PA10 = 表單2_dgv.Rows(i).Cells("交期結束").Value : PA11 = 表單2_dgv.Rows(i).Cells("備註").Value
  358. PA12 = 表單2_dgv.Rows(i).Cells("工廠交期").Value : PA13 = 表單2_dgv.Rows(i).Cells("BUYER").Value
  359. PA14 = 表單2_dgv.Rows(i).Cells("資料流水號").Value
  360. SQL_修改訂單控制表5() : conn.Close()
  361. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  362. For i As Integer = 0 To 表單3_dgv.Rows.Count - 1
  363. 資料數 = 表單3_dgv.Rows.Count : MyModule1.進度條()
  364. PA15 = 表單3_dgv.Rows(i).Cells("4").Value : PA16 = 表單3_dgv.Rows(i).Cells("4.5").Value
  365. PA17 = 表單3_dgv.Rows(i).Cells("5").Value : PA18 = 表單3_dgv.Rows(i).Cells("5.5").Value
  366. PA19 = 表單3_dgv.Rows(i).Cells("6").Value : PA20 = 表單3_dgv.Rows(i).Cells("6.5").Value
  367. PA21 = 表單3_dgv.Rows(i).Cells("7").Value : PA22 = 表單3_dgv.Rows(i).Cells("7.5").Value
  368. PA23 = 表單3_dgv.Rows(i).Cells("8").Value : PA24 = 表單3_dgv.Rows(i).Cells("8.5").Value
  369. PA25 = 表單3_dgv.Rows(i).Cells("9").Value : PA26 = 表單3_dgv.Rows(i).Cells("9.5").Value
  370. PA27 = 表單3_dgv.Rows(i).Cells("10").Value : PA28 = 表單3_dgv.Rows(i).Cells("10.5").Value
  371. PA29 = 表單3_dgv.Rows(i).Cells("11").Value : PA30 = 表單3_dgv.Rows(i).Cells("11.5").Value
  372. PA31 = 表單3_dgv.Rows(i).Cells("12").Value : PA32 = 表單3_dgv.Rows(i).Cells("12.5").Value
  373. PA33 = 表單3_dgv.Rows(i).Cells("13").Value : PA7 = 表單3_dgv.Rows(i).Cells("14").Value
  374. PA4 = 表單3_dgv.Rows(i).Cells("資料流水號").Value
  375. SQL_修改訂單明細表1() : conn.Close()
  376. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  377. MsgBox("存檔完成。")
  378. End Sub
  379. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles 訂單附件導入_bt.Click
  380. Dim NUM1 As Integer
  381. SQL_訂單附件資料1()
  382. If dr.Read() Then : 新流水號3 = dr("附件數") : Else : 新流水號3 = "V00" : End If : conn.Close()
  383. NUM1 = Double.Parse(Strings.Right(新流水號3, 2)) + 1
  384. If NUM1 < 10 Then : 新流水號3 = "V" & "0" & NUM1
  385. ElseIf NUM1 > 9 Then : 新流水號3 = "V" & NUM1
  386. End If
  387. TextBox3.Text = 新流水號3
  388. GroupBox1.Visible = True
  389. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  390. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  391. End If
  392. End Sub
  393. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  394. GroupBox1.Visible = False
  395. End Sub
  396. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  397. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  398. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  399. End If
  400. End Sub
  401. Private Sub TextBox4_DragEnter(sender As Object, e As DragEventArgs) Handles TextBox4.DragEnter
  402. If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  403. Dim files As String()
  404. Try
  405. files = CType(e.Data.GetData(DataFormats.FileDrop), String())
  406. TextBox4.Text = files(files.Length - 1)
  407. Catch ex As Exception
  408. MessageBox.Show(ex.Message)
  409. Return
  410. End Try
  411. End If
  412. Dim STR2 As Integer = 0
  413. TextBox7.Text = TextBox4.Text
  414. If TextBox4.Text = "" Then
  415. Else
  416. For i As Integer = 0 To 9999
  417. Dim STR1 As Integer = Strings.Len(TextBox7.Text)
  418. If Strings.Right((TextBox7.Text), 1) <> "\" Then
  419. STR1 -= 1 : STR2 += 1
  420. If STR1 = 0 Then
  421. TextBox7.Text = ""
  422. TextBox4.Text = ""
  423. i = 9999
  424. Else
  425. TextBox7.Text = Strings.Left((TextBox7.Text), STR1)
  426. End If
  427. Else
  428. TextBox7.Text = Strings.Right((TextBox4.Text), STR2)
  429. TextBox4.Text = TextBox7.Text
  430. i = 9999
  431. End If
  432. Next
  433. End If
  434. End Sub
  435. Private Sub TextBox4_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox4.DragDrop
  436. Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
  437. For Each file As String In files
  438. TextBox4.AppendText(file + Environment.NewLine)
  439. Next
  440. End Sub
  441. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  442. If TextBox3.Text = "" Or TextBox4.Text = "" Then
  443. MsgBox("請注意圖片檔案已準備完畢")
  444. Else
  445. SQL_新增訂單附件資料() : conn.Close()
  446. '---FTP方式刪除檔案----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  447. Dim frq As FtpWebRequest, frp As FtpWebResponse, fcr As NetworkCredential
  448. frq = CType(WebRequest.Create(New Uri(Target1 & TextBox4.Text)), FtpWebRequest)
  449. fcr = New NetworkCredential(FTP帳號, FTP密碼)
  450. frq.Credentials = fcr
  451. frq.Method = WebRequestMethods.Ftp.DeleteFile
  452. frq.UseBinary = True
  453. frp = CType(frq.GetResponse, FtpWebResponse)
  454. frp.Close()
  455. WebBrowser1.Refresh()
  456. '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  457. PictureBox2.Image = Nothing
  458. SQL_訂單附件資料3()
  459. While dr.Read() = True
  460. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  461. Dim oStream As New MemoryStream(bytes) : PictureBox2.Image = Bitmap.FromStream(oStream)
  462. End While
  463. conn.Close() : PictureBox2.SizeMode = 4 : TextBox3.Text = "" : TextBox4.Text = "" : MsgBox("新增完成") : GroupBox1.Visible = False : Set_清單2()
  464. End If
  465. End Sub
  466. Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox2.MouseUp
  467. m_DeltaX = m_MousePosX - e.X
  468. m_DeltaY = m_MousePosY - e.Y
  469. m_Leftx -= m_DeltaX
  470. m_Lefty -= m_DeltaY
  471. Picturemove(sender, e)
  472. Me.Cursor = Cursors.Arrow
  473. End Sub
  474. '@#当鼠标按下时,将鼠标变成手形,并且记录下当前鼠标的位置
  475. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox2.MouseDown
  476. Me.Cursor = Cursors.Hand
  477. m_MousePosX = e.X
  478. m_MousePosY = e.Y
  479. End Sub
  480. '@#根据偏移量计算出的图片位置,重画图片
  481. Private Sub Picturemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  482. Dim myBit As New Bitmap(PictureBox2.Image)
  483. Dim myPicGrh As Graphics = Me.PictureBox2.CreateGraphics
  484. myPicGrh.Clear(Me.PictureBox2.BackColor)
  485. myPicGrh.DrawImageUnscaled(myBit, m_Leftx - 152, m_Lefty)
  486. myBit.Dispose()
  487. myPicGrh.Dispose()
  488. End Sub
  489. Private Sub Button20_Click(sender As Object, e As EventArgs) Handles 放大_bt.Click
  490. Dim image = PictureBox2.Image
  491. Dim g As Graphics = PictureBox2.CreateGraphics
  492. g.DrawImage(image, New Rectangle(0, 0, image.Width * 1.01, image.Height * 1.01))
  493. End Sub
  494. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles 復原_bt.Click
  495. PictureBox2.Refresh()
  496. End Sub
  497. Private Sub Button25_Click(sender As Object, e As EventArgs) Handles 順時鐘90度旋轉_bt.Click
  498. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  499. End Sub
  500. Private Sub Button24_Click(sender As Object, e As EventArgs) Handles 逆時鐘90度旋轉_bt.Click
  501. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate270FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  502. End Sub
  503. Private Sub Button23_Click(sender As Object, e As EventArgs) Handles 水平翻轉_bt.Click
  504. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipY) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  505. End Sub
  506. Private Sub Button21_Click(sender As Object, e As EventArgs) Handles 垂直翻轉_bt.Click
  507. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipX) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  508. End Sub
  509. Private Sub Button26_Click(sender As Object, e As EventArgs) Handles 更新BUYER_bt.Click
  510. For i As Integer = 0 To 表單2_dgv.Rows.Count - 1
  511. 表單2_dgv.Rows(i).Cells("BUYER").Value = Brand_cb.Text
  512. Next
  513. MsgBox("注意還未存檔喔")
  514. End Sub
  515. Private Sub 表單3_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 表單3_dgv.MouseUp
  516. If 表單3_dgv.SelectedCells.Count = 1 Then
  517. 已超出 = False
  518. End If
  519. If 表單3_dgv.SelectedCells.Count > 0 Then
  520. '設定滑鼠點擊DGV時候的範圍,超出範圍時有可能不是數字所以不計算
  521. If 表單3_dgv.SelectedCells(0).ColumnIndex >= 6 And 表單3_dgv.SelectedCells(0).ColumnIndex <= 25 Then
  522. If 已超出 = False Then
  523. Dim x As Double = 0
  524. For i As Integer = 0 To 表單3_dgv.SelectedCells.Count - 1
  525. '表單3_dgv.SelectedCells.Item(i).ColumnIndex + 8 是因為該DGV顯示項與計算像剛好差8格,使用時要注意可直接計算的不需要加數字。
  526. x += Val(表單3_dgv.Rows(表單3_dgv.SelectedCells.Item(i).RowIndex).Cells(表單3_dgv.SelectedCells.Item(i).ColumnIndex).Value)
  527. Next i
  528. '將計算好的資料放置到指定的控件中
  529. WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(x, "#,##0.0")
  530. Else
  531. WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.0")
  532. End If
  533. Else
  534. 已超出 = True
  535. WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.0")
  536. End If
  537. End If
  538. End Sub
  539. End Class