Nessuna descrizione
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.

形體總表MINI WALL.vb 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. Option Strict Off
  2. Imports System.IO
  3. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  4. Imports Microsoft.Office.Interop.Excel.Constants
  5. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  6. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  7. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  8. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  9. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  10. Imports Microsoft.Office.Interop.Excel.XlWindowState
  11. Imports Microsoft.Office.Interop.Excel
  12. Imports System.Threading
  13. Public Class 形體總表MINI_WALL
  14. Private ReadOnly ds, ds1, ds2, ds3, ds4 As New DataSet
  15. Private 楦頭最大數, 草圖計算數, 草圖最大數, N1, N2 As Integer
  16. Private 位置1, 位置2, 位置3, 位置4, 位置5, 位置6, 位置7, 位置8, 位置9, 位置10 As String
  17. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  18. Private Sub 草圖表清單()
  19. 資料完備的鞋樣素描圖清單_dgv.DataSource = Nothing : ds.Clear()
  20. 資料完備的鞋樣素描圖清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  21. 資料完備的鞋樣素描圖清單_dgv.ColumnHeadersHeight = 25
  22. 資料完備的鞋樣素描圖清單_dgv.AllowUserToAddRows = False
  23. SQL_草圖表清單()
  24. da.Fill(ds) : 資料完備的鞋樣素描圖清單_dgv.DataSource = ds.Tables(0) : conn.Close()
  25. 資料完備的鞋樣素描圖清單_dgv.Columns(0).Width = 120 : 資料完備的鞋樣素描圖清單_dgv.Columns(1).Width = 120
  26. 資料完備的鞋樣素描圖清單_dgv.Columns(2).Width = 120 : 資料完備的鞋樣素描圖清單_dgv.Columns(3).Width = 40
  27. 資料完備的鞋樣素描圖清單_dgv.Columns(4).Visible = False
  28. For i As Integer = 0 To 資料完備的鞋樣素描圖清單_dgv.Rows.Count - 1
  29. 資料完備的鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = False
  30. Next i
  31. End Sub
  32. Private Sub Set_清單2()
  33. 楦頭清單_dgv.DataSource = Nothing : ds1.Clear()
  34. 楦頭清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  35. 楦頭清單_dgv.ColumnHeadersHeight = 25
  36. 楦頭清單_dgv.AllowUserToAddRows = False
  37. 楦頭清單_dgv.RowTemplate.Height = 60
  38. SQL_清單2()
  39. da.Fill(ds1) : 楦頭清單_dgv.DataSource = ds1.Tables(0) : conn.Close()
  40. 楦頭清單_dgv.Columns(0).Width = 100 : 楦頭清單_dgv.Columns(1).Width = 70 : 楦頭清單_dgv.Columns(2).Visible = False : 楦頭清單_dgv.Columns(3).Width = 70 : 楦頭清單_dgv.Columns(4).Width = 40
  41. 楦頭清單_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  42. Dim mycol As DataGridViewImageColumn = 楦頭清單_dgv.Columns("楦頭圖片")
  43. mycol.ImageLayout = DataGridViewImageCellLayout.Zoom
  44. For i As Integer = 0 To 楦頭清單_dgv.Rows.Count - 1
  45. If 楦頭清單_dgv.Rows(i).Cells("選擇").Value Is DBNull.Value Then
  46. 楦頭清單_dgv.Rows(i).Cells("選擇").Value = False
  47. End If
  48. Next i
  49. End Sub
  50. Private Sub Set_楦頭清單()
  51. 資料完備的楦頭清單_dgv.DataSource = Nothing : ds2.Clear()
  52. 資料完備的楦頭清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  53. 資料完備的楦頭清單_dgv.ColumnHeadersHeight = 25
  54. 資料完備的楦頭清單_dgv.AllowUserToAddRows = False
  55. SQL_楦頭清單()
  56. da.Fill(ds2) : 資料完備的楦頭清單_dgv.DataSource = ds2.Tables(0) : conn.Close()
  57. For i As Integer = 0 To 資料完備的楦頭清單_dgv.Rows.Count - 1
  58. 資料完備的楦頭清單_dgv.Rows(i).Cells("選擇").Value = False
  59. Next i
  60. 資料完備的楦頭清單_dgv.Columns(0).Width = 120 : 資料完備的楦頭清單_dgv.Columns(1).Visible = False
  61. End Sub
  62. Private Sub Set_DGV4載入前設定()
  63. 鞋樣素描圖清單_dgv.DataSource = Nothing : ds3.Clear()
  64. 鞋樣素描圖清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  65. 鞋樣素描圖清單_dgv.ColumnHeadersHeight = 25
  66. 鞋樣素描圖清單_dgv.AllowUserToAddRows = False
  67. 鞋樣素描圖清單_dgv.RowTemplate.Height = 60
  68. End Sub
  69. Private Sub Set_DGV4載入後設定()
  70. da.Fill(ds3) : 鞋樣素描圖清單_dgv.DataSource = ds3.Tables(0) : conn.Close()
  71. End Sub
  72. Private Sub 清單3()
  73. Set_DGV4載入前設定()
  74. SQL_清單3()
  75. Set_DGV4載入後設定() : Set_grid3()
  76. End Sub
  77. Private Sub Set_grid3()
  78. 鞋樣素描圖清單_dgv.Columns(0).Width = 120 : 鞋樣素描圖清單_dgv.Columns(1).Width = 120 : 鞋樣素描圖清單_dgv.Columns(2).Width = 120
  79. 鞋樣素描圖清單_dgv.Columns(3).Width = 120 : 鞋樣素描圖清單_dgv.Columns(4).Width = 120
  80. 鞋樣素描圖清單_dgv.Columns(5).Width = 40 : 鞋樣素描圖清單_dgv.Columns(6).Visible = False
  81. Dim mycol As DataGridViewImageColumn = 鞋樣素描圖清單_dgv.Columns("圖片")
  82. mycol.ImageLayout = DataGridViewImageCellLayout.Zoom
  83. For i As Integer = 0 To 鞋樣素描圖清單_dgv.Rows.Count - 1
  84. If 鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value Is DBNull.Value Then
  85. 鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = False
  86. End If
  87. Next i
  88. End Sub
  89. Private Sub Set_清單1()
  90. 清單_dgv.DataSource = Nothing : ds4.Clear()
  91. 清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  92. 清單_dgv.ColumnHeadersHeight = 25
  93. 清單_dgv.AllowUserToAddRows = False
  94. SQL_清單1()
  95. da.Fill(ds4) : 清單_dgv.DataSource = ds4.Tables(0) : conn.Close()
  96. 清單_dgv.Columns(0).Width = 100 : 清單_dgv.Columns(1).Width = 60 : 清單_dgv.Columns(2).Width = 140
  97. End Sub
  98. Private Sub ComboBox1下拉表單資料載入()
  99. SQL_型體控制表()
  100. 品牌_cb.Items.Clear() : While (dr.Read()) : 品牌_cb.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
  101. End Sub
  102. Private Sub ComboBox7下拉表單資料載入()
  103. SQL_季節清單()
  104. 季節_cb.Items.Clear() : While (dr.Read()) : 季節_cb.Items.Add(dr("SEASON")) : End While : conn.Close()
  105. End Sub
  106. Private Sub 圖片導入1()
  107. SQL_楦頭圖片庫()
  108. PictureBox1.Image = Nothing
  109. While dr.Read() = True
  110. Dim bytes As Byte() = New Byte(-1) {}
  111. bytes = DirectCast(dr.Item("楦頭圖片"), Byte())
  112. Dim oStream As New MemoryStream(bytes)
  113. PictureBox1.Image = Bitmap.FromStream(oStream)
  114. End While
  115. conn.Close()
  116. PictureBox1.SizeMode = 4
  117. End Sub
  118. Private Sub 圖片導入2()
  119. SQL_楦頭圖片庫1()
  120. PictureBox2.Image = Nothing
  121. While dr.Read() = True
  122. Dim bytes As Byte() = New Byte(-1) {}
  123. bytes = DirectCast(dr.Item("圖片"), Byte())
  124. Dim oStream As New MemoryStream(bytes)
  125. PictureBox2.Image = Bitmap.FromStream(oStream)
  126. End While
  127. conn.Close()
  128. PictureBox2.SizeMode = 4
  129. End Sub
  130. Private Sub 形體總表MINI_WALL_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  131. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  132. WINPROFIT_ERP_SYS.WindowState = 2 : ComboBox1下拉表單資料載入() : ComboBox7下拉表單資料載入() : Set_清單1()
  133. MiniWall編號_tb.Enabled = False : 選中要刪除的楦頭_tb.Enabled = False : 選中要刪除的鞋樣素描_tb.Enabled = False
  134. End Sub
  135. Private Sub DataGridView5_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 清單_dgv.CellClick
  136. If e.RowIndex = -1 Then : Else
  137. MiniWall編號_tb.Text = 清單_dgv.Rows(e.RowIndex).Cells("MW編號").Value : 季節_cb.Text = 清單_dgv.Rows(e.RowIndex).Cells("季節").Value
  138. 品牌_cb.Text = 清單_dgv.Rows(e.RowIndex).Cells("品牌").Value
  139. Set_清單2() : 選中要刪除的楦頭_tb.Text = "" : 選中要刪除的鞋樣素描_tb.Text = ""
  140. End If
  141. End Sub
  142. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 楦頭清單_dgv.CellClick
  143. If e.RowIndex = -1 Then : Else
  144. AASS = 楦頭清單_dgv.Rows(e.RowIndex).Cells("楦頭編號").Value
  145. 選中要刪除的楦頭_tb.Text = 楦頭清單_dgv.Rows(e.RowIndex).Cells("楦頭編號").Value
  146. 清單3() : 選中要刪除的鞋樣素描_tb.Text = ""
  147. End If
  148. End Sub
  149. Private Sub DataGridView4_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 鞋樣素描圖清單_dgv.CellClick
  150. If e.RowIndex = -1 Then : Else
  151. 選中要刪除的鞋樣素描_tb.Text = 鞋樣素描圖清單_dgv.Rows(e.RowIndex).Cells("鞋樣素描圖編號").Value
  152. End If
  153. End Sub
  154. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 資料完備的楦頭清單_dgv.CellClick
  155. If e.RowIndex = -1 Then : Else
  156. AASS = 資料完備的楦頭清單_dgv.Rows(e.RowIndex).Cells("楦頭編號").Value
  157. 草圖表清單() : 圖片導入1()
  158. End If
  159. End Sub
  160. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 資料完備的鞋樣素描圖清單_dgv.CellClick
  161. If e.RowIndex = -1 Then : Else
  162. SSDD = 資料完備的鞋樣素描圖清單_dgv.Rows(e.RowIndex).Cells("鞋樣素描圖編號").Value
  163. 圖片導入2()
  164. End If
  165. End Sub
  166. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 品牌_cb.SelectedIndexChanged
  167. Set_楦頭清單()
  168. End Sub
  169. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles 新增季節清單_bt.Click
  170. 清單修改.Close() : 季節清單修改 = True : 清單修改.ShowDialog() : ComboBox7下拉表單資料載入() : 季節清單修改 = False
  171. End Sub
  172. Private Sub Button29_Click(sender As Object, e As EventArgs) Handles 新增MINIWALL主題_bt.Click
  173. If 季節_cb.Text = "" Or 品牌_cb.Text = "" Then
  174. MsgBox("季節與品牌沒有選擇")
  175. Else
  176. SQL_查詢MW編號()
  177. If dr.Read() Then : MiniWall編號_tb.Text = dr("MW編號").ToString : Else : MiniWall編號_tb.Text = "MW00000000" : End If
  178. conn.Close()
  179. Dim NUM1 As Integer
  180. NUM1 = Double.Parse(Strings.Right(MiniWall編號_tb.Text, 8)) + 1
  181. If NUM1 < 10 Then : MiniWall編號_tb.Text = "MW" & "0000000" & NUM1
  182. ElseIf NUM1 > 9 And NUM1 < 100 Then : MiniWall編號_tb.Text = "MW" & "000000" & NUM1
  183. ElseIf NUM1 > 99 And NUM1 < 1000 Then : MiniWall編號_tb.Text = "MW" & "00000" & NUM1
  184. ElseIf NUM1 > 999 And NUM1 < 10000 Then : MiniWall編號_tb.Text = "MW" & "0000" & NUM1
  185. ElseIf NUM1 > 9999 And NUM1 < 100000 Then : MiniWall編號_tb.Text = "MW" & "000" & NUM1
  186. ElseIf NUM1 > 99999 And NUM1 < 100000 Then : MiniWall編號_tb.Text = "MW" & "00" & NUM1
  187. ElseIf NUM1 > 999999 And NUM1 < 1000000 Then : MiniWall編號_tb.Text = "MW" & "0" & NUM1
  188. ElseIf NUM1 > 9999999 Then : MiniWall編號_tb.Text = "MW" & NUM1 + 1
  189. End If
  190. SQL_新增MINI_WALL_控制表()
  191. conn.Close()
  192. MsgBox("MINI WALL主體準備完畢") : Set_清單1()
  193. End If
  194. End Sub
  195. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles 全部選擇2_bt.Click
  196. For i As Integer = 0 To 資料完備的鞋樣素描圖清單_dgv.Rows.Count - 1 : 資料完備的鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = True : Next i
  197. End Sub
  198. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles 全部取消2_bt.Click
  199. For i As Integer = 0 To 資料完備的鞋樣素描圖清單_dgv.Rows.Count - 1 : 資料完備的鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = False : Next i
  200. End Sub
  201. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles 全部選擇_bt.Click
  202. For i As Integer = 0 To 楦頭清單_dgv.Rows.Count - 1 : 楦頭清單_dgv.Rows(i).Cells("選擇").Value = True : Next i
  203. End Sub
  204. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles 全部取消_bt.Click
  205. For i As Integer = 0 To 楦頭清單_dgv.Rows.Count - 1 : 楦頭清單_dgv.Rows(i).Cells("選擇").Value = False : Next i
  206. End Sub
  207. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles 全部選擇1_bt.Click
  208. For i As Integer = 0 To 鞋樣素描圖清單_dgv.Rows.Count - 1 : 鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = True : Next i
  209. End Sub
  210. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles 全部取消1_bt.Click
  211. For i As Integer = 0 To 鞋樣素描圖清單_dgv.Rows.Count - 1 : 鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = False : Next i
  212. End Sub
  213. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 新增楦頭_bt.Click
  214. If AASS = "" Then
  215. MsgBox("沒有選擇楦頭")
  216. Else
  217. Dim DDFF As Boolean
  218. For i As Integer = 0 To 資料完備的鞋樣素描圖清單_dgv.Rows.Count - 1
  219. DDFF = 資料完備的鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = True
  220. If DDFF = True Then
  221. Exit For
  222. ElseIf i = 資料完備的鞋樣素描圖清單_dgv.Rows.Count - 1 And DDFF = False Then
  223. MsgBox("沒有選擇鞋樣素描") : Exit For
  224. End If
  225. Next i
  226. If DDFF = True Then
  227. SQL_查閱MW編號()
  228. If dr.Read() Then : Else
  229. SQL_新增MINI_WALL_明細表()
  230. conn.Close()
  231. End If
  232. conn.Close()
  233. For i As Integer = 0 To 資料完備的鞋樣素描圖清單_dgv.Rows.Count - 1
  234. 資料數 = 資料完備的鞋樣素描圖清單_dgv.Rows.Count : MyModule1.進度條()
  235. If 資料完備的鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value = True Then
  236. PA7 = 資料完備的鞋樣素描圖清單_dgv.Rows(i).Cells("鞋樣素描圖編號").Value
  237. SQL_讀取MW編號()
  238. If dr.Read() Then : Else
  239. SQL_新增MINI_WALL_草圖明細()
  240. conn.Close()
  241. End If
  242. conn.Close()
  243. Else : End If
  244. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  245. Set_清單2() : 清單3() : AASS = ""
  246. MsgBox("新增完成")
  247. End If
  248. End If
  249. End Sub
  250. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles 楦頭存檔_bt.Click
  251. For i As Integer = 0 To 楦頭清單_dgv.Rows.Count - 1
  252. 資料數 = 楦頭清單_dgv.Rows.Count : MyModule1.進度條()
  253. PA8 = 楦頭清單_dgv.Rows(i).Cells("選擇").Value : PA9 = 楦頭清單_dgv.Rows(i).Cells("製造").Value
  254. PA10 = 楦頭清單_dgv.Rows(i).Cells("楦頭編號").Value
  255. SQL_修改MINI_WALL_明細表()
  256. conn.Close()
  257. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  258. MsgBox("存檔完成")
  259. End Sub
  260. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles 鞋樣素描存檔_bt.Click
  261. For i As Integer = 0 To 鞋樣素描圖清單_dgv.Rows.Count - 1
  262. 資料數 = 鞋樣素描圖清單_dgv.Rows.Count : MyModule1.進度條()
  263. PA8 = 鞋樣素描圖清單_dgv.Rows(i).Cells("選擇").Value : PA9 = 鞋樣素描圖清單_dgv.Rows(i).Cells("鞋樣素描圖編號").Value
  264. SQL_更改MINI_WALL_草圖明細() : conn.Close()
  265. Next i : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  266. MsgBox("存檔完成")
  267. End Sub
  268. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles 刪除選中Minwall主題_bt.Click
  269. Dim aa As MsgBoxResult
  270. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  271. If aa = MsgBoxResult.Ok Then
  272. SQL_刪除MINI_WALL_控制表() : conn.Close()
  273. SQL_MINI_WALL_明細表() : conn.Close()
  274. SQL_MINI_WALL_草圖明細() : conn.Close()
  275. MsgBox("刪除完成") : Set_清單1() : Set_清單2() : 清單3()
  276. End If
  277. End Sub
  278. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles 刪除楦頭_bt.Click
  279. Dim aa As MsgBoxResult
  280. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  281. If aa = MsgBoxResult.Ok Then
  282. SQL_刪除MINI_WALL明細表() : conn.Close()
  283. SQL_刪除MINI_WALL_楦頭() : conn.Close()
  284. MsgBox("刪除完成") : Set_清單2() : 清單3()
  285. End If
  286. End Sub
  287. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles 刪除素描資料_bt.Click
  288. Dim aa As MsgBoxResult
  289. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  290. If aa = MsgBoxResult.Ok Then
  291. SQL_刪除素描資料() : conn.Close()
  292. MsgBox("刪除完成") : Set_清單2() : 清單3()
  293. End If
  294. End Sub
  295. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  296. 楦頭最大數 = 0 : 草圖最大數 = 0
  297. For i As Integer = 0 To 楦頭清單_dgv.Rows.Count - 1
  298. If 楦頭清單_dgv.Rows(i).Cells("選擇").Value = True Then
  299. 楦頭最大數 += 1
  300. Set_DGV4載入前設定()
  301. PA12 = 楦頭清單_dgv.Rows(i).Cells("楦頭編號").Value
  302. SQL_列印清單()
  303. Set_DGV4載入後設定() : Set_grid3()
  304. 草圖計算數 = 0
  305. For ii As Integer = 0 To 鞋樣素描圖清單_dgv.Rows.Count - 1
  306. If 鞋樣素描圖清單_dgv.Rows(ii).Cells("選擇").Value = True Then
  307. 草圖計算數 += 1
  308. End If
  309. Next ii
  310. If 草圖計算數 > 草圖最大數 Then
  311. 草圖最大數 = 草圖計算數
  312. End If
  313. End If
  314. Next i
  315. xlApp = CType(CreateObject("Excel.Application"), Application)
  316. xlBook = xlApp.Workbooks.Add
  317. xlApp.DisplayAlerts = True
  318. xlBook.Activate()
  319. xlSheet = NewMethod(xlBook)
  320. xlSheet.Activate()
  321. xlApp.Visible = True
  322. xlApp.Application.WindowState = xlMaximized
  323. xlSheet.Cells(1, 1) = 品牌_cb.Text & " - " & 季節_cb.Text & " - MINI WALL" : AA(xlApp, xlSheet) : N1 = 0
  324. For I As Integer = 0 To 草圖最大數 - 1
  325. xlSheet.Cells(10 + N1, 1) = "Sketch" : xlSheet.Cells(11 + N1, 1) = "STYLE #" : xlSheet.Cells(12 + N1, 1) = "STYLE NAME"
  326. xlSheet.Cells(13 + N1, 1) = "LAST #" : xlSheet.Cells(14 + N1, 1) = "OUTSOLE #"
  327. BB(xlApp, xlSheet) : JJ(xlApp, xlSheet)
  328. N1 += 5
  329. Next
  330. N2 = 0
  331. For i As Integer = 0 To 楦頭清單_dgv.Rows.Count - 1
  332. If 楦頭清單_dgv.Rows(i).Cells("選擇").Value = True Then
  333. DD(xlApp, xlSheet)
  334. AASS = 楦頭清單_dgv.Rows(i).Cells("楦頭編號").Value : 圖片導入1()
  335. If 列印_cb.Checked = True Then
  336. xlSheet.Cells(3, 2 + N2) = 楦頭清單_dgv.Rows(i).Cells("製造").Value
  337. End If
  338. xlSheet.Cells(8, 2 + N2) = 楦頭清單_dgv.Rows(i).Cells("楦頭名").Value
  339. FF(xlApp, xlSheet)
  340. For ii As Integer = 0 To 999999999
  341. If PictureBox1.Image Is Nothing Then
  342. Else
  343. CC(xlApp, xlSheet)
  344. ii = 999999999
  345. End If
  346. Next
  347. Set_DGV4載入前設定()
  348. PA13 = 楦頭清單_dgv.Rows(i).Cells("楦頭編號").Value
  349. SQL_列印清單1()
  350. Set_DGV4載入後設定() : Set_grid3()
  351. N1 = 0
  352. For ii As Integer = 0 To 鞋樣素描圖清單_dgv.Rows.Count - 1
  353. If 鞋樣素描圖清單_dgv.Rows(ii).Cells("選擇").Value = True Then
  354. SSDD = 鞋樣素描圖清單_dgv.Rows(ii).Cells("鞋樣素描圖編號").Value
  355. 圖片導入2()
  356. xlSheet.Cells(11 + N1, 2 + N2) = 鞋樣素描圖清單_dgv.Rows(ii).Cells("型體編號").Value : xlSheet.Cells(12 + N1, 2 + N2) = 鞋樣素描圖清單_dgv.Rows(ii).Cells("型體名稱").Value
  357. xlSheet.Cells(13 + N1, 2 + N2) = 鞋樣素描圖清單_dgv.Rows(ii).Cells("楦頭編號").Value : xlSheet.Cells(14 + N1, 2 + N2) = 鞋樣素描圖清單_dgv.Rows(ii).Cells("模具編號").Value
  358. GG(xlApp, xlSheet)
  359. For iii As Integer = 0 To 999999999
  360. If PictureBox2.Image Is Nothing Then
  361. Else
  362. EE(xlApp, xlSheet)
  363. iii = 999999999
  364. End If
  365. Next
  366. N1 += 5
  367. End If
  368. Next
  369. N2 += 2
  370. End If
  371. Next
  372. HH(xlApp, xlSheet)
  373. xlSheet.PageSetup.PrintArea = ""
  374. xlApp.Cells.Select()
  375. xlSheet.Range("B1").Select()
  376. xlApp.Application.WindowState = xlMinimized
  377. MsgBox("列印完成")
  378. PictureBox1.Image = Nothing : PictureBox2.Image = Nothing : 楦頭清單_dgv.DataSource = Nothing : ds1.Clear() : 鞋樣素描圖清單_dgv.DataSource = Nothing : ds3.Clear()
  379. End Sub
  380. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  381. Return CType(xlBook.Worksheets.Add, Worksheet)
  382. End Function
  383. Private Sub RTFGRTFG()
  384. If N2 = 0 Then : 位置1 = "B6" : 位置3 = "C"
  385. ElseIf N2 = 2 Then : 位置1 = "D6" : 位置3 = "E" : ElseIf N2 = 4 Then : 位置1 = "F6" : 位置3 = "G" : ElseIf N2 = 6 Then : 位置1 = "H6" : 位置3 = "I"
  386. ElseIf N2 = 8 Then : 位置1 = "J6" : 位置3 = "K" : ElseIf N2 = 10 Then : 位置1 = "L6" : 位置3 = "M" : ElseIf N2 = 12 Then : 位置1 = "N6" : 位置3 = "O"
  387. ElseIf N2 = 14 Then : 位置1 = "P6" : 位置3 = "Q" : ElseIf N2 = 16 Then : 位置1 = "R6" : 位置3 = "S" : ElseIf N2 = 18 Then : 位置1 = "T6" : 位置3 = "U"
  388. ElseIf N2 = 20 Then : 位置1 = "V6" : 位置3 = "W" : ElseIf N2 = 22 Then : 位置1 = "X6" : 位置3 = "Y" : ElseIf N2 = 24 Then : 位置1 = "Z6" : 位置3 = "AA"
  389. ElseIf N2 = 26 Then : 位置1 = "AB6" : 位置3 = "AC" : ElseIf N2 = 28 Then : 位置1 = "AD6" : 位置3 = "AE" : ElseIf N2 = 30 Then : 位置1 = "AF6" : 位置3 = "AG"
  390. ElseIf N2 = 32 Then : 位置1 = "AH6" : 位置3 = "AI" : ElseIf N2 = 34 Then : 位置1 = "AJ6" : 位置3 = "AK" : ElseIf N2 = 36 Then : 位置1 = "AL6" : 位置3 = "AM"
  391. ElseIf N2 = 38 Then : 位置1 = "AN6" : 位置3 = "AO" : ElseIf N2 = 40 Then : 位置1 = "AP6" : 位置3 = "AQ" : ElseIf N2 = 42 Then : 位置1 = "AR6" : 位置3 = "AS"
  392. ElseIf N2 = 44 Then : 位置1 = "AT6" : 位置3 = "AU" : ElseIf N2 = 46 Then : 位置1 = "AV6" : 位置3 = "AW" : ElseIf N2 = 48 Then : 位置1 = "AX6" : 位置3 = "AY"
  393. ElseIf N2 = 50 Then : 位置1 = "AZ6" : 位置3 = "BA" : ElseIf N2 = 52 Then : 位置1 = "BB6" : 位置3 = "BC" : ElseIf N2 = 54 Then : 位置1 = "BD6" : 位置3 = "BE"
  394. ElseIf N2 = 56 Then : 位置1 = "BF6" : 位置3 = "BG" : ElseIf N2 = 58 Then : 位置1 = "BH6" : 位置3 = "BI" : ElseIf N2 = 60 Then : 位置1 = "BJ6" : 位置3 = "BK"
  395. ElseIf N2 = 62 Then : 位置1 = "BL6" : 位置3 = "BM" : ElseIf N2 = 64 Then : 位置1 = "BN6" : 位置3 = "BO" : ElseIf N2 = 66 Then : 位置1 = "BP6" : 位置3 = "BQ"
  396. ElseIf N2 = 68 Then : 位置1 = "BR6" : 位置3 = "BS" : ElseIf N2 = 70 Then : 位置1 = "BT6" : 位置3 = "BU" : ElseIf N2 = 72 Then : 位置1 = "BV6" : 位置3 = "BW"
  397. ElseIf N2 = 74 Then : 位置1 = "BX6" : 位置3 = "BY" : ElseIf N2 = 76 Then : 位置1 = "BZ6" : 位置3 = "CA" : ElseIf N2 = 78 Then : 位置1 = "CB6" : 位置3 = "CC"
  398. ElseIf N2 = 80 Then : 位置1 = "DD6" : 位置3 = "CE" : End If
  399. If N2 > 24 Then
  400. 位置2 = Strings.Left(位置1, 2) & ":" & Strings.Left(位置1, 2) : 位置3 = Strings.Left(位置3, 2) & ":" & Strings.Left(位置3, 2) : 位置4 = Strings.Left(位置1, 2) & 10 + N1
  401. 位置5 = Strings.Left(位置1, 2) & "6:" & Strings.Left(位置1, 2) & "9" : 位置6 = Strings.Left(位置1, 2) & 10 + N1 & ":" & Strings.Left(位置1, 2) & 14 + N1
  402. 位置7 = "A1:" & Strings.Left(位置3, 2) & 1 : 位置8 = "B3:" & Strings.Left(位置1, 2) & 3 : 位置9 = "A6:" & Strings.Left(位置3, 2) & 5 * 草圖最大數 + 9
  403. ElseIf N2 = 24 Then
  404. 位置2 = Strings.Left(位置1, 1) & ":" & Strings.Left(位置1, 1) : 位置3 = Strings.Left(位置3, 2) & ":" & Strings.Left(位置3, 2) : 位置4 = Strings.Left(位置1, 1) & 10 + N1
  405. 位置5 = Strings.Left(位置1, 1) & "6:" & Strings.Left(位置1, 1) & "9" : 位置6 = Strings.Left(位置1, 1) & 10 + N1 & ":" & Strings.Left(位置1, 1) & 14 + N1
  406. 位置7 = "A1:" & Strings.Left(位置3, 2) & 1 : 位置8 = "B3:" & Strings.Left(位置1, 1) & 3 : 位置9 = "A6:" & Strings.Left(位置3, 2) & 5 * 草圖最大數 + 9
  407. ElseIf N2 < 24 Then
  408. 位置2 = Strings.Left(位置1, 1) & ":" & Strings.Left(位置1, 1) : 位置3 = Strings.Left(位置3, 1) & ":" & Strings.Left(位置3, 1) : 位置4 = Strings.Left(位置1, 1) & 10 + N1
  409. 位置5 = Strings.Left(位置1, 1) & "6:" & Strings.Left(位置1, 1) & "9" : 位置6 = Strings.Left(位置1, 1) & 10 + N1 & ":" & Strings.Left(位置1, 1) & 14 + N1
  410. 位置7 = "A1:" & Strings.Left(位置3, 1) & 1 : 位置8 = "B3:" & Strings.Left(位置1, 1) & 3 : 位置9 = "A6:" & Strings.Left(位置3, 1) & 5 * 草圖最大數 + 9
  411. End If
  412. End Sub
  413. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  414. xlSheet.Cells.Select()
  415. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  416. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  417. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 15
  418. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 5
  419. xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("4:5").Select : myExcel.Selection.RowHeight = 5
  420. xlSheet.Rows("6:6").Select : myExcel.Selection.RowHeight = 90 : xlSheet.Rows("7:7").Select : myExcel.Selection.RowHeight = 5
  421. xlSheet.Rows("9:9").Select : myExcel.Selection.RowHeight = 5
  422. End Sub
  423. Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  424. xlSheet.Rows(10 + N1 & ":" & 10 + N1).Select : myExcel.Selection.RowHeight = 90
  425. End Sub
  426. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  427. RTFGRTFG()
  428. Clipboard.SetDataObject(PictureBox1.Image)
  429. Thread.Sleep(100) '延迟0.1秒
  430. xlSheet.Range(位置1).Select()
  431. myExcel.ActiveSheet.Paste
  432. If PictureBox1.Image.Height < PictureBox1.Image.Width Then
  433. myExcel.Selection.ShapeRange.Width = 90
  434. Else
  435. myExcel.Selection.ShapeRange.Height = 85
  436. End If
  437. myExcel.Selection.ShapeRange.IncrementLeft(2)
  438. myExcel.Selection.ShapeRange.IncrementTop(2)
  439. End Sub
  440. Private Sub DD(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  441. RTFGRTFG()
  442. xlSheet.Columns(位置2).Select : myExcel.Selection.ColumnWidth = 15
  443. xlSheet.Columns(位置3).Select : myExcel.Selection.ColumnWidth = 1
  444. End Sub
  445. Private Sub EE(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  446. RTFGRTFG()
  447. Clipboard.SetDataObject(PictureBox2.Image)
  448. xlSheet.Cells(1, 1).Select
  449. Thread.Sleep(100) '延迟0.1秒
  450. xlSheet.Range(位置4).Select()
  451. myExcel.ActiveSheet.Paste
  452. If PictureBox2.Image.Height < PictureBox2.Image.Width Then
  453. myExcel.Selection.ShapeRange.Width = 90
  454. Else
  455. myExcel.Selection.ShapeRange.Height = 85
  456. End If
  457. myExcel.Selection.ShapeRange.IncrementLeft(2)
  458. myExcel.Selection.ShapeRange.IncrementTop(2)
  459. End Sub
  460. Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  461. RTFGRTFG()
  462. xlSheet.Range(位置5).Select()
  463. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  464. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  465. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  466. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  467. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  468. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  469. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  470. End Sub
  471. Private Sub GG(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  472. RTFGRTFG()
  473. xlSheet.Range(位置6).Select()
  474. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  475. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  476. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  477. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  478. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  479. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  480. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  481. End Sub
  482. Private Sub HH(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  483. N2 = 楦頭最大數 * 2 - 2
  484. RTFGRTFG()
  485. xlSheet.Cells.Select()
  486. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  487. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  488. xlSheet.Range(位置7).Select()
  489. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  490. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  491. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  492. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  493. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  494. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  495. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  496. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  497. xlSheet.Range(位置8).Select()
  498. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  499. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  500. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  501. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  502. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  503. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  504. xlSheet.Range(位置9).Select()
  505. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  506. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  507. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  508. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  509. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  510. myExcel.ActiveWindow.DisplayGridlines = False
  511. End Sub
  512. Private Sub JJ(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  513. 位置10 = "A" & 10 + N1 & ":A" & 14 + N1
  514. xlSheet.Range(位置10).Select()
  515. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  516. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  517. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  518. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  519. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  520. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  521. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  522. End Sub
  523. End Class