설명 없음
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.

樣品INVOICE.vb 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.Text.RegularExpressions
  4. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  5. Imports Microsoft.Office.Interop.Excel.Constants
  6. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  7. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  8. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  9. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  10. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  11. Imports Microsoft.Office.Interop.Excel.XlWindowState
  12. Imports Microsoft.Office.Interop.Excel
  13. Public Class 樣品INVOICE
  14. Dim conn As New SqlConnection
  15. Dim da As New SqlDataAdapter
  16. Dim cmd As New SqlCommand
  17. Dim ds As New DataSet : Dim ds2 As New DataSet : Dim ds3 As New DataSet
  18. Dim dr As SqlDataReader
  19. Dim DTP As String : Dim GGHH As String : Dim DDFF As String
  20. Dim BBNN1 As Integer : Dim BBNN11 As String : Dim AAWW As String : Dim HHGG As String
  21. Dim RRTT As New Regex("[\u4e00-\u9fa5]")
  22. Dim KKOO As Double : Dim N1 As Integer
  23. Dim xlApp As Application
  24. Dim xlBook As Workbook
  25. Dim xlSheet As Worksheet
  26. Private Sub Set_DGV2載入前設定()
  27. DataGridView2.DataSource = Nothing : ds2.Clear()
  28. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  29. DataGridView2.ColumnHeadersHeight = 25
  30. DataGridView2.AllowUserToAddRows = False
  31. DataGridView2.RowTemplate.Height = 25
  32. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  33. End Sub
  34. Private Sub Set_DGV2載入後設定()
  35. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView2.DataSource = ds2.Tables(0) : conn.Close() : Set_grid()
  36. End Sub
  37. Private Sub Set_清單()
  38. Set_DGV2載入前設定()
  39. SQL1 = "SELECT 樣品訂單控制表.客戶, INVOICE樣品單.UPS, INVOICE樣品單.ATTN, INVOICE樣品單.CARTON, INVOICE樣品單.DATE
  40. FROM 樣品訂單控制表 INNER JOIN 樣品訂單清單 ON 樣品訂單控制表.SO = 樣品訂單清單.SO AND 樣品訂單控制表.版次 = 樣品訂單清單.版次 RIGHT OUTER JOIN
  41. INVOICE樣品單 ON 樣品訂單清單.流水號 = INVOICE樣品單.對應流水號
  42. WHERE INVOICE樣品單.狀態 LIKE N'" & 樣品進度表分類4 & "'
  43. GROUP BY 樣品訂單控制表.客戶, INVOICE樣品單.UPS, INVOICE樣品單.ATTN, INVOICE樣品單.CARTON, INVOICE樣品單.DATE
  44. ORDER BY INVOICE樣品單.UPS DESC"
  45. Set_DGV2載入後設定()
  46. End Sub
  47. Private Sub Set_grid()
  48. DataGridView2.Columns(0).Width = 195 : DataGridView2.Columns(1).Width = 265 : DataGridView2.Columns(2).Width = 165 : DataGridView2.Columns(3).Width = 100 : DataGridView2.Columns(4).Width = 100
  49. End Sub
  50. Private Sub Set_DGV1載入前設定()
  51. DataGridView1.DataSource = Nothing : ds.Clear()
  52. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  53. DataGridView1.ColumnHeadersHeight = 25
  54. DataGridView1.AllowUserToAddRows = False
  55. DataGridView1.RowTemplate.Height = 50
  56. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  57. End Sub
  58. Private Sub Set_DGV1載入後設定()
  59. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid1()
  60. End Sub
  61. Private Sub Set_清單1()
  62. Set_DGV1載入前設定()
  63. SQL1 = "SELECT 樣品訂單控制表.客戶 AS Customer, 樣品訂單控制表.狀態 AS [Sample type], INVOICE樣品單.HTS_CODE AS [Hts Code], 樣品訂單控制表.型體號碼 AS [Styie Number],
  64. 樣品訂單清單.顏色 AS Colorway, 樣品訂單清單.SO AS [Upper Material], 樣品訂單清單.SO AS [Outsole Material], INVOICE樣品單.G_S_F, INVOICE樣品單.PAIRS,
  65. INVOICE樣品單.UNIT AS [UNIT], INVOICE樣品單.PAIRS * INVOICE樣品單.UNIT AS [TTL], INVOICE樣品單.對應流水號
  66. FROM 樣品訂單控制表 INNER JOIN 樣品訂單清單 ON 樣品訂單控制表.SO = 樣品訂單清單.SO AND 樣品訂單控制表.版次 = 樣品訂單清單.版次 RIGHT OUTER JOIN INVOICE樣品單 ON
  67. 樣品訂單清單.流水號 = INVOICE樣品單.對應流水號
  68. WHERE (INVOICE樣品單.UPS LIKE N'" & TextBox2.Text & "')
  69. ORDER BY [Styie Number], Colorway"
  70. Set_DGV1載入後設定()
  71. End Sub
  72. Private Sub Set_grid1()
  73. DataGridView1.Columns(0).Width = 100 : DataGridView1.Columns(1).Width = 100 : DataGridView1.Columns(2).Width = 85 : DataGridView1.Columns(3).Width = 100 : DataGridView1.Columns(4).Width = 100
  74. DataGridView1.Columns(5).Width = 163 : DataGridView1.Columns(6).Width = 162 : DataGridView1.Columns(7).Width = 50 : DataGridView1.Columns(8).Width = 50 : DataGridView1.Columns(9).Width = 50
  75. DataGridView1.Columns(10).Width = 50 : DataGridView1.Columns(11).Visible = False
  76. DataGridView1.Columns(8).DefaultCellStyle.Format = "#,##0.0" : DataGridView1.Columns(9).DefaultCellStyle.Format = "#,##0.0" : DataGridView1.Columns(10).DefaultCellStyle.Format = "#,##0.0"
  77. DataGridView1.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  78. DataGridView1.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  79. DataGridView1.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  80. DataGridView1.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  81. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  82. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  83. conn.Close()
  84. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  85. SQL1 = "SELECT TOP (1) 材料名稱 FROM 樣品訂單部件表
  86. WHERE (流水號 LIKE N'" & DataGridView1.Rows(i).Cells("對應流水號").Value & "') AND (部件 LIKE 'A.%') AND (部件 LIKE '%面料A' OR 部件 LIKE '%面料')"
  87. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  88. If (dr.Read()) Then : DDFF = dr("材料名稱") : Else : DDFF = "" : End If : conn.Close()
  89. '--------------------------------------------------------------------------------------------
  90. BBNN1 = DDFF.Length.ToString()
  91. For II As Integer = 0 To BBNN1 - 1
  92. If II = 0 Then
  93. AAWW = Strings.Left(DDFF, 1)
  94. If RRTT.IsMatch(AAWW) Then : Else : BBNN11 = Strings.Left(DDFF, 1) : End If
  95. Else
  96. AAWW = Strings.Mid(DDFF, II + 1, 1) : If RRTT.IsMatch(AAWW) Then : Else : HHGG = BBNN11 : BBNN11 = HHGG & AAWW : End If
  97. End If
  98. Next : DataGridView1.Rows(i).Cells("Upper Material").Value = BBNN11
  99. '--------------------------------------------------------------------------------------------
  100. conn.Close()
  101. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  102. SQL1 = "SELECT TOP (1) 材料名稱 FROM 樣品訂單部件表
  103. WHERE (流水號 LIKE N'" & DataGridView1.Rows(i).Cells("對應流水號").Value & "') AND (部件 LIKE N'E.OUTSOLE 大底')"
  104. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  105. If (dr.Read()) Then : DDFF = dr("材料名稱") : Else : DDFF = "" : End If : conn.Close()
  106. '--------------------------------------------------------------------------------------------
  107. BBNN1 = DDFF.Length.ToString()
  108. For II As Integer = 0 To BBNN1 - 1
  109. If II = 0 Then
  110. AAWW = Strings.Left(DDFF, 1)
  111. If RRTT.IsMatch(AAWW) Then : Else : BBNN11 = Strings.Left(DDFF, 1) : End If
  112. Else
  113. AAWW = Strings.Mid(DDFF, II + 1, 1) : If RRTT.IsMatch(AAWW) Then : Else : HHGG = BBNN11 : BBNN11 = HHGG & AAWW : End If
  114. End If
  115. Next : DataGridView1.Rows(i).Cells("Outsole Material").Value = BBNN11
  116. '--------------------------------------------------------------------------------------------
  117. Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  118. End Sub
  119. Private Sub Set_DGV3載入前設定()
  120. DataGridView3.DataSource = Nothing : ds3.Clear()
  121. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  122. DataGridView3.ColumnHeadersHeight = 25
  123. DataGridView3.AllowUserToAddRows = False
  124. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  125. End Sub
  126. Private Sub Set_DGV3載入後設定()
  127. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds3) : DataGridView3.DataSource = ds3.Tables(0) : conn.Close() : Set_grid4()
  128. End Sub
  129. Private Sub Set_清單3()
  130. Set_DGV3載入前設定()
  131. SQL1 = "SELECT 樣品訂單控制表.季節, 樣品訂單控制表.客戶, 樣品訂單控制表.SO, 樣品訂單控制表.版次, 樣品訂單控制表.型體號碼,
  132. 樣品訂單控制表.型體名稱, 樣品訂單清單.顏色, 樣品訂單清單.數量, CONVERT(money, 樣品訂單清單.KEEP) AS KEEP,
  133. 樣品訂單清單.寄出, 樣品訂單清單.流水號
  134. FROM 樣品訂單清單 LEFT OUTER JOIN 樣品訂單控制表 ON 樣品訂單清單.SO = 樣品訂單控制表.SO AND 樣品訂單清單.版次 = 樣品訂單控制表.版次
  135. WHERE (樣品訂單清單.數量 - CONVERT(money, 樣品訂單清單.KEEP) - 樣品訂單清單.寄出 > 0) AND (樣品訂單控制表.狀態 LIKE N'" & 樣品進度表分類4 & "')
  136. ORDER BY 樣品訂單控制表.型體號碼, 樣品訂單控制表.型體名稱, 樣品訂單清單.顏色"
  137. Set_DGV3載入後設定()
  138. End Sub
  139. Private Sub Set_grid4()
  140. DataGridView3.Columns(0).Width = 85 : DataGridView3.Columns(1).Width = 140 : DataGridView3.Columns(2).Width = 60 : DataGridView3.Columns(3).Width = 40 : DataGridView3.Columns(4).Width = 120
  141. DataGridView3.Columns(5).Width = 140 : DataGridView3.Columns(6).Width = 120 : DataGridView3.Columns(7).Width = 40 : DataGridView3.Columns(8).Width = 40 : DataGridView3.Columns(9).Width = 40
  142. DataGridView3.Columns(10).Visible = False
  143. DataGridView3.Columns(7).DefaultCellStyle.Format = "#,##0.0" : DataGridView3.Columns(8).DefaultCellStyle.Format = "#,##0.0" : DataGridView3.Columns(9).DefaultCellStyle.Format = "#,##0.0"
  144. DataGridView3.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView3.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  145. DataGridView3.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  146. DataGridView3.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView3.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  147. DataGridView3.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  148. End Sub
  149. Private Sub ComboBox1下拉表單資料載入()
  150. conn.Close()
  151. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  152. SQL1 = "SELECT ATTN FROM INVOICE用客戶資料 ORDER BY ATTN"
  153. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  154. ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("ATTN")) : End While : conn.Close()
  155. End Sub
  156. Private Sub 樣品INVOICE_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  157. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  158. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  159. SQL1 = "UPDATE 樣品訂單清單 SET KEEP = N'0' WHERE (KEEP LIKE N'')"
  160. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader : conn.Close()
  161. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  162. SQL1 = "UPDATE 樣品訂單清單 SET 寄出 = N'0' WHERE (寄出 IS NULL)"
  163. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader : conn.Close()
  164. ComboBox1下拉表單資料載入()
  165. Set_清單3() : Set_清單()
  166. ComboBox3.Text = "NA" : ComboBox2.Text = "NA" : ComboBox4.Text = "NA"
  167. Button8.Enabled = False : Button2.Enabled = False : Button6.Enabled = False : Button15.Enabled = False : Button4.Enabled = False
  168. Button3.Enabled = False : TextBox4.Enabled = False : TextBox3.Enabled = False
  169. DataGridView2.Visible = True : DataGridView3.Visible = False
  170. End Sub
  171. Private Sub 樣品INVOICE_Unload(sender As Object, e As EventArgs) Handles MyBase.Closing
  172. If Button8.Enabled = True Then
  173. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  174. SQL1 = "DELETE FROM INVOICE樣品單 WHERE (UPS = N'" & TextBox2.Text & "')"
  175. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader : conn.Close()
  176. End If
  177. End Sub
  178. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  179. If e.RowIndex = -1 Then : Else
  180. TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("對應流水號").Value : TextBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("PAIRS").Value
  181. End If
  182. End Sub
  183. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  184. If e.RowIndex = -1 Then : Else
  185. TextBox2.Text = DataGridView2.Rows(e.RowIndex).Cells("UPS").Value
  186. ComboBox1.Text = DataGridView2.Rows(e.RowIndex).Cells("ATTN").Value
  187. ComboBox2.Text = DataGridView2.Rows(e.RowIndex).Cells("CARTON").Value
  188. TextBox6.Text = DataGridView2.Rows(e.RowIndex).Cells("DATE").Value
  189. Set_清單1()
  190. End If
  191. End Sub
  192. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
  193. If e.RowIndex = -1 Then : Else
  194. TextBox3.Text = DataGridView3.Rows(e.RowIndex).Cells("流水號").Value
  195. TextBox4.Text = DataGridView3.Rows(e.RowIndex).Cells("數量").Value - DataGridView3.Rows(e.RowIndex).Cells("KEEP").Value - DataGridView3.Rows(e.RowIndex).Cells("寄出").Value
  196. TextBox4.Text = Strings.Format(Val(TextBox4.Text), "#,##0.0")
  197. End If
  198. End Sub
  199. Private Sub DataGridView3_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView3.RowPostPaint
  200. Dim linePen As New Pen(Color.Blue, 2)
  201. If e.RowIndex = DataGridView3.Rows.Count - 1 Then
  202. Exit Sub
  203. Else
  204. If DataGridView3(4, e.RowIndex).Value.ToString <> DataGridView3(4, e.RowIndex + 1).Value.ToString Then
  205. Dim startX As Integer = IIf(DataGridView3.RowHeadersVisible, DataGridView3.RowHeadersWidth, 0)
  206. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  207. Dim endX As Integer = startX + DataGridView3.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView3.HorizontalScrollingOffset
  208. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  209. Exit Sub
  210. End If
  211. End If
  212. End Sub
  213. Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
  214. If TextBox5.Text = "" Then
  215. TextBox5.Text = "0"
  216. Else
  217. End If
  218. End Sub
  219. Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
  220. 清單修改2.Close() : INVOICE用客戶資料 = True : 清單修改2.ShowDialog() : ComboBox1下拉表單資料載入() : INVOICE用客戶資料 = False
  221. End Sub
  222. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
  223. conn.Close()
  224. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  225. SQL1 = "SELECT TEL FROM INVOICE用客戶資料 WHERE ATTN LIKE N'" & ComboBox1.Text & "' ORDER BY ATTN"
  226. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  227. If (dr.Read()) Then : TextBox1.Text = dr("TEL") : End If : conn.Close()
  228. End Sub
  229. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  230. If TextBox2.Text = "" Or ComboBox1.Text = "" Or ComboBox2.Text = "NA" Then
  231. MsgBox("資料不齊全,請檢查UPS號、ATTN、CARTON等位置不可空白或NA")
  232. Else
  233. Button1.Enabled = False : TextBox2.Enabled = False : Button6.Enabled = True : Button15.Enabled = True
  234. Button18.Enabled = False : ComboBox1.Enabled = False : ComboBox2.Enabled = False : DataGridView2.Visible = False : DataGridView3.Visible = True
  235. conn.Close()
  236. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  237. SQL1 = "SELECT TOP(1) UPS FROM INVOICE樣品單 WHERE UPS LIKE N'" & TextBox2.Text & "' ORDER BY ATTN"
  238. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  239. If (dr.Read()) Then
  240. Button2.Enabled = True : conn.Close()
  241. Button6.Visible = False : Button15.Visible = False : Button6.Enabled = False : Button15.Enabled = False
  242. Button4.Visible = True : Button3.Visible = True : Button4.Enabled = True : Button3.Enabled = True
  243. Else
  244. Button8.Enabled = True : conn.Close()
  245. Button6.Visible = True : Button15.Visible = True : Button6.Enabled = True : Button15.Enabled = True
  246. Button4.Visible = False : Button3.Visible = False : Button4.Enabled = False : Button3.Enabled = False
  247. DataGridView1.DataSource = Nothing : ds.Clear()
  248. End If
  249. Set_清單3()
  250. End If
  251. End Sub
  252. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  253. Button1.Enabled = True : Button8.Enabled = False : TextBox2.Enabled = True : Button6.Enabled = False : Button15.Enabled = False : Button4.Enabled = False : Button3.Enabled = False
  254. Button18.Enabled = True : ComboBox1.Enabled = True : ComboBox2.Enabled = True : DataGridView2.Visible = True : DataGridView3.Visible = False
  255. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  256. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  257. conn.Close()
  258. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  259. SQL1 = "SELECT 寄出 FROM 樣品訂單清單 WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("對應流水號").Value & "'"
  260. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  261. If (dr.Read()) Then
  262. KKOO = dr("寄出")
  263. End If : conn.Close()
  264. KKOO = KKOO + DataGridView1.Rows(i).Cells("PAIRS").Value
  265. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  266. SQL1 = "UPDATE 樣品訂單清單 SET 寄出 = N'" & KKOO & "' WHERE (流水號 LIKE N'" & DataGridView1.Rows(i).Cells("對應流水號").Value & "')"
  267. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  268. Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  269. Set_清單()
  270. TextBox2.Text = "" : ComboBox1下拉表單資料載入() : ComboBox3.Text = "NA" : ComboBox2.Text = "NA" : ComboBox4.Text = "NA" : DataGridView1.DataSource = Nothing : ds.Clear()
  271. End Sub
  272. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  273. Button1.Enabled = True : Button2.Enabled = False : TextBox2.Enabled = True : Button6.Enabled = False : Button15.Enabled = False : Button4.Enabled = False : Button3.Enabled = False
  274. Button18.Enabled = True : ComboBox1.Enabled = True : ComboBox2.Enabled = True : DataGridView2.Visible = True : DataGridView3.Visible = False
  275. Set_清單()
  276. End Sub
  277. Private Sub Set_日期格式轉換()
  278. DTP = Strings.Format(Today(), "yyyy/MM/dd")
  279. End Sub
  280. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  281. If ComboBox3.Text = "NA" Then
  282. MsgBox("材質不可為NA")
  283. ElseIf ComboBox4.Text = "NA" Then
  284. MsgBox("size不可為NA")
  285. Else
  286. If Val(TextBox4.Text) < Val(TextBox5.Text) Then
  287. MsgBox("寄出數不可大於可寄數,哪來的鞋子?")
  288. ElseIf Val(TextBox5.Text) = 0 Then
  289. MsgBox("寄出數不可為零,快遞公司無法寄幽靈?")
  290. Else
  291. Set_日期格式轉換()
  292. conn.Close()
  293. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  294. SQL1 = "SELECT UPS FROM INVOICE樣品單 WHERE UPS LIKE N'" & TextBox2.Text & "' AND 對應流水號 LIKE N'" & TextBox3.Text & "' ORDER BY ATTN"
  295. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  296. If (dr.Read()) Then
  297. MsgBox("本單號中已有新增過該資料,如有錯誤請刪除後從新添加。")
  298. conn.Close()
  299. Else
  300. If ComboBox3.Text = "皮" Then : GGHH = "6403990090" : ElseIf ComboBox3.Text = "PU" Then : GGHH = "6402992900" : ElseIf ComboBox3.Text = "布" Then : GGHH = "6404199000" : End If
  301. conn.Close() : dr.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  302. SQL1 = "INSERT INTO INVOICE樣品單 (UPS, ATTN, DATE, CARTON, G_S_F, PAIRS, UNIT, 對應流水號, HTS_CODE, 狀態)
  303. VALUES (N'" & TextBox2.Text & "', N'" & ComboBox1.Text & "', N'" & DTP & "', N'" & ComboBox2.Text & "', N'" & ComboBox4.Text &
  304. "', N'" & TextBox5.Text & "', N'2', N'" & TextBox3.Text & "', N'" & GGHH & "', N'" & 樣品進度表分類4 & "')"
  305. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  306. Set_清單1()
  307. End If
  308. End If
  309. End If
  310. End Sub
  311. Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
  312. If TextBox3.Text = "" Then
  313. MsgBox("沒有選擇要刪除的資料")
  314. Else
  315. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  316. SQL1 = "DELETE FROM INVOICE樣品單 WHERE (UPS = N'" & TextBox2.Text & "') AND (對應流水號 = N'" & TextBox3.Text & "')"
  317. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader : conn.Close()
  318. Set_清單1()
  319. End If
  320. End Sub
  321. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  322. If ComboBox3.Text = "NA" Then
  323. MsgBox("材質不可為NA")
  324. ElseIf ComboBox4.Text = "NA" Then
  325. MsgBox("size不可為NA")
  326. Else
  327. If Val(TextBox4.Text) < Val(TextBox5.Text) Then
  328. MsgBox("寄出數不可大於可寄數,哪來的鞋子?")
  329. ElseIf Val(TextBox5.Text) = 0 Then
  330. MsgBox("寄出數不可為零,快遞公司無法寄幽靈?")
  331. Else
  332. Set_日期格式轉換()
  333. conn.Close()
  334. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  335. SQL1 = "SELECT UPS FROM INVOICE樣品單 WHERE UPS LIKE N'" & TextBox2.Text & "' AND 對應流水號 LIKE N'" & TextBox3.Text & "' ORDER BY ATTN"
  336. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  337. If (dr.Read()) Then
  338. MsgBox("本單號中已有新增過該資料,如有錯誤請刪除後從新添加。")
  339. conn.Close()
  340. Else
  341. conn.Close()
  342. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  343. SQL1 = "SELECT 寄出 FROM 樣品訂單清單 WHERE 流水號 LIKE N'" & TextBox3.Text & "'"
  344. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  345. If (dr.Read()) Then
  346. KKOO = dr("寄出")
  347. End If : conn.Close()
  348. KKOO = KKOO + Val(TextBox5.Text)
  349. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  350. SQL1 = "UPDATE 樣品訂單清單 SET 寄出 = N'" & KKOO & "' WHERE (流水號 LIKE N'" & TextBox3.Text & "')"
  351. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  352. Set_清單3()
  353. If ComboBox3.Text = "皮" Then : GGHH = "6403990090" : ElseIf ComboBox3.Text = "PU" Then : GGHH = "6402992900" : ElseIf ComboBox3.Text = "布" Then : GGHH = "6404199000" : End If
  354. conn.Close() : dr.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  355. SQL1 = "INSERT INTO INVOICE樣品單 (UPS, ATTN, DATE, CARTON, G_S_F, PAIRS, UNIT, 對應流水號, HTS_CODE, 狀態)
  356. VALUES (N'" & TextBox2.Text & "', N'" & ComboBox1.Text & "', N'" & DTP & "', N'" & ComboBox2.Text & "', N'" & ComboBox4.Text &
  357. "', N'" & TextBox5.Text & "', N'2', N'" & TextBox3.Text & "', N'" & GGHH & "', N'" & 樣品進度表分類4 & "')"
  358. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  359. Set_清單1()
  360. End If
  361. End If
  362. End If
  363. End Sub
  364. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  365. If TextBox3.Text = "" Then
  366. MsgBox("沒有選擇要刪除的資料")
  367. Else
  368. conn.Close()
  369. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  370. SQL1 = "SELECT 寄出 FROM 樣品訂單清單 WHERE 流水號 LIKE N'" & TextBox3.Text & "'"
  371. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  372. If (dr.Read()) Then
  373. KKOO = dr("寄出")
  374. End If : conn.Close()
  375. KKOO = KKOO - Val(TextBox5.Text)
  376. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  377. SQL1 = "UPDATE 樣品訂單清單 SET 寄出 = N'" & KKOO & "' WHERE (流水號 LIKE N'" & TextBox3.Text & "')"
  378. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  379. Set_清單3()
  380. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  381. SQL1 = "DELETE FROM INVOICE樣品單 WHERE (UPS = N'" & TextBox2.Text & "') AND (對應流水號 = N'" & TextBox3.Text & "')"
  382. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader : conn.Close()
  383. Set_清單1()
  384. End If
  385. End Sub
  386. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  387. xlApp = CType(CreateObject("Excel.Application"), Application)
  388. xlBook = xlApp.Workbooks.Add
  389. xlApp.DisplayAlerts = True
  390. xlBook.Activate()
  391. xlSheet = NewMethod(xlBook)
  392. xlSheet.Activate()
  393. xlApp.Visible = True
  394. xlApp.Application.WindowState = xlMaximized
  395. xlSheet.Cells(1, 1) = "SHIP TO :" : xlSheet.Cells(1, 2) = "Me Too LLC" : xlSheet.Cells(2, 2) = "49, West 37th street-2nd FL." : xlSheet.Cells(3, 2) = "New York, NY 10018" : xlSheet.Cells(4, 2) = "USA"
  396. xlSheet.Cells(1, 6) = "FROM :" : xlSheet.Cells(1, 7) = "DONGGUAN SEN KANG FOOTWEAR CO.,LTD" : xlSheet.Cells(2, 7) = "HuJing Road, Jiao yuan village," : xlSheet.Cells(3, 7) = "He Tian Managemet District.HouJie Town, "
  397. xlSheet.Cells(4, 7) = "Dongguan City Guangdong, CN 523945" : xlSheet.Cells(5, 7) = "China"
  398. xlSheet.Cells(6, 1) = "ATTN : " : xlSheet.Cells(6, 2) = ComboBox1.Text : xlSheet.Cells(7, 1) = "TEL : " : xlSheet.Cells(7, 2) = TextBox1.Text : xlSheet.Cells(8, 1) = "FAX : "
  399. xlSheet.Cells(9, 1) = "DATE : " : xlSheet.Cells(9, 2) = TextBox6.Text : xlSheet.Cells(7, 6) = "TEL : " : xlSheet.Cells(7, 7) = "0769-38937740"
  400. xlSheet.Cells(10, 1) = "INVOICE" : xlSheet.Cells(11, 1) = "Carton# : " & ComboBox2.Text
  401. xlSheet.Cells(12, 1) = "Customer" : xlSheet.Cells(12, 2) = "Sample type" : xlSheet.Cells(12, 3) = "HTS CODE" : xlSheet.Cells(12, 4) = "Style Name" : xlSheet.Cells(12, 5) = "Colorway"
  402. xlSheet.Cells(12, 6) = "Upper Material" : xlSheet.Cells(12, 7) = "Outsole Material" : xlSheet.Cells(12, 8) = "Gender/Size/Foot" : xlSheet.Cells(12, 9) = "Pairs" : xlSheet.Cells(12, 10) = "UNIT(US$)"
  403. xlSheet.Cells(12, 11) = "TTL(US$)"
  404. N1 = 0
  405. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  406. xlSheet.Cells(i + 13, 1) = DataGridView1.Rows(i).Cells("Customer").Value
  407. xlSheet.Cells(i + 13, 2) = DataGridView1.Rows(i).Cells("Sample type").Value
  408. xlSheet.Cells(i + 13, 3) = DataGridView1.Rows(i).Cells("Hts Code").Value
  409. xlSheet.Cells(i + 13, 4) = DataGridView1.Rows(i).Cells("Styie Number").Value
  410. xlSheet.Cells(i + 13, 5) = DataGridView1.Rows(i).Cells("Colorway").Value
  411. xlSheet.Cells(i + 13, 6) = DataGridView1.Rows(i).Cells("Upper Material").Value
  412. xlSheet.Cells(i + 13, 7) = DataGridView1.Rows(i).Cells("Outsole Material").Value
  413. xlSheet.Cells(i + 13, 8) = DataGridView1.Rows(i).Cells("G_S_F").Value
  414. xlSheet.Cells(i + 13, 9) = DataGridView1.Rows(i).Cells("PAIRS").Value
  415. xlSheet.Cells(i + 13, 10) = DataGridView1.Rows(i).Cells("UNIT").Value
  416. xlSheet.Cells(i + 13, 11) = DataGridView1.Rows(i).Cells("TTL").Value
  417. N1 = i
  418. Next
  419. xlSheet.Cells(N1 + 15, 8) = "TOTAL" : xlSheet.Cells(N1 + 15, 9) = "=SUM(I13:I" & N1 + 14 & ")" : xlSheet.Cells(N1 + 15, 11) = "=SUM(K13:K" & N1 + 14 & ")"
  420. xlSheet.Cells(N1 + 16, 1) = "Samples are marked or mutilated and classified HTS 6403990090&6402992900& 6404199000 per ruling letter N247780 attached"
  421. xlSheet.Cells(N1 + 17, 1) = "VALUE FOR CUSTOMS PURPOSES ONLY"
  422. xlSheet.Cells(N1 + 18, 1) = "UPS " & TextBox2.Text
  423. xlSheet.Cells(N1 + 19, 1) = "MADE IN CHINA SAMPLE NOT FOR RESALE"
  424. xlSheet.Cells(N1 + 20, 1) = "SIGNATURE : " & gUserName
  425. AA(xlApp, xlSheet)
  426. xlSheet.PageSetup.PrintArea = ""
  427. xlApp.Cells.Select()
  428. xlSheet.Range("B1").Select()
  429. xlApp.Application.WindowState = xlMinimized
  430. MsgBox("列印完成")
  431. End Sub
  432. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  433. Return CType(xlBook.Worksheets.Add, Worksheet)
  434. End Function
  435. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  436. xlSheet.Cells.Select()
  437. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  438. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  439. xlSheet.Range("A1:A9").Select()
  440. myExcel.Selection.Font.Bold = True
  441. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  442. .ReadingOrder = xlContext : .MergeCells = False : End With
  443. xlSheet.Range("F1:F9").Select()
  444. myExcel.Selection.Font.Bold = True
  445. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  446. .ReadingOrder = xlContext : .MergeCells = False : End With
  447. xlSheet.Rows("1:9").Select : myExcel.Selection.RowHeight = 20 : xlSheet.Rows("10:10").Select : myExcel.Selection.RowHeight = 25
  448. xlSheet.Rows("11:11").Select : myExcel.Selection.RowHeight = 30 : xlSheet.Rows("12:12").Select : myExcel.Selection.RowHeight = 25
  449. xlSheet.Rows("13:" & N1 + 15).Select : myExcel.Selection.RowHeight = 30
  450. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  451. .ReadingOrder = xlContext : .MergeCells = False : End With
  452. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 20
  453. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 15
  454. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 13
  455. xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 15
  456. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 15
  457. xlSheet.Columns("F:G").Select : myExcel.Selection.ColumnWidth = 20
  458. xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 15
  459. xlSheet.Columns("I:K").Select : myExcel.Selection.ColumnWidth = 8
  460. xlSheet.Rows("12:" & N1 + 15).Select
  461. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  462. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  463. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  464. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  465. xlSheet.Rows(13 + N1 + 3 & ":" & 13 + N1 + 7).Select : myExcel.Selection.RowHeight = 25 : myExcel.Selection.Font.Bold = True
  466. xlSheet.Rows("10:11").Select : myExcel.Selection.Font.Bold = True
  467. xlSheet.Range("A10:K10").Select()
  468. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  469. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  470. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 20 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  471. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  472. xlSheet.Range("A11:K11").Select()
  473. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  474. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  475. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  476. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  477. xlSheet.Range("A" & 13 + N1 + 3 & ":K" & 13 + N1 + 3).Select()
  478. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  479. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  480. xlSheet.Range("A" & 13 + N1 + 4 & ":K" & 13 + N1 + 4).Select()
  481. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  482. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  483. xlSheet.Range("A" & 13 + N1 + 5 & ":K" & 13 + N1 + 5).Select()
  484. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  485. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  486. xlSheet.Range("A" & 13 + N1 + 6 & ":K" & 13 + N1 + 6).Select()
  487. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  488. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  489. xlSheet.Range("A" & 13 + N1 + 7 & ":K" & 13 + N1 + 7).Select()
  490. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  491. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  492. xlSheet.Range("A10:K10").Select()
  493. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  494. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  495. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  496. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  497. xlSheet.Range("A12:K" & 13 + N1 + 2).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. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  504. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  505. myExcel.ActiveWindow.DisplayGridlines = False
  506. myExcel.Application.CutCopyMode = False
  507. myExcel.Application.PrintCommunication = False
  508. With myExcel.ActiveSheet.PageSetup
  509. .PrintTitleRows = "$1:$12"
  510. .PrintTitleColumns = ""
  511. End With
  512. myExcel.Application.PrintCommunication = True
  513. myExcel.ActiveSheet.PageSetup.PrintArea = ""
  514. myExcel.Application.PrintCommunication = False
  515. With myExcel.ActiveSheet.PageSetup
  516. .LeftHeader = ""
  517. .CenterHeader = ""
  518. .RightHeader = ""
  519. .LeftFooter = ""
  520. .CenterFooter = ""
  521. .RightFooter = ""
  522. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  523. .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  524. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  525. .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  526. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  527. .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  528. .PrintHeadings = False
  529. .PrintGridlines = False
  530. .PrintQuality = 600
  531. .CenterHorizontally = False
  532. .CenterVertically = False
  533. .Draft = False
  534. .FirstPageNumber = xlAutomatic
  535. .BlackAndWhite = False
  536. .Zoom = False
  537. .FitToPagesWide = 1
  538. .FitToPagesTall = 1
  539. .OddAndEvenPagesHeaderFooter = False
  540. .DifferentFirstPageHeaderFooter = False
  541. .ScaleWithDocHeaderFooter = True
  542. .AlignMarginsHeaderFooter = True
  543. .EvenPage.LeftHeader.Text = ""
  544. .EvenPage.CenterHeader.Text = ""
  545. .EvenPage.RightHeader.Text = ""
  546. .EvenPage.LeftFooter.Text = ""
  547. .EvenPage.CenterFooter.Text = ""
  548. .EvenPage.RightFooter.Text = ""
  549. .FirstPage.LeftHeader.Text = ""
  550. .FirstPage.CenterHeader.Text = ""
  551. .FirstPage.RightHeader.Text = ""
  552. .FirstPage.LeftFooter.Text = ""
  553. .FirstPage.CenterFooter.Text = ""
  554. .FirstPage.RightFooter.Text = ""
  555. End With
  556. myExcel.Application.PrintCommunication = True
  557. End Sub
  558. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  559. DataGridView2.Visible = True : DataGridView3.Visible = False
  560. End Sub
  561. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  562. DataGridView2.Visible = False : DataGridView3.Visible = True
  563. End Sub
  564. End Class