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

採購單編輯.vb 89KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. Option Strict Off
  2. Imports System.IO
  3. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  4. Imports Microsoft.Office.Interop.Excel.Constants
  5. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  6. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  7. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  8. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  9. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  10. Imports Microsoft.Office.Interop.Excel.XlWindowState
  11. Imports Microsoft.Office.Interop.Excel
  12. Imports System.Windows.Forms.DataVisualization.Charting
  13. Public Class 採購單編輯
  14. ReadOnly ds8 As New DataSet
  15. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  16. Dim QQQ1, QQQ2, QQQ3, 新項次, 物料規格, 採購選擇, 對話框(10) As String
  17. Dim NUM1, NA1, N1 As Integer
  18. Dim 可繪圖 As Boolean
  19. Private Sub Set_明細清單()
  20. Dim ds As New DataSet : 明細_dgv.DataSource = Nothing : ds.Clear()
  21. 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  22. 明細_dgv.ColumnHeadersHeight = 40
  23. 明細_dgv.AllowUserToAddRows = False
  24. If 小間距_ch.Checked = False And 中間距_ch.Checked = False And 大間距_ch.Checked = True Then
  25. 明細_dgv.RowTemplate.Height = 65
  26. ElseIf 小間距_ch.Checked = False And 中間距_ch.Checked = True And 大間距_ch.Checked = False Then
  27. 明細_dgv.RowTemplate.Height = 45
  28. ElseIf 小間距_ch.Checked = True And 中間距_ch.Checked = False And 大間距_ch.Checked = False Then
  29. 明細_dgv.RowTemplate.Height = 25
  30. End If
  31. PA20 = 採購選擇 : If PA20 = "" Then : PA20 = "B" : End If
  32. PA1 = QQQ1 : PA2 = 採購單號_tb.Text : SQL_建築物料採購單生成_明細()
  33. da.Fill(ds) : 明細_dgv.DataSource = ds.Tables(0) : conn.Close()
  34. 明細_dgv.Columns(0).Visible = False : 明細_dgv.Columns(1).FillWeight = 52 : 明細_dgv.Columns(3).FillWeight = 243 : 明細_dgv.Columns(4).FillWeight = 230
  35. 明細_dgv.Columns(5).FillWeight = 145 : 明細_dgv.Columns(6).FillWeight = 80 : 明細_dgv.Columns(7).FillWeight = 80 : 明細_dgv.Columns(8).FillWeight = 80
  36. 明細_dgv.Columns(9).FillWeight = 80 : 明細_dgv.Columns(10).Visible = False : 明細_dgv.Columns(11).Visible = False : 明細_dgv.Columns(12).Visible = False
  37. 明細_dgv.Columns(13).Visible = False : 明細_dgv.Columns(14).Visible = False : 明細_dgv.Columns(15).Visible = False : 明細_dgv.Columns(16).FillWeight = 95
  38. 明細_dgv.Columns(17).Visible = False : 明細_dgv.Columns(18).Visible = False : 明細_dgv.Columns(19).Visible = False : 明細_dgv.Columns(20).Visible = False
  39. 明細_dgv.Columns(21).Visible = False : 明細_dgv.Columns(22).Visible = False : 明細_dgv.Columns(23).Visible = False : 明細_dgv.Columns(24).Visible = False
  40. 明細_dgv.Columns(25).Visible = False : 明細_dgv.Columns(26).FillWeight = 40 : 明細_dgv.Columns("KEY").Visible = False : 明細_dgv.Columns("OUP").FillWeight = 80
  41. 明細_dgv.Columns(2).FillWeight = 86 : 明細_dgv.Columns(27).FillWeight = 80 : 明細_dgv.Columns("SP%").FillWeight = 80
  42. 明細_dgv.Columns(6).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(9).DefaultCellStyle.Format = "#,##0"
  43. 明細_dgv.Columns("OUP").DefaultCellStyle.Format = "#,##0"
  44. 明細_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  45. 明細_dgv.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns("OUP").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  46. 明細_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  47. 明細_dgv.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns("OUP").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  48. 明細_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  49. 明細_dgv.Columns(1).ReadOnly = True : 明細_dgv.Columns(3).ReadOnly = True : 明細_dgv.Columns(4).ReadOnly = True : 明細_dgv.Columns(16).ReadOnly = True
  50. 明細_dgv.Columns(表頭(16)).ReadOnly = True : 明細_dgv.Columns(表頭(27)).ReadOnly = True : 明細_dgv.Columns("OUP").ReadOnly = True : 明細_dgv.Columns("SP%").ReadOnly = True
  51. If 低網速模式 = False Then
  52. 明細_dgv.Columns(29).FillWeight = 80 : 明細_dgv.Columns("Image").Visible = True
  53. Dim mycol As DataGridViewImageColumn = 明細_dgv.Columns("Image")
  54. mycol.ImageLayout = DataGridViewImageCellLayout.Zoom
  55. Else
  56. If 明細_dgv.Columns.Count = 30 Then
  57. 明細_dgv.Columns("Image").Visible = False
  58. End If
  59. End If
  60. 新項次 = "00"
  61. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  62. 明細_dgv.Columns("OUP").DefaultCellStyle.Format = "#,0"
  63. NUM1 = Double.Parse(新項次) + 1
  64. If NUM1 < 10 Then : 新項次 = "0" & NUM1
  65. ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1
  66. End If
  67. 明細_dgv.Rows(i).Cells("" & 表頭(11) & "").Value = 新項次
  68. '-------------------------規格合併呈現----------------------------------------------------------------------------------------------------------------------------------------
  69. If i = 0 Then
  70. AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = "" : PA3 = 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value
  71. SQL_規格庫抬頭讀取()
  72. If dr.Read() Then : AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8") : End If
  73. conn.Close()
  74. Else
  75. If 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value.ToString <> 明細_dgv.Rows(i - 1).Cells("規格庫抬頭指定").Value.ToString Then
  76. AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = "" : PA3 = 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value : SQL_規格庫抬頭讀取()
  77. If dr.Read() Then : AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8") : End If
  78. conn.Close()
  79. End If
  80. End If
  81. Dim ZA1, ZA2, ZA3, ZA4, ZA5, ZA6, ZA7, ZA8 As String : 物料規格 = ""
  82. If 詳細資料2_ch.Checked = True Then
  83. If 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" Then
  84. ZA1 = AAA1 & "=" & 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 物料規格 = ZA1 : End If
  85. If 明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : ZA2 = AAA2 & "=" & 明細_dgv.Rows(i).Cells("A2").Value
  86. If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
  87. If 明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : ZA3 = AAA3 & "=" & 明細_dgv.Rows(i).Cells("A3").Value
  88. If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
  89. If 明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : ZA4 = AAA4 & "=" & 明細_dgv.Rows(i).Cells("A4").Value
  90. If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
  91. If 明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : ZA5 = AAA5 & "=" & 明細_dgv.Rows(i).Cells("A5").Value
  92. If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
  93. If 明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : ZA6 = AAA6 & "=" & 明細_dgv.Rows(i).Cells("A6").Value
  94. If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
  95. If 明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : ZA7 = AAA7 & "=" & 明細_dgv.Rows(i).Cells("A7").Value
  96. If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
  97. If 明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : ZA8 = AAA8 & "=" & 明細_dgv.Rows(i).Cells("A8").Value
  98. If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
  99. Else
  100. If 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" Then : ZA1 = 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 物料規格 = ZA1 : End If
  101. If 明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then
  102. ZA2 = 明細_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If
  103. If 明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then
  104. ZA3 = 明細_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If
  105. If 明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then
  106. ZA4 = 明細_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If
  107. If 明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then
  108. ZA5 = 明細_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If
  109. If 明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then
  110. ZA6 = 明細_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If
  111. If 明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then
  112. ZA7 = 明細_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If
  113. If 明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then
  114. ZA8 = 明細_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If
  115. End If
  116. 明細_dgv.Rows(i).Cells("" & 表頭(13) & "").Value = 物料規格
  117. '-------------------------歷史單價----------------------------------------------------------------------------------------------------------------------------------------
  118. PA = 明細_dgv.Rows(i).Cells("料號").Value : Set_單價()
  119. If 價錢_dgv.Rows.Count = 0 Then : 明細_dgv.Rows(i).Cells("OUP").Value = 0 : Else : 明細_dgv.Rows(i).Cells("OUP").Value = 價錢_dgv.Rows(0).Cells("單價").Value : End If
  120. Next i
  121. Dim FFGG As Long = 0
  122. 總金額_tb.Text = "0"
  123. If 採購選擇 = "A" Then
  124. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  125. 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value = "0.0"
  126. 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value * 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value
  127. FFGG = CLng(FFGG) + 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value : 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = False
  128. Next i
  129. ElseIf 採購選擇 = "B" Then
  130. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  131. 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value * 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value
  132. FFGG = CLng(FFGG) + 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value : 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = True
  133. Next i
  134. End If
  135. 折扣金額_tb.Text = CLng(折扣比_tb.Text) * FFGG / 100
  136. If 稅金計算_ch.Checked = True Then
  137. If 折扣比_tb.Text = "0" Then : 稅金金額_tb.Text = FFGG * CLng(稅金比_tb.Text) / 100 : Else : 稅金金額_tb.Text = (FFGG - 折扣金額_tb.Text) * CLng(稅金比_tb.Text) / 100 : End If
  138. Else : 稅金金額_tb.Text = "0" : End If
  139. 總金額_tb.Text = FFGG - CLng(折扣金額_tb.Text) + CLng(稅金金額_tb.Text)
  140. 折扣金額_tb.Text = Strings.Format(CLng(折扣金額_tb.Text), "#,##0") : 稅金金額_tb.Text = Strings.Format(CLng(稅金金額_tb.Text), "#,##0")
  141. 總金額_tb.Text = Strings.Format(CLng(總金額_tb.Text), "#,##0")
  142. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  143. If 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = True Then
  144. 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = False
  145. End If
  146. For II As Integer = 0 To 最新單價_dgv.Rows.Count - 1
  147. If 明細_dgv.Rows(i).Cells("料號").Value.ToString = 最新單價_dgv.Rows(II).Cells("料號").Value.ToString And CLng(明細_dgv.Rows(i).Cells(表頭(26)).Value.ToString) = 0 Then
  148. 明細_dgv.Rows(i).Cells(表頭(26)).Value = 最新單價_dgv.Rows(II).Cells("單價").Value.ToString : Exit For
  149. End If
  150. Next
  151. Next
  152. End Sub
  153. Private Sub Set_清單1()
  154. Dim ds1 As New DataSet : 請購單_dgv.DataSource = Nothing : ds1.Clear()
  155. 請購單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  156. 請購單_dgv.ColumnHeadersHeight = 25
  157. 請購單_dgv.AllowUserToAddRows = False
  158. SQL_建築物料採購單生成_請購()
  159. da.Fill(ds1) : 請購單_dgv.DataSource = ds1.Tables(0) : conn.Close()
  160. 請購單_dgv.Columns(0).FillWeight = 125 : 請購單_dgv.Columns(1).Visible = False : 請購單_dgv.Columns(2).Visible = False : 請購單_dgv.Columns(3).Visible = False
  161. 請購單_dgv.Columns(4).Visible = False : 請購單_dgv.Columns(5).Visible = False : 請購單_dgv.Columns(6).Visible = False : 請購單_dgv.Columns(7).Visible = False
  162. 請購單_dgv.Columns(8).Visible = False : 請購單_dgv.Columns(9).Visible = False
  163. End Sub
  164. Private Sub Set_清單2()
  165. Dim ds2 As New DataSet : 採購單_dgv.DataSource = Nothing : ds2.Clear()
  166. 採購單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  167. 採購單_dgv.ColumnHeadersHeight = 25
  168. 採購單_dgv.AllowUserToAddRows = False
  169. SQL_建築物料採購單生成_採購()
  170. da.Fill(ds2) : 採購單_dgv.DataSource = ds2.Tables(0) : conn.Close()
  171. 採購單_dgv.Columns(0).FillWeight = 125 : 採購單_dgv.Columns(1).Visible = False : 採購單_dgv.Columns(2).Visible = False : 採購單_dgv.Columns(3).Visible = False
  172. 採購單_dgv.Columns(4).Visible = False : 採購單_dgv.Columns(5).Visible = False : 採購單_dgv.Columns(6).Visible = False : 採購單_dgv.Columns(7).Visible = False
  173. 採購單_dgv.Columns(8).Visible = False : 採購單_dgv.Columns(9).Visible = False : 採購單_dgv.Columns(10).Visible = False : 採購單_dgv.Columns(11).Visible = False
  174. 採購單_dgv.Columns(12).Visible = False : 採購單_dgv.Columns(13).Visible = False : 採購單_dgv.Columns(14).Visible = False : 採購單_dgv.Columns(15).Visible = False
  175. End Sub
  176. Private Sub Set_清單3()
  177. Dim ds1 As New DataSet : 最新單價_dgv.DataSource = Nothing : ds1.Clear()
  178. 最新單價_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  179. 最新單價_dgv.ColumnHeadersHeight = 25
  180. 最新單價_dgv.AllowUserToAddRows = False
  181. PA14 = 供應商編碼_tb.Text : SQL_物料最新單價查詢()
  182. da.Fill(ds1) : 最新單價_dgv.DataSource = ds1.Tables(0) : conn.Close()
  183. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  184. For II As Integer = 0 To 最新單價_dgv.Rows.Count - 1
  185. If 明細_dgv.Rows(i).Cells("料號").Value.ToString = 最新單價_dgv.Rows(II).Cells("料號").Value.ToString And CLng(明細_dgv.Rows(i).Cells(表頭(26)).Value.ToString) = 0 Then
  186. 明細_dgv.Rows(i).Cells(表頭(26)).Value = 最新單價_dgv.Rows(II).Cells("單價").Value.ToString : Exit For
  187. End If
  188. Next
  189. Next
  190. End Sub
  191. Private Sub 總金額計算()
  192. Dim FFGG As Long = 0
  193. 總金額_tb.Text = "0"
  194. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  195. 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value * 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value
  196. If 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value = "0" Then
  197. 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = False
  198. Else
  199. 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = True
  200. End If
  201. FFGG = CLng(FFGG) + 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value
  202. If 明細_dgv(表頭(28), i).Value = True Then
  203. 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
  204. Else
  205. 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  206. End If
  207. Next i
  208. If 折扣比_tb.Text = "" Then : 折扣比_tb.Text = "0" : End If
  209. 折扣金額_tb.Text = CLng(折扣比_tb.Text) * FFGG / 100
  210. If 稅金計算_ch.Checked = True Then
  211. If 折扣比_tb.Text = "0" Then
  212. 稅金金額_tb.Text = FFGG * CLng(稅金比_tb.Text) / 100
  213. Else
  214. 稅金金額_tb.Text = (FFGG - 折扣金額_tb.Text) * CLng(稅金比_tb.Text) / 100
  215. End If
  216. Else
  217. 稅金金額_tb.Text = "0"
  218. End If
  219. 總金額_tb.Text = FFGG - CLng(折扣金額_tb.Text) + CLng(稅金金額_tb.Text)
  220. 折扣金額_tb.Text = Strings.Format(CLng(折扣金額_tb.Text), "#,##0") : 稅金金額_tb.Text = Strings.Format(CLng(稅金金額_tb.Text), "#,##0")
  221. 總金額_tb.Text = Strings.Format(CLng(總金額_tb.Text), "#,##0")
  222. End Sub
  223. Private Sub Set_語言()
  224. 語言_dgv.DataSource = Nothing : ds8.Clear()
  225. 語言_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  226. 語言_dgv.ColumnHeadersHeight = 25
  227. 語言_dgv.AllowUserToAddRows = False
  228. SQL_系統語言導入()
  229. da.Fill(ds8) : 語言_dgv.DataSource = ds8.Tables(0) : conn.Close()
  230. End Sub
  231. Private Sub Set_單價()
  232. Dim ds6 As New DataSet : 價錢_dgv.DataSource = Nothing : ds6.Clear()
  233. 價錢_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  234. 價錢_dgv.ColumnHeadersHeight = 25
  235. 價錢_dgv.AllowUserToAddRows = False
  236. If 日期_rb.Checked = False And 單價_rb.Checked = True Then
  237. SQL_加權平均()
  238. ElseIf 日期_rb.Checked = True And 單價_rb.Checked = False Then
  239. SQL_最近日期()
  240. End If
  241. da.Fill(ds6) : 價錢_dgv.DataSource = ds6.Tables(0) : conn.Close()
  242. End Sub
  243. Private Sub Set_料號比價()
  244. Dim ds1 As New DataSet
  245. 料號_dgv.DataSource = Nothing : ds1.Clear()
  246. 料號_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  247. 料號_dgv.ColumnHeadersHeight = 25
  248. 料號_dgv.AllowUserToAddRows = False
  249. PA = 料號1_tb.Text : SQL_料號比對價格()
  250. da.Fill(ds1) : 料號_dgv.DataSource = ds1.Tables(0) : conn.Close()
  251. 料號_dgv.Columns(3).DefaultCellStyle.Format = "#,##0.00"
  252. 料號_dgv.Columns(3).FillWeight = 50
  253. End Sub
  254. Private Sub 語言轉換讀取()
  255. Set_語言() : conn.Close()
  256. For i As Integer = 0 To 語言_dgv.Rows.Count - 1
  257. If 語言_dgv("控件", i).Value.ToString = "建築物料採購單生成" Then : Me.Text = 語言_dgv("內容", i).Value.ToString : End If
  258. If 語言_dgv("控件", i).Value.ToString = "核准請購未生成_lb" Then : 核准請購未生成_lb.Text = 語言_dgv("內容", i).Value.ToString : End If
  259. If 語言_dgv("控件", i).Value.ToString = "已生未核准的採購單_lb" Then : 已生未核准的採購單_lb.Text = 語言_dgv("內容", i).Value.ToString : End If
  260. If 語言_dgv("控件", i).Value.ToString = "簡稱_lb" Then : 簡稱_lb.Text = 語言_dgv("內容", i).Value.ToString : End If
  261. If 語言_dgv("控件", i).Value.ToString = "總金額_lb" Then : 總金額_lb.Text = 語言_dgv("內容", i).Value.ToString : End If
  262. If 語言_dgv("控件", i).Value.ToString = "選擇公司_lb" Then : 選擇公司_lb.Text = 語言_dgv("內容", i).Value.ToString : End If
  263. If 語言_dgv("控件", i).Value.ToString = "重新整理_tsm" Then : 重新整理_tsm.Text = 語言_dgv("內容", i).Value.ToString : End If
  264. If 語言_dgv("控件", i).Value.ToString = "全部選擇_tsm" Then : 全部選擇_bt.Text = 語言_dgv("內容", i).Value.ToString : End If
  265. If 語言_dgv("控件", i).Value.ToString = "全部取消_tsm" Then : 全部取消_bt.Text = 語言_dgv("內容", i).Value.ToString : End If
  266. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_項次" Then : 表頭(11) = 語言_dgv("內容", i).Value.ToString : End If
  267. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_品名" Then : 表頭(12) = 語言_dgv("內容", i).Value.ToString : End If
  268. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_規格" Then : 表頭(13) = 語言_dgv("內容", i).Value.ToString : End If
  269. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_備註" Then : 表頭(14) = 語言_dgv("內容", i).Value.ToString : End If
  270. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_數量" Then : 表頭(15) = 語言_dgv("內容", i).Value.ToString : End If
  271. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_單位" Then : 表頭(16) = 語言_dgv("內容", i).Value.ToString : End If
  272. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_單價" Then : 表頭(26) = 語言_dgv("內容", i).Value.ToString : End If
  273. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_單號" Then : 表頭(18) = 語言_dgv("內容", i).Value.ToString : End If
  274. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_金額" Then : 表頭(27) = 語言_dgv("內容", i).Value.ToString : End If
  275. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_已採購" Then : 表頭(28) = 語言_dgv("內容", i).Value.ToString : End If
  276. If 語言_dgv("控件", i).Value.ToString = "對話框1" Then : 對話框(0) = 語言_dgv("內容", i).Value.ToString : End If
  277. If 語言_dgv("控件", i).Value.ToString = "對話框2" Then : 對話框(1) = 語言_dgv("內容", i).Value.ToString : End If
  278. If 語言_dgv("控件", i).Value.ToString = "對話框3" Then : 對話框(2) = 語言_dgv("內容", i).Value.ToString : End If
  279. If 語言_dgv("控件", i).Value.ToString = "對話框4" Then : 對話框(3) = 語言_dgv("內容", i).Value.ToString : End If
  280. If 語言_dgv("控件", i).Value.ToString = "對話框5" Then : 對話框(4) = 語言_dgv("內容", i).Value.ToString : End If
  281. If 語言_dgv("控件", i).Value.ToString = "對話框6" Then : 對話框(5) = 語言_dgv("內容", i).Value.ToString : End If
  282. If 語言_dgv("控件", i).Value.ToString = "文字_lb" Then : 文字_lb.Text = 語言_dgv("內容", i).Value.ToString : End If
  283. If 語言_dgv("控件", i).Value.ToString = "單價_rb" Then : 單價_rb.Text = 語言_dgv("內容", i).Value.ToString : End If
  284. If 語言_dgv("控件", i).Value.ToString = "日期_rb" Then : 日期_rb.Text = 語言_dgv("內容", i).Value.ToString : End If
  285. If 語言_dgv("控件", i).Value.ToString = "對話框7" Then : 對話框(6) = 語言_dgv("內容", i).Value.ToString : End If
  286. If 語言_dgv("控件", i).Value.ToString = "對話框8" Then : 對話框(7) = 語言_dgv("內容", i).Value.ToString : End If
  287. If 語言_dgv("控件", i).Value.ToString = "對話框9" Then : 對話框(8) = 語言_dgv("內容", i).Value.ToString : End If
  288. If 語言_dgv("控件", i).Value.ToString = "對話框10" Then : 對話框(9) = 語言_dgv("內容", i).Value.ToString : End If
  289. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_合約號" Then : 表頭(134) = 語言_dgv("內容", i).Value.ToString : End If
  290. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_申請人" Then : 表頭(19) = 語言_dgv("內容", i).Value.ToString : End If
  291. If 語言_dgv("控件", i).Value.ToString = "對話框11" Then : 對話框(10) = 語言_dgv("內容", i).Value.ToString : End If
  292. If 語言_dgv("控件", i).Value.ToString = "清單_dgv_採購單號" Then : 表頭(24) = 語言_dgv("內容", i).Value.ToString : End If
  293. Next
  294. End Sub
  295. Private Sub 類別管理_cb_下拉表單資料載入()
  296. SQL_供應商類別_下拉清單() : 類別管理_cb.Items.Clear() : 類別管理_cb.Items.Add("")
  297. While (dr.Read()) : 類別管理_cb.Items.Add(dr("類別")) : End While : conn.Close()
  298. End Sub
  299. Private Sub 廠商_cb_下拉表單資料載入()
  300. SQL_供應商資料表_公司名_下拉用() : 廠商_cb.Items.Clear() : 廠商_cb.Items.Add("") : While (dr.Read()) : 廠商_cb.Items.Add(dr("公司名")) : End While : conn.Close()
  301. End Sub
  302. Private Sub 廠商清空()
  303. 供應商編碼_tb.Text = "" : 地址_tb.Text = "" : 電話_tb.Text = "" : 郵件_tb.Text = "" : 傳真_tb.Text = "" : 類別管理_cb_下拉表單資料載入() : 廠商_cb_下拉表單資料載入()
  304. End Sub
  305. Private Sub 採購單編輯_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  306. Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  307. H(205) = True : 介面 = "H205" : 語言轉換讀取()
  308. 地址_tb.Enabled = False : 電話_tb.Enabled = False : 郵件_tb.Enabled = False : 採購單號_tb.Enabled = False : 傳真_tb.Enabled = False
  309. 折扣金額_tb.Enabled = False : 稅金金額_tb.Enabled = False : 總金額_tb.Enabled = False : 使用地點_tb.Enabled = False : 單價_rb.Checked = True
  310. 小間距_ch.Checked = False : 中間距_ch.Checked = True : 大間距_ch.Checked = False
  311. Label4.Text = 對話框(6) & 比例1 & 對話框(7) & 比例2 & 對話框(8) & 比例2 & 對話框(7) & 比例3 & 對話框(9) & 比例3
  312. 類別管理_cb_下拉表單資料載入() : Set_清單1() : Set_清單2()
  313. MyModule1.清單字體大小調整()
  314. 採購單_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  315. 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  316. 料號_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  317. End Sub
  318. Private Sub 採購單編輯_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
  319. MyModule1.清單字體大小調整()
  320. 採購單_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  321. 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  322. 料號_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  323. End Sub
  324. Private Sub 採購單編輯_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
  325. H(205) = False
  326. End Sub
  327. Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click
  328. 介面 = "H205" : 語言轉換讀取()
  329. 類別管理_cb_下拉表單資料載入() : Set_清單1() : Set_清單2() : Set_單價() : Set_明細清單() : Set_料號比價()
  330. Label4.Text = 對話框(6) & 比例1 & 對話框(7) & 比例2 & 對話框(8) & 比例2 & 對話框(7) & 比例3 & 對話框(9) & 比例3
  331. End Sub
  332. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  333. timeNow = 0
  334. GCM_ERP_SYS.Timer1.Enabled = False
  335. GCM_ERP_SYS.Timer1.Enabled = True
  336. End Sub
  337. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  338. timeNow = 0
  339. GCM_ERP_SYS.Timer1.Enabled = False
  340. GCM_ERP_SYS.Timer1.Enabled = True
  341. End Sub
  342. Private Sub 價格()
  343. Dim 差異, 比對 As Double
  344. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  345. If 明細_dgv.Rows(i).Cells("OUP").Value = 0 And 明細_dgv.Rows(i).Cells(表頭(26)).Value = 0 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  346. 明細_dgv.Rows(i).Cells("SP%").Value = "0 % →"
  347. ElseIf 明細_dgv.Rows(i).Cells(表頭(26)).Value = 0 And 明細_dgv.Rows(i).Cells("OUP").Value <> 0 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  348. 明細_dgv.Rows(i).Cells("SP%").Value = "0 % →"
  349. ElseIf 明細_dgv.Rows(i).Cells("OUP").Value <> 0 And 明細_dgv.Rows(i).Cells(表頭(26)).Value <> 0 Then
  350. 差異 = 明細_dgv.Rows(i).Cells(表頭(26)).Value - 明細_dgv.Rows(i).Cells("OUP").Value : 比對 = 差異 / 明細_dgv.Rows(i).Cells(表頭(26)).Value * 100
  351. If 比對 > 0 Then : 明細_dgv.Rows(i).Cells("SP%").Value = CInt(比對) & " % ↗" : 比對 *= 1
  352. ElseIf 比對 < 0 Then : 明細_dgv.Rows(i).Cells("SP%").Value = CInt(比對) & " % ↘" : 比對 *= -1
  353. ElseIf 比對 = 0 Then : 明細_dgv.Rows(i).Cells("SP%").Value = CInt(比對) & " % →" : End If
  354. If 比對 < 比例1 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  355. ElseIf 比對 > 比例1 And 比對 < 比例2 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
  356. ElseIf 比對 > 比例2 And 比對 < 比例3 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue
  357. ElseIf 比對 >= 比例3 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink : End If
  358. End If
  359. Next
  360. End Sub
  361. Private Sub 單價_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 單價_rb.Click
  362. Set_明細清單()
  363. End Sub
  364. Private Sub 日期_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 日期_rb.Click
  365. Set_明細清單()
  366. End Sub
  367. Dim 已超出 As Boolean
  368. Private Sub 明細_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 明細_dgv.MouseUp
  369. 'If 明細_dgv.SelectedCells.Count = 1 Then : MsgBox(明細_dgv.SelectedCells(0).ColumnIndex & " " & 明細_dgv.SelectedCells(0).RowIndex) : End If
  370. If 明細_dgv.SelectedCells.Count = 1 Then : 已超出 = False : End If
  371. If 明細_dgv.SelectedCells.Count > 0 Then
  372. If 明細_dgv.SelectedCells(0).ColumnIndex = 9 Then
  373. If 已超出 = False Then
  374. Dim x As Double = 0
  375. For i As Integer = 0 To 明細_dgv.SelectedCells.Count - 1
  376. Dim 變數 As String = "" : Dim 取變數 As String
  377. 取變數 = 明細_dgv.Rows(明細_dgv.SelectedCells.Item(i).RowIndex).Cells(明細_dgv.SelectedCells.Item(i).ColumnIndex).Value
  378. For ii As Integer = 1 To Len(取變數)
  379. If ii = 1 Then : 變數 = Strings.Left(取變數, ii) : Else : If Strings.Mid(取變數, ii, 1) <> "," Then : 變數 &= Strings.Mid(取變數, ii, 1) : End If : End If
  380. Next : x += CLng(變數)
  381. Next i : GCM_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(x, "#,##0")
  382. Else : GCM_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(0, "#,##0")
  383. End If
  384. Else : 已超出 = True : GCM_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(0, "#,##0")
  385. End If
  386. End If
  387. End Sub
  388. Private Sub 明細_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細_dgv.CellClick
  389. If e.RowIndex = -1 Then : Else
  390. 物料圖2_pb.Image = Nothing : 物料圖1_pb.Image = Nothing
  391. PA2 = 明細_dgv.Rows(e.RowIndex).Cells("料號原則").Value : SQL_物料圖庫_圖檔讀取一()
  392. While dr.Read() = True
  393. Dim unused As Byte() = New Byte(-1) {}
  394. Dim bytes As Byte() = DirectCast(dr.Item("圖檔"), Byte())
  395. Dim oStream As New MemoryStream(bytes)
  396. 物料圖1_pb.Image = Bitmap.FromStream(oStream)
  397. End While
  398. conn.Close() : 物料圖1_pb.SizeMode = 4
  399. 料號1_tb.Text = 明細_dgv("料號", e.RowIndex).Value.ToString
  400. 品名_tb.Text = 明細_dgv(表頭(12), e.RowIndex).Value.ToString
  401. If 歷史單價_P.Visible = True Then : Set_料號比價() : 繪圖() : End If
  402. End If
  403. 價格()
  404. End Sub
  405. Private Sub 明細_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 明細_dgv.CellEnter
  406. 總金額計算() : 價格()
  407. End Sub
  408. Private Sub 請購單_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 請購單_dgv.CellClick
  409. 選擇公司_cb.Enabled = True : 採購選擇 = "A"
  410. If e.RowIndex = -1 Then : Else
  411. QQQ1 = 請購單_dgv(0, e.RowIndex).Value.ToString : QQQ2 = 請購單_dgv(3, e.RowIndex).Value.ToString : QQQ3 = 請購單_dgv(4, e.RowIndex).Value.ToString
  412. If 請購單_dgv.Rows(e.RowIndex).Cells("用途").Value.ToString = "" Then : 使用地點_tb.Text = "" : Else
  413. 使用地點_tb.Text = 請購單_dgv.Rows(e.RowIndex).Cells("用途").Value.ToString & "-" & 請購單_dgv.Rows(e.RowIndex).Cells("倉名").Value
  414. End If
  415. 折扣比_tb.Text = "0" : 稅金計算_ch.Checked = True : 稅金比_tb.Text = "10" : 採購單號_tb.Text = ""
  416. End If : Set_明細清單()
  417. End Sub
  418. Private Sub 採購單_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 採購單_dgv.CellClick
  419. PA = "" : 廠商清空()
  420. 選擇公司_cb.Enabled = False : 採購選擇 = "B"
  421. If e.RowIndex = -1 Then : Else
  422. 採購單號_tb.Text = 採購單_dgv(0, e.RowIndex).Value.ToString : 折扣比_tb.Text = 採購單_dgv(13, e.RowIndex).Value.ToString : 稅金計算_ch.Checked = 採購單_dgv(14, e.RowIndex).Value
  423. 稅金比_tb.Text = 採購單_dgv(15, e.RowIndex).Value.ToString : 核對員_tb.Text = 採購單_dgv(4, e.RowIndex).Value.ToString : 核對日期_tb.Text = 採購單_dgv(5, e.RowIndex).Value.ToString
  424. 詢價員_tb.Text = 採購單_dgv(6, e.RowIndex).Value.ToString : 尋價日期_tb.Text = 採購單_dgv(7, e.RowIndex).Value.ToString
  425. If Strings.Left(採購單號_tb.Text, 3) = "HXI" Then
  426. 選擇公司_cb.Text = "PT HONG XHE INDUSTRIAL"
  427. ElseIf Strings.Left(採購單號_tb.Text, 3) = "PGS" Then
  428. 選擇公司_cb.Text = "PT PUNCAK GEMILANG SEMESTA" : End If
  429. 供應商編碼_tb.Text = 採購單_dgv(1, e.RowIndex).Value.ToString : conn.Close() : PA1 = 供應商編碼_tb.Text
  430. SQL_建築物料採購單生成_供應商資料一()
  431. If dr.Read() Then : 廠商_cb.Text = dr("公司名") : conn.Close() : End If : conn.Close()
  432. 使用地點_tb.Text = 採購單_dgv(3, e.RowIndex).Value.ToString : 需求日期_dtp.Value = 採購單_dgv(2, e.RowIndex).Value
  433. Set_明細清單() : 歷史單價_P.Visible = False
  434. End If
  435. End Sub
  436. Private Sub Set_日期格式轉換()
  437. DTP = Strings.Format(Today(), "yyyy/MM/dd") : DTP1 = Strings.Format(Today(), "yyyyMMdd") : DTP2 = Strings.Format(需求日期_dtp.Value, "yyyy/MM/dd")
  438. End Sub
  439. Private Sub 類別管理_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 類別管理_cb.SelectedIndexChanged
  440. PA20 = 類別管理_cb.Text : SQL_供應商類別管理_查詢()
  441. If dr.Read() Then : 供應商簡稱_tb.Text = dr("編碼").ToString : Else : 供應商簡稱_tb.Text = "" : End If
  442. PA = 供應商簡稱_tb.Text : 廠商_cb_下拉表單資料載入()
  443. End Sub
  444. Private Sub 廠商_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 廠商_cb.SelectedIndexChanged
  445. PA1 = 廠商_cb.Text : SQL_建築物料採購單生成_供應商資料二()
  446. If dr.Read() Then
  447. 地址_tb.Text = dr("公司地址") : 電話_tb.Text = dr("公司電話1") : 郵件_tb.Text = dr("聯繫人1郵箱")
  448. 傳真_tb.Text = dr("公司傳真1") : 供應商編碼_tb.Text = dr("流水碼")
  449. End If : conn.Close()
  450. End Sub
  451. Private Sub 供應商編碼_tb_TextChanged(sender As Object, e As EventArgs) Handles 供應商編碼_tb.TextChanged
  452. Set_清單3()
  453. End Sub
  454. Private Sub 清空供應商_bt_Click(sender As Object, e As EventArgs) Handles 清空供應商_bt.Click
  455. If 採購單號_tb.Text = "" Then
  456. Else
  457. SQL_採購單供應商_清空() : MsgBox(對話框(5))
  458. End If
  459. End Sub
  460. Private Sub 折扣比_tb_TextChanged(sender As Object, e As EventArgs) Handles 折扣比_tb.TextChanged
  461. 總金額計算()
  462. End Sub
  463. Private Sub 稅金計算_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 稅金計算_ch.CheckedChanged
  464. 總金額計算()
  465. End Sub
  466. Private Sub 稅金比_tb_TextChanged(sender As Object, e As EventArgs) Handles 稅金比_tb.TextChanged
  467. 總金額計算()
  468. End Sub
  469. Private Sub 全部選擇_bt_Click(sender As Object, e As EventArgs) Handles 全部選擇_bt.Click
  470. For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = True : Next i
  471. End Sub
  472. Private Sub 全部取消_bt_Click(sender As Object, e As EventArgs) Handles 全部取消_bt.Click
  473. For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = False : Next i
  474. End Sub
  475. Private Sub 生成採購單_bt_Click(sender As Object, e As EventArgs) Handles 生成採購單_bt.Click
  476. If 採購選擇 = "A" Then
  477. 生成新的採購訂單()
  478. ElseIf 採購選擇 = "B" Then
  479. 修改的採購單存檔()
  480. End If
  481. End Sub
  482. Private Sub 生成新的採購訂單()
  483. If 選擇公司_cb.Text = "PT HONG XHE INDUSTRIAL" Then
  484. Set_日期格式轉換() : Dim NUM1 As Integer
  485. For i As Integer = 1 To 999
  486. NUM1 = 0 + i
  487. If NUM1 < 10 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-00" & NUM1
  488. ElseIf NUM1 > 9 And NUM1 < 100 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-0" & NUM1
  489. ElseIf NUM1 > 99 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-" & NUM1
  490. End If
  491. PA1 = 採購單號_tb.Text
  492. SQL_採購單控制表_單號最後一筆() : If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
  493. Next
  494. 確定新增()
  495. ElseIf 選擇公司_cb.Text = "PT PUNCAK GEMILANG SEMESTA" Then
  496. Set_日期格式轉換() : Dim NUM1 As Integer
  497. For i As Integer = 1 To 999
  498. NUM1 = 0 + i
  499. If NUM1 < 10 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-00" & NUM1
  500. ElseIf NUM1 > 9 And NUM1 < 100 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-0" & NUM1
  501. ElseIf NUM1 > 99 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-" & NUM1
  502. End If
  503. PA1 = 採購單號_tb.Text
  504. SQL_採購單控制表_單號最後一筆() : If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
  505. Next
  506. 確定新增()
  507. End If
  508. End Sub
  509. Private Sub 修改的採購單存檔()
  510. If 廠商_cb.Text = "" Then
  511. MsgBox(對話框(5))
  512. Else
  513. Set_日期格式轉換()
  514. PA1 = 供應商編碼_tb.Text : PA2 = 使用地點_tb.Text : PA3 = 折扣比_tb.Text : BL1 = 稅金計算_ch.Checked : PA4 = 稅金比_tb.Text : PA5 = 採購單號_tb.Text
  515. SQL_採購單控制表_編輯() : conn.Close()
  516. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  517. 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條()
  518. PA6 = 明細_dgv.Rows(i).Cells("" & 表頭(14) & "").Value : PA7 = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value
  519. PA8 = 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value : PA9 = 明細_dgv.Rows(i).Cells("" & 表頭(16) & "").Value
  520. PA10 = 明細_dgv.Rows(i).Cells("項次").Value : PA4 = 明細_dgv.Rows(i).Cells("KEY").Value
  521. SQL_採購單明細表_修改() : conn.Close()
  522. Next
  523. Set_清單1() : Set_清單2() : MsgBox(對話框(4)) : GCM_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  524. End If
  525. End Sub
  526. Private Sub 確定新增()
  527. Set_日期格式轉換()
  528. If 採購單號_tb.Text = "" Or 供應商編碼_tb.Text = "" Or 明細_dgv.Rows.Count = 0 Then
  529. MsgBox(對話框(0))
  530. Else
  531. PA1 = 採購單號_tb.Text : PA2 = 供應商編碼_tb.Text : PA3 = 使用地點_tb.Text : PA4 = QQQ2
  532. PA5 = QQQ3 : PA6 = QQQ1 : PA7 = 折扣比_tb.Text : BL1 = 稅金計算_ch.Checked : PA8 = 稅金比_tb.Text
  533. SQL_採購單控制表_新增() : SQL_請購單控制表_轉採修改() : conn.Close()
  534. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  535. 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條()
  536. If 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = True Then
  537. PA9 = 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value : PA2 = 明細_dgv.Rows(i).Cells("" & 表頭(18) & "").Value : PA3 = 明細_dgv.Rows(i).Cells("項次").Value
  538. PA4 = 明細_dgv.Rows(i).Cells("" & 表頭(12) & "").Value : PA5 = 明細_dgv.Rows(i).Cells("" & 表頭(13) & "").Value : PA6 = 明細_dgv.Rows(i).Cells("" & 表頭(14) & "").Value
  539. NU1 = 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value : PA8 = 明細_dgv.Rows(i).Cells("" & 表頭(16) & "").Value : PA10 = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value
  540. PA11 = 明細_dgv.Rows(i).Cells("群組碼").Value : PA12 = 明細_dgv.Rows(i).Cells("料號原則").Value : PA13 = 明細_dgv.Rows(i).Cells("料號").Value
  541. SQL_請購單明細表_轉採修改() : SQL_採購單明細表_新增() : conn.Close()
  542. End If
  543. Next
  544. Set_清單1() : Set_清單2() : MsgBox(對話框(1)) : GCM_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  545. End If
  546. End Sub
  547. Private Sub 料號_bt_Click(sender As Object, e As EventArgs) Handles 料號_bt.Click
  548. Set_料號比價()
  549. If 料號1_tb.Text = "" Then
  550. MsgBox(對話框(10))
  551. Else
  552. If 歷史單價_P.Visible = True Then : 歷史單價_P.Visible = False
  553. Else : 歷史單價_P.Visible = True : 繪圖() : End If
  554. End If
  555. End Sub
  556. Private Sub 繪圖()
  557. Chart1.Series.Clear() : Chart1.ChartAreas(0).AxisX.Minimum = 0
  558. If 品名_tb.Text <> "" Then
  559. If 折線圖_ch.Checked = True Then
  560. Chart1.Series.Add(品名_tb.Text & "_1") : Chart1.Series(品名_tb.Text & "_1").ChartType = SeriesChartType.Line : Chart1.Series(品名_tb.Text & "_1").IsVisibleInLegend = False
  561. End If
  562. If 長條圖_ch.Checked = True Then
  563. Chart1.Series.Add(品名_tb.Text) : Chart1.Series(品名_tb.Text).ChartType = SeriesChartType.Column
  564. End If
  565. For i As Integer = 0 To 料號_dgv.Rows.Count - 1
  566. Chart1.Series(品名_tb.Text).Points.AddXY(料號_dgv.Rows(i).Cells(表頭(134)).Value.ToString, 料號_dgv.Rows(i).Cells(表頭(26)).Value.ToString)
  567. Next
  568. End If
  569. End Sub
  570. Private Sub 小間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 小間距_ch.Click
  571. 小間距_ch.Checked = True : 中間距_ch.Checked = False : 大間距_ch.Checked = False : MyModule1.間距設定存檔_1() : Set_明細清單()
  572. End Sub
  573. Private Sub 中間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 中間距_ch.Click
  574. 小間距_ch.Checked = False : 中間距_ch.Checked = True : 大間距_ch.Checked = False : MyModule1.間距設定存檔_2() : Set_明細清單()
  575. End Sub
  576. Private Sub 大間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 大間距_ch.Click
  577. 小間距_ch.Checked = False : 中間距_ch.Checked = False : 大間距_ch.Checked = True : MyModule1.間距設定存檔_3() : Set_明細清單()
  578. End Sub
  579. Private Sub 物料圖1_pb_Click(sender As Object, e As EventArgs) Handles 物料圖1_pb.Click
  580. If IsNothing(物料圖1_pb.Image) = False Then
  581. 圖片傳遞 = 物料圖1_pb.Image : 圖片放大視窗.ShowDialog()
  582. End If
  583. End Sub
  584. Private Sub 詳細資料2_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 詳細資料2_ch.Click
  585. If 詳細資料2_ch.Checked = True Then : 詳細資料2_ch.Checked = True : Else : 詳細資料2_ch.Checked = False : End If : Set_明細清單()
  586. End Sub
  587. Private Sub 列印成詢價單_bt_Click(sender As Object, e As EventArgs) Handles 列印成詢價單_bt.Click
  588. If 採購單號_tb.Text = "" Then
  589. MsgBox(對話框(2))
  590. Else
  591. xlApp = CType(CreateObject("Excel.Application"), Application)
  592. xlBook = xlApp.Workbooks.Add
  593. xlApp.DisplayAlerts = True
  594. xlBook.Activate()
  595. xlSheet = NewMethod(xlBook)
  596. xlSheet.Activate()
  597. xlApp.Visible = True
  598. xlApp.Application.WindowState = xlMaximized
  599. xlSheet.Cells(2, 1) = 選擇公司_cb.Text : xlSheet.Cells(3, 1) = "MINTA PESANAN HARGA"
  600. xlSheet.Cells(5, 1) = "ORDER TO : " & 廠商_cb.Text : xlSheet.Cells(6, 1) = "ALAMAT : " & 地址_tb.Text : xlSheet.Cells(7, 1) = "Telp : " & 電話_tb.Text
  601. xlSheet.Cells(8, 1) = "Fax : " & 傳真_tb.Text : xlSheet.Cells(9, 1) = "Email : " & 郵件_tb.Text
  602. xlSheet.Cells(10, 1) = "No." : xlSheet.Cells(10, 2) = "Nama produk" : xlSheet.Cells(10, 3) = "Spesifikasi" : xlSheet.Cells(10, 4) = "Komentar" : xlSheet.Cells(10, 5) = "SATUAN"
  603. xlSheet.Cells(10, 6) = "QTY" : xlSheet.Cells(10, 7) = "UNIT PRICE" : xlSheet.Cells(10, 8) = "TOTAL PRICE"
  604. xlSheet.Cells(7, 5) = "PO NOMOR : " : xlSheet.Cells(7, 7) = 採購單號_tb.Text
  605. xlSheet.Cells(8, 5) = "TGL/BLN/THN : " : xlSheet.Cells(8, 7) = 需求日期_dtp.Value
  606. xlSheet.Cells(9, 5) = "TEMPAT PEMAKAIAN : " : xlSheet.Cells(9, 7) = 使用地點_tb.Text
  607. Dim GGHH As Integer = 0
  608. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  609. xlSheet.Cells(i + 11, 1) = 明細_dgv.Rows(i).Cells("" & 表頭(11) & "").Value : xlSheet.Cells(i + 11, 2) = 明細_dgv.Rows(i).Cells("" & 表頭(12) & "").Value
  610. xlSheet.Cells(i + 11, 3) = 明細_dgv.Rows(i).Cells("" & 表頭(13) & "").Value : xlSheet.Cells(i + 11, 4) = 明細_dgv.Rows(i).Cells("" & 表頭(14) & "").Value
  611. xlSheet.Cells(i + 11, 5) = 明細_dgv.Rows(i).Cells("" & 表頭(16) & "").Value : xlSheet.Cells(i + 11, 6) = 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value
  612. xlSheet.Cells(i + 11, 7) = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value : xlSheet.Cells(i + 11, 8) = 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value
  613. GGHH += 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value
  614. N1 = i + 11
  615. Next i
  616. xlSheet.Cells(N1 + 2, 7) = "TOTAL :" : xlSheet.Cells(N1 + 2, 8) = GGHH
  617. xlSheet.Cells(N1 + 3, 7) = "DISC " & 折扣比_tb.Text & "% :" : xlSheet.Cells(N1 + 3, 8) = 折扣金額_tb.Text
  618. xlSheet.Cells(N1 + 4, 7) = "PPN " & 稅金比_tb.Text & "% :" : xlSheet.Cells(N1 + 4, 8) = 稅金金額_tb.Text
  619. xlSheet.Cells(N1 + 5, 7) = "GRAND TOTAL :" : xlSheet.Cells(N1 + 5, 8) = 總金額_tb.Text
  620. xlSheet.Cells(N1 + 6, 1) = "Bagian Pembelian Barang"
  621. xlSheet.Cells(N1 + 6, 3) = "Direktur Utama"
  622. xlSheet.Cells(N1 + 6, 4) = "Bagian Pemeriksa"
  623. xlSheet.Cells(N1 + 6, 6) = "Bagian Pengisian Harga" : xlSheet.Cells(N1 + 8, 6) = 詢價員_tb.Text : xlSheet.Cells(N1 + 9, 6) = 尋價日期_tb.Text
  624. xlSheet.Cells(N1 + 6, 8) = "Asisten Proyek" : xlSheet.Cells(N1 + 8, 8) = 核對員_tb.Text : xlSheet.Cells(N1 + 9, 8) = 核對日期_tb.Text
  625. AA(xlApp, xlSheet)
  626. xlSheet.PageSetup.PrintArea = ""
  627. xlApp.Cells.Select()
  628. xlSheet.Range("B1").Select()
  629. xlApp.Application.WindowState = xlMinimized
  630. xlSheet.Cells.Select()
  631. xlApp.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="0911274990")
  632. xlApp.ActiveSheet.EnableSelection = 1
  633. MsgBox(對話框(3))
  634. End If
  635. End Sub
  636. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  637. Return CType(xlBook.Worksheets.Add, Worksheet)
  638. End Function
  639. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  640. xlSheet.Cells.Select()
  641. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  642. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  643. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 6 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 24
  644. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 30 : xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 20
  645. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 10 : xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 15
  646. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 15 : xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 30
  647. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 5 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 35
  648. xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("4:4").Select : myExcel.Selection.RowHeight = 5
  649. xlSheet.Rows("5:9").Select : myExcel.Selection.RowHeight = 20 : xlSheet.Rows("10:10").Select : myExcel.Selection.RowHeight = 20
  650. xlSheet.Rows("11:" & N1).Select : myExcel.Selection.RowHeight = 65 : xlSheet.Rows(N1 + 1 & ":" & N1 + 1).Select : myExcel.Selection.RowHeight = 5
  651. xlSheet.Rows(N1 + 2 & ":" & N1 + 5).Select : myExcel.Selection.RowHeight = 17 : xlSheet.Rows(N1 + 6 & ":" & N1 + 6).Select : myExcel.Selection.RowHeight = 35
  652. xlSheet.Rows(N1 + 7 & ":" & N1 + 9).Select : myExcel.Selection.RowHeight = 35
  653. xlSheet.Range("A2:H2").Select()
  654. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  655. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  656. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 26 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  657. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  658. xlSheet.Range("A3:H3").Select()
  659. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  660. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  661. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  662. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  663. xlSheet.Range("A10:H" & N1).Select()
  664. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  665. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  666. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  667. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  668. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  669. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  670. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  671. xlSheet.Range("A" & N1 + 2 & ":H" & N1 + 2).Select()
  672. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  673. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  674. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  675. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  676. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  677. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  678. xlSheet.Range("A" & N1 + 3 & ":H" & N1 + 3).Select()
  679. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  680. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  681. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  682. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  683. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  684. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  685. xlSheet.Range("A" & N1 + 4 & ":H" & N1 + 4).Select()
  686. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  687. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  688. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  689. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  690. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  691. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  692. xlSheet.Range("A" & N1 + 5 & ":H" & N1 + 5).Select()
  693. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  694. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  695. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  696. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  697. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  698. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  699. xlSheet.Range("A" & N1 + 6 & ":B" & N1 + 6).Select()
  700. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  701. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  702. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  703. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  704. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  705. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  706. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  707. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  708. xlSheet.Range("C" & N1 + 6 & ":C" & N1 + 6).Select()
  709. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  710. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  711. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  712. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  713. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  714. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  715. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  716. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  717. xlSheet.Range("D" & N1 + 6 & ":E" & N1 + 6).Select()
  718. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  719. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  720. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  721. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  722. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  723. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  724. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  725. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  726. xlSheet.Range("F" & N1 + 6 & ":G" & N1 + 6).Select()
  727. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  728. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  729. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  730. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  731. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  732. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  733. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  734. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  735. xlSheet.Range("H" & N1 + 6).Select()
  736. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  737. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  738. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  739. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  740. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  741. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  742. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  743. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  744. xlSheet.Range("A" & N1 + 7 & ":B" & N1 + 9).Select()
  745. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  746. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  747. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  748. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  749. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  750. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  751. xlSheet.Range("C" & N1 + 7 & ":C" & N1 + 9).Select()
  752. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  753. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  754. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  755. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  756. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  757. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  758. xlSheet.Range("D" & N1 + 7 & ":E" & N1 + 9).Select()
  759. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  760. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  761. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  762. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  763. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  764. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  765. xlSheet.Range("F" & N1 + 7 & ":G" & N1 + 9).Select()
  766. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  767. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  768. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  769. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  770. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  771. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  772. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  773. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  774. xlSheet.Range("H" & N1 + 7 & ":H" & N1 + 9).Select()
  775. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  776. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  777. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  778. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  779. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  780. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  781. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  782. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  783. xlSheet.Range("A10:A" & N1).Select()
  784. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  785. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  786. xlSheet.Range("B11:D" & N1).Select()
  787. With myExcel.Selection
  788. .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  789. .ReadingOrder = xlContext : .MergeCells = False : End With
  790. xlSheet.Range("E11:F" & N1).Select()
  791. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  792. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  793. xlSheet.Range("G11:H" & N1).Select() : myExcel.Selection.NumberFormatLocal = "#,##0"
  794. xlSheet.Range("H" & N1 + 2).Select() : myExcel.Selection.NumberFormatLocal = "#,##0"
  795. xlSheet.Range("H" & N1 + 2 & ":H" & N1 + 5).Select()
  796. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  797. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  798. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  799. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  800. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  801. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  802. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  803. myExcel.ActiveWindow.DisplayGridlines = False
  804. xlSheet.Range("A3:H3").Select()
  805. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  806. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  807. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  808. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  809. xlSheet.Range("G7:G9").Select()
  810. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  811. .ReadingOrder = xlContext : .MergeCells = False : End With
  812. xlSheet.Range("A10:H" & N1).Select()
  813. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  814. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  815. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  816. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  817. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  818. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  819. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  820. xlSheet.Range("A" & N1 + 2 & ":H" & N1 + 5).Select()
  821. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  822. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  823. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  824. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  825. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  826. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  827. xlSheet.Range("A" & N1 + 6 & ":B" & N1 + 9).Select()
  828. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  829. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  830. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  831. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  832. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  833. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  834. xlSheet.Range("C" & N1 + 6 & ":C" & N1 + 9).Select()
  835. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  836. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  837. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  838. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  839. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  840. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  841. xlSheet.Range("D" & N1 + 6 & ":E" & N1 + 9).Select()
  842. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  843. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  844. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  845. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  846. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  847. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  848. xlSheet.Range("F" & N1 + 6 & ":G" & N1 + 9).Select()
  849. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  850. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  851. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  852. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  853. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  854. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  855. xlSheet.Range("H" & N1 + 6 & ":H" & N1 + 9).Select()
  856. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  857. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  858. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  859. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  860. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  861. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  862. xlSheet.Rows("5:9").Select
  863. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  864. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  865. xlSheet.Rows("11:" & N1).Select
  866. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  867. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  868. xlSheet.Range("A10:H10").Select()
  869. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  870. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  871. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  872. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  873. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  874. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  875. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  876. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  877. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  878. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  879. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  880. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  881. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  882. xlSheet.Range("A11:H" & N1).Select()
  883. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  884. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  885. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  886. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  887. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  888. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  889. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  890. xlSheet.Range("B11:D" & N1).Select()
  891. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  892. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  893. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  894. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  895. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  896. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  897. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  898. xlSheet.Range("F11:F" & N1).Select()
  899. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  900. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  901. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  902. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  903. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  904. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  905. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  906. xlSheet.Range("H11:H" & N1).Select()
  907. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  908. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  909. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  910. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  911. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  912. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  913. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  914. xlSheet.Range("A" & N1 + 2 & ":H" & N1 + 5).Select()
  915. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  916. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  917. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  918. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  919. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  920. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  921. xlSheet.Range("H" & N1 + 2 & ":H" & N1 + 5).Select()
  922. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  923. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  924. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  925. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  926. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  927. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  928. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  929. xlSheet.Range("G" & N1 + 2 & ":G" & N1 + 5).Select()
  930. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  931. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  932. xlSheet.Range("F" & N1 + 8 & ":G" & N1 + 8).Select()
  933. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  934. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  935. xlSheet.Range("F" & N1 + 9 & ":G" & N1 + 9).Select()
  936. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  937. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  938. myExcel.Application.PrintCommunication = False
  939. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$10" : .PrintTitleColumns = "" : End With
  940. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  941. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "" : .RightFooter = ""
  942. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  943. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  944. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  945. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False
  946. .Draft = False : .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = 60 : .OddAndEvenPagesHeaderFooter = False
  947. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True : .EvenPage.LeftHeader.Text = ""
  948. .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = ""
  949. .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = ""
  950. .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  951. End With
  952. myExcel.Application.PrintCommunication = True
  953. End Sub
  954. '-----------------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------
  955. Private Sub 重新整理ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理_tsm.Click
  956. Set_清單1() : Set_清單2()
  957. End Sub
  958. End Class