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

訂單價格利潤明細表.vb 124KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  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. Public Class 訂單價格利潤明細表
  13. ReadOnly conn As New SqlConnection
  14. ReadOnly da As New SqlDataAdapter
  15. ReadOnly cmd As New SqlCommand
  16. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet
  17. Dim dr As SqlDataReader
  18. Dim xlApp As Application
  19. Dim xlBook As Workbook
  20. Dim xlSheet As Worksheet
  21. ReadOnly BB(3) As Boolean : Dim WW As String : Public 平均數 As Integer : Public 最終數 As Integer = 0 : Public 資料數 As Integer = 0 : Dim NUM2 As Integer : Dim N1 As Integer
  22. ReadOnly MYSQL1 As String = "SELECT 訂單控制表.BUYER, 訂單控制表.年份季度, 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號, 訂單控制表.型體號碼, 訂單控制表.GOODBOX AS 型體名稱, 訂單控制表.APMA確認 AS 顏色,
  23. 訂單控制表.TVW AS 楦型, 訂單控制表.訂單數量, 訂單控制表.客戶交期 AS 交期開始, 訂單控制表.客戶交期1 AS 交期結束, 訂單控制表.單價, 訂單控制表.總金額 AS 銷售金額,
  24. 訂單控制表.備註, 訂單控制表.生產工廠, 訂單控制表.資料流水號, 訂單價格利潤明細表.Quantity, 訂單價格利潤明細表.Currency, 訂單價格利潤明細表.Exchange,
  25. 訂單價格利潤明細表.Price, 訂單價格利潤明細表.Discount_price AS [Discount price], 訂單價格利潤明細表.Commercial_invoice AS [Commercial invoice],
  26. 訂單價格利潤明細表.Overage_invoice AS [Overage invoice], 訂單價格利潤明細表.Selling_price AS [Selling price], 訂單價格利潤明細表.HTS_code AS [HTS code],
  27. 訂單價格利潤明細表.Remark1, 訂單價格利潤明細表.Fty_price AS [Fty price], 訂單價格利潤明細表.Mold_cost AS [Mold cost],
  28. 訂單價格利潤明細表.Collected_mold_cost AS [Collected mold cost], 訂單價格利潤明細表.Amortization_qty AS [Amortization qty], 訂單價格利潤明細表.Profit,
  29. 訂單價格利潤明細表.Commission, 訂單價格利潤明細表.Remark2, 訂單價格利潤明細表.Price AS 客戶付款, 訂單價格利潤明細表.Price AS 未收款項,
  30. 訂單價格利潤明細表.Price AS 預收款項, 訂單價格利潤明細表.Price AS 成本金額, 訂單價格利潤明細表.Price AS 利潤, 訂單價格利潤明細表.Price AS 實際收款,
  31. 訂單價格利潤明細表.年份, 訂單價格利潤明細表.利潤表流水號, 訂單價格利潤明細表.審核
  32. FROM 訂單控制表 LEFT OUTER JOIN 訂單價格利潤明細表 ON 訂單控制表.資料流水號 = 訂單價格利潤明細表.資料流水號 "
  33. ReadOnly MYSQL2 As String = "SELECT 訂單控制表.BUYER, 訂單控制表.年份季度, 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號, 訂單控制表.型體號碼, 訂單控制表.GOODBOX AS 型體名稱,
  34. 訂單控制表.APMA確認 AS 顏色, 訂單控制表.TVW AS 楦型, 訂單控制表.訂單數量, 訂單控制表.客戶交期 AS 交期開始, 訂單控制表.客戶交期1 AS 交期結束, 訂單控制表.單價,
  35. 訂單控制表.總金額 AS 銷售金額, 訂單控制表.備註, 訂單控制表.生產工廠, 訂單控制表.資料流水號, 訂單價格利潤明細表.Quantity, 訂單價格利潤明細表.Currency,
  36. 訂單價格利潤明細表.Exchange, 訂單價格利潤明細表.Price, 訂單價格利潤明細表.Discount_price AS [Discount price],
  37. 訂單價格利潤明細表.Commercial_invoice AS [Commercial invoice], 訂單價格利潤明細表.Overage_invoice AS [Overage invoice],
  38. 訂單價格利潤明細表.Selling_price AS [Selling price], 訂單價格利潤明細表.HTS_code AS [HTS code], 訂單價格利潤明細表.Remark1,
  39. 訂單價格利潤明細表.Fty_price AS [Fty price], 訂單價格利潤明細表.Mold_cost AS [Mold cost], 訂單價格利潤明細表.Collected_mold_cost AS [Collected mold cost],
  40. 訂單價格利潤明細表.Amortization_qty AS [Amortization qty], 訂單價格利潤明細表.Profit, 訂單價格利潤明細表.Commission, 訂單價格利潤明細表.Remark2,
  41. 訂單價格利潤明細表.Price AS 客戶付款, 訂單價格利潤明細表.Price AS 未收款項, 訂單價格利潤明細表.Price AS 預收款項, 訂單價格利潤明細表.Price AS 成本金額,
  42. 訂單價格利潤明細表.Price AS 利潤, 訂單價格利潤明細表.Price AS 實際收款, 訂單價格利潤明細表.年份, 訂單價格利潤表暫存檔.利潤表流水號, 訂單價格利潤明細表.審核
  43. FROM 訂單控制表 INNER JOIN 訂單價格利潤表暫存檔 ON 訂單控制表.資料流水號 = 訂單價格利潤表暫存檔.資料流水號 LEFT OUTER JOIN
  44. 訂單價格利潤明細表 ON 訂單控制表.資料流水號 = 訂單價格利潤明細表.資料流水號
  45. ORDER BY 訂單控制表.訂單流水號 DESC"
  46. Private Sub Set_DGV1載入前設定()
  47. 清單1_dgv.DataSource = Nothing : ds.Clear()
  48. 清單1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  49. 清單1_dgv.ColumnHeadersHeight = 50
  50. 清單1_dgv.AllowUserToAddRows = False
  51. 清單1_dgv.RowTemplate.Height = 35
  52. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  53. End Sub
  54. Private Sub Set_DGV1載入後設定()
  55. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.SelectCommand.CommandTimeout = 900 : da.Fill(ds) : 清單1_dgv.DataSource = ds.Tables(0) : conn.Close()
  56. End Sub
  57. Private Sub Set_訂單清單1()
  58. Set_DGV1載入前設定()
  59. If CheckBox1.Checked = True Then
  60. Timer1.Enabled = True : Button6.Enabled = True : Button5.Enabled = False : Button9.Enabled = False
  61. Button11.Enabled = True : Button12.Enabled = True : Button13.Enabled = True
  62. If TextBox1.Text = "" Then
  63. SQL1 = MYSQL1 & "WHERE ((訂單控制表.訂單流水號 Like '%" & PA & "%') OR (訂單控制表.年份季度 LIKE '%" & PA & "%') OR (訂單控制表.客戶訂單號 LIKE '%" & PA & "%') OR
  64. (訂單控制表.型體號碼 Like '%" & PA & "%') OR (訂單控制表.APMA確認 LIKE '%" & PA & "%') OR (訂單控制表.GOODBOX LIKE '%" & PA & "%') OR
  65. (訂單控制表.TVW Like '%" & PA & "%') OR (訂單控制表.備註 LIKE '%" & PA & "%') OR (訂單控制表.生產工廠 LIKE '%" & PA & "%')) AND
  66. (訂單價格利潤明細表.訂單流水號 Is Not NULL) AND (訂單價格利潤明細表.CFMSPEC LIKE 'LANDED BRANDED')
  67. ORDER BY 訂單控制表.訂單流水號 DESC"
  68. Else
  69. SQL1 = MYSQL1 & "WHERE (訂單控制表.訂單流水號 LIKE '" & TextBox1.Text & "') AND (訂單控制表.CXL IS NULL OR 訂單控制表.CXL = 0) AND (訂單控制表.CFMSPEC LIKE 'LANDED BRANDED')
  70. ORDER BY 訂單控制表.訂單流水號 DESC"
  71. End If
  72. Set_DGV1載入後設定() : Set_grid() : Set_自動彙總1()
  73. Set_暫存資料設定() : Set_編輯清單1() : Set_grid() : Set_grid3() : Set_自動彙總1()
  74. ElseIf CheckBox1.Checked = False Then
  75. Timer1.Enabled = False : Label47.Visible = False : Button6.Enabled = False : Button5.Enabled = True : Button9.Enabled = True
  76. Button11.Enabled = False : Button12.Enabled = False : Button13.Enabled = False
  77. If PA = "" Then
  78. SQL1 = MYSQL1 & "WHERE (訂單控制表.CXL IS NULL) OR (訂單控制表.CXL = 0) AND (訂單價格利潤明細表.年份 LIKE '" & ComboBox1.Text & "') AND (訂單控制表.CFMSPEC LIKE 'LANDED BRANDED')
  79. ORDER BY 訂單控制表.訂單流水號 DESC"
  80. Else
  81. SQL1 = MYSQL1 & "WHERE ((訂單控制表.訂單流水號 Like '%" & PA & "%') OR (訂單控制表.年份季度 LIKE '%" & PA & "%') OR (訂單控制表.客戶訂單號 LIKE '%" & PA & "%') OR
  82. (訂單控制表.型體號碼 LIKE '%" & PA & "%') OR (訂單控制表.APMA確認 LIKE '%" & PA & "%') OR (訂單控制表.GOODBOX LIKE '%" & PA & "%') OR
  83. (訂單控制表.TVW LIKE '%" & PA & "%') OR (訂單控制表.備註 LIKE '%" & PA & "%') OR (訂單控制表.生產工廠 LIKE '%" & PA & "%')) AND
  84. (訂單價格利潤明細表.訂單流水號 IS NOT NULL) AND (訂單價格利潤明細表.年份 LIKE '" & ComboBox1.Text & "') AND
  85. (訂單控制表.CXL IS NULL OR 訂單控制表.CXL = 0) AND (訂單控制表.CFMSPEC LIKE 'LANDED BRANDED')
  86. ORDER BY 訂單控制表.訂單流水號 DESC"
  87. End If
  88. 列印用SQL = SQL1
  89. Set_DGV1載入後設定()
  90. End If
  91. End Sub
  92. Private Sub Set_編輯清單1()
  93. Set_DGV1載入前設定() : SQL1 = MYSQL2 : Set_DGV1載入後設定() : Me.Button13.PerformClick() : Me.Button11.PerformClick()
  94. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1 : 清單1_dgv.Rows(i).Cells("Currency").Value = "USD" : 清單1_dgv.Rows(i).Cells("年份").Value = ComboBox1.Text : Next i
  95. End Sub
  96. Private Sub Set_DGV3載入前設定()
  97. 清單2_dgv.DataSource = Nothing : ds2.Clear()
  98. 清單2_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  99. 清單2_dgv.ColumnHeadersHeight = 50
  100. 清單2_dgv.AllowUserToAddRows = False
  101. 清單2_dgv.RowTemplate.Height = 35
  102. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  103. End Sub
  104. Private Sub Set_DGV3載入後設定()
  105. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.SelectCommand.CommandTimeout = 900 : da.Fill(ds2) : 清單2_dgv.DataSource = ds2.Tables(0) : conn.Close()
  106. End Sub
  107. Private Sub Set_訂單清單2()
  108. Set_DGV3載入前設定()
  109. If CheckBox1.Checked = True Then
  110. Timer1.Enabled = True : Button6.Enabled = True : Button5.Enabled = False : Button9.Enabled = False
  111. Button11.Enabled = True : Button12.Enabled = True : Button13.Enabled = True
  112. If TextBox1.Text = "" Then
  113. SQL1 = MYSQL1 & "WHERE ((訂單控制表.訂單流水號 Like '%" & PA & "%') OR (訂單控制表.年份季度 LIKE '%" & PA & "%') OR (訂單控制表.客戶訂單號 LIKE '%" & PA & "%') OR
  114. (訂單控制表.型體號碼 Like '%" & PA & "%') OR (訂單控制表.APMA確認 LIKE '%" & PA & "%') OR (訂單控制表.GOODBOX LIKE '%" & PA & "%') OR
  115. (訂單控制表.TVW Like '%" & PA & "%') OR (訂單控制表.備註 LIKE '%" & PA & "%') OR (訂單控制表.生產工廠 LIKE '%" & PA & "%')) AND
  116. (訂單價格利潤明細表.訂單流水號 Is Not NULL) AND (訂單控制表.CFMSPEC LIKE 'FIRST COST')
  117. ORDER BY 訂單控制表.訂單流水號 DESC"
  118. Else
  119. SQL1 = MYSQL1 & "WHERE (訂單控制表.訂單流水號 LIKE '" & TextBox1.Text & "') AND (訂單控制表.CXL IS NULL OR 訂單控制表.CXL = 0) AND (訂單控制表.CFMSPEC LIKE 'FIRST COST')
  120. ORDER BY 訂單控制表.訂單流水號 DESC"
  121. End If
  122. Set_DGV3載入後設定() : Set_grid3() : Set_自動彙總1()
  123. Set_暫存資料設定() : Set_編輯清單2() : Set_grid3() : Set_自動彙總1()
  124. ElseIf CheckBox1.Checked = False Then
  125. Timer1.Enabled = False : Label47.Visible = False : Button6.Enabled = False : Button5.Enabled = True : Button9.Enabled = True
  126. Button11.Enabled = False : Button12.Enabled = False : Button13.Enabled = False
  127. If PA = "" Then
  128. SQL1 = MYSQL1 & "WHERE (訂單控制表.CXL IS NULL) OR (訂單控制表.CXL = 0) AND (訂單價格利潤明細表.年份 LIKE '" & ComboBox1.Text & "') AND (訂單控制表.CFMSPEC LIKE 'FIRST COST')
  129. ORDER BY 訂單控制表.訂單流水號 DESC"
  130. Else
  131. SQL1 = MYSQL1 & "WHERE ((訂單控制表.訂單流水號 Like '%" & PA & "%') OR (訂單控制表.年份季度 LIKE '%" & PA & "%') OR (訂單控制表.客戶訂單號 LIKE '%" & PA & "%') OR
  132. (訂單控制表.型體號碼 LIKE '%" & PA & "%') OR (訂單控制表.APMA確認 LIKE '%" & PA & "%') OR (訂單控制表.GOODBOX LIKE '%" & PA & "%') OR
  133. (訂單控制表.TVW LIKE '%" & PA & "%') OR (訂單控制表.備註 LIKE '%" & PA & "%') OR (訂單控制表.生產工廠 LIKE '%" & PA & "%')) AND
  134. (訂單價格利潤明細表.訂單流水號 IS NOT NULL) AND (訂單價格利潤明細表.年份 LIKE '" & ComboBox1.Text & "') AND
  135. (訂單控制表.CXL IS NULL OR 訂單控制表.CXL = 0) AND (訂單控制表.CFMSPEC LIKE 'FIRST COST')
  136. ORDER BY 訂單控制表.訂單流水號 DESC"
  137. End If
  138. 列印用SQL = SQL1
  139. Set_DGV3載入後設定()
  140. End If
  141. End Sub
  142. Private Sub Set_編輯清單2()
  143. Set_DGV3載入前設定() : SQL1 = MYSQL2 : Set_DGV3載入後設定() : Me.Button13.PerformClick() : Me.Button11.PerformClick()
  144. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1 : 清單2_dgv.Rows(i).Cells("Currency").Value = "USD" : 清單2_dgv.Rows(i).Cells("年份").Value = ComboBox1.Text : Next i
  145. End Sub
  146. Private Sub Set_暫存資料設定()
  147. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  148. SQL1 = "DELETE FROM 訂單價格利潤表暫存檔"
  149. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : cmd.ExecuteNonQuery() : conn.Close()
  150. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  151. SQL1 = "SELECT TOP (1) 利潤表流水號 FROM 訂單價格利潤明細表 ORDER BY 利潤表流水號 DESC"
  152. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  153. If dr.Read() Then : NUM2 = Strings.Right(dr("利潤表流水號").ToString, 8) : End If
  154. conn.Close()
  155. If ComboBox10.Text = "LANDED BRANDED" Then
  156. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  157. Set_暫存資料設定1()
  158. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  159. SQL1 = "INSERT INTO 訂單價格利潤表暫存檔 (資料流水號, 利潤表流水號, 訂單流水號) " &
  160. "VALUES ('" & 清單1_dgv.Rows(i).Cells("資料流水號").Value & "','" & WW & "', '" & 清單1_dgv.Rows(i).Cells("訂單流水號").Value & "')"
  161. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  162. Next i
  163. Else
  164. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1
  165. Set_暫存資料設定1()
  166. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  167. SQL1 = "INSERT INTO 訂單價格利潤表暫存檔 (資料流水號, 利潤表流水號, 訂單流水號) " &
  168. "VALUES ('" & 清單2_dgv.Rows(i).Cells("資料流水號").Value & "','" & WW & "', '" & 清單2_dgv.Rows(i).Cells("訂單流水號").Value & "')"
  169. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  170. Next i
  171. End If
  172. End Sub
  173. Private Sub Set_暫存資料設定1()
  174. NUM2 += 1
  175. If NUM2 < 10 Then : WW = "PR" & "0000000" & NUM2
  176. ElseIf NUM2 > 9 And NUM2 < 100 Then : WW = "PR" & "000000" & NUM2
  177. ElseIf NUM2 > 99 And NUM2 < 1000 Then : WW = "PR" & "00000" & NUM2
  178. ElseIf NUM2 > 999 And NUM2 < 10000 Then : WW = "PR" & "0000" & NUM2
  179. ElseIf NUM2 > 9999 And NUM2 < 100000 Then : WW = "PR" & "000" & NUM2
  180. ElseIf NUM2 > 99999 And NUM2 < 100000 Then : WW = "PR" & "00" & NUM2
  181. ElseIf NUM2 > 999999 And NUM2 < 1000000 Then : WW = "PR" & "0" & NUM2
  182. ElseIf NUM2 > 9999999 Then : WW = "PR" & NUM2
  183. End If
  184. End Sub
  185. Private Sub Set_未建檔清單()
  186. DataGridView2.DataSource = Nothing : ds1.Clear()
  187. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  188. DataGridView2.ColumnHeadersHeight = 25
  189. DataGridView2.AllowUserToAddRows = False
  190. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  191. SQL1 = "SELECT 訂單控制表.訂單流水號
  192. FROM 訂單控制表 FULL OUTER JOIN 訂單價格利潤明細表 ON 訂單控制表.資料流水號 = 訂單價格利潤明細表.資料流水號
  193. WHERE (訂單控制表.CXL IS NULL OR 訂單控制表.CXL = 0) AND (訂單控制表.CFMSPEC LIKE '" & ComboBox10.Text & "') AND
  194. (訂單價格利潤明細表.資料流水號 IS NULL) AND (訂單控制表.CFMSPEC LIKE '" & ComboBox10.Text & "')
  195. GROUP BY 訂單控制表.訂單流水號
  196. ORDER BY 訂單控制表.訂單流水號 DESC"
  197. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.SelectCommand.CommandTimeout = 900 : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
  198. End Sub
  199. Private Sub Set_grid()
  200. 清單1_dgv.Columns(0).ReadOnly = True : 清單1_dgv.Columns(1).ReadOnly = True : 清單1_dgv.Columns(2).ReadOnly = True : 清單1_dgv.Columns(3).ReadOnly = True
  201. 清單1_dgv.Columns(4).ReadOnly = True : 清單1_dgv.Columns(5).ReadOnly = True : 清單1_dgv.Columns(6).ReadOnly = True : 清單1_dgv.Columns(7).ReadOnly = True
  202. 清單1_dgv.Columns(8).ReadOnly = True : 清單1_dgv.Columns(9).ReadOnly = True : 清單1_dgv.Columns(10).ReadOnly = True : 清單1_dgv.Columns(12).ReadOnly = True
  203. 清單1_dgv.Columns(13).ReadOnly = True : 清單1_dgv.Columns(14).ReadOnly = True : 清單1_dgv.Columns(20).ReadOnly = True : 清單1_dgv.Columns(22).ReadOnly = True
  204. 清單1_dgv.Columns(28).ReadOnly = True : 清單1_dgv.Columns(30).ReadOnly = True : 清單1_dgv.Columns(31).ReadOnly = True : 清單1_dgv.Columns(33).ReadOnly = True
  205. 清單1_dgv.Columns(34).ReadOnly = True : 清單1_dgv.Columns(35).ReadOnly = True : 清單1_dgv.Columns(36).ReadOnly = True : 清單1_dgv.Columns(37).ReadOnly = True
  206. 清單1_dgv.Columns(38).ReadOnly = True : 清單1_dgv.Columns(39).ReadOnly = True : 清單1_dgv.Columns(40).ReadOnly = True
  207. '764
  208. 清單1_dgv.Columns(0).Width = 90 : 清單1_dgv.Columns(1).Width = 100 : 清單1_dgv.Columns(2).Width = 115 : 清單1_dgv.Columns(3).Width = 80
  209. 清單1_dgv.Columns(4).Width = 90 : 清單1_dgv.Columns(5).Width = 90 : 清單1_dgv.Columns(6).Width = 100 : 清單1_dgv.Columns(7).Width = 50
  210. 清單1_dgv.Columns(8).Width = 60 : 清單1_dgv.Columns(9).Width = 70 : 清單1_dgv.Columns(10).Width = 70 : 清單1_dgv.Columns(11).Width = 60
  211. 清單1_dgv.Columns(12).Width = 80 : 清單1_dgv.Columns(13).Width = 100 : 清單1_dgv.Columns(14).Width = 80 : 清單1_dgv.Columns(15).Visible = False
  212. 清單1_dgv.Columns(16).Width = 60 : 清單1_dgv.Columns(17).Width = 60 : 清單1_dgv.Columns(18).Width = 65 : 清單1_dgv.Columns(19).Width = 60
  213. 清單1_dgv.Columns(20).Width = 70 : 清單1_dgv.Columns(21).Width = 80 : 清單1_dgv.Columns(22).Width = 70
  214. 清單1_dgv.Columns(23).Visible = False : 清單1_dgv.Columns(24).Visible = False
  215. 清單1_dgv.Columns(25).Width = 168 : 清單1_dgv.Columns(26).Width = 60 : 清單1_dgv.Columns(27).Width = 60 : 清單1_dgv.Columns(28).Width = 80 : 清單1_dgv.Columns(29).Width = 100
  216. 清單1_dgv.Columns(30).Width = 80 : 清單1_dgv.Columns(31).Width = 80 : 清單1_dgv.Columns(31).Width = 100 : 清單1_dgv.Columns(32).Width = 263 : 清單1_dgv.Columns(39).Width = 70
  217. 清單1_dgv.Columns(40).Width = 85 : 清單1_dgv.Columns(41).Width = 57
  218. 清單1_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" : 清單1_dgv.Columns(11).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(12).DefaultCellStyle.Format = "#,##0.00"
  219. 清單1_dgv.Columns(16).DefaultCellStyle.Format = "#,##0" : 清單1_dgv.Columns(18).DefaultCellStyle.Format = "#,##0.0000" : 清單1_dgv.Columns(19).DefaultCellStyle.Format = "#,##0.00"
  220. 清單1_dgv.Columns(20).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(21).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(22).DefaultCellStyle.Format = "#,##0.00"
  221. 清單1_dgv.Columns(26).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(27).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(28).DefaultCellStyle.Format = "#,##0.00"
  222. 清單1_dgv.Columns(29).DefaultCellStyle.Format = "#,##0" : 清單1_dgv.Columns(30).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(31).DefaultCellStyle.Format = "#,##0.00"
  223. 清單1_dgv.Columns(33).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(34).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(35).DefaultCellStyle.Format = "#,##0.00"
  224. 清單1_dgv.Columns(36).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(37).DefaultCellStyle.Format = "#,##0.00" : 清單1_dgv.Columns(38).DefaultCellStyle.Format = "#,##0.00"
  225. 清單1_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  226. 清單1_dgv.Columns(11).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(11).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  227. 清單1_dgv.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  228. 清單1_dgv.Columns(16).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(16).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  229. 清單1_dgv.Columns(17).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(17).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  230. 清單1_dgv.Columns(18).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(18).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  231. 清單1_dgv.Columns(19).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(19).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  232. 清單1_dgv.Columns(20).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(20).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  233. 清單1_dgv.Columns(21).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(21).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  234. 清單1_dgv.Columns(22).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(22).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  235. 清單1_dgv.Columns(26).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(26).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  236. 清單1_dgv.Columns(27).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(27).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  237. 清單1_dgv.Columns(28).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(28).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  238. 清單1_dgv.Columns(29).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(29).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  239. 清單1_dgv.Columns(30).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(30).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  240. 清單1_dgv.Columns(31).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(31).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  241. 清單1_dgv.Columns(33).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(33).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  242. 清單1_dgv.Columns(34).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(34).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  243. 清單1_dgv.Columns(35).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(35).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  244. 清單1_dgv.Columns(36).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(36).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  245. 清單1_dgv.Columns(37).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(37).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  246. 清單1_dgv.Columns(38).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(38).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  247. 清單1_dgv.Columns(39).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(39).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  248. 清單1_dgv.Columns(40).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(40).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  249. 清單1_dgv.Columns(41).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單1_dgv.Columns(41).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  250. 清單1_dgv.Columns(11).DefaultCellStyle.BackColor = Color.MistyRose : 清單1_dgv.Columns(16).DefaultCellStyle.BackColor = Color.MistyRose
  251. 清單1_dgv.Columns(17).DefaultCellStyle.BackColor = Color.MistyRose : 清單1_dgv.Columns(18).DefaultCellStyle.BackColor = Color.MistyRose
  252. 清單1_dgv.Columns(19).DefaultCellStyle.BackColor = Color.MistyRose : 清單1_dgv.Columns(21).DefaultCellStyle.BackColor = Color.MistyRose
  253. 清單1_dgv.Columns(26).DefaultCellStyle.BackColor = Color.MistyRose : 清單1_dgv.Columns(27).DefaultCellStyle.BackColor = Color.MistyRose
  254. 清單1_dgv.Columns(29).DefaultCellStyle.BackColor = Color.MistyRose
  255. 清單1_dgv.Columns(0).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(1).DefaultCellStyle.ForeColor = Color.Blue
  256. 清單1_dgv.Columns(2).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(3).DefaultCellStyle.ForeColor = Color.Blue
  257. 清單1_dgv.Columns(4).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(5).DefaultCellStyle.ForeColor = Color.Blue
  258. 清單1_dgv.Columns(6).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(7).DefaultCellStyle.ForeColor = Color.Blue
  259. 清單1_dgv.Columns(8).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(9).DefaultCellStyle.ForeColor = Color.Blue
  260. 清單1_dgv.Columns(10).DefaultCellStyle.ForeColor = Color.Blue
  261. 清單1_dgv.Columns(12).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(20).DefaultCellStyle.ForeColor = Color.Red
  262. 清單1_dgv.Columns(22).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(28).DefaultCellStyle.ForeColor = Color.Red
  263. 清單1_dgv.Columns(30).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(31).DefaultCellStyle.ForeColor = Color.Red
  264. 清單1_dgv.Columns(33).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(36).DefaultCellStyle.ForeColor = Color.Red
  265. 清單1_dgv.Columns(34).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(37).DefaultCellStyle.ForeColor = Color.Red
  266. 清單1_dgv.Columns(35).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(38).DefaultCellStyle.ForeColor = Color.Red
  267. If BB(0) = True And BB(1) = False And BB(2) = False And BB(3) = False Then
  268. 清單1_dgv.Columns(17).Visible = True : 清單1_dgv.Columns(18).Visible = True : 清單1_dgv.Columns(19).Visible = True : 清單1_dgv.Columns(20).Visible = True
  269. 清單1_dgv.Columns(21).Visible = True : 清單1_dgv.Columns(22).Visible = True : 清單1_dgv.Columns(25).Visible = True : 清單1_dgv.Columns(13).Visible = True
  270. 清單1_dgv.Columns(14).Visible = True : 清單1_dgv.Columns(16).Visible = True
  271. 清單1_dgv.Columns(26).Visible = False : 清單1_dgv.Columns(27).Visible = False : 清單1_dgv.Columns(28).Visible = False : 清單1_dgv.Columns(29).Visible = False
  272. 清單1_dgv.Columns(30).Visible = False : 清單1_dgv.Columns(31).Visible = False : 清單1_dgv.Columns(32).Visible = False : 清單1_dgv.Columns(33).Visible = False
  273. 清單1_dgv.Columns(34).Visible = False : 清單1_dgv.Columns(35).Visible = False : 清單1_dgv.Columns(36).Visible = False : 清單1_dgv.Columns(37).Visible = False
  274. 清單1_dgv.Columns(38).Visible = False : 清單1_dgv.Columns(39).Visible = False : 清單1_dgv.Columns(40).Visible = False : 清單1_dgv.Columns(41).Visible = False
  275. ElseIf BB(0) = False And BB(1) = True And BB(2) = False And BB(3) = False Then
  276. 清單1_dgv.Columns(17).Visible = False : 清單1_dgv.Columns(18).Visible = False : 清單1_dgv.Columns(19).Visible = False : 清單1_dgv.Columns(20).Visible = False
  277. 清單1_dgv.Columns(21).Visible = False : 清單1_dgv.Columns(22).Visible = False : 清單1_dgv.Columns(25).Visible = False : 清單1_dgv.Columns(13).Visible = False
  278. 清單1_dgv.Columns(14).Visible = False : 清單1_dgv.Columns(16).Visible = False
  279. 清單1_dgv.Columns(26).Visible = True : 清單1_dgv.Columns(27).Visible = True : 清單1_dgv.Columns(28).Visible = True : 清單1_dgv.Columns(29).Visible = True
  280. 清單1_dgv.Columns(30).Visible = True : 清單1_dgv.Columns(31).Visible = True : 清單1_dgv.Columns(32).Visible = True : 清單1_dgv.Columns(39).Visible = True
  281. 清單1_dgv.Columns(34).Visible = False : 清單1_dgv.Columns(35).Visible = False : 清單1_dgv.Columns(36).Visible = False : 清單1_dgv.Columns(37).Visible = False
  282. 清單1_dgv.Columns(38).Visible = False : 清單1_dgv.Columns(33).Visible = False : 清單1_dgv.Columns(40).Visible = False : 清單1_dgv.Columns(41).Visible = False
  283. ElseIf BB(0) = False And BB(1) = False And BB(2) = True And BB(3) = False Then
  284. 清單1_dgv.Columns(17).Visible = False : 清單1_dgv.Columns(18).Visible = False : 清單1_dgv.Columns(19).Visible = False : 清單1_dgv.Columns(20).Visible = False
  285. 清單1_dgv.Columns(21).Visible = False : 清單1_dgv.Columns(22).Visible = False : 清單1_dgv.Columns(25).Visible = False : 清單1_dgv.Columns(13).Visible = False
  286. 清單1_dgv.Columns(14).Visible = False : 清單1_dgv.Columns(16).Visible = False : 清單1_dgv.Columns(26).Visible = False : 清單1_dgv.Columns(27).Visible = False
  287. 清單1_dgv.Columns(28).Visible = False : 清單1_dgv.Columns(29).Visible = False : 清單1_dgv.Columns(30).Visible = False : 清單1_dgv.Columns(31).Visible = False
  288. 清單1_dgv.Columns(32).Visible = False
  289. 清單1_dgv.Columns(33).Visible = True : 清單1_dgv.Columns(34).Visible = True : 清單1_dgv.Columns(35).Visible = True : 清單1_dgv.Columns(36).Visible = True
  290. 清單1_dgv.Columns(37).Visible = True : 清單1_dgv.Columns(38).Visible = True : 清單1_dgv.Columns(39).Visible = True : 清單1_dgv.Columns(40).Visible = True
  291. 清單1_dgv.Columns(41).Visible = True
  292. End If
  293. 清單1_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  294. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  295. 清單1_dgv("年份", i).Value = Strings.Left(清單1_dgv("交期開始", i).Value.ToString, 4)
  296. Next
  297. End Sub
  298. Private Sub Set_grid3()
  299. 清單2_dgv.Columns(0).ReadOnly = True : 清單2_dgv.Columns(1).ReadOnly = True : 清單2_dgv.Columns(2).ReadOnly = True : 清單2_dgv.Columns(3).ReadOnly = True
  300. 清單2_dgv.Columns(4).ReadOnly = True : 清單2_dgv.Columns(5).ReadOnly = True : 清單2_dgv.Columns(6).ReadOnly = True : 清單2_dgv.Columns(7).ReadOnly = True
  301. 清單2_dgv.Columns(8).ReadOnly = True : 清單2_dgv.Columns(9).ReadOnly = True : 清單2_dgv.Columns(10).ReadOnly = True : 清單2_dgv.Columns(12).ReadOnly = True
  302. 清單2_dgv.Columns(13).ReadOnly = True : 清單2_dgv.Columns(14).ReadOnly = True : 清單2_dgv.Columns(20).ReadOnly = True : 清單2_dgv.Columns(22).ReadOnly = True
  303. 清單2_dgv.Columns(28).ReadOnly = True : 清單2_dgv.Columns(30).ReadOnly = True : 清單2_dgv.Columns(31).ReadOnly = True : 清單2_dgv.Columns(33).ReadOnly = True
  304. 清單2_dgv.Columns(34).ReadOnly = True : 清單2_dgv.Columns(35).ReadOnly = True : 清單2_dgv.Columns(36).ReadOnly = True : 清單2_dgv.Columns(37).ReadOnly = True
  305. 清單2_dgv.Columns(38).ReadOnly = True : 清單2_dgv.Columns(39).ReadOnly = True : 清單2_dgv.Columns(40).ReadOnly = True
  306. '764
  307. 清單2_dgv.Columns(0).Width = 90 : 清單2_dgv.Columns(1).Width = 100 : 清單2_dgv.Columns(2).Width = 115 : 清單2_dgv.Columns(3).Width = 80
  308. 清單2_dgv.Columns(4).Width = 90 : 清單2_dgv.Columns(5).Width = 90 : 清單2_dgv.Columns(6).Width = 100 : 清單2_dgv.Columns(7).Width = 50
  309. 清單2_dgv.Columns(8).Width = 60 : 清單2_dgv.Columns(9).Width = 70 : 清單2_dgv.Columns(10).Width = 70 : 清單2_dgv.Columns(11).Width = 60
  310. 清單2_dgv.Columns(12).Width = 80 : 清單2_dgv.Columns(13).Width = 100 : 清單2_dgv.Columns(14).Width = 80 : 清單2_dgv.Columns(15).Visible = False
  311. 清單2_dgv.Columns(16).Width = 60 : 清單2_dgv.Columns(17).Width = 60 : 清單2_dgv.Columns(18).Width = 65 : 清單2_dgv.Columns(19).Width = 60
  312. 清單2_dgv.Columns(20).Width = 70
  313. 清單2_dgv.Columns(21).Visible = False : 清單2_dgv.Columns(22).Visible = False : 清單2_dgv.Columns(23).Width = 80 : 清單2_dgv.Columns(24).Width = 105
  314. 清單2_dgv.Columns(25).Width = 133 : 清單2_dgv.Columns(26).Width = 60 : 清單2_dgv.Columns(27).Width = 60 : 清單2_dgv.Columns(28).Width = 80 : 清單2_dgv.Columns(29).Width = 100
  315. 清單2_dgv.Columns(30).Width = 80 : 清單2_dgv.Columns(31).Width = 80 : 清單2_dgv.Columns(31).Width = 100 : 清單2_dgv.Columns(32).Width = 263 : 清單2_dgv.Columns(39).Width = 70
  316. 清單2_dgv.Columns(40).Width = 85 : 清單2_dgv.Columns(41).Width = 57
  317. 清單2_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" : 清單2_dgv.Columns(11).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(12).DefaultCellStyle.Format = "#,##0.00"
  318. 清單2_dgv.Columns(16).DefaultCellStyle.Format = "#,##0" : 清單2_dgv.Columns(18).DefaultCellStyle.Format = "#,##0.0000" : 清單2_dgv.Columns(19).DefaultCellStyle.Format = "#,##0.00"
  319. 清單2_dgv.Columns(20).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(21).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(22).DefaultCellStyle.Format = "#,##0.00"
  320. 清單2_dgv.Columns(26).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(27).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(28).DefaultCellStyle.Format = "#,##0.00"
  321. 清單2_dgv.Columns(29).DefaultCellStyle.Format = "#,##0" : 清單2_dgv.Columns(30).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(31).DefaultCellStyle.Format = "#,##0.00"
  322. 清單2_dgv.Columns(33).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(34).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(35).DefaultCellStyle.Format = "#,##0.00"
  323. 清單2_dgv.Columns(36).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(37).DefaultCellStyle.Format = "#,##0.00" : 清單2_dgv.Columns(38).DefaultCellStyle.Format = "#,##0.00"
  324. 清單2_dgv.Columns(23).DefaultCellStyle.Format = "#,##0.00"
  325. 清單2_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  326. 清單2_dgv.Columns(11).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(11).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  327. 清單2_dgv.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  328. 清單2_dgv.Columns(16).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(16).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  329. 清單2_dgv.Columns(17).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(17).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  330. 清單2_dgv.Columns(18).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(18).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  331. 清單2_dgv.Columns(19).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(19).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  332. 清單2_dgv.Columns(20).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(20).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  333. 清單2_dgv.Columns(21).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(21).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  334. 清單2_dgv.Columns(22).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(22).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  335. 清單2_dgv.Columns(26).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(26).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  336. 清單2_dgv.Columns(27).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(27).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  337. 清單2_dgv.Columns(28).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(28).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  338. 清單2_dgv.Columns(29).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(29).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  339. 清單2_dgv.Columns(30).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(30).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  340. 清單2_dgv.Columns(31).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(31).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  341. 清單2_dgv.Columns(23).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(23).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  342. 清單2_dgv.Columns(33).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(33).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  343. 清單2_dgv.Columns(34).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(34).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  344. 清單2_dgv.Columns(35).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(35).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  345. 清單2_dgv.Columns(36).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(36).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  346. 清單2_dgv.Columns(37).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(37).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  347. 清單2_dgv.Columns(38).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(38).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  348. 清單2_dgv.Columns(39).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(39).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  349. 清單2_dgv.Columns(40).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(40).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  350. 清單2_dgv.Columns(41).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 清單2_dgv.Columns(41).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  351. 清單2_dgv.Columns(11).DefaultCellStyle.BackColor = Color.MistyRose : 清單2_dgv.Columns(16).DefaultCellStyle.BackColor = Color.MistyRose
  352. 清單2_dgv.Columns(17).DefaultCellStyle.BackColor = Color.MistyRose : 清單2_dgv.Columns(18).DefaultCellStyle.BackColor = Color.MistyRose
  353. 清單2_dgv.Columns(19).DefaultCellStyle.BackColor = Color.MistyRose : 清單2_dgv.Columns(21).DefaultCellStyle.BackColor = Color.MistyRose
  354. 清單2_dgv.Columns(26).DefaultCellStyle.BackColor = Color.MistyRose : 清單2_dgv.Columns(27).DefaultCellStyle.BackColor = Color.MistyRose
  355. 清單2_dgv.Columns(29).DefaultCellStyle.BackColor = Color.MistyRose : 清單2_dgv.Columns(23).DefaultCellStyle.BackColor = Color.MistyRose
  356. 清單2_dgv.Columns(24).DefaultCellStyle.BackColor = Color.MistyRose
  357. 清單2_dgv.Columns(0).DefaultCellStyle.ForeColor = Color.Green : 清單2_dgv.Columns(1).DefaultCellStyle.ForeColor = Color.Green
  358. 清單2_dgv.Columns(2).DefaultCellStyle.ForeColor = Color.Green : 清單2_dgv.Columns(3).DefaultCellStyle.ForeColor = Color.Green
  359. 清單2_dgv.Columns(4).DefaultCellStyle.ForeColor = Color.Green : 清單2_dgv.Columns(5).DefaultCellStyle.ForeColor = Color.Green
  360. 清單2_dgv.Columns(6).DefaultCellStyle.ForeColor = Color.Green : 清單2_dgv.Columns(7).DefaultCellStyle.ForeColor = Color.Green
  361. 清單2_dgv.Columns(8).DefaultCellStyle.ForeColor = Color.Green : 清單2_dgv.Columns(9).DefaultCellStyle.ForeColor = Color.Green
  362. 清單2_dgv.Columns(10).DefaultCellStyle.ForeColor = Color.Green
  363. 清單2_dgv.Columns(12).DefaultCellStyle.ForeColor = Color.Red : 清單2_dgv.Columns(20).DefaultCellStyle.ForeColor = Color.Red
  364. 清單2_dgv.Columns(22).DefaultCellStyle.ForeColor = Color.Red : 清單2_dgv.Columns(28).DefaultCellStyle.ForeColor = Color.Red
  365. 清單2_dgv.Columns(30).DefaultCellStyle.ForeColor = Color.Red : 清單2_dgv.Columns(31).DefaultCellStyle.ForeColor = Color.Red
  366. 清單2_dgv.Columns(33).DefaultCellStyle.ForeColor = Color.Red : 清單2_dgv.Columns(36).DefaultCellStyle.ForeColor = Color.Red
  367. 清單2_dgv.Columns(34).DefaultCellStyle.ForeColor = Color.Red : 清單2_dgv.Columns(37).DefaultCellStyle.ForeColor = Color.Red
  368. 清單2_dgv.Columns(35).DefaultCellStyle.ForeColor = Color.Red : 清單2_dgv.Columns(38).DefaultCellStyle.ForeColor = Color.Red
  369. If BB(0) = True And BB(1) = False And BB(2) = False And BB(3) = False Then
  370. 清單2_dgv.Columns(17).Visible = True : 清單2_dgv.Columns(18).Visible = True : 清單2_dgv.Columns(19).Visible = True : 清單2_dgv.Columns(20).Visible = True
  371. 清單2_dgv.Columns(23).Visible = True : 清單2_dgv.Columns(24).Visible = True : 清單2_dgv.Columns(25).Visible = True : 清單2_dgv.Columns(13).Visible = True
  372. 清單2_dgv.Columns(14).Visible = True : 清單2_dgv.Columns(16).Visible = True
  373. 清單2_dgv.Columns(26).Visible = False : 清單2_dgv.Columns(27).Visible = False : 清單2_dgv.Columns(28).Visible = False : 清單2_dgv.Columns(29).Visible = False
  374. 清單2_dgv.Columns(30).Visible = False : 清單2_dgv.Columns(31).Visible = False : 清單2_dgv.Columns(32).Visible = False : 清單2_dgv.Columns(33).Visible = False
  375. 清單2_dgv.Columns(34).Visible = False : 清單2_dgv.Columns(35).Visible = False : 清單2_dgv.Columns(36).Visible = False : 清單2_dgv.Columns(37).Visible = False
  376. 清單2_dgv.Columns(38).Visible = False : 清單2_dgv.Columns(39).Visible = False : 清單2_dgv.Columns(40).Visible = False : 清單2_dgv.Columns(41).Visible = False
  377. ElseIf BB(0) = False And BB(1) = True And BB(2) = False And BB(3) = False Then
  378. 清單2_dgv.Columns(17).Visible = False : 清單2_dgv.Columns(18).Visible = False : 清單2_dgv.Columns(19).Visible = False : 清單2_dgv.Columns(20).Visible = False
  379. 清單2_dgv.Columns(23).Visible = False : 清單2_dgv.Columns(24).Visible = False : 清單2_dgv.Columns(25).Visible = False : 清單2_dgv.Columns(13).Visible = False
  380. 清單2_dgv.Columns(14).Visible = False : 清單2_dgv.Columns(16).Visible = False
  381. 清單2_dgv.Columns(26).Visible = True : 清單2_dgv.Columns(27).Visible = True : 清單2_dgv.Columns(28).Visible = True : 清單2_dgv.Columns(29).Visible = True
  382. 清單2_dgv.Columns(30).Visible = True : 清單2_dgv.Columns(31).Visible = True : 清單2_dgv.Columns(32).Visible = True : 清單2_dgv.Columns(39).Visible = True
  383. 清單2_dgv.Columns(34).Visible = False : 清單2_dgv.Columns(35).Visible = False : 清單2_dgv.Columns(36).Visible = False : 清單2_dgv.Columns(37).Visible = False
  384. 清單2_dgv.Columns(38).Visible = False : 清單2_dgv.Columns(33).Visible = False : 清單2_dgv.Columns(40).Visible = False : 清單2_dgv.Columns(41).Visible = False
  385. ElseIf BB(0) = False And BB(1) = False And BB(2) = True And BB(3) = False Then
  386. 清單2_dgv.Columns(17).Visible = False : 清單2_dgv.Columns(18).Visible = False : 清單2_dgv.Columns(19).Visible = False : 清單2_dgv.Columns(20).Visible = False
  387. 清單2_dgv.Columns(23).Visible = False : 清單2_dgv.Columns(24).Visible = False : 清單2_dgv.Columns(25).Visible = False : 清單2_dgv.Columns(13).Visible = False
  388. 清單2_dgv.Columns(14).Visible = False : 清單2_dgv.Columns(16).Visible = False : 清單2_dgv.Columns(26).Visible = False : 清單2_dgv.Columns(27).Visible = False
  389. 清單2_dgv.Columns(28).Visible = False : 清單2_dgv.Columns(29).Visible = False : 清單2_dgv.Columns(30).Visible = False : 清單2_dgv.Columns(31).Visible = False
  390. 清單2_dgv.Columns(32).Visible = False
  391. 清單2_dgv.Columns(33).Visible = True : 清單2_dgv.Columns(34).Visible = True : 清單2_dgv.Columns(35).Visible = True : 清單2_dgv.Columns(36).Visible = True
  392. 清單2_dgv.Columns(37).Visible = True : 清單2_dgv.Columns(38).Visible = True : 清單2_dgv.Columns(39).Visible = True : 清單2_dgv.Columns(40).Visible = True
  393. 清單2_dgv.Columns(41).Visible = True
  394. End If
  395. 清單2_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  396. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1
  397. 清單2_dgv("年份", i).Value = Strings.Left(清單2_dgv("交期開始", i).Value.ToString, 4)
  398. Next
  399. End Sub
  400. Private Sub Set_grid1()
  401. DataGridView2.Columns(0).FillWeight = 100
  402. End Sub
  403. Private Sub Set_自動彙總1()
  404. TextBox2.Text = "0" : TextBox19.Text = "0" : TextBox34.Text = "0" : TextBox3.Text = "0" : TextBox4.Text = "0" : TextBox36.Text = "0" : TextBox5.Text = "0" : TextBox11.Text = "0"
  405. TextBox35.Text = "0" : TextBox9.Text = "0" : TextBox20.Text = "0" : TextBox33.Text = "0" : TextBox21.Text = "0" : TextBox22.Text = "0" : TextBox32.Text = "0" : TextBox24.Text = "0"
  406. TextBox23.Text = "0" : TextBox31.Text = "0" : TextBox26.Text = "0" : TextBox25.Text = "0" : TextBox30.Text = "0" : TextBox28.Text = "0" : TextBox27.Text = "0" : TextBox29.Text = "0"
  407. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  408. If 清單1_dgv("Discount price", i).Value.ToString = "" Then : 清單1_dgv("Discount price", i).Value = 0 : End If
  409. If 清單1_dgv("Commercial invoice", i).Value.ToString = "" Then : 清單1_dgv("Commercial invoice", i).Value = 0 : End If
  410. If 清單1_dgv("Mold cost", i).Value.ToString = "" Then : 清單1_dgv("Mold cost", i).Value = 0 : End If
  411. If 清單1_dgv("Fty price", i).Value.ToString = "" Then : 清單1_dgv("Fty price", i).Value = 0 : End If
  412. 清單1_dgv("銷售金額", i).Value = Double.Parse(清單1_dgv("單價", i).Value.ToString) * Double.Parse(清單1_dgv("訂單數量", i).Value)
  413. 清單1_dgv("Discount price", i).Value = Double.Parse(清單1_dgv("單價", i).Value.ToString)
  414. 清單1_dgv("Overage invoice", i).Value = Double.Parse(清單1_dgv("Discount price", i).Value.ToString) - Double.Parse(清單1_dgv("Commercial invoice", i).Value)
  415. 清單1_dgv("Collected mold cost", i).Value = Double.Parse(清單1_dgv("Mold cost", i).Value.ToString) * Double.Parse(清單1_dgv("訂單數量", i).Value)
  416. If Double.Parse(清單1_dgv("Discount price", i).Value.ToString) - Double.Parse(清單1_dgv("Mold cost", i).Value) = 0 Then
  417. 清單1_dgv("Profit", i).Value = 0
  418. Else
  419. 清單1_dgv("Profit", i).Value = (Double.Parse(清單1_dgv("Discount price", i).Value.ToString) - Double.Parse(清單1_dgv("Mold cost", i).Value) -
  420. Double.Parse(清單1_dgv("Fty price", i).Value)) / (Double.Parse(清單1_dgv("Discount price", i).Value.ToString) -
  421. Double.Parse(清單1_dgv("Mold cost", i).Value)) * 100
  422. End If
  423. 清單1_dgv("Commission", i).Value = (Double.Parse(清單1_dgv("單價", i).Value.ToString) - Double.Parse(清單1_dgv("Fty price", i).Value) -
  424. Double.Parse(清單1_dgv("Mold cost", i).Value)) * Double.Parse(清單1_dgv("訂單數量", i).Value)
  425. 清單1_dgv("客戶付款", i).Value = Double.Parse(清單1_dgv("Commercial invoice", i).Value.ToString) * Double.Parse(清單1_dgv("訂單數量", i).Value)
  426. 清單1_dgv("未收款項", i).Value = Double.Parse(清單1_dgv("Overage invoice", i).Value.ToString) * Double.Parse(清單1_dgv("訂單數量", i).Value)
  427. 清單1_dgv("預收款項", i).Value = 0
  428. 清單1_dgv("成本金額", i).Value = (Double.Parse(清單1_dgv("Fty price", i).Value.ToString) + Double.Parse(清單1_dgv("Mold cost", i).Value)) *
  429. Double.Parse(清單1_dgv("訂單數量", i).Value)
  430. 清單1_dgv("利潤", i).Value = (Double.Parse(清單1_dgv("銷售金額", i).Value.ToString) - Double.Parse(清單1_dgv("成本金額", i).Value))
  431. 清單1_dgv("實際收款", i).Value = (Double.Parse(清單1_dgv("利潤", i).Value.ToString) - Double.Parse(清單1_dgv("未收款項", i).Value))
  432. TextBox2.Text = Val(TextBox2.Text) + Double.Parse(清單1_dgv("訂單數量", i).Value) : TextBox3.Text = Val(TextBox3.Text) + Double.Parse(清單1_dgv("銷售金額", i).Value)
  433. TextBox5.Text = Val(TextBox5.Text) + Double.Parse(清單1_dgv("客戶付款", i).Value) : TextBox9.Text = Val(TextBox9.Text) + Double.Parse(清單1_dgv("未收款項", i).Value)
  434. TextBox21.Text = Val(TextBox21.Text) + Double.Parse(清單1_dgv("預收款項", i).Value) : TextBox24.Text = Val(TextBox24.Text) + Double.Parse(清單1_dgv("成本金額", i).Value)
  435. TextBox26.Text = Val(TextBox26.Text) + Double.Parse(清單1_dgv("利潤", i).Value) : TextBox28.Text = Val(TextBox28.Text) + Double.Parse(清單1_dgv("實際收款", i).Value)
  436. Next
  437. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1
  438. If 清單2_dgv("Discount price", i).Value.ToString = "" Then : 清單2_dgv("Discount price", i).Value = 0 : End If
  439. If 清單2_dgv("Commercial invoice", i).Value.ToString = "" Then : 清單2_dgv("Commercial invoice", i).Value = 0 : End If
  440. If 清單2_dgv("Mold cost", i).Value.ToString = "" Then : 清單2_dgv("Mold cost", i).Value = 0 : End If
  441. If 清單2_dgv("Fty price", i).Value.ToString = "" Then : 清單2_dgv("Fty price", i).Value = 0 : End If
  442. If 清單2_dgv("Selling price", i).Value.ToString = "" Then : 清單2_dgv("Selling price", i).Value = 0 : End If
  443. 清單2_dgv("銷售金額", i).Value = Double.Parse(清單2_dgv("單價", i).Value.ToString) * Double.Parse(清單2_dgv("訂單數量", i).Value)
  444. 清單2_dgv("Discount price", i).Value = Double.Parse(清單2_dgv("單價", i).Value.ToString)
  445. 清單2_dgv("Overage invoice", i).Value = Double.Parse(清單2_dgv("Discount price", i).Value.ToString) - Double.Parse(清單2_dgv("Commercial invoice", i).Value)
  446. 清單2_dgv("Collected mold cost", i).Value = Double.Parse(清單2_dgv("Mold cost", i).Value.ToString) * Double.Parse(清單2_dgv("訂單數量", i).Value)
  447. If Double.Parse(清單2_dgv("Discount price", i).Value.ToString) - Double.Parse(清單2_dgv("Mold cost", i).Value) = 0 Then
  448. 清單2_dgv("Profit", i).Value = 0
  449. Else
  450. 清單2_dgv("Profit", i).Value = (Double.Parse(清單2_dgv("Discount price", i).Value.ToString) - Double.Parse(清單2_dgv("Mold cost", i).Value) -
  451. Double.Parse(清單2_dgv("Fty price", i).Value)) / (Double.Parse(清單2_dgv("Discount price", i).Value.ToString) -
  452. Double.Parse(清單2_dgv("Mold cost", i).Value)) * 100
  453. End If
  454. 清單2_dgv("Commission", i).Value = (Double.Parse(清單2_dgv("單價", i).Value.ToString) - Double.Parse(清單2_dgv("Fty price", i).Value) -
  455. Double.Parse(清單2_dgv("Mold cost", i).Value)) * Double.Parse(清單2_dgv("訂單數量", i).Value)
  456. 清單2_dgv("客戶付款", i).Value = Double.Parse(清單2_dgv("Selling price", i).Value.ToString) * Double.Parse(清單2_dgv("訂單數量", i).Value)
  457. 清單2_dgv("未收款項", i).Value = 0
  458. If 清單2_dgv("Selling price", i).Value = 0 Then : 清單2_dgv("預收款項", i).Value = 0 : Else
  459. 清單2_dgv("預收款項", i).Value = (Double.Parse(清單2_dgv("Selling price", i).Value.ToString) - Double.Parse(清單2_dgv("Discount price", i).Value)) *
  460. Double.Parse(清單2_dgv("訂單數量", i).Value)
  461. End If
  462. 清單2_dgv("成本金額", i).Value = (Double.Parse(清單2_dgv("Fty price", i).Value.ToString) + Double.Parse(清單2_dgv("Mold cost", i).Value)) *
  463. Double.Parse(清單2_dgv("訂單數量", i).Value)
  464. 清單2_dgv("利潤", i).Value = (Double.Parse(清單2_dgv("銷售金額", i).Value.ToString) - Double.Parse(清單2_dgv("成本金額", i).Value))
  465. 清單2_dgv("實際收款", i).Value = (Double.Parse(清單2_dgv("利潤", i).Value.ToString) + Double.Parse(清單2_dgv("預收款項", i).Value))
  466. TextBox19.Text = Val(TextBox19.Text) + Double.Parse(清單2_dgv("訂單數量", i).Value) : TextBox4.Text = Val(TextBox4.Text) + Double.Parse(清單2_dgv("銷售金額", i).Value)
  467. TextBox11.Text = Val(TextBox11.Text) + Double.Parse(清單2_dgv("客戶付款", i).Value) : TextBox20.Text = Val(TextBox20.Text) + Double.Parse(清單2_dgv("未收款項", i).Value)
  468. TextBox22.Text = Val(TextBox22.Text) + Double.Parse(清單2_dgv("預收款項", i).Value) : TextBox23.Text = Val(TextBox23.Text) + Double.Parse(清單2_dgv("成本金額", i).Value)
  469. TextBox25.Text = Val(TextBox25.Text) + Double.Parse(清單2_dgv("利潤", i).Value) : TextBox27.Text = Val(TextBox27.Text) + Double.Parse(清單2_dgv("實際收款", i).Value)
  470. Next
  471. TextBox34.Text = Val(TextBox19.Text) + Val(TextBox2.Text) : TextBox36.Text = Val(TextBox3.Text) + Val(TextBox4.Text) : TextBox35.Text = Val(TextBox5.Text) + Val(TextBox11.Text)
  472. TextBox33.Text = Val(TextBox9.Text) + Val(TextBox20.Text) : TextBox32.Text = Val(TextBox21.Text) + Val(TextBox22.Text) : TextBox31.Text = Val(TextBox24.Text) + Val(TextBox23.Text)
  473. TextBox30.Text = Val(TextBox26.Text) + Val(TextBox25.Text) : TextBox29.Text = Val(TextBox28.Text) + Val(TextBox27.Text) : TextBox37.Text = Val(TextBox32.Text) - Val(TextBox33.Text)
  474. If Val(TextBox28.Text) >= 0 Then : TextBox28.ForeColor = Color.Blue : Else : TextBox28.ForeColor = Color.Red : End If
  475. If Val(TextBox27.Text) >= 0 Then : TextBox27.ForeColor = Color.Blue : Else : TextBox27.ForeColor = Color.Red : End If
  476. If Val(TextBox29.Text) >= 0 Then : TextBox29.ForeColor = Color.Blue : Else : TextBox29.ForeColor = Color.Red : End If
  477. If Val(TextBox37.Text) >= 0 Then : TextBox37.ForeColor = Color.Blue : Else : TextBox37.ForeColor = Color.Red : End If
  478. TextBox2.Text = Strings.Format(Val(TextBox2.Text), "#,##0") : TextBox19.Text = Strings.Format(Val(TextBox19.Text), "#,##0") : TextBox34.Text = Strings.Format(Val(TextBox34.Text), "#,##0")
  479. TextBox3.Text = Strings.Format(Val(TextBox3.Text), "#,##0.00") : TextBox4.Text = Strings.Format(Val(TextBox4.Text), "#,##0.00") : TextBox36.Text = Strings.Format(Val(TextBox36.Text), "#,##0.00")
  480. TextBox5.Text = Strings.Format(Val(TextBox5.Text), "#,##0.00") : TextBox11.Text = Strings.Format(Val(TextBox11.Text), "#,##0.00") : TextBox35.Text = Strings.Format(Val(TextBox35.Text), "#,##0.00")
  481. TextBox9.Text = Strings.Format(Val(TextBox9.Text), "#,##0.00") : TextBox20.Text = Strings.Format(Val(TextBox20.Text), "#,##0.00") : TextBox33.Text = Strings.Format(Val(TextBox33.Text), "#,##0.00")
  482. TextBox21.Text = Strings.Format(Val(TextBox21.Text), "#,##0.00") : TextBox22.Text = Strings.Format(Val(TextBox22.Text), "#,##0.00") : TextBox32.Text = Strings.Format(Val(TextBox32.Text), "#,##0.00")
  483. TextBox24.Text = Strings.Format(Val(TextBox24.Text), "#,##0.00") : TextBox23.Text = Strings.Format(Val(TextBox23.Text), "#,##0.00") : TextBox31.Text = Strings.Format(Val(TextBox31.Text), "#,##0.00")
  484. TextBox26.Text = Strings.Format(Val(TextBox26.Text), "#,##0.00") : TextBox25.Text = Strings.Format(Val(TextBox25.Text), "#,##0.00") : TextBox30.Text = Strings.Format(Val(TextBox30.Text), "#,##0.00")
  485. TextBox28.Text = Strings.Format(Val(TextBox28.Text), "#,##0.00") : TextBox27.Text = Strings.Format(Val(TextBox27.Text), "#,##0.00") : TextBox29.Text = Strings.Format(Val(TextBox29.Text), "#,##0.00")
  486. TextBox37.Text = Strings.Format(Val(TextBox37.Text), "#,##0.00")
  487. End Sub
  488. Private Sub Set_格式()
  489. TextBox1.Enabled = False : TextBox12.Enabled = False : TextBox13.Enabled = False : TextBox14.Enabled = False : TextBox15.Enabled = False
  490. TextBox6.Visible = False : TextBox7.Visible = False : TextBox16.Visible = False : TextBox17.Visible = False : TextBox10.Visible = False : TextBox8.Visible = False
  491. Button6.Enabled = False : Timer1.Enabled = False : Label47.Visible = False : Button5.Enabled = True : Button9.Enabled = True
  492. Button11.Enabled = False : Button12.Enabled = False : Button13.Enabled = False
  493. End Sub
  494. Private Sub 訂單價格利潤明細表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  495. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  496. ComboBox1.Text = Year(Today) : ComboBox10.SelectedIndex = 0 : ComboBox2.SelectedIndex = 0
  497. BB(0) = True : BB(1) = False : BB(2) = False : BB(3) = False
  498. Button34.Enabled = False : TextBox18.Visible = False
  499. Set_訂單清單1() : Set_訂單清單2() : Set_grid() : Set_grid3() : Set_未建檔清單() : Set_grid1() : Set_自動彙總1() : Set_格式()
  500. End Sub
  501. Private Sub ComboBox10_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox10.TextChanged
  502. If ComboBox10.Text = "LANDED BRANDED" Then
  503. 清單1_dgv.Visible = True : 清單2_dgv.Visible = False
  504. Else
  505. 清單1_dgv.Visible = False : 清單2_dgv.Visible = True
  506. End If
  507. Set_未建檔清單() : Set_自動彙總1()
  508. End Sub
  509. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  510. If Label47.Visible = True Then : Label47.Visible = False : Else : Label47.Visible = True : End If
  511. End Sub
  512. Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 清單1_dgv.CellEndEdit
  513. Set_自動彙總1()
  514. End Sub
  515. Private Sub DataGridView3_CellEndEdit(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 清單2_dgv.CellEndEdit
  516. Set_自動彙總1()
  517. End Sub
  518. Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 清單1_dgv.CellClick
  519. If e.RowIndex = -1 Then : Else
  520. TextBox1.Text = 清單1_dgv("訂單流水號", e.RowIndex).Value.ToString : TextBox12.Text = 清單1_dgv("客戶訂單號", e.RowIndex).Value.ToString
  521. TextBox13.Text = 清單1_dgv("型體號碼", e.RowIndex).Value.ToString : TextBox14.Text = 清單1_dgv("顏色", e.RowIndex).Value.ToString
  522. TextBox15.Text = 清單1_dgv("楦型", e.RowIndex).Value.ToString : TextBox16.Text = 清單1_dgv("資料流水號", e.RowIndex).Value.ToString
  523. ComboBox1.Text = 清單1_dgv("年份", e.RowIndex).Value.ToString : ComboBox2.Text = 清單1_dgv("Currency", e.RowIndex).Value.ToString
  524. TextBox17.Text = 清單1_dgv("利潤表流水號", e.RowIndex).Value.ToString
  525. End If
  526. End Sub
  527. Private Sub DataGridView3_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 清單2_dgv.CellClick
  528. If e.RowIndex = -1 Then : Else
  529. TextBox1.Text = 清單2_dgv("訂單流水號", e.RowIndex).Value.ToString : TextBox12.Text = 清單2_dgv("客戶訂單號", e.RowIndex).Value.ToString
  530. TextBox13.Text = 清單2_dgv("型體號碼", e.RowIndex).Value.ToString : TextBox14.Text = 清單2_dgv("顏色", e.RowIndex).Value.ToString
  531. TextBox15.Text = 清單2_dgv("楦型", e.RowIndex).Value.ToString : TextBox16.Text = 清單2_dgv("資料流水號", e.RowIndex).Value.ToString
  532. ComboBox1.Text = 清單2_dgv("年份", e.RowIndex).Value.ToString : ComboBox2.Text = 清單2_dgv("Currency", e.RowIndex).Value.ToString
  533. TextBox17.Text = 清單2_dgv("利潤表流水號", e.RowIndex).Value.ToString
  534. End If
  535. End Sub
  536. Private Sub DataGridView2_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  537. If e.RowIndex = -1 Then : Else
  538. TextBox1.Text = DataGridView2(0, e.RowIndex).Value.ToString
  539. Timer1.Enabled = True : Button6.Enabled = True : CheckBox1.Checked = True : CheckBox2.Checked = False : Button5.Enabled = False : Button9.Enabled = False
  540. Button11.Enabled = True : Button12.Enabled = True : Button13.Enabled = True
  541. Set_訂單清單1() : Set_訂單清單2()
  542. End If
  543. End Sub
  544. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
  545. If CheckBox1.Checked = True Then
  546. If TextBox16.Text = "" Or TextBox1.Text = "" Then
  547. MsgBox("沒有選擇將要拆分的資料")
  548. Else
  549. Dim NUM2 As Integer
  550. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  551. SQL1 = "Select Top(1) 利潤表流水號 FROM 訂單價格利潤表暫存檔 ORDER BY 利潤表流水號 DESC"
  552. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  553. If dr.Read() Then : NUM2 = Strings.Right(dr("利潤表流水號").ToString, 8) : End If
  554. conn.Close()
  555. NUM2 += 1
  556. If NUM2 < 10 Then : WW = "PR" & "0000000" & NUM2
  557. ElseIf NUM2 > 9 And NUM2 < 100 Then : WW = "PR" & "000000" & NUM2
  558. ElseIf NUM2 > 99 And NUM2 < 1000 Then : WW = "PR" & "00000" & NUM2
  559. ElseIf NUM2 > 999 And NUM2 < 10000 Then : WW = "PR" & "0000" & NUM2
  560. ElseIf NUM2 > 9999 And NUM2 < 100000 Then : WW = "PR" & "000" & NUM2
  561. ElseIf NUM2 > 99999 And NUM2 < 100000 Then : WW = "PR" & "00" & NUM2
  562. ElseIf NUM2 > 999999 And NUM2 < 1000000 Then : WW = "PR" & "0" & NUM2
  563. ElseIf NUM2 > 9999999 Then : WW = "PR" & NUM2
  564. End If
  565. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  566. SQL1 = "INSERT INTO 訂單價格利潤表暫存檔 (資料流水號, 利潤表流水號, 訂單流水號) " &
  567. "VALUES ('" & TextBox16.Text & "','" & WW & "', '" & TextBox1.Text & "')"
  568. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  569. Set_編輯清單1() : Set_編輯清單2() : Set_grid() : Set_grid3() : Set_自動彙總1()
  570. End If
  571. ElseIf CheckBox1.Checked = False Then
  572. Dim NUM2 As Integer
  573. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  574. SQL1 = "SELECT TOP (1) 利潤表流水號 FROM 訂單價格利潤明細表 ORDER BY 利潤表流水號 DESC"
  575. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  576. If dr.Read() Then : NUM2 = Strings.Right(dr("利潤表流水號").ToString, 8) : End If
  577. conn.Close()
  578. NUM2 += 1
  579. If NUM2 < 10 Then : WW = "PR" & "0000000" & NUM2
  580. ElseIf NUM2 > 9 And NUM2 < 100 Then : WW = "PR" & "000000" & NUM2
  581. ElseIf NUM2 > 99 And NUM2 < 1000 Then : WW = "PR" & "00000" & NUM2
  582. ElseIf NUM2 > 999 And NUM2 < 10000 Then : WW = "PR" & "0000" & NUM2
  583. ElseIf NUM2 > 9999 And NUM2 < 100000 Then : WW = "PR" & "000" & NUM2
  584. ElseIf NUM2 > 99999 And NUM2 < 100000 Then : WW = "PR" & "00" & NUM2
  585. ElseIf NUM2 > 999999 And NUM2 < 1000000 Then : WW = "PR" & "0" & NUM2
  586. ElseIf NUM2 > 9999999 Then : WW = "PR" & NUM2
  587. End If
  588. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  589. SQL1 = "INSERT INTO 訂單價格利潤明細表 (資料流水號, 訂單流水號, 客戶訂單號, 利潤表流水號, 年份, Quantity, Exchange, 審核, 類型, Price,
  590. Discount_price, Commercial_invoice, Overage_invoice, Selling_price, HTS_code, Remark1, Fty_price, Mold_cost,
  591. Collected_mold_cost, Amortization_qty, Profit, Commission, Remark2, Currency) " &
  592. "VALUES ('" & TextBox16.Text & "', '" & TextBox1.Text & "', '" & TextBox12.Text & "', '" & WW & "', '" & ComboBox1.Text & "', N'0', N'0', N'0', N'0', '" & ComboBox10.Text &
  593. "', N'0', N'0', N'0', N'0', N'0', N'', N'', N'0', N'0', N'0', N'0', N'0', N'0', N'', '" & ComboBox2.Text & "')"
  594. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  595. Set_訂單清單1() : Set_訂單清單2() : Set_grid() : Set_grid3() : Set_自動彙總1()
  596. End If
  597. End Sub
  598. Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
  599. If CheckBox1.Checked = True Then
  600. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  601. SQL1 = "DELETE FROM 訂單價格利潤表暫存檔 WHERE 利潤表流水號 LIKE '" & TextBox17.Text & "'"
  602. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : cmd.ExecuteNonQuery() : conn.Close()
  603. Set_編輯清單1() : Set_編輯清單2() : Set_grid() : Set_grid3() : Set_自動彙總1()
  604. ElseIf CheckBox1.Checked = False Then
  605. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  606. SQL1 = "DELETE FROM 訂單價格利潤明細表 WHERE 利潤表流水號 LIKE '" & TextBox17.Text & "'"
  607. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : cmd.ExecuteNonQuery() : conn.Close()
  608. Set_訂單清單1() : Set_訂單清單2() : Set_grid() : Set_grid3() : Set_自動彙總1()
  609. End If
  610. End Sub
  611. Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 清單1_dgv.RowPostPaint
  612. Dim linePen As New Pen(Color.Blue, 2)
  613. If e.RowIndex = 清單1_dgv.Rows.Count - 1 Then
  614. Exit Sub
  615. Else
  616. If 清單1_dgv(2, e.RowIndex).Value.ToString <> 清單1_dgv(2, e.RowIndex + 1).Value.ToString Then
  617. Dim startX As Integer = IIf(清單1_dgv.RowHeadersVisible, 清單1_dgv.RowHeadersWidth, 0)
  618. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  619. Dim endX As Integer = startX + 清單1_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 清單1_dgv.HorizontalScrollingOffset
  620. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  621. Exit Sub
  622. End If
  623. End If
  624. End Sub
  625. Private Sub DataGridView3_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 清單2_dgv.RowPostPaint
  626. Dim linePen As New Pen(Color.Blue, 2)
  627. If e.RowIndex = 清單2_dgv.Rows.Count - 1 Then
  628. Exit Sub
  629. Else
  630. If 清單2_dgv(2, e.RowIndex).Value.ToString <> 清單2_dgv(2, e.RowIndex + 1).Value.ToString Then
  631. Dim startX As Integer = IIf(清單2_dgv.RowHeadersVisible, 清單2_dgv.RowHeadersWidth, 0)
  632. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  633. Dim endX As Integer = startX + 清單2_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 清單2_dgv.HorizontalScrollingOffset
  634. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  635. Exit Sub
  636. End If
  637. End If
  638. End Sub
  639. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  640. PA = ""
  641. CheckBox1.Checked = False : CheckBox2.Checked = True : TextBox1.Text = ""
  642. Timer1.Enabled = False : Label47.Visible = False : Button6.Enabled = False : Button5.Enabled = True : Button9.Enabled = True
  643. Button11.Enabled = False : Button12.Enabled = False : Button13.Enabled = False
  644. Set_訂單清單1() : Set_訂單清單2() : Set_grid() : Set_grid3() : Set_未建檔清單() : Set_grid1() : Set_自動彙總1()
  645. End Sub
  646. Private Sub Button34_Click(sender As Object, e As EventArgs) Handles Button34.Click
  647. Button34.Enabled = False : Button35.Enabled = True : Button2.Enabled = True
  648. BB(0) = True : BB(1) = False : BB(2) = False : BB(3) = False
  649. Set_grid() : Set_grid3()
  650. End Sub
  651. Private Sub Button35_Click(sender As Object, e As EventArgs) Handles Button35.Click
  652. Button34.Enabled = True : Button35.Enabled = False : Button2.Enabled = True
  653. BB(0) = False : BB(1) = True : BB(2) = False : BB(3) = False
  654. Set_grid() : Set_grid3()
  655. End Sub
  656. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  657. Button34.Enabled = True : Button35.Enabled = True : Button2.Enabled = False
  658. BB(0) = False : BB(1) = False : BB(2) = True : BB(3) = False
  659. Set_grid() : Set_grid3()
  660. End Sub
  661. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  662. PA = InputBox("請輸入要查詢的資料") : TextBox1.Text = ""
  663. If ComboBox10.Text = "LANDED BRANDED" Then
  664. Set_訂單清單1() : Set_grid() : Set_自動彙總1()
  665. Else
  666. Set_訂單清單2() : Set_grid3() : Set_自動彙總1()
  667. End If
  668. End Sub
  669. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click
  670. CheckBox1.Checked = True : CheckBox2.Checked = False
  671. End Sub
  672. Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click
  673. CheckBox1.Checked = False : CheckBox2.Checked = True
  674. End Sub
  675. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  676. Set_未建檔清單() : Set_grid1()
  677. End Sub
  678. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  679. If ComboBox1.Text = "" Or ComboBox2.Text = "" Then
  680. MsgBox("年份或幣別沒有選擇")
  681. Else
  682. If ComboBox10.Text = "LANDED BRANDED" Then
  683. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  684. 資料數 = 清單1_dgv.Rows.Count : 進度條()
  685. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  686. SQL1 = "SELECT 利潤表流水號 FROM 訂單價格利潤明細表 WHERE (資料流水號 LIKE '" & 清單1_dgv.Rows(i).Cells("資料流水號").Value & "')"
  687. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  688. If dr.Read() Then
  689. conn.Close()
  690. Else
  691. conn.Close()
  692. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  693. SQL1 = "UPDATE 訂單控制表 SET 單價 = '" & 清單1_dgv.Rows(i).Cells("單價").Value & "', 總金額 = '" & 清單1_dgv.Rows(i).Cells("銷售金額").Value & "' " &
  694. "WHERE (資料流水號 LIKE '" & 清單1_dgv.Rows(i).Cells("資料流水號").Value & "')"
  695. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  696. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  697. SQL1 = "INSERT INTO 訂單價格利潤明細表 (資料流水號, 訂單流水號, 客戶訂單號, 利潤表流水號, 年份, Quantity, Exchange, 審核, 類型, Price,
  698. Discount_price, Commercial_invoice, Overage_invoice, Selling_price, HTS_code, Remark1, Fty_price, Mold_cost,
  699. Collected_mold_cost, Amortization_qty, Profit, Commission, Remark2, Currency) " &
  700. "VALUES ('" & 清單1_dgv.Rows(i).Cells("資料流水號").Value & "', '" & 清單1_dgv.Rows(i).Cells("訂單流水號").Value &
  701. "', '" & 清單1_dgv.Rows(i).Cells("客戶訂單號").Value & "', '" & 清單1_dgv.Rows(i).Cells("利潤表流水號").Value &
  702. "', '" & ComboBox1.Text & "', '" & 清單1_dgv.Rows(i).Cells("Quantity").Value &
  703. "', '" & 清單1_dgv.Rows(i).Cells("Exchange").Value & "', '" & 清單1_dgv.Rows(i).Cells("審核").Value & "', '" & ComboBox10.Text &
  704. "', '" & 清單1_dgv.Rows(i).Cells("Price").Value & "', '" & 清單1_dgv.Rows(i).Cells("Discount price").Value &
  705. "', '" & 清單1_dgv.Rows(i).Cells("Commercial invoice").Value & "', '" & 清單1_dgv.Rows(i).Cells("Overage invoice").Value &
  706. "', '" & 清單1_dgv.Rows(i).Cells("Selling price").Value & "', '" & 清單1_dgv.Rows(i).Cells("HTS code").Value &
  707. "', '" & 清單1_dgv.Rows(i).Cells("Remark1").Value & "', '" & 清單1_dgv.Rows(i).Cells("Fty price").Value &
  708. "', '" & 清單1_dgv.Rows(i).Cells("Mold cost").Value & "', '" & 清單1_dgv.Rows(i).Cells("Collected mold cost").Value &
  709. "', '" & 清單1_dgv.Rows(i).Cells("Amortization qty").Value & "', '" & 清單1_dgv.Rows(i).Cells("Profit").Value &
  710. "', '" & 清單1_dgv.Rows(i).Cells("Commission").Value & "', '" & 清單1_dgv.Rows(i).Cells("Remark2").Value & "', '" & ComboBox2.Text & "')"
  711. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  712. End If
  713. Next i : ProgressBar1.Value = 0 : 最終數 = 0
  714. Else
  715. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1
  716. 資料數 = 清單2_dgv.Rows.Count : 進度條()
  717. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  718. SQL1 = "SELECT 利潤表流水號 FROM 訂單價格利潤明細表 WHERE (資料流水號 LIKE '" & 清單2_dgv.Rows(i).Cells("資料流水號").Value & "')"
  719. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  720. If dr.Read() Then
  721. conn.Close()
  722. Else
  723. conn.Close()
  724. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  725. SQL1 = "UPDATE 訂單控制表 SET 單價 = '" & 清單2_dgv.Rows(i).Cells("單價").Value & "', 總金額 = '" & 清單2_dgv.Rows(i).Cells("銷售金額").Value & "' " &
  726. "WHERE (資料流水號 LIKE '" & 清單2_dgv.Rows(i).Cells("資料流水號").Value & "')"
  727. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  728. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  729. SQL1 = "INSERT INTO 訂單價格利潤明細表 (資料流水號, 訂單流水號, 客戶訂單號, 利潤表流水號, 年份, Quantity, Exchange, 審核, 類型, Price,
  730. Discount_price, Commercial_invoice, Overage_invoice, Selling_price, HTS_code, Remark1, Fty_price, Mold_cost,
  731. Collected_mold_cost, Amortization_qty, Profit, Commission, Remark2, Currency) " &
  732. "VALUES ('" & 清單2_dgv.Rows(i).Cells("資料流水號").Value & "', '" & 清單2_dgv.Rows(i).Cells("訂單流水號").Value &
  733. "', '" & 清單2_dgv.Rows(i).Cells("客戶訂單號").Value & "', '" & 清單2_dgv.Rows(i).Cells("利潤表流水號").Value &
  734. "', '" & ComboBox1.Text & "', '" & 清單2_dgv.Rows(i).Cells("Quantity").Value &
  735. "', '" & 清單2_dgv.Rows(i).Cells("Exchange").Value & "', '" & 清單2_dgv.Rows(i).Cells("審核").Value & "', '" & ComboBox10.Text &
  736. "', '" & 清單2_dgv.Rows(i).Cells("Price").Value & "', '" & 清單2_dgv.Rows(i).Cells("Discount price").Value &
  737. "', '" & 清單2_dgv.Rows(i).Cells("Commercial invoice").Value & "', '" & 清單2_dgv.Rows(i).Cells("Overage invoice").Value &
  738. "', '" & 清單2_dgv.Rows(i).Cells("Selling price").Value & "', '" & 清單2_dgv.Rows(i).Cells("HTS code").Value &
  739. "', '" & 清單2_dgv.Rows(i).Cells("Remark1").Value & "', '" & 清單2_dgv.Rows(i).Cells("Fty price").Value &
  740. "', '" & 清單2_dgv.Rows(i).Cells("Mold cost").Value & "', '" & 清單2_dgv.Rows(i).Cells("Collected mold cost").Value &
  741. "', '" & 清單2_dgv.Rows(i).Cells("Amortization qty").Value & "', '" & 清單2_dgv.Rows(i).Cells("Profit").Value &
  742. "', '" & 清單2_dgv.Rows(i).Cells("Commission").Value & "', '" & 清單2_dgv.Rows(i).Cells("Remark2").Value & "', '" & ComboBox2.Text & "')"
  743. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  744. End If
  745. Next i : ProgressBar1.Value = 0 : 最終數 = 0
  746. End If
  747. MsgBox("存檔完成")
  748. CheckBox1.Checked = False : CheckBox2.Checked = True
  749. Set_訂單清單1() : Set_訂單清單2() : Set_grid() : Set_grid3() : Set_未建檔清單() : Set_grid1() : Set_自動彙總1() : Set_格式()
  750. End If
  751. End Sub
  752. Private Sub 進度條()
  753. 平均數 = 10000 / 資料數
  754. 最終數 += 平均數
  755. If 最終數 > 10000 Then : 最終數 = 10000 : End If
  756. ProgressBar1.Value = 最終數
  757. End Sub
  758. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  759. If ComboBox1.Text = "" Or ComboBox2.Text = "" Then
  760. MsgBox("年份或幣別沒有選擇")
  761. Else
  762. If ComboBox10.Text = "LANDED BRANDED" Then
  763. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  764. 資料數 = 清單1_dgv.Rows.Count : 進度條()
  765. conn.Close()
  766. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  767. SQL1 = "UPDATE 訂單控制表 SET 單價 = '" & 清單1_dgv.Rows(i).Cells("單價").Value & "', 總金額 = '" & 清單1_dgv.Rows(i).Cells("銷售金額").Value & "' " &
  768. "WHERE (資料流水號 LIKE '" & 清單1_dgv.Rows(i).Cells("資料流水號").Value & "')"
  769. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  770. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  771. SQL1 = "UPDATE 訂單價格利潤明細表 SET 年份 = '" & 清單1_dgv.Rows(i).Cells("年份").Value & "', Quantity = '" & 清單1_dgv.Rows(i).Cells("Quantity").Value &
  772. "', Exchange = '" & 清單1_dgv.Rows(i).Cells("Exchange").Value & "', 審核 = '" & 清單1_dgv.Rows(i).Cells("審核").Value &
  773. "', Price = '" & 清單1_dgv.Rows(i).Cells("Price").Value & "', Discount_price = '" & 清單1_dgv.Rows(i).Cells("Discount price").Value &
  774. "', Commercial_invoice = '" & 清單1_dgv.Rows(i).Cells("Commercial invoice").Value &
  775. "', Overage_invoice = '" & 清單1_dgv.Rows(i).Cells("Overage invoice").Value &
  776. "', Selling_price = '" & 清單1_dgv.Rows(i).Cells("Selling price").Value & "', HTS_code = '" & 清單1_dgv.Rows(i).Cells("HTS code").Value &
  777. "', Remark1 = '" & 清單1_dgv.Rows(i).Cells("Remark1").Value & "', Fty_price = '" & 清單1_dgv.Rows(i).Cells("Fty price").Value &
  778. "', Mold_cost = '" & 清單1_dgv.Rows(i).Cells("Mold cost").Value &
  779. "', Collected_mold_cost = '" & 清單1_dgv.Rows(i).Cells("Collected mold cost").Value &
  780. "', Amortization_qty = '" & 清單1_dgv.Rows(i).Cells("Amortization qty").Value & "' , Profit = '" & 清單1_dgv.Rows(i).Cells("Profit").Value &
  781. "', Commission = '" & 清單1_dgv.Rows(i).Cells("Commission").Value & "', Remark2 = '" & 清單1_dgv.Rows(i).Cells("Remark2").Value &
  782. "', Currency = '" & ComboBox2.Text & "'
  783. WHERE (利潤表流水號 LIKE '" & 清單1_dgv.Rows(i).Cells("利潤表流水號").Value & "')"
  784. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  785. TextBox18.Text = Strings.Format(Val((i / (清單1_dgv.Rows.Count - 1)) * 100), "#,##0.0") & "%"
  786. Next i : ProgressBar1.Value = 0 : 最終數 = 0
  787. Else
  788. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1
  789. 資料數 = 清單2_dgv.Rows.Count : 進度條()
  790. conn.Close()
  791. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  792. SQL1 = "UPDATE 訂單控制表 SET 單價 = '" & 清單2_dgv.Rows(i).Cells("單價").Value & "', 總金額 = '" & 清單2_dgv.Rows(i).Cells("銷售金額").Value & "' " &
  793. "WHERE (資料流水號 LIKE '" & 清單2_dgv.Rows(i).Cells("資料流水號").Value & "')"
  794. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  795. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  796. SQL1 = "UPDATE 訂單價格利潤明細表 SET 年份 = '" & 清單2_dgv.Rows(i).Cells("年份").Value & "', Quantity = '" & 清單2_dgv.Rows(i).Cells("Quantity").Value &
  797. "', Exchange = '" & 清單2_dgv.Rows(i).Cells("Exchange").Value & "', 審核 = '" & 清單2_dgv.Rows(i).Cells("審核").Value &
  798. "', Price = '" & 清單2_dgv.Rows(i).Cells("Price").Value & "', Discount_price = '" & 清單2_dgv.Rows(i).Cells("Discount price").Value &
  799. "', Commercial_invoice = '" & 清單2_dgv.Rows(i).Cells("Commercial invoice").Value &
  800. "', Overage_invoice = '" & 清單2_dgv.Rows(i).Cells("Overage invoice").Value &
  801. "', Selling_price = '" & 清單2_dgv.Rows(i).Cells("Selling price").Value & "', HTS_code = '" & 清單2_dgv.Rows(i).Cells("HTS code").Value &
  802. "', Remark1 = '" & 清單2_dgv.Rows(i).Cells("Remark1").Value & "', Fty_price = '" & 清單2_dgv.Rows(i).Cells("Fty price").Value &
  803. "', Mold_cost = '" & 清單2_dgv.Rows(i).Cells("Mold cost").Value &
  804. "', Collected_mold_cost = '" & 清單2_dgv.Rows(i).Cells("Collected mold cost").Value &
  805. "', Amortization_qty = '" & 清單2_dgv.Rows(i).Cells("Amortization qty").Value & "' , Profit = '" & 清單2_dgv.Rows(i).Cells("Profit").Value &
  806. "', Commission = '" & 清單2_dgv.Rows(i).Cells("Commission").Value & "', Remark2 = '" & 清單2_dgv.Rows(i).Cells("Remark2").Value &
  807. "', Currency = '" & ComboBox2.Text & "'
  808. WHERE (利潤表流水號 LIKE '" & 清單2_dgv.Rows(i).Cells("利潤表流水號").Value & "')"
  809. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  810. TextBox18.Text = Strings.Format(Val((i / (清單2_dgv.Rows.Count - 1)) * 100), "#,##0.0") & "%"
  811. Next i : ProgressBar1.Value = 0 : 最終數 = 0
  812. End If
  813. MsgBox("修改完成")
  814. CheckBox1.Checked = False : CheckBox2.Checked = True
  815. Set_訂單清單1() : Set_訂單清單2() : Set_grid() : Set_grid3() : Set_未建檔清單() : Set_grid1() : Set_自動彙總1() : Set_格式()
  816. End If
  817. End Sub
  818. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  819. If TextBox1.Text = "" Then
  820. MsgBox("請選擇要刪除的資料")
  821. Else
  822. Dim aa As MsgBoxResult
  823. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  824. If aa = MsgBoxResult.Ok Then
  825. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  826. SQL1 = "UPDATE 訂單控制表 SET 單價 = '0.00', 總金額 = '0.00' " &
  827. "WHERE (訂單流水號 LIKE '" & TextBox1.Text & "')"
  828. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  829. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  830. SQL1 = "DELETE FROM 訂單價格利潤明細表 WHERE (訂單流水號 = '" & TextBox1.Text & "')"
  831. cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : cmd.ExecuteNonQuery() : conn.Close()
  832. MsgBox("刪除完成")
  833. End If
  834. End If
  835. Set_訂單清單1() : Set_訂單清單2() : Set_grid() : Set_grid3() : Set_未建檔清單() : Set_grid1() : Set_自動彙總1() : Set_格式()
  836. End Sub
  837. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  838. If ComboBox10.Text = "LANDED BRANDED" Then
  839. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1 : 清單1_dgv.Rows(i).Cells("Quantity").Value = 0 : Next i
  840. Else
  841. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1 : 清單2_dgv.Rows(i).Cells("Quantity").Value = 0 : Next i
  842. End If
  843. End Sub
  844. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  845. If ComboBox10.Text = "LANDED BRANDED" Then
  846. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1 : 清單1_dgv.Rows(i).Cells("Quantity").Value = 清單1_dgv.Rows(i).Cells("訂單數量").Value : Next i
  847. Else
  848. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1 : 清單2_dgv.Rows(i).Cells("Quantity").Value = 清單2_dgv.Rows(i).Cells("訂單數量").Value : Next i
  849. End If
  850. End Sub
  851. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  852. If ComboBox10.Text = "LANDED BRANDED" Then
  853. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1 : 清單1_dgv.Rows(i).Cells("Exchange").Value = 1 : Next i
  854. Else
  855. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1 : 清單2_dgv.Rows(i).Cells("Exchange").Value = 1 : Next i
  856. End If
  857. End Sub
  858. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
  859. If ComboBox10.Text = "LANDED BRANDED" Then
  860. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1 : 清單1_dgv.Rows(i).Cells("Currency").Value = ComboBox2.Text : Next i
  861. Else
  862. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1 : 清單2_dgv.Rows(i).Cells("Currency").Value = ComboBox2.Text : Next i
  863. End If
  864. End Sub
  865. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
  866. If ComboBox10.Text = "LANDED BRANDED" Then
  867. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1 : 清單1_dgv.Rows(i).Cells("年份").Value = ComboBox1.Text : Next i
  868. Else
  869. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1 : 清單2_dgv.Rows(i).Cells("年份").Value = ComboBox1.Text : Next i
  870. End If
  871. End Sub
  872. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  873. If 列印用SQL = "" Then : MsgBox("請先搜尋資料後再行列印")
  874. Else
  875. xlApp = CType(CreateObject("Excel.Application"), Application)
  876. xlBook = xlApp.Workbooks.Add
  877. xlApp.DisplayAlerts = True
  878. xlApp.Visible = True
  879. xlApp.Application.WindowState = xlMaximized
  880. xlSheet = NewMethod(xlBook)
  881. xlApp.Sheets(1).Name = "FIRST COST"
  882. xlBook.Activate() : xlSheet.Activate()
  883. xlSheet.Cells(3, 1) = "BUYER" : xlSheet.Cells(3, 7) = "顏色" : xlSheet.Cells(3, 13) = "銷售金額" : xlSheet.Cells(3, 19) = "Remark1" : xlSheet.Cells(3, 25) = "Commission"
  884. xlSheet.Cells(3, 2) = "年份季度" : xlSheet.Cells(3, 8) = "楦型" : xlSheet.Cells(3, 14) = "備註" : xlSheet.Cells(3, 20) = "Fty price" : xlSheet.Cells(3, 26) = "Remark2"
  885. xlSheet.Cells(3, 3) = "訂單流水號" : xlSheet.Cells(3, 9) = "訂單數量" : xlSheet.Cells(3, 15) = "Price" : xlSheet.Cells(3, 21) = "Mold cost" : xlSheet.Cells(3, 27) = "客戶付款"
  886. xlSheet.Cells(3, 4) = "客戶訂單號" : xlSheet.Cells(3, 10) = "交期開始" : xlSheet.Cells(3, 16) = "Discount price" : xlSheet.Cells(3, 22) = "Collected mold cost" : xlSheet.Cells(3, 28) = "預收款項"
  887. xlSheet.Cells(3, 5) = "型體號碼" : xlSheet.Cells(3, 11) = "交期結束" : xlSheet.Cells(3, 17) = "Selling price" : xlSheet.Cells(3, 23) = "Amortization qty" : xlSheet.Cells(3, 29) = "成本金額"
  888. xlSheet.Cells(3, 6) = "型體名稱" : xlSheet.Cells(3, 12) = "單價" : xlSheet.Cells(3, 18) = "HTS code" : xlSheet.Cells(3, 24) = "Profit" : xlSheet.Cells(3, 30) = "利潤"
  889. xlSheet.Cells(1, 8) = "Total-PRS" : xlSheet.Cells(2, 8) = "=SUBTOTAL(9,I4:I$99999)" : xlSheet.Cells(1, 24) = "Total-Commission" : xlSheet.Cells(2, 24) = "=SUBTOTAL(9,Y4:Y$99999)"
  890. xlSheet.Cells(3, 31) = "實際收款" : xlSheet.Cells(3, 32) = "Currency" : xlSheet.Cells(3, 33) = "Exchange" : xlSheet.Cells(3, 34) = "年份" : xlSheet.Cells(1, 26) = "合計"
  891. xlSheet.Cells(1, 27) = "=SUBTOTAL(9,AA4:AA$99999)" : xlSheet.Cells(1, 28) = "=SUBTOTAL(9,AB4:AB$99999)" : xlSheet.Cells(1, 29) = "=SUBTOTAL(9,AC4:AC$99999)"
  892. xlSheet.Cells(1, 30) = "=SUBTOTAL(9,AD4:AD$99999)" : xlSheet.Cells(1, 31) = "=SUBTOTAL(9,AE4:AE$99999)" : xlSheet.Cells(1, 1) = "FIRST COST"
  893. For i As Integer = 0 To 清單2_dgv.Rows.Count - 1
  894. xlSheet.Cells(i + 4, 1) = 清單2_dgv.Rows(i).Cells("BUYER").Value : xlSheet.Cells(i + 4, 2) = 清單2_dgv.Rows(i).Cells("年份季度").Value
  895. xlSheet.Cells(i + 4, 3) = 清單2_dgv.Rows(i).Cells("訂單流水號").Value : xlSheet.Cells(i + 4, 4) = 清單2_dgv.Rows(i).Cells("客戶訂單號").Value
  896. xlSheet.Cells(i + 4, 5) = 清單2_dgv.Rows(i).Cells("型體號碼").Value : xlSheet.Cells(i + 4, 6) = 清單2_dgv.Rows(i).Cells("型體名稱").Value
  897. xlSheet.Cells(i + 4, 7) = 清單2_dgv.Rows(i).Cells("顏色").Value : xlSheet.Cells(i + 4, 8) = 清單2_dgv.Rows(i).Cells("楦型").Value
  898. xlSheet.Cells(i + 4, 9) = 清單2_dgv.Rows(i).Cells("訂單數量").Value : xlSheet.Cells(i + 4, 10) = 清單2_dgv.Rows(i).Cells("交期開始").Value
  899. xlSheet.Cells(i + 4, 11) = 清單2_dgv.Rows(i).Cells("交期結束").Value : xlSheet.Cells(i + 4, 12) = 清單2_dgv.Rows(i).Cells("單價").Value
  900. xlSheet.Cells(i + 4, 13) = 清單2_dgv.Rows(i).Cells("銷售金額").Value : xlSheet.Cells(i + 4, 14) = 清單2_dgv.Rows(i).Cells("備註").Value
  901. xlSheet.Cells(i + 4, 15) = 清單2_dgv.Rows(i).Cells("Price").Value : xlSheet.Cells(i + 4, 16) = 清單2_dgv.Rows(i).Cells("Discount price").Value
  902. xlSheet.Cells(i + 4, 17) = 清單2_dgv.Rows(i).Cells("Selling price").Value : xlSheet.Cells(i + 4, 18) = 清單2_dgv.Rows(i).Cells("HTS code").Value
  903. xlSheet.Cells(i + 4, 19) = 清單2_dgv.Rows(i).Cells("Remark1").Value : xlSheet.Cells(i + 4, 20) = 清單2_dgv.Rows(i).Cells("Fty price").Value
  904. xlSheet.Cells(i + 4, 21) = 清單2_dgv.Rows(i).Cells("Mold cost").Value : xlSheet.Cells(i + 4, 22) = "=U" & i + 4 & "*I" & i + 4
  905. xlSheet.Cells(i + 4, 23) = 清單2_dgv.Rows(i).Cells("Amortization qty").Value
  906. xlSheet.Cells(i + 4, 24) = "=IF((P" & i + 4 & "-U" & i + 4 & ")=0,0,(P" & i + 4 & "-T" & i + 4 & "-U" & i + 4 & ")/(P" & i + 4 & "-U" & i + 4 & "))"
  907. xlSheet.Cells(i + 4, 25) = "=(P" & i + 4 & "-T" & i + 4 & "-U" & i + 4 & ")*I" & i + 4 : xlSheet.Cells(i + 4, 26) = 清單2_dgv.Rows(i).Cells("Remark2").Value
  908. xlSheet.Cells(i + 4, 27) = "=Q" & i + 4 & "*I" & i + 4 : xlSheet.Cells(i + 4, 28) = "=(Q" & i + 4 & "-P" & i + 4 & ")*I" & i + 4
  909. xlSheet.Cells(i + 4, 29) = "=(T" & i + 4 & "+U" & i + 4 & ")*I" & i + 4 : xlSheet.Cells(i + 4, 30) = "=M" & i + 4 & "-AC" & i + 4
  910. xlSheet.Cells(i + 4, 31) = "=AA" & i + 4 & "-AC" & i + 4 : xlSheet.Cells(i + 4, 32) = 清單2_dgv.Rows(i).Cells("Currency").Value
  911. xlSheet.Cells(i + 4, 33) = 清單2_dgv.Rows(i).Cells("Exchange").Value : xlSheet.Cells(i + 4, 34) = 清單2_dgv.Rows(i).Cells("年份").Value
  912. N1 = i
  913. Next i
  914. CC(xlApp, xlSheet)
  915. xlSheet = NewMethod(xlBook)
  916. xlApp.Sheets(1).Name = "LANDED BRANDED"
  917. xlBook.Activate() : xlSheet.Activate()
  918. xlSheet.Cells(3, 1) = "BUYER" : xlSheet.Cells(3, 7) = "顏色" : xlSheet.Cells(3, 13) = "銷售金額" : xlSheet.Cells(3, 19) = "Remark1" : xlSheet.Cells(3, 25) = "Commission"
  919. xlSheet.Cells(3, 2) = "年份季度" : xlSheet.Cells(3, 8) = "楦型" : xlSheet.Cells(3, 14) = "備註" : xlSheet.Cells(3, 20) = "Fty price" : xlSheet.Cells(3, 26) = "Remark2"
  920. xlSheet.Cells(3, 3) = "訂單流水號" : xlSheet.Cells(3, 9) = "訂單數量" : xlSheet.Cells(3, 15) = "Price" : xlSheet.Cells(3, 21) = "Mold cost" : xlSheet.Cells(3, 27) = "客戶付款"
  921. xlSheet.Cells(3, 4) = "客戶訂單號" : xlSheet.Cells(3, 10) = "交期開始" : xlSheet.Cells(3, 16) = "Discount price" : xlSheet.Cells(3, 22) = "Collected mold cost" : xlSheet.Cells(3, 28) = "未收款項"
  922. xlSheet.Cells(3, 5) = "型體號碼" : xlSheet.Cells(3, 11) = "交期結束" : xlSheet.Cells(3, 17) = "Commercial invoice" : xlSheet.Cells(3, 23) = "Amortization qty" : xlSheet.Cells(3, 29) = "成本金額"
  923. xlSheet.Cells(3, 6) = "型體名稱" : xlSheet.Cells(3, 12) = "單價" : xlSheet.Cells(3, 18) = "Overage invoice" : xlSheet.Cells(3, 24) = "Profit" : xlSheet.Cells(3, 30) = "利潤"
  924. xlSheet.Cells(1, 8) = "Total-PRS" : xlSheet.Cells(2, 8) = "=SUBTOTAL(9,I4:I$99999)" : xlSheet.Cells(1, 24) = "Total-Commission" : xlSheet.Cells(2, 24) = "=SUBTOTAL(9,Y4:Y$99999)"
  925. xlSheet.Cells(3, 31) = "實際收款" : xlSheet.Cells(3, 32) = "Currency" : xlSheet.Cells(3, 33) = "Exchange" : xlSheet.Cells(3, 34) = "年份" : xlSheet.Cells(1, 26) = "合計"
  926. xlSheet.Cells(1, 27) = "=SUBTOTAL(9,AA4:AA$99999)" : xlSheet.Cells(1, 28) = "=SUBTOTAL(9,AB4:AB$99999)" : xlSheet.Cells(1, 29) = "=SUBTOTAL(9,AC4:AC$99999)"
  927. xlSheet.Cells(1, 30) = "=SUBTOTAL(9,AD4:AD$99999)" : xlSheet.Cells(1, 31) = "=SUBTOTAL(9,AE4:AE$99999)" : xlSheet.Cells(1, 1) = "LANDED BRANDED"
  928. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  929. xlSheet.Cells(i + 4, 1) = 清單1_dgv.Rows(i).Cells("BUYER").Value : xlSheet.Cells(i + 4, 2) = 清單1_dgv.Rows(i).Cells("年份季度").Value
  930. xlSheet.Cells(i + 4, 3) = 清單1_dgv.Rows(i).Cells("訂單流水號").Value : xlSheet.Cells(i + 4, 4) = 清單1_dgv.Rows(i).Cells("客戶訂單號").Value
  931. xlSheet.Cells(i + 4, 5) = 清單1_dgv.Rows(i).Cells("型體號碼").Value : xlSheet.Cells(i + 4, 6) = 清單1_dgv.Rows(i).Cells("型體名稱").Value
  932. xlSheet.Cells(i + 4, 7) = 清單1_dgv.Rows(i).Cells("顏色").Value : xlSheet.Cells(i + 4, 8) = 清單1_dgv.Rows(i).Cells("楦型").Value
  933. xlSheet.Cells(i + 4, 9) = 清單1_dgv.Rows(i).Cells("訂單數量").Value : xlSheet.Cells(i + 4, 10) = 清單1_dgv.Rows(i).Cells("交期開始").Value
  934. xlSheet.Cells(i + 4, 11) = 清單1_dgv.Rows(i).Cells("交期結束").Value : xlSheet.Cells(i + 4, 12) = 清單1_dgv.Rows(i).Cells("單價").Value
  935. xlSheet.Cells(i + 4, 13) = 清單1_dgv.Rows(i).Cells("銷售金額").Value : xlSheet.Cells(i + 4, 14) = 清單1_dgv.Rows(i).Cells("備註").Value
  936. xlSheet.Cells(i + 4, 15) = 清單1_dgv.Rows(i).Cells("Price").Value : xlSheet.Cells(i + 4, 16) = 清單1_dgv.Rows(i).Cells("Discount price").Value
  937. xlSheet.Cells(i + 4, 17) = 清單1_dgv.Rows(i).Cells("Commercial invoice").Value : xlSheet.Cells(i + 4, 18) = 清單1_dgv.Rows(i).Cells("Overage invoice").Value
  938. xlSheet.Cells(i + 4, 19) = 清單1_dgv.Rows(i).Cells("Remark1").Value : xlSheet.Cells(i + 4, 20) = 清單1_dgv.Rows(i).Cells("Fty price").Value
  939. xlSheet.Cells(i + 4, 21) = 清單1_dgv.Rows(i).Cells("Mold cost").Value : xlSheet.Cells(i + 4, 22) = "=U" & i + 4 & "*I" & i + 4
  940. xlSheet.Cells(i + 4, 23) = 清單1_dgv.Rows(i).Cells("Amortization qty").Value
  941. xlSheet.Cells(i + 4, 24) = "=IF((P" & i + 4 & "-U" & i + 4 & ")=0,0,(P" & i + 4 & "-T" & i + 4 & "-U" & i + 4 & ")/(P" & i + 4 & "-U" & i + 4 & "))"
  942. xlSheet.Cells(i + 4, 25) = "=(P" & i + 4 & "-T" & i + 4 & "-U" & i + 4 & ")*I" & i + 4 : xlSheet.Cells(i + 4, 26) = 清單1_dgv.Rows(i).Cells("Remark2").Value
  943. xlSheet.Cells(i + 4, 27) = "=Q" & i + 4 & "*I" & i + 4 : xlSheet.Cells(i + 4, 28) = "=R" & i + 4 & "*I" & i + 4
  944. xlSheet.Cells(i + 4, 29) = "=(T" & i + 4 & "+U" & i + 4 & ")*I" & i + 4 : xlSheet.Cells(i + 4, 30) = "=M" & i + 4 & "-AC" & i + 4
  945. xlSheet.Cells(i + 4, 31) = "=AA" & i + 4 & "-AC" & i + 4 : xlSheet.Cells(i + 4, 32) = 清單1_dgv.Rows(i).Cells("Currency").Value
  946. xlSheet.Cells(i + 4, 33) = 清單1_dgv.Rows(i).Cells("Exchange").Value : xlSheet.Cells(i + 4, 34) = 清單1_dgv.Rows(i).Cells("年份").Value
  947. N1 = i
  948. Next i
  949. CC(xlApp, xlSheet)
  950. xlSheet = NewMethod(xlBook)
  951. xlApp.Sheets(1).Name = "彙總"
  952. xlBook.Activate() : xlSheet.Activate()
  953. xlSheet.Cells(2, 1) = "ORDER SUMMARY DATA COLLECTION"
  954. xlSheet.Cells(3, 2) = "平均單價" '
  955. xlSheet.Cells(3, 3) = "總雙數" : xlSheet.Cells(3, 4) = "銷售金額" : xlSheet.Cells(3, 5) = "客戶付款" : xlSheet.Cells(3, 6) = "未收款項"
  956. xlSheet.Cells(3, 7) = "預收款項" : xlSheet.Cells(3, 8) = "成本金額" : xlSheet.Cells(3, 9) = "利潤" : xlSheet.Cells(3, 10) = "實際收款"
  957. xlSheet.Cells(4, 1) = "LANDED BRANDED" : xlSheet.Cells(4, 2) = "=D4/C4"
  958. xlSheet.Cells(4, 3) = TextBox2.Text : xlSheet.Cells(4, 4) = TextBox3.Text : xlSheet.Cells(4, 5) = TextBox5.Text : xlSheet.Cells(4, 6) = TextBox9.Text
  959. xlSheet.Cells(4, 7) = TextBox21.Text : xlSheet.Cells(4, 8) = TextBox24.Text : xlSheet.Cells(4, 9) = TextBox26.Text : xlSheet.Cells(4, 10) = TextBox28.Text
  960. xlSheet.Cells(5, 1) = "FIRST COST" : xlSheet.Cells(5, 2) = "=D5/C5"
  961. xlSheet.Cells(5, 3) = TextBox19.Text : xlSheet.Cells(5, 4) = TextBox4.Text : xlSheet.Cells(5, 5) = TextBox11.Text : xlSheet.Cells(5, 6) = TextBox20.Text
  962. xlSheet.Cells(5, 7) = TextBox22.Text : xlSheet.Cells(5, 8) = TextBox23.Text : xlSheet.Cells(5, 9) = TextBox25.Text : xlSheet.Cells(5, 10) = TextBox27.Text
  963. xlSheet.Cells(6, 1) = "合 計" : xlSheet.Cells(6, 2) = "=D6/C6"
  964. xlSheet.Cells(6, 3) = TextBox34.Text : xlSheet.Cells(6, 4) = TextBox36.Text : xlSheet.Cells(6, 5) = TextBox35.Text : xlSheet.Cells(6, 6) = TextBox33.Text
  965. xlSheet.Cells(6, 7) = TextBox32.Text : xlSheet.Cells(6, 8) = TextBox31.Text : xlSheet.Cells(6, 9) = TextBox30.Text : xlSheet.Cells(7, 10) = TextBox29.Text
  966. xlSheet.Cells(7, 6) = "PS : 應收應付如果 = 正數,及為應付;如果 = 負數,及惟應收。 預收款項 - 未收款項 = 應收應付"
  967. xlSheet.Cells(7, 9) = "利潤 + 應收應付 = 總實際收款" : xlSheet.Cells(7, 7) = TextBox37.Text
  968. AA(xlApp, xlSheet)
  969. xlSheet.PageSetup.PrintArea = ""
  970. xlApp.Cells.Select()
  971. xlSheet.Range("B1").Select()
  972. xlApp.Application.WindowState = xlMinimized
  973. MsgBox("列印完成")
  974. End If
  975. End Sub
  976. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  977. Return CType(xlBook.Worksheets.Add, Worksheet)
  978. End Function
  979. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  980. xlSheet.Cells.Select()
  981. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  982. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  983. End With
  984. xlSheet.Rows("2:7").Select : myExcel.Selection.RowHeight = 35
  985. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 20
  986. xlSheet.Columns("B:J").Select : myExcel.Selection.ColumnWidth = 18
  987. xlSheet.Range("A2:J2").Select()
  988. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  989. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  990. End With : myExcel.Selection.Merge
  991. xlSheet.Range("B4:J6").Select() : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  992. xlSheet.Range("G7").Select() : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  993. xlSheet.Range("J7").Select() : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  994. xlSheet.Range("I7").Select()
  995. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  996. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  997. End With
  998. xlSheet.Range("F7").Select()
  999. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 1
  1000. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  1001. End With
  1002. xlSheet.Range("A3:J3").Select()
  1003. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1004. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  1005. End With
  1006. xlSheet.Range("A2:J6").Select()
  1007. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1008. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1009. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1010. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1011. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1012. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1013. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1014. myExcel.ActiveWindow.DisplayGridlines = False
  1015. xlSheet.Range("C4:C6").Select() : myExcel.Selection.NumberFormatLocal = "#,##0;[紅色]-#,##0"
  1016. xlSheet.Range("B3:J3").Select()
  1017. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent5 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
  1018. xlSheet.Range("A4:A6").Select()
  1019. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent4 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With
  1020. End Sub
  1021. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  1022. myExcel.ActiveWindow.Zoom = 90
  1023. xlSheet.Cells.Select()
  1024. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1025. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  1026. End With
  1027. myExcel.Application.CutCopyMode = False
  1028. xlSheet.Columns("D:D").Select : myExcel.Selection.NumberFormatLocal = "@"
  1029. xlSheet.Columns("I:I").Select : myExcel.Selection.NumberFormatLocal = "#,##0;[紅色]-#,##0"
  1030. xlSheet.Columns("J:K").Select : myExcel.Selection.NumberFormatLocal = "yyyy/mm/dd"
  1031. xlSheet.Columns("L:L").Select : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  1032. xlSheet.Columns("M:M").Select : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  1033. xlSheet.Columns("O:R").Select : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  1034. xlSheet.Columns("T:V").Select : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  1035. xlSheet.Columns("W:W").Select : myExcel.Selection.NumberFormatLocal = "#,##0;[紅色]-#,##0"
  1036. xlSheet.Columns("X:X").Select : myExcel.Selection.NumberFormatLocal = "0.00%"
  1037. xlSheet.Columns("Y:Y").Select : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  1038. xlSheet.Columns("AA:AE").Select : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  1039. xlSheet.Columns("AG:AG").Select : myExcel.Selection.NumberFormatLocal = "#,##0.0000;[紅色]-#,##0.0000"
  1040. xlSheet.Columns("AF:AH").Select
  1041. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1042. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  1043. End With
  1044. xlSheet.Rows("3:3").Select
  1045. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1046. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  1047. End With
  1048. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 18
  1049. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 12
  1050. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 16
  1051. xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 12
  1052. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 13
  1053. xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 12
  1054. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 20
  1055. xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 5
  1056. xlSheet.Columns("I:I").Select : myExcel.Selection.ColumnWidth = 8
  1057. xlSheet.Columns("J:K").Select : myExcel.Selection.ColumnWidth = 9.5
  1058. xlSheet.Columns("L:L").Select : myExcel.Selection.ColumnWidth = 6
  1059. xlSheet.Columns("M:M").Select : myExcel.Selection.ColumnWidth = 12
  1060. xlSheet.Columns("N:N").Select : myExcel.Selection.ColumnWidth = 20
  1061. xlSheet.Columns("O:R").Select : xlSheet.Columns("O:R").EntireColumn.AutoFit
  1062. xlSheet.Columns("T:Y").Select : xlSheet.Columns("T:Y").EntireColumn.AutoFit
  1063. xlSheet.Columns("AA:AH").Select : xlSheet.Columns("AA:AH").EntireColumn.AutoFit
  1064. xlSheet.Rows("4:4").Select : myExcel.ActiveWindow.FreezePanes = True : myExcel.ActiveWindow.DisplayGridlines = False
  1065. xlSheet.Range("A3:AH" & N1 + 5).Select() : myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1066. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1067. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1068. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1069. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1070. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1071. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1072. xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 45
  1073. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1074. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  1075. End With : myExcel.Selection.AutoFilter
  1076. xlSheet.Range("H1:I1").Select()
  1077. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1078. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1079. xlSheet.Range("H2:I2").Select()
  1080. myExcel.Selection.Merge
  1081. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1082. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  1083. xlSheet.Range("H1:I2").Select()
  1084. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1085. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1086. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1087. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1088. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1089. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1090. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1091. xlSheet.Range("A1:N3").Select()
  1092. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1093. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1094. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1095. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1096. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1097. xlSheet.Range("A1:N3").Select()
  1098. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorDark1 : .TintAndShade = -0.249977111117893 : .PatternTintAndShade = 0 : End With
  1099. xlSheet.Range("X1:Y1").Select()
  1100. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1101. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1102. xlSheet.Range("X2:Y2").Select()
  1103. myExcel.Selection.Merge
  1104. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1105. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  1106. xlSheet.Range("Z1:Z2").Select()
  1107. myExcel.Selection.Merge
  1108. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1109. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  1110. xlSheet.Range("AA1:AA2").Select()
  1111. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1112. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1113. xlSheet.Range("AB1:AB2").Select()
  1114. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1115. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1116. xlSheet.Range("AC1:AC2").Select()
  1117. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1118. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1119. xlSheet.Range("AD1:AD2").Select()
  1120. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1121. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1122. xlSheet.Range("AE1:AE2").Select()
  1123. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1124. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1125. xlSheet.Range("O1:Z3").Select()
  1126. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1127. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1128. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1129. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1130. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1131. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 65535 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
  1132. xlSheet.Range("AA1:AE3").Select()
  1133. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1134. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1135. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1136. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1137. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1138. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1139. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1140. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 5296274 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
  1141. xlSheet.Range("AF1:AH3").Select()
  1142. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1143. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1144. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1145. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1146. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1147. xlSheet.Range("A1:G2").Select()
  1148. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1149. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1150. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1151. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  1152. End With
  1153. xlSheet.Range("X3").Activate() : myExcel.Selection.ColumnWidth = 8
  1154. xlSheet.Columns("Y:Y").Select : myExcel.Selection.ColumnWidth = 12
  1155. xlSheet.Range("X2:Y2").Select() : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  1156. xlSheet.Range("X1:Y2").Select()
  1157. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1158. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1159. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1160. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1161. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1162. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1163. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1164. xlSheet.Columns("AA:AE").Select : myExcel.Selection.ColumnWidth = 10
  1165. xlSheet.Range("X1:Y1").Select()
  1166. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1167. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  1168. xlSheet.Range("H1:I1").Select()
  1169. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1170. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  1171. End Sub
  1172. End Class