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

量產訂單明細表.vb 56KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.IO
  4. Imports System.Net
  5. Public Class 量產訂單明細表
  6. ReadOnly conn As New SqlConnection
  7. ReadOnly da As New SqlDataAdapter
  8. ReadOnly cmd As New SqlCommand
  9. ReadOnly ds As New DataSet : ReadOnly ds2 As New DataSet : ReadOnly ds3 As New DataSet
  10. Dim dr As SqlDataReader
  11. Dim Date1 As String : Dim Date2 As String : Dim Date3 As String : Dim Date4 As String : Dim Date5 As String : Dim Date6 As String : Dim Date7 As String
  12. ReadOnly DTP(6) As String : Dim 新流水號3 As String
  13. Private m_Leftx As Integer = 152
  14. Private m_Lefty As Integer = 0
  15. Dim m_MousePosX As Integer
  16. Dim m_MousePosY As Integer
  17. Dim m_DeltaX As Integer
  18. Dim m_DeltaY As Integer
  19. Private Sub 基本資料載入()
  20. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  21. SQL1 = "SELECT 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號, 訂單控制表.生產工廠, 工廠控制表.供應商資料, 工廠控制表.供應商地址, " &
  22. "SUM(訂單控制表.訂單數量) AS 訂單數量 FROM 訂單控制表 INNER JOIN 工廠控制表 ON 訂單控制表.生產工廠 = 工廠控制表.工廠 " &
  23. "WHERE (訂單控制表.訂單流水號 LIKE '" & TextBox13.Text & "') " &
  24. "GROUP BY 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號, 訂單控制表.生產工廠, 工廠控制表.供應商資料, 工廠控制表.供應商地址"
  25. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  26. If dr.Read() Then
  27. TextBox1.Text = dr("客戶訂單號").ToString : TextBox2.Text = dr("供應商資料").ToString : TextBox5.Text = dr("供應商地址").ToString
  28. TextBox14.Text = dr("生產工廠").ToString : TextBox51.Text = Format(Val(dr("訂單數量").ToString), "#,##0")
  29. Else : TextBox1.Text = "" : End If : conn.Close()
  30. End Sub
  31. Private Sub Set_DGV1載入前設定()
  32. DataGridView1.DataSource = Nothing : ds.Clear()
  33. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  34. DataGridView1.ColumnHeadersHeight = 25
  35. DataGridView1.AllowUserToAddRows = False
  36. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  37. End Sub
  38. Private Sub Set_DGV1載入後設定()
  39. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  40. End Sub
  41. Private Sub Set_訂單清單()
  42. Set_DGV1載入前設定()
  43. SQL1 = "SELECT 訂單明細表.訂單流水號, 訂單明細表.客戶訂單號, 訂單明細表.ItemNumber, 訂單控制表.GOODBOX AS ProductName,
  44. 訂單明細表.Color, 訂單明細表.DM, 訂單明細表.[4], 訂單明細表.[4.5], 訂單明細表.[5], 訂單明細表.[5.5],
  45. 訂單明細表.[6], 訂單明細表.[6.5], 訂單明細表.[7], 訂單明細表.[7.5], 訂單明細表.[8], 訂單明細表.[8.5], 訂單明細表.[9],
  46. 訂單明細表.[9.5], 訂單明細表.[10], 訂單明細表.[10.5], 訂單明細表.[11], 訂單明細表.[11.5], 訂單明細表.[12],
  47. 訂單明細表.[12.5], 訂單明細表.[13], 訂單明細表.[14],
  48. 訂單明細表.[4] + 訂單明細表.[4.5] + 訂單明細表.[5] + 訂單明細表.[5.5] + 訂單明細表.[6] + 訂單明細表.[6.5] + 訂單明細表.[7]
  49. + 訂單明細表.[7.5] + 訂單明細表.[8] + 訂單明細表.[8.5] + 訂單明細表.[9] + 訂單明細表.[9.5] + 訂單明細表.[10] + 訂單明細表.[10.5]
  50. + 訂單明細表.[11] + 訂單明細表.[11.5] + 訂單明細表.[12] + 訂單明細表.[12.5] + 訂單明細表.[13] + 訂單明細表.[14] AS TOTAL,
  51. 訂單明細表.資料流水號
  52. FROM 訂單明細表 FULL OUTER JOIN
  53. 訂單控制表 ON 訂單明細表.資料流水號 = 訂單控制表.資料流水號
  54. WHERE (訂單明細表.客戶訂單號 LIKE N'" & TextBox1.Text & "') AND (訂單明細表.訂單流水號 LIKE N'" & TextBox13.Text & "')
  55. ORDER BY ProductName, 訂單明細表.Color"
  56. 列印用SQL = SQL1
  57. Set_DGV1載入後設定()
  58. End Sub
  59. Private Sub Set_grid()
  60. DataGridView1.Columns(0).Visible = False : DataGridView1.Columns(1).Visible = False
  61. DataGridView1.Columns(2).FillWeight = 120 : DataGridView1.Columns(3).FillWeight = 150 : DataGridView1.Columns(4).FillWeight = 100 : DataGridView1.Columns(5).FillWeight = 70
  62. DataGridView1.Columns(6).FillWeight = 40 : DataGridView1.Columns(7).FillWeight = 40 : DataGridView1.Columns(8).FillWeight = 40 : DataGridView1.Columns(9).FillWeight = 40
  63. DataGridView1.Columns(10).FillWeight = 40 : DataGridView1.Columns(11).FillWeight = 40 : DataGridView1.Columns(12).FillWeight = 40 : DataGridView1.Columns(13).FillWeight = 40
  64. DataGridView1.Columns(14).FillWeight = 40 : DataGridView1.Columns(15).FillWeight = 40 : DataGridView1.Columns(16).FillWeight = 40 : DataGridView1.Columns(17).FillWeight = 40
  65. DataGridView1.Columns(18).FillWeight = 40 : DataGridView1.Columns(19).FillWeight = 40 : DataGridView1.Columns(20).FillWeight = 40 : DataGridView1.Columns(21).FillWeight = 40
  66. DataGridView1.Columns(22).FillWeight = 40 : DataGridView1.Columns(23).FillWeight = 40 : DataGridView1.Columns(24).FillWeight = 40 : DataGridView1.Columns(25).FillWeight = 40
  67. DataGridView1.Columns(26).FillWeight = 60 : DataGridView1.Columns(27).Visible = False
  68. DataGridView1.Columns(7).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(8).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(9).DefaultCellStyle.Format = "#,##0"
  69. DataGridView1.Columns(10).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(11).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(12).DefaultCellStyle.Format = "#,##0"
  70. DataGridView1.Columns(13).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(14).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(15).DefaultCellStyle.Format = "#,##0"
  71. DataGridView1.Columns(16).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(17).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(18).DefaultCellStyle.Format = "#,##0"
  72. DataGridView1.Columns(19).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(20).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(21).DefaultCellStyle.Format = "#,##0"
  73. DataGridView1.Columns(22).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(23).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(24).DefaultCellStyle.Format = "#,##0"
  74. DataGridView1.Columns(25).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(26).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(6).DefaultCellStyle.Format = "#,##0"
  75. DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
  76. End Sub
  77. Private Sub Set_DGV2載入前設定()
  78. DataGridView2.DataSource = Nothing : ds2.Clear()
  79. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  80. DataGridView2.ColumnHeadersHeight = 25
  81. DataGridView2.AllowUserToAddRows = False
  82. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  83. End Sub
  84. Private Sub Set_DGV2載入後設定()
  85. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView2.DataSource = ds2.Tables(0) : conn.Close() : Set_grid2()
  86. End Sub
  87. Private Sub Set_清單2()
  88. Set_DGV2載入前設定()
  89. SQL1 = "SELECT 訂單流水號, 附件數 FROM 訂單附件資料 WHERE 訂單流水號 LIKE N'" & TextBox13.Text & "' ORDER BY 附件數"
  90. Set_DGV2載入後設定()
  91. End Sub
  92. Private Sub Set_grid2()
  93. DataGridView2.Columns(0).FillWeight = 120 : DataGridView2.Columns(1).FillWeight = 45
  94. End Sub
  95. Private Sub Set_DGV3載入前設定()
  96. DataGridView3.DataSource = Nothing : ds3.Clear()
  97. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  98. DataGridView3.ColumnHeadersHeight = 25
  99. DataGridView3.AllowUserToAddRows = False
  100. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  101. End Sub
  102. Private Sub Set_DGV3載入後設定()
  103. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds3) : DataGridView3.DataSource = ds3.Tables(0) : conn.Close() : Set_grid4()
  104. End Sub
  105. Private Sub Set_清單3()
  106. Set_DGV3載入前設定()
  107. SQL1 = "SELECT 資料流水號, 年份季度, 客戶訂單號, 型體號碼, GOODBOX AS 型體名稱, APMA確認 AS 顏色, TVW AS 楦型, 訂單數量, 工廠回復交期 AS 工廠交期, 客戶交期 AS 交期開始, 客戶交期1 AS 交期結束,
  108. 單價, 總金額, 備註, 生產工廠, 訂單種類, BUYER, CFMSPEC, CFMSAMPLE, TRIAL1, TRIAL2, TRIAL3, TRIAL4, 包裝確認時間, 貼標時間, 裁斷時間, 針車時間, 成型時間, 驗貨時間, 實際離廠日,
  109. 訂單流水號, 明細建檔, LEATHER, LEA_Note, CXL, CXLTime, 出貨數量, PO_S_Date, Requested_XF, Confirm_XF, Revised_XF, Special_Packaging, Remarks, 出貨地, 楦頭號, 材質, 長期試穿,
  110. 面料, 副料, 中底, 鞋墊, 大底, 跟, 工廠進度表備註1, 七號模具, 工廠進度表備註2, 國標測試, 客戶包裝確認, 東莞業務備註, 驗貨報告圖片
  111. FROM 訂單控制表 WHERE 訂單流水號 LIKE N'" & TextBox13.Text & "' ORDER BY GOODBOX, APMA確認, TVW"
  112. Set_DGV3載入後設定()
  113. End Sub
  114. Private Sub Set_grid4()
  115. DataGridView3.Columns(0).FillWeight = 85 : DataGridView3.Columns(1).FillWeight = 70 : DataGridView3.Columns(2).FillWeight = 130 : DataGridView3.Columns(3).FillWeight = 120
  116. DataGridView3.Columns(4).FillWeight = 130 : DataGridView3.Columns(5).FillWeight = 80 : DataGridView3.Columns(6).FillWeight = 50 : DataGridView3.Columns(7).FillWeight = 80
  117. DataGridView3.Columns(8).FillWeight = 90 : DataGridView3.Columns(9).FillWeight = 90 : DataGridView3.Columns(10).FillWeight = 90
  118. DataGridView3.Columns(11).Visible = False : DataGridView3.Columns(12).Visible = False
  119. DataGridView3.Columns(13).FillWeight = 62 : DataGridView3.Columns(14).FillWeight = 80 : DataGridView3.Columns(15).FillWeight = 120 : DataGridView3.Columns(16).FillWeight = 130
  120. DataGridView3.Columns(17).Visible = False : DataGridView3.Columns(18).Visible = False : DataGridView3.Columns(19).Visible = False : DataGridView3.Columns(20).Visible = False
  121. DataGridView3.Columns(21).Visible = False : DataGridView3.Columns(22).Visible = False : DataGridView3.Columns(23).Visible = False : DataGridView3.Columns(24).Visible = False
  122. DataGridView3.Columns(25).Visible = False : DataGridView3.Columns(26).Visible = False : DataGridView3.Columns(27).Visible = False : DataGridView3.Columns(28).Visible = False
  123. DataGridView3.Columns(29).Visible = False : DataGridView3.Columns(30).Visible = False : DataGridView3.Columns(31).Visible = False : DataGridView3.Columns(32).Visible = False
  124. DataGridView3.Columns(33).Visible = False : DataGridView3.Columns(34).Visible = False : DataGridView3.Columns(35).Visible = False : DataGridView3.Columns(36).Visible = False
  125. DataGridView3.Columns(37).Visible = False : DataGridView3.Columns(38).Visible = False : DataGridView3.Columns(39).Visible = False : DataGridView3.Columns(40).Visible = False
  126. DataGridView3.Columns(41).Visible = False : DataGridView3.Columns(42).Visible = False : DataGridView3.Columns(43).Visible = False : DataGridView3.Columns(44).Visible = False
  127. DataGridView3.Columns(45).Visible = False : DataGridView3.Columns(46).Visible = False : DataGridView3.Columns(47).Visible = False : DataGridView3.Columns(48).Visible = False
  128. DataGridView3.Columns(49).Visible = False : DataGridView3.Columns(50).Visible = False : DataGridView3.Columns(51).Visible = False : DataGridView3.Columns(52).Visible = False
  129. DataGridView3.Columns(53).Visible = False : DataGridView3.Columns(54).Visible = False : DataGridView3.Columns(55).Visible = False : DataGridView3.Columns(56).Visible = False
  130. DataGridView3.Columns(57).Visible = False : DataGridView3.Columns(58).Visible = False : DataGridView3.Columns(59).Visible = False
  131. DataGridView3.Columns(7).DefaultCellStyle.Format = "#,##0"
  132. DataGridView3.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  133. DataGridView3.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  134. DataGridView3.EditMode = DataGridViewEditMode.EditOnEnter
  135. End Sub
  136. Private Sub Set_格式設定1()
  137. TextBox1.Enabled = False : TextBox3.Enabled = False : TextBox13.Enabled = False : TextBox14.Enabled = False : TextBox51.Enabled = False : TextBox7.Visible = False
  138. DateTimePicker1.Format = DateTimePickerFormat.Custom : DateTimePicker1.CustomFormat = " "
  139. DateTimePicker2.Format = DateTimePickerFormat.Custom : DateTimePicker2.CustomFormat = " "
  140. DateTimePicker3.Format = DateTimePickerFormat.Custom : DateTimePicker3.CustomFormat = " "
  141. DateTimePicker4.Format = DateTimePickerFormat.Custom : DateTimePicker4.CustomFormat = " "
  142. DateTimePicker5.Format = DateTimePickerFormat.Custom : DateTimePicker5.CustomFormat = " "
  143. DateTimePicker6.Format = DateTimePickerFormat.Custom : DateTimePicker6.CustomFormat = " "
  144. DateTimePicker7.Format = DateTimePickerFormat.Custom : DateTimePicker7.CustomFormat = " "
  145. TextBox8.Text = "" : TextBox9.Text = ""
  146. TextBox10.Text = "" : TextBox11.Text = "" : TextBox12.Text = ""
  147. End Sub
  148. Private Sub Set_自動彙總1()
  149. Dim 加總(20) As Double
  150. 加總(0) = 0 : 加總(1) = 0 : 加總(2) = 0 : 加總(3) = 0 : 加總(4) = 0 : 加總(5) = 0 : 加總(6) = 0 : 加總(7) = 0 : 加總(8) = 0
  151. 加總(9) = 0 : 加總(10) = 0 : 加總(11) = 0 : 加總(12) = 0 : 加總(13) = 0 : 加總(14) = 0 : 加總(15) = 0 : 加總(16) = 0 : 加總(17) = 0 : 加總(18) = 0 : 加總(19) = 0 : 加總(20) = 0
  152. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox56.Text = "0" : Else : 加總(19) += DataGridView1.Rows(i).Cells("4").Value : End If
  153. Next i : TextBox56.Text = Format(Val(加總(19)), "#,##0") : If TextBox56.Text = "0" Then : TextBox56.ForeColor = Color.Black : Else : TextBox56.ForeColor = Color.Red : End If
  154. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox57.Text = "0" : Else : 加總(20) += DataGridView1.Rows(i).Cells("4.5").Value : End If
  155. Next i : TextBox57.Text = Format(Val(加總(20)), "#,##0") : If TextBox57.Text = "0" Then : TextBox57.ForeColor = Color.Black : Else : TextBox57.ForeColor = Color.Red : End If
  156. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox15.Text = "0" : Else : 加總(0) += DataGridView1.Rows(i).Cells("5").Value : End If
  157. Next i : TextBox15.Text = Format(Val(加總(0)), "#,##0") : If TextBox15.Text = "0" Then : TextBox15.ForeColor = Color.Black : Else : TextBox15.ForeColor = Color.Red : End If
  158. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox16.Text = "0" : Else : 加總(1) += DataGridView1.Rows(i).Cells("5.5").Value : End If
  159. Next i : TextBox16.Text = Format(Val(加總(1)), "#,##0") : If TextBox16.Text = "0" Then : TextBox16.ForeColor = Color.Black : Else : TextBox16.ForeColor = Color.Red : End If
  160. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox17.Text = "0" : Else : 加總(2) += DataGridView1.Rows(i).Cells("6").Value : End If
  161. Next i : TextBox17.Text = Format(Val(加總(2)), "#,##0") : If TextBox17.Text = "0" Then : TextBox17.ForeColor = Color.Black : Else : TextBox17.ForeColor = Color.Red : End If
  162. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox18.Text = "0" : Else : 加總(3) += DataGridView1.Rows(i).Cells("6.5").Value : End If
  163. Next i : TextBox18.Text = Format(Val(加總(3)), "#,##0") : If TextBox18.Text = "0" Then : TextBox18.ForeColor = Color.Black : Else : TextBox18.ForeColor = Color.Red : End If
  164. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox19.Text = "0" : Else : 加總(4) += DataGridView1.Rows(i).Cells("7").Value : End If
  165. Next i : TextBox19.Text = Format(Val(加總(4)), "#,##0") : If TextBox19.Text = "0" Then : TextBox19.ForeColor = Color.Black : Else : TextBox19.ForeColor = Color.Red : End If
  166. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox20.Text = "0" : Else : 加總(5) += DataGridView1.Rows(i).Cells("7.5").Value : End If
  167. Next i : TextBox20.Text = Format(Val(加總(5)), "#,##0") : If TextBox20.Text = "0" Then : TextBox20.ForeColor = Color.Black : Else : TextBox20.ForeColor = Color.Red : End If
  168. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox21.Text = "0" : Else : 加總(6) += DataGridView1.Rows(i).Cells("8").Value : End If
  169. Next i : TextBox21.Text = Format(Val(加總(6)), "#,##0") : If TextBox21.Text = "0" Then : TextBox21.ForeColor = Color.Black : Else : TextBox21.ForeColor = Color.Red : End If
  170. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox22.Text = "0" : Else : 加總(7) += DataGridView1.Rows(i).Cells("8.5").Value : End If
  171. Next i : TextBox22.Text = Format(Val(加總(7)), "#,##0") : If TextBox22.Text = "0" Then : TextBox22.ForeColor = Color.Black : Else : TextBox22.ForeColor = Color.Red : End If
  172. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox23.Text = "0" : Else : 加總(8) += DataGridView1.Rows(i).Cells("9").Value : End If
  173. Next i : TextBox23.Text = Format(Val(加總(8)), "#,##0") : If TextBox23.Text = "0" Then : TextBox23.ForeColor = Color.Black : Else : TextBox23.ForeColor = Color.Red : End If
  174. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox24.Text = "0" : Else : 加總(9) += DataGridView1.Rows(i).Cells("9.5").Value : End If
  175. Next i : TextBox24.Text = Format(Val(加總(9)), "#,##0") : If TextBox24.Text = "0" Then : TextBox24.ForeColor = Color.Black : Else : TextBox24.ForeColor = Color.Red : End If
  176. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox25.Text = "0" : Else : 加總(10) += DataGridView1.Rows(i).Cells("10").Value : End If
  177. Next i : TextBox25.Text = Format(Val(加總(10)), "#,##0") : If TextBox25.Text = "0" Then : TextBox25.ForeColor = Color.Black : Else : TextBox25.ForeColor = Color.Red : End If
  178. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox26.Text = "0" : Else : 加總(11) += DataGridView1.Rows(i).Cells("10.5").Value : End If
  179. Next i : TextBox26.Text = Format(Val(加總(11)), "#,##0") : If TextBox26.Text = "0" Then : TextBox26.ForeColor = Color.Black : Else : TextBox26.ForeColor = Color.Red : End If
  180. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox27.Text = "0" : Else : 加總(12) += DataGridView1.Rows(i).Cells("11").Value : End If
  181. Next i : TextBox27.Text = Format(Val(加總(12)), "#,##0") : If TextBox27.Text = "0" Then : TextBox27.ForeColor = Color.Black : Else : TextBox27.ForeColor = Color.Red : End If
  182. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox53.Text = "0" : Else : 加總(17) += DataGridView1.Rows(i).Cells("11.5").Value : End If
  183. Next i : TextBox53.Text = Format(Val(加總(17)), "#,##0") : If TextBox53.Text = "0" Then : TextBox53.ForeColor = Color.Black : Else : TextBox53.ForeColor = Color.Red : End If
  184. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox28.Text = "0" : Else : 加總(13) += DataGridView1.Rows(i).Cells("12").Value : End If
  185. Next i : TextBox28.Text = Format(Val(加總(13)), "#,##0") : If TextBox28.Text = "0" Then : TextBox28.ForeColor = Color.Black : Else : TextBox28.ForeColor = Color.Red : End If
  186. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox54.Text = "0" : Else : 加總(18) += DataGridView1.Rows(i).Cells("12.5").Value : End If
  187. Next i : TextBox54.Text = Format(Val(加總(18)), "#,##0") : If TextBox54.Text = "0" Then : TextBox54.ForeColor = Color.Black : Else : TextBox54.ForeColor = Color.Red : End If
  188. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox29.Text = "0" : Else : 加總(14) += DataGridView1.Rows(i).Cells("13").Value : End If
  189. Next i : TextBox29.Text = Format(Val(加總(14)), "#,##0") : If TextBox29.Text = "0" Then : TextBox29.ForeColor = Color.Black : Else : TextBox29.ForeColor = Color.Red : End If
  190. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : If DataGridView1.RowCount = 0 Then : TextBox30.Text = "0" : Else : 加總(15) += DataGridView1.Rows(i).Cells("14").Value : End If
  191. Next i : TextBox30.Text = Format(Val(加總(15)), "#,##0") : If TextBox30.Text = "0" Then : TextBox30.ForeColor = Color.Black : Else : TextBox30.ForeColor = Color.Red : End If
  192. 加總(16) = 加總(0) + 加總(1) + 加總(2) + 加總(3) + 加總(4) + 加總(5) + 加總(6) + 加總(7) + 加總(8) + 加總(9) + 加總(10) + 加總(11) + 加總(12) + 加總(13) + 加總(14) + 加總(15) + 加總(17) + 加總(18) +
  193. 加總(19) + 加總(20)
  194. TextBox31.Text = Format(Val(加總(16)), "#,##0")
  195. 加總(16) = 0
  196. If TextBox31.Text = "0" Then : TextBox31.ForeColor = Color.Black : Else : TextBox31.ForeColor = Color.Blue : End If
  197. End Sub
  198. Private Sub 下拉表單資料載入1()
  199. conn.Close()
  200. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  201. SQL1 = "SELECT 客戶簡稱 FROM 客戶控制表"
  202. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox1.Items.Clear()
  203. While (dr.Read()) : ComboBox1.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
  204. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  205. SQL1 = "SELECT MODEOFDELIVERY FROM MODEOFDELIVERY"
  206. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox4.Items.Clear()
  207. While (dr.Read()) : ComboBox4.Items.Add(dr("MODEOFDELIVERY")) : End While : conn.Close()
  208. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  209. SQL1 = "SELECT DELIVERYTERMS FROM DELIVERYTERMS"
  210. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox5.Items.Clear()
  211. While (dr.Read()) : ComboBox5.Items.Add(dr("DELIVERYTERMS")) : End While : conn.Close()
  212. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  213. SQL1 = "SELECT FOB FROM 港口清單"
  214. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox6.Items.Clear()
  215. While (dr.Read()) : ComboBox6.Items.Add(dr("FOB")) : End While : conn.Close()
  216. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  217. SQL1 = "SELECT TOPORT FROM TOPORT ORDER BY TOPORT"
  218. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox7.Items.Clear()
  219. While (dr.Read()) : ComboBox7.Items.Add(dr("TOPORT")) : End While : conn.Close()
  220. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  221. SQL1 = "SELECT REMARK FROM DELIVERYADDRESS ORDER BY REMARK"
  222. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader : ComboBox8.Items.Clear()
  223. While (dr.Read()) : ComboBox8.Items.Add(dr("REMARK")) : End While : conn.Close()
  224. End Sub
  225. Private Sub 量產訂單明細表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  226. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True : Set_格式設定1()
  227. Target1 = Target & AA(1) & "/"
  228. WebBrowser1.Url = New Uri(Target1)
  229. GroupBox1.Visible = False : DateTimePicker8.Visible = False
  230. If PA = "" Then : Else
  231. TextBox13.Text = PA
  232. 下拉表單資料載入1()
  233. 基本資料載入()
  234. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  235. SQL1 = "SELECT 訂單明細表抬頭.客戶訂單號, 訂單明細表抬頭.訂單流水號, 訂單明細表抬頭.ModeOfDelivery, 訂單明細表抬頭.DeliveryTerms, 訂單明細表抬頭.OrgShipDate, " &
  236. "訂單明細表抬頭.FromPort, 訂單明細表抬頭.ToPort, 訂單明細表抬頭.ShippingCarrier, 訂單明細表抬頭.VendorReference, 訂單明細表抬頭.ModifiedDate, 訂單明細表抬頭.CustomerName, " &
  237. "訂單明細表抬頭.ShipDate, 訂單明細表抬頭.SalesOrder, 訂單明細表抬頭.DeliveryAddress, 訂單明細表抬頭.下單日, 訂單明細表抬頭.交期, 訂單明細表抬頭.ETADate, 訂單明細表抬頭.CreatedDate, " &
  238. "訂單明細表抬頭.Brand, 訂單明細表抬頭.CustomerRequisition, DELIVERYADDRESS.REMARK FROM 訂單明細表抬頭 INNER JOIN DELIVERYADDRESS ON 訂單明細表抬頭.DeliveryAddress = " &
  239. "DELIVERYADDRESS.DELIVERYADDRESS WHERE (訂單明細表抬頭.客戶訂單號 LIKE '" & TextBox1.Text & "') AND (訂單明細表抬頭.訂單流水號 LIKE '" & TextBox13.Text & "')"
  240. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  241. If dr.Read() Then
  242. ComboBox4.Text = dr("ModeOfDelivery").ToString : ComboBox5.Text = dr("DeliveryTerms").ToString : ComboBox6.Text = dr("FromPort").ToString
  243. ComboBox7.Text = dr("ToPort").ToString : TextBox8.Text = dr("ShippingCarrier").ToString : TextBox9.Text = dr("VendorReference").ToString
  244. TextBox10.Text = dr("CustomerName").ToString : TextBox11.Text = dr("SalesOrder").ToString : TextBox12.Text = dr("DeliveryAddress").ToString
  245. ComboBox1.Text = dr("Brand").ToString : TextBox6.Text = dr("CustomerRequisition").ToString
  246. Date1 = dr("CreatedDate").ToString : Date2 = dr("OrgShipDate").ToString : Date3 = dr("ModifiedDate").ToString
  247. Date4 = dr("ShipDate").ToString : Date5 = dr("下單日").ToString : Date6 = dr("交期").ToString : Date7 = dr("ETADate").ToString
  248. If Date1 = " " Or Date1 = "" Then : Else : DateTimePicker1.Format = DateTimePickerFormat.Short : DateTimePicker1.Text = dr("CreatedDate").ToString : End If
  249. If Date2 = " " Or Date2 = "" Then : Else : DateTimePicker2.Format = DateTimePickerFormat.Short : DateTimePicker2.Text = dr("OrgShipDate").ToString : End If
  250. If Date3 = " " Or Date3 = "" Then : Else : DateTimePicker3.Format = DateTimePickerFormat.Short : DateTimePicker3.Text = dr("ModifiedDate").ToString : End If
  251. If Date4 = " " Or Date4 = "" Then : Else : DateTimePicker4.Format = DateTimePickerFormat.Short : DateTimePicker4.Text = dr("ShipDate").ToString : End If
  252. If Date5 = " " Or Date5 = "" Then : Else : DateTimePicker5.Format = DateTimePickerFormat.Short : DateTimePicker5.Text = dr("下單日").ToString : End If
  253. If Date6 = " " Or Date6 = "" Then : Else : DateTimePicker6.Format = DateTimePickerFormat.Short : DateTimePicker6.Text = dr("交期").ToString : End If
  254. If Date7 = " " Or Date7 = "" Then : Else : DateTimePicker7.Format = DateTimePickerFormat.Short : DateTimePicker7.Text = dr("ETADate").ToString : End If
  255. ComboBox8.Text = dr("REMARK").ToString
  256. End If
  257. conn.Close()
  258. Set_訂單清單() : Set_自動彙總1() : Set_grid() : Set_清單3() : Set_清單2()
  259. TextBox32.Text = DataGridView3.Rows(0).Cells("CFMSPEC").Value
  260. PictureBox1.Image = Nothing : conn.Close()
  261. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  262. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(0).Cells("型體號碼").Value & "' AND 類別 LIKE N'設計圖'"
  263. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  264. If dr.Read() Then
  265. PictureBox1.Image = Nothing : conn.Close()
  266. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  267. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(0).Cells("型體號碼").Value & "' AND 類別 LIKE N'設計圖'"
  268. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  269. While dr.Read() = True
  270. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  271. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  272. End While
  273. conn.Close()
  274. Else
  275. PictureBox1.Image = Nothing : conn.Close()
  276. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  277. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(0).Cells("型體號碼").Value & "'"
  278. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  279. If dr.Read() Then
  280. PictureBox1.Image = Nothing : conn.Close()
  281. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  282. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(0).Cells("型體號碼").Value & "'"
  283. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  284. While dr.Read() = True
  285. Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  286. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  287. End While
  288. conn.Close()
  289. Else
  290. PictureBox1.Image = Nothing : conn.Close()
  291. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  292. SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView3.Rows(0).Cells("型體號碼").Value & "'"
  293. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  294. If dr.Read() Then
  295. PictureBox1.Image = Nothing : conn.Close()
  296. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  297. SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView3.Rows(0).Cells("型體號碼").Value & "'"
  298. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  299. While dr.Read() = True
  300. Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  301. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  302. End While
  303. conn.Close()
  304. Else
  305. conn.Close()
  306. End If
  307. End If
  308. End If : PictureBox1.SizeMode = 4
  309. 列印用SQL1 = TextBox13.Text
  310. End If : PA = ""
  311. End Sub
  312. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  313. PictureBox2.Image = Nothing : conn.Close()
  314. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  315. SQL1 = "SELECT TOP(1) 圖片 FROM 訂單附件資料 WHERE 訂單流水號 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("訂單流水號").Value & "' AND 附件數 LIKE N'" & DataGridView2.Rows(e.RowIndex).Cells("附件數").Value & "'"
  316. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  317. While dr.Read() = True
  318. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  319. Dim oStream As New MemoryStream(bytes) : PictureBox2.Image = Bitmap.FromStream(oStream)
  320. End While
  321. conn.Close()
  322. PictureBox2.SizeMode = 4
  323. End Sub
  324. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
  325. If e.RowIndex = -1 Then : Else
  326. PictureBox1.Image = Nothing : conn.Close()
  327. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  328. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(e.RowIndex).Cells("型體號碼").Value & "' AND 類別 LIKE N'設計圖'"
  329. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  330. If dr.Read() Then
  331. PictureBox1.Image = Nothing : conn.Close()
  332. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  333. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(e.RowIndex).Cells("型體號碼").Value & "' AND 類別 LIKE N'設計圖'"
  334. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  335. While dr.Read() = True
  336. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  337. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  338. End While
  339. conn.Close()
  340. Else
  341. PictureBox1.Image = Nothing : conn.Close()
  342. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  343. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
  344. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  345. If dr.Read() Then
  346. PictureBox1.Image = Nothing : conn.Close()
  347. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  348. SQL1 = "SELECT TOP(1) 圖片 FROM 鞋型圖片資料庫 WHERE 形體號 LIKE N'" & DataGridView3.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
  349. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  350. While dr.Read() = True
  351. Dim unused1 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  352. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  353. End While
  354. conn.Close()
  355. Else
  356. PictureBox1.Image = Nothing : conn.Close()
  357. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  358. SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView3.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
  359. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  360. If dr.Read() Then
  361. PictureBox1.Image = Nothing : conn.Close()
  362. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  363. SQL1 = "SELECT 圖片 FROM 鞋樣素描圖控制表 WHERE 型體編號 LIKE N'" & DataGridView3.Rows(e.RowIndex).Cells("型體號碼").Value & "'"
  364. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  365. While dr.Read() = True
  366. Dim unused2 As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  367. Dim oStream As New MemoryStream(bytes) : PictureBox1.Image = Bitmap.FromStream(oStream)
  368. End While
  369. conn.Close()
  370. Else
  371. conn.Close()
  372. End If
  373. End If
  374. End If : PictureBox1.SizeMode = 4
  375. End If
  376. End Sub
  377. Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
  378. TextBox51.Text = "0"
  379. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  380. DataGridView3.Rows(i).Cells("訂單數量").Value = DataGridView1.Rows(i).Cells("4").Value + DataGridView1.Rows(i).Cells("4.5").Value + DataGridView1.Rows(i).Cells("5").Value +
  381. DataGridView1.Rows(i).Cells("5.5").Value + DataGridView1.Rows(i).Cells("6").Value + DataGridView1.Rows(i).Cells("6.5").Value + DataGridView1.Rows(i).Cells("7").Value +
  382. DataGridView1.Rows(i).Cells("7.5").Value + DataGridView1.Rows(i).Cells("8").Value + DataGridView1.Rows(i).Cells("8.5").Value + DataGridView1.Rows(i).Cells("9").Value +
  383. DataGridView1.Rows(i).Cells("9.5").Value + DataGridView1.Rows(i).Cells("10").Value + DataGridView1.Rows(i).Cells("10.5").Value + DataGridView1.Rows(i).Cells("11").Value +
  384. DataGridView1.Rows(i).Cells("11.5").Value + DataGridView1.Rows(i).Cells("12").Value + DataGridView1.Rows(i).Cells("12.5").Value + DataGridView1.Rows(i).Cells("13").Value +
  385. DataGridView1.Rows(i).Cells("14").Value
  386. DataGridView1.Rows(i).Cells("TOTAL").Value = DataGridView3.Rows(i).Cells("訂單數量").Value
  387. Next i
  388. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  389. TextBox51.Text = Val(TextBox51.Text) + DataGridView3.Rows(i).Cells("訂單數量").Value
  390. Next i
  391. TextBox51.Text = Format(Val(TextBox51.Text), "#,##0")
  392. Set_自動彙總1()
  393. End Sub
  394. Private Sub DataGridView3_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellEndEdit
  395. Dim EU(2) As String
  396. EU(0) = DataGridView3("交期開始", e.RowIndex).Value.ToString
  397. If EU(0) = "" Then
  398. Else
  399. DateTimePicker8.Text = EU(0)
  400. DataGridView3.Rows(e.RowIndex).Cells("交期開始").Value = Format(DateTimePicker8.Value, "yyyy/MM/dd")
  401. End If
  402. EU(1) = DataGridView3("交期結束", e.RowIndex).Value.ToString
  403. If EU(1) = "" Then
  404. Else
  405. DateTimePicker8.Text = EU(1)
  406. DataGridView3.Rows(e.RowIndex).Cells("交期結束").Value = Format(DateTimePicker8.Value, "yyyy/MM/dd")
  407. End If
  408. EU(2) = DataGridView3("工廠交期", e.RowIndex).Value.ToString
  409. If EU(2) = "" Then
  410. Else
  411. DateTimePicker8.Text = EU(2)
  412. DataGridView3.Rows(e.RowIndex).Cells("工廠交期").Value = Format(DateTimePicker8.Value, "yyyy/MM/dd")
  413. End If
  414. End Sub
  415. Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox8.TextChanged
  416. conn.Close()
  417. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  418. SQL1 = "SELECT DELIVERYADDRESS FROM DELIVERYADDRESS WHERE REMARK LIKE '" & ComboBox8.Text & "'"
  419. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  420. If dr.Read() Then : TextBox12.Text = dr("DELIVERYADDRESS").ToString : End If : conn.Close()
  421. End Sub
  422. Private Sub Button30_Click(sender As Object, e As EventArgs) Handles Button30.Click
  423. Me.Close()
  424. 列印用SQL = ""
  425. End Sub
  426. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  427. OD(0) = TextBox1.Text : OD(1) = DateTimePicker1.Text : OD(2) = ComboBox1.Text : OD(3) = TextBox2.Text : OD(4) = ComboBox4.Text
  428. OD(5) = ComboBox5.Text : OD(6) = TextBox5.Text
  429. OD(7) = DateTimePicker2.Text : OD(8) = ComboBox6.Text : OD(9) = ComboBox7.Text : OD(10) = TextBox8.Text : OD(11) = TextBox9.Text
  430. OD(12) = DateTimePicker3.Text : OD(13) = TextBox10.Text : OD(14) = DateTimePicker4.Text : OD(15) = TextBox11.Text
  431. OD(16) = DateTimePicker7.Text : OD(17) = TextBox12.Text
  432. OD(18) = TextBox13.Text : OD(19) = TextBox14.Text : OD(20) = DateTimePicker5.Text : OD(21) = DateTimePicker6.Text
  433. OD(40) = ComboBox8.Text
  434. OD(22) = TextBox15.Text : OD(23) = TextBox16.Text : OD(24) = TextBox17.Text : OD(25) = TextBox18.Text : OD(26) = TextBox19.Text
  435. OD(27) = TextBox20.Text : OD(28) = TextBox21.Text : OD(29) = TextBox22.Text : OD(30) = TextBox23.Text : OD(31) = TextBox24.Text
  436. OD(32) = TextBox25.Text : OD(33) = TextBox26.Text : OD(34) = TextBox27.Text : OD(35) = TextBox28.Text : OD(36) = TextBox29.Text
  437. OD(37) = TextBox30.Text : OD(38) = TextBox31.Text : OD(39) = TextBox6.Text : OD(41) = TextBox53.Text : OD(42) = TextBox54.Text
  438. OD(43) = TextBox56.Text : OD(44) = TextBox57.Text : OD(45) = TextBox32.Text
  439. 列印_訂單明細.Show()
  440. End Sub
  441. Private Sub Set_日期格式轉換()
  442. DTP(0) = DateTimePicker1.Text : DTP(1) = DateTimePicker2.Text : DTP(2) = DateTimePicker3.Text : DTP(3) = DateTimePicker4.Text : DTP(4) = DateTimePicker5.Text
  443. DTP(5) = DateTimePicker6.Text : DTP(6) = DateTimePicker7.Text
  444. If DTP(0) = " " Then : DTP(0) = "" : Else : DTP(0) = Format(DateTimePicker1.Value, "yyyy/MM/dd") : End If
  445. If DTP(1) = " " Then : DTP(1) = "" : Else : DTP(1) = Format(DateTimePicker2.Value, "yyyy/MM/dd") : End If
  446. If DTP(2) = " " Then : DTP(2) = "" : Else : DTP(2) = Format(DateTimePicker3.Value, "yyyy/MM/dd") : End If
  447. If DTP(3) = " " Then : DTP(3) = "" : Else : DTP(3) = Format(DateTimePicker4.Value, "yyyy/MM/dd") : End If
  448. If DTP(4) = " " Then : DTP(4) = "" : Else : DTP(4) = Format(DateTimePicker5.Value, "yyyy/MM/dd") : End If
  449. If DTP(5) = " " Then : DTP(5) = "" : Else : DTP(5) = Format(DateTimePicker6.Value, "yyyy/MM/dd") : End If
  450. If DTP(6) = " " Then : DTP(6) = "" : Else : DTP(6) = Format(DateTimePicker7.Value, "yyyy/MM/dd") : End If
  451. End Sub
  452. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  453. Set_日期格式轉換()
  454. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  455. SQL1 = "UPDATE 訂單明細表抬頭 SET ModeOfDelivery = N'" & ComboBox4.Text & "', DeliveryTerms = N'" & ComboBox5.Text & "', FromPort = N'" & ComboBox6.Text & "', ToPort = N'" & ComboBox7.Text & "',
  456. 工廠 = N'" & TextBox14.Text & "', DeliveryAddress = N'" & TextBox12.Text & "', CustomerRequisition = N'" & TextBox6.Text & "', OrgShipDate = N'" & DTP(1) & "',
  457. ShippingCarrier = N'" & TextBox8.Text & "', VendorReference = N'" & TextBox9.Text & "', ModifiedDate = N'" & DTP(2) & "', ShipDate = N'" & DTP(3) & "',
  458. SalesOrder = N'" & TextBox11.Text & "', CustomerName = N'" & TextBox10.Text & "', 下單日 = N'" & DTP(4) & "', 交期 = N'" & DTP(5) & "', ETADate = N'" & DTP(6) & "',
  459. CreatedDate = N'" & DTP(0) & "', Brand = N'" & ComboBox1.Text & "'
  460. WHERE (訂單流水號 LIKE N'" & TextBox13.Text & "')"
  461. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  462. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  463. 資料數 = DataGridView3.Rows.Count : MyModule1.進度條()
  464. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  465. SQL1 = "UPDATE 訂單控制表 SET 訂單數量 = N'" & DataGridView3.Rows(i).Cells("訂單數量").Value & "', 客戶交期 = N'" & DataGridView3.Rows(i).Cells("交期開始").Value &
  466. "', 客戶交期1 = N'" & DataGridView3.Rows(i).Cells("交期結束").Value & "', 備註 = N'" & DataGridView3.Rows(i).Cells("備註").Value &
  467. "', 工廠回復交期 = N'" & DataGridView3.Rows(i).Cells("工廠交期").Value & "', BUYER = N'" & DataGridView3.Rows(i).Cells("BUYER").Value & "'
  468. WHERE (資料流水號 LIKE N'" & DataGridView3.Rows(i).Cells("資料流水號").Value & "')"
  469. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  470. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  471. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  472. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  473. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  474. SQL1 = "UPDATE 訂單明細表 SET [4] = N'" & DataGridView1.Rows(i).Cells("4").Value & "', [4.5] = N'" & DataGridView1.Rows(i).Cells("4.5").Value &
  475. "', [5] = N'" & DataGridView1.Rows(i).Cells("5").Value & "', [5.5] = N'" & DataGridView1.Rows(i).Cells("5.5").Value &
  476. "', [6] = N'" & DataGridView1.Rows(i).Cells("6").Value & "', [6.5] = N'" & DataGridView1.Rows(i).Cells("6.5").Value &
  477. "', [7] = N'" & DataGridView1.Rows(i).Cells("7").Value & "', [7.5] = N'" & DataGridView1.Rows(i).Cells("7.5").Value &
  478. "', [8] = N'" & DataGridView1.Rows(i).Cells("8").Value & "', [8.5] = N'" & DataGridView1.Rows(i).Cells("8.5").Value &
  479. "', [9] = N'" & DataGridView1.Rows(i).Cells("9").Value & "', [9.5] = N'" & DataGridView1.Rows(i).Cells("9.5").Value &
  480. "', [10] = N'" & DataGridView1.Rows(i).Cells("10").Value & "', [10.5] = N'" & DataGridView1.Rows(i).Cells("10.5").Value &
  481. "', [11] = N'" & DataGridView1.Rows(i).Cells("11").Value & "', [11.5] = N'" & DataGridView1.Rows(i).Cells("11.5").Value &
  482. "', [12] = N'" & DataGridView1.Rows(i).Cells("12").Value & "', [12.5] = N'" & DataGridView1.Rows(i).Cells("12.5").Value &
  483. "', [13] = N'" & DataGridView1.Rows(i).Cells("13").Value & "', [14] = N'" & DataGridView1.Rows(i).Cells("14").Value & "'
  484. WHERE (資料流水號 LIKE N'" & DataGridView1.Rows(i).Cells("資料流水號").Value & "')"
  485. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  486. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  487. MsgBox("存檔完成。")
  488. End Sub
  489. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  490. Dim NUM1 As Integer
  491. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  492. SQL1 = "SELECT 附件數 FROM 訂單附件資料 WHERE 訂單流水號 LIKE N'" & TextBox13.Text & "' ORDER BY 附件數 DESC"
  493. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  494. If dr.Read() Then : 新流水號3 = dr("附件數") : Else : 新流水號3 = "V00" : End If : conn.Close()
  495. NUM1 = Double.Parse(Strings.Right(新流水號3, 2)) + 1
  496. If NUM1 < 10 Then : 新流水號3 = "V" & "0" & NUM1
  497. ElseIf NUM1 > 9 Then : 新流水號3 = "V" & NUM1
  498. End If
  499. TextBox3.Text = 新流水號3
  500. GroupBox1.Visible = True
  501. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  502. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  503. End If
  504. End Sub
  505. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  506. GroupBox1.Visible = False
  507. End Sub
  508. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  509. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  510. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  511. End If
  512. End Sub
  513. Private Sub TextBox4_DragEnter(sender As Object, e As DragEventArgs) Handles TextBox4.DragEnter
  514. If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  515. Dim files As String()
  516. Try
  517. files = CType(e.Data.GetData(DataFormats.FileDrop), String())
  518. TextBox4.Text = files(files.Length - 1)
  519. Catch ex As Exception
  520. MessageBox.Show(ex.Message)
  521. Return
  522. End Try
  523. End If
  524. Dim STR2 As Integer = 0
  525. TextBox7.Text = TextBox4.Text
  526. If TextBox4.Text = "" Then
  527. Else
  528. For i As Integer = 0 To 9999
  529. Dim STR1 As Integer = Strings.Len(TextBox7.Text)
  530. If Strings.Right((TextBox7.Text), 1) <> "\" Then
  531. STR1 -= 1 : STR2 += 1
  532. If STR1 = 0 Then
  533. TextBox7.Text = ""
  534. TextBox4.Text = ""
  535. i = 9999
  536. Else
  537. TextBox7.Text = Strings.Left((TextBox7.Text), STR1)
  538. End If
  539. Else
  540. TextBox7.Text = Strings.Right((TextBox4.Text), STR2)
  541. TextBox4.Text = TextBox7.Text
  542. i = 9999
  543. End If
  544. Next
  545. End If
  546. End Sub
  547. Private Sub TextBox4_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox4.DragDrop
  548. Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
  549. For Each file As String In files
  550. TextBox4.AppendText(file + Environment.NewLine)
  551. Next
  552. End Sub
  553. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  554. If TextBox3.Text = "" Or TextBox4.Text = "" Then
  555. MsgBox("請注意圖片檔案已準備完畢")
  556. Else
  557. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  558. SQL1 = "INSERT INTO 訂單附件資料 (訂單流水號, 附件數, 圖片) SELECT N'" & TextBox13.Text & "',N'" & TextBox3.Text &
  559. "', BULKCOLUMN FROM OPENROWSET ( BULK '" & FTP實體位置 & AA(1) & "\" & TextBox4.Text & "', SINGLE_BLOB) AS EMPLOYEEPICTURE"
  560. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  561. '---FTP方式刪除檔案----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  562. Dim frq As FtpWebRequest, frp As FtpWebResponse, fcr As NetworkCredential
  563. frq = CType(WebRequest.Create(New Uri(Target1 & TextBox4.Text)), FtpWebRequest)
  564. fcr = New NetworkCredential(FTP帳號, FTP密碼)
  565. frq.Credentials = fcr
  566. frq.Method = WebRequestMethods.Ftp.DeleteFile
  567. frq.UseBinary = True
  568. frp = CType(frq.GetResponse, FtpWebResponse)
  569. frp.Close()
  570. WebBrowser1.Refresh()
  571. '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  572. PictureBox2.Image = Nothing : conn.Close()
  573. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  574. SQL1 = "SELECT TOP(1) 圖片 FROM 訂單附件資料 WHERE 訂單流水號 LIKE N'" & TextBox13.Text & "' AND 附件數 LIKE N'" & TextBox3.Text & "'"
  575. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  576. While dr.Read() = True
  577. Dim unused As Byte() = New Byte(-1) {} : Dim bytes As Byte() = DirectCast(dr.Item("圖片"), Byte())
  578. Dim oStream As New MemoryStream(bytes) : PictureBox2.Image = Bitmap.FromStream(oStream)
  579. End While
  580. conn.Close() : PictureBox2.SizeMode = 4 : TextBox3.Text = "" : TextBox4.Text = "" : MsgBox("新增完成") : GroupBox1.Visible = False : Set_清單2()
  581. End If
  582. End Sub
  583. Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox2.MouseUp
  584. m_DeltaX = m_MousePosX - e.X
  585. m_DeltaY = m_MousePosY - e.Y
  586. m_Leftx -= m_DeltaX
  587. m_Lefty -= m_DeltaY
  588. Picturemove(sender, e)
  589. Me.Cursor = Cursors.Arrow
  590. End Sub
  591. '@#当鼠标按下时,将鼠标变成手形,并且记录下当前鼠标的位置
  592. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox2.MouseDown
  593. Me.Cursor = Cursors.Hand
  594. m_MousePosX = e.X
  595. m_MousePosY = e.Y
  596. End Sub
  597. '@#根据偏移量计算出的图片位置,重画图片
  598. Private Sub Picturemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  599. Dim myBit As New Bitmap(PictureBox2.Image)
  600. Dim myPicGrh As Graphics = Me.PictureBox2.CreateGraphics
  601. myPicGrh.Clear(Me.PictureBox2.BackColor)
  602. myPicGrh.DrawImageUnscaled(myBit, m_Leftx - 152, m_Lefty)
  603. myBit.Dispose()
  604. myPicGrh.Dispose()
  605. End Sub
  606. Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
  607. Dim image = PictureBox2.Image
  608. Dim g As Graphics = PictureBox2.CreateGraphics
  609. g.DrawImage(image, New Rectangle(0, 0, image.Width * 1.01, image.Height * 1.01))
  610. End Sub
  611. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  612. PictureBox2.Refresh()
  613. End Sub
  614. Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
  615. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  616. End Sub
  617. Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click
  618. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate270FlipNone) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  619. End Sub
  620. Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click
  621. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipY) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  622. End Sub
  623. Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click
  624. PictureBox2.Image.RotateFlip(RotateFlipType.Rotate180FlipX) : PictureBox2.Refresh() : PictureBox2.SizeMode = 4
  625. End Sub
  626. Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click
  627. For i As Integer = 0 To DataGridView3.Rows.Count - 1
  628. DataGridView3.Rows(i).Cells("BUYER").Value = ComboBox1.Text
  629. Next
  630. MsgBox("注意還未存檔喔")
  631. End Sub
  632. End Class