No Description
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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  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 = HX_PGS_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. SQL_清單欄位查詢()
  311. If Acdr.Read() Then
  312. 小間距_ch.Checked = Acdr("L_1_1") : 中間距_ch.Checked = Acdr("L_2_1") : 大間距_ch.Checked = Acdr("L_3_1")
  313. End If : Access1.Close()
  314. Label4.Text = 對話框(6) & 比例1 & 對話框(7) & 比例2 & 對話框(8) & 比例2 & 對話框(7) & 比例3 & 對話框(9) & 比例3
  315. 類別管理_cb_下拉表單資料載入() : Set_清單1() : Set_清單2()
  316. MyModule1.清單字體大小調整()
  317. 採購單_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  318. 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  319. 料號_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  320. End Sub
  321. Private Sub 採購單編輯_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
  322. MyModule1.清單字體大小調整()
  323. 採購單_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  324. 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  325. 料號_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  326. End Sub
  327. Private Sub 採購單編輯_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
  328. H(205) = False : MyModule1.虛擬桌面開啟()
  329. End Sub
  330. Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click
  331. 介面 = "H205" : 語言轉換讀取()
  332. 類別管理_cb_下拉表單資料載入() : Set_清單1() : Set_清單2() : Set_單價() : Set_明細清單() : Set_料號比價()
  333. Label4.Text = 對話框(6) & 比例1 & 對話框(7) & 比例2 & 對話框(8) & 比例2 & 對話框(7) & 比例3 & 對話框(9) & 比例3
  334. End Sub
  335. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  336. timeNow = 0
  337. HX_PGS_ERP_SYS.Timer1.Enabled = False
  338. HX_PGS_ERP_SYS.Timer1.Enabled = True
  339. End Sub
  340. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  341. timeNow = 0
  342. HX_PGS_ERP_SYS.Timer1.Enabled = False
  343. HX_PGS_ERP_SYS.Timer1.Enabled = True
  344. End Sub
  345. Private Sub 價格()
  346. Dim 差異, 比對 As Double
  347. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  348. If 明細_dgv.Rows(i).Cells("OUP").Value = 0 And 明細_dgv.Rows(i).Cells(表頭(26)).Value = 0 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  349. 明細_dgv.Rows(i).Cells("SP%").Value = "0 % →"
  350. ElseIf 明細_dgv.Rows(i).Cells(表頭(26)).Value = 0 And 明細_dgv.Rows(i).Cells("OUP").Value <> 0 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  351. 明細_dgv.Rows(i).Cells("SP%").Value = "0 % →"
  352. ElseIf 明細_dgv.Rows(i).Cells("OUP").Value <> 0 And 明細_dgv.Rows(i).Cells(表頭(26)).Value <> 0 Then
  353. 差異 = 明細_dgv.Rows(i).Cells(表頭(26)).Value - 明細_dgv.Rows(i).Cells("OUP").Value : 比對 = 差異 / 明細_dgv.Rows(i).Cells(表頭(26)).Value * 100
  354. If 比對 > 0 Then : 明細_dgv.Rows(i).Cells("SP%").Value = CInt(比對) & " % ↗" : 比對 *= 1
  355. ElseIf 比對 < 0 Then : 明細_dgv.Rows(i).Cells("SP%").Value = CInt(比對) & " % ↘" : 比對 *= -1
  356. ElseIf 比對 = 0 Then : 明細_dgv.Rows(i).Cells("SP%").Value = CInt(比對) & " % →" : End If
  357. If 比對 < 比例1 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  358. ElseIf 比對 > 比例1 And 比對 < 比例2 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
  359. ElseIf 比對 > 比例2 And 比對 < 比例3 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue
  360. ElseIf 比對 >= 比例3 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink : End If
  361. End If
  362. Next
  363. End Sub
  364. Private Sub 單價_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 單價_rb.Click
  365. Set_明細清單()
  366. End Sub
  367. Private Sub 日期_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 日期_rb.Click
  368. Set_明細清單()
  369. End Sub
  370. Dim 已超出 As Boolean
  371. Private Sub 明細_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 明細_dgv.MouseUp
  372. 'If 明細_dgv.SelectedCells.Count = 1 Then : MsgBox(明細_dgv.SelectedCells(0).ColumnIndex & " " & 明細_dgv.SelectedCells(0).RowIndex) : End If
  373. If 明細_dgv.SelectedCells.Count = 1 Then : 已超出 = False : End If
  374. If 明細_dgv.SelectedCells.Count > 0 Then
  375. If 明細_dgv.SelectedCells(0).ColumnIndex = 9 Then
  376. If 已超出 = False Then
  377. Dim x As Double = 0
  378. For i As Integer = 0 To 明細_dgv.SelectedCells.Count - 1
  379. Dim 變數 As String = "" : Dim 取變數 As String
  380. 取變數 = 明細_dgv.Rows(明細_dgv.SelectedCells.Item(i).RowIndex).Cells(明細_dgv.SelectedCells.Item(i).ColumnIndex).Value
  381. For ii As Integer = 1 To Len(取變數)
  382. If ii = 1 Then : 變數 = Strings.Left(取變數, ii) : Else : If Strings.Mid(取變數, ii, 1) <> "," Then : 變數 &= Strings.Mid(取變數, ii, 1) : End If : End If
  383. Next : x += CLng(變數)
  384. Next i : HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(x, "#,##0")
  385. Else : HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(0, "#,##0")
  386. End If
  387. Else : 已超出 = True : HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(0, "#,##0")
  388. End If
  389. End If
  390. End Sub
  391. Private Sub 明細_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細_dgv.CellClick
  392. If e.RowIndex = -1 Then : Else
  393. 物料圖2_pb.Image = Nothing : 物料圖1_pb.Image = Nothing
  394. PA2 = 明細_dgv.Rows(e.RowIndex).Cells("料號原則").Value : SQL_物料圖庫_圖檔讀取一()
  395. While dr.Read() = True
  396. Dim unused As Byte() = New Byte(-1) {}
  397. Dim bytes As Byte() = DirectCast(dr.Item("圖檔"), Byte())
  398. Dim oStream As New MemoryStream(bytes)
  399. 物料圖1_pb.Image = Bitmap.FromStream(oStream)
  400. End While
  401. conn.Close() : 物料圖1_pb.SizeMode = 4
  402. 料號1_tb.Text = 明細_dgv("料號", e.RowIndex).Value.ToString
  403. 品名_tb.Text = 明細_dgv(表頭(12), e.RowIndex).Value.ToString
  404. If 歷史單價_P.Visible = True Then : Set_料號比價() : 繪圖() : End If
  405. End If
  406. 價格()
  407. End Sub
  408. Private Sub 明細_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 明細_dgv.CellEnter
  409. 總金額計算() : 價格()
  410. End Sub
  411. Private Sub 請購單_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 請購單_dgv.CellClick
  412. 選擇公司_cb.Enabled = True : 採購選擇 = "A"
  413. If e.RowIndex = -1 Then : Else
  414. QQQ1 = 請購單_dgv(0, e.RowIndex).Value.ToString : QQQ2 = 請購單_dgv(3, e.RowIndex).Value.ToString : QQQ3 = 請購單_dgv(4, e.RowIndex).Value.ToString
  415. If 請購單_dgv.Rows(e.RowIndex).Cells("用途").Value.ToString = "" Then : 使用地點_tb.Text = "" : Else
  416. 使用地點_tb.Text = 請購單_dgv.Rows(e.RowIndex).Cells("用途").Value.ToString & "-" & 請購單_dgv.Rows(e.RowIndex).Cells("倉名").Value
  417. End If
  418. 折扣比_tb.Text = "0" : 稅金計算_ch.Checked = True : 稅金比_tb.Text = "10" : 採購單號_tb.Text = ""
  419. End If : Set_明細清單()
  420. End Sub
  421. Private Sub 採購單_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 採購單_dgv.CellClick
  422. PA = "" : 廠商清空()
  423. 選擇公司_cb.Enabled = False : 採購選擇 = "B"
  424. If e.RowIndex = -1 Then : Else
  425. 採購單號_tb.Text = 採購單_dgv(0, e.RowIndex).Value.ToString : 折扣比_tb.Text = 採購單_dgv(13, e.RowIndex).Value.ToString : 稅金計算_ch.Checked = 採購單_dgv(14, e.RowIndex).Value
  426. 稅金比_tb.Text = 採購單_dgv(15, e.RowIndex).Value.ToString : 核對員_tb.Text = 採購單_dgv(4, e.RowIndex).Value.ToString : 核對日期_tb.Text = 採購單_dgv(5, e.RowIndex).Value.ToString
  427. 詢價員_tb.Text = 採購單_dgv(6, e.RowIndex).Value.ToString : 尋價日期_tb.Text = 採購單_dgv(7, e.RowIndex).Value.ToString
  428. If Strings.Left(採購單號_tb.Text, 3) = "HXI" Then
  429. 選擇公司_cb.Text = "PT HONG XHE INDUSTRIAL"
  430. ElseIf Strings.Left(採購單號_tb.Text, 3) = "PGS" Then
  431. 選擇公司_cb.Text = "PT PUNCAK GEMILANG SEMESTA" : End If
  432. 供應商編碼_tb.Text = 採購單_dgv(1, e.RowIndex).Value.ToString : conn.Close() : PA1 = 供應商編碼_tb.Text
  433. SQL_建築物料採購單生成_供應商資料一()
  434. If dr.Read() Then : 廠商_cb.Text = dr("公司名") : conn.Close() : End If : conn.Close()
  435. 使用地點_tb.Text = 採購單_dgv(3, e.RowIndex).Value.ToString : 需求日期_dtp.Value = 採購單_dgv(2, e.RowIndex).Value
  436. Set_明細清單() : 歷史單價_P.Visible = False
  437. End If
  438. End Sub
  439. Private Sub Set_日期格式轉換()
  440. DTP = Strings.Format(Today(), "yyyy/MM/dd") : DTP1 = Strings.Format(Today(), "yyyyMMdd") : DTP2 = Strings.Format(需求日期_dtp.Value, "yyyy/MM/dd")
  441. End Sub
  442. Private Sub 類別管理_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 類別管理_cb.SelectedIndexChanged
  443. PA20 = 類別管理_cb.Text : SQL_供應商類別管理_查詢()
  444. If dr.Read() Then : 供應商簡稱_tb.Text = dr("編碼").ToString : Else : 供應商簡稱_tb.Text = "" : End If
  445. PA = 供應商簡稱_tb.Text : 廠商_cb_下拉表單資料載入()
  446. End Sub
  447. Private Sub 廠商_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 廠商_cb.SelectedIndexChanged
  448. PA1 = 廠商_cb.Text : SQL_建築物料採購單生成_供應商資料二()
  449. If dr.Read() Then
  450. 地址_tb.Text = dr("公司地址") : 電話_tb.Text = dr("公司電話1") : 郵件_tb.Text = dr("聯繫人1郵箱")
  451. 傳真_tb.Text = dr("公司傳真1") : 供應商編碼_tb.Text = dr("供應商編碼")
  452. End If : conn.Close()
  453. End Sub
  454. Private Sub 供應商編碼_tb_TextChanged(sender As Object, e As EventArgs) Handles 供應商編碼_tb.TextChanged
  455. Set_清單3()
  456. End Sub
  457. Private Sub 清空供應商_bt_Click(sender As Object, e As EventArgs) Handles 清空供應商_bt.Click
  458. If 採購單號_tb.Text = "" Then
  459. Else
  460. SQL_採購單供應商_清空() : MsgBox(對話框(5))
  461. End If
  462. End Sub
  463. Private Sub 折扣比_tb_TextChanged(sender As Object, e As EventArgs) Handles 折扣比_tb.TextChanged
  464. 總金額計算()
  465. End Sub
  466. Private Sub 稅金計算_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 稅金計算_ch.CheckedChanged
  467. 總金額計算()
  468. End Sub
  469. Private Sub 稅金比_tb_TextChanged(sender As Object, e As EventArgs) Handles 稅金比_tb.TextChanged
  470. 總金額計算()
  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 = True : Next i
  474. End Sub
  475. Private Sub 全部取消_bt_Click(sender As Object, e As EventArgs) Handles 全部取消_bt.Click
  476. For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = False : Next i
  477. End Sub
  478. Private Sub 生成採購單_bt_Click(sender As Object, e As EventArgs) Handles 生成採購單_bt.Click
  479. If 採購選擇 = "A" Then
  480. 生成新的採購訂單()
  481. ElseIf 採購選擇 = "B" Then
  482. 修改的採購單存檔()
  483. End If
  484. End Sub
  485. Private Sub 生成新的採購訂單()
  486. If 選擇公司_cb.Text = "PT HONG XHE INDUSTRIAL" Then
  487. Set_日期格式轉換() : Dim NUM1 As Integer
  488. For i As Integer = 1 To 999
  489. NUM1 = 0 + i
  490. If NUM1 < 10 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-00" & NUM1
  491. ElseIf NUM1 > 9 And NUM1 < 100 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-0" & NUM1
  492. ElseIf NUM1 > 99 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-" & NUM1
  493. End If
  494. PA1 = 採購單號_tb.Text
  495. SQL_採購單控制表_單號最後一筆() : If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
  496. Next
  497. 確定新增()
  498. ElseIf 選擇公司_cb.Text = "PT PUNCAK GEMILANG SEMESTA" Then
  499. Set_日期格式轉換() : Dim NUM1 As Integer
  500. For i As Integer = 1 To 999
  501. NUM1 = 0 + i
  502. If NUM1 < 10 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-00" & NUM1
  503. ElseIf NUM1 > 9 And NUM1 < 100 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-0" & NUM1
  504. ElseIf NUM1 > 99 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-" & NUM1
  505. End If
  506. PA1 = 採購單號_tb.Text
  507. SQL_採購單控制表_單號最後一筆() : If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
  508. Next
  509. 確定新增()
  510. End If
  511. End Sub
  512. Private Sub 修改的採購單存檔()
  513. If 廠商_cb.Text = "" Then
  514. MsgBox(對話框(5))
  515. Else
  516. Set_日期格式轉換()
  517. PA1 = 供應商編碼_tb.Text : PA2 = 使用地點_tb.Text : PA3 = 折扣比_tb.Text : BL1 = 稅金計算_ch.Checked : PA4 = 稅金比_tb.Text : PA5 = 採購單號_tb.Text
  518. SQL_採購單控制表_編輯() : conn.Close()
  519. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  520. 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條()
  521. PA6 = 明細_dgv.Rows(i).Cells("" & 表頭(14) & "").Value : PA7 = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value
  522. PA8 = 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value : PA9 = 明細_dgv.Rows(i).Cells("" & 表頭(16) & "").Value
  523. PA10 = 明細_dgv.Rows(i).Cells("項次").Value : PA4 = 明細_dgv.Rows(i).Cells("KEY").Value
  524. SQL_採購單明細表_修改() : conn.Close()
  525. Next
  526. Set_清單1() : Set_清單2() : MsgBox(對話框(4)) : HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  527. End If
  528. End Sub
  529. Private Sub 確定新增()
  530. Set_日期格式轉換()
  531. If 採購單號_tb.Text = "" Or 供應商編碼_tb.Text = "" Or 明細_dgv.Rows.Count = 0 Then
  532. MsgBox(對話框(0))
  533. Else
  534. PA1 = 採購單號_tb.Text : PA2 = 供應商編碼_tb.Text : PA3 = 使用地點_tb.Text : PA4 = QQQ2
  535. PA5 = QQQ3 : PA6 = QQQ1 : PA7 = 折扣比_tb.Text : BL1 = 稅金計算_ch.Checked : PA8 = 稅金比_tb.Text
  536. SQL_採購單控制表_新增() : SQL_請購單控制表_轉採修改() : conn.Close()
  537. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  538. 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條()
  539. If 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value = True Then
  540. PA9 = 明細_dgv.Rows(i).Cells("" & 表頭(28) & "").Value : PA2 = 明細_dgv.Rows(i).Cells("" & 表頭(18) & "").Value : PA3 = 明細_dgv.Rows(i).Cells("項次").Value
  541. PA4 = 明細_dgv.Rows(i).Cells("" & 表頭(12) & "").Value : PA5 = 明細_dgv.Rows(i).Cells("" & 表頭(13) & "").Value : PA6 = 明細_dgv.Rows(i).Cells("" & 表頭(14) & "").Value
  542. NU1 = 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value : PA8 = 明細_dgv.Rows(i).Cells("" & 表頭(16) & "").Value : PA10 = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value
  543. PA11 = 明細_dgv.Rows(i).Cells("群組碼").Value : PA12 = 明細_dgv.Rows(i).Cells("料號原則").Value : PA13 = 明細_dgv.Rows(i).Cells("料號").Value
  544. SQL_請購單明細表_轉採修改() : SQL_採購單明細表_新增() : conn.Close()
  545. End If
  546. Next
  547. Set_清單1() : Set_清單2() : MsgBox(對話框(1)) : HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  548. End If
  549. End Sub
  550. Private Sub 料號_bt_Click(sender As Object, e As EventArgs) Handles 料號_bt.Click
  551. Set_料號比價()
  552. If 料號1_tb.Text = "" Then
  553. MsgBox(對話框(10))
  554. Else
  555. If 歷史單價_P.Visible = True Then : 歷史單價_P.Visible = False
  556. Else : 歷史單價_P.Visible = True : 繪圖() : End If
  557. End If
  558. End Sub
  559. Private Sub 繪圖()
  560. Chart1.Series.Clear() : Chart1.ChartAreas(0).AxisX.Minimum = 0
  561. If 品名_tb.Text <> "" Then
  562. If 折線圖_ch.Checked = True Then
  563. Chart1.Series.Add(品名_tb.Text & "_1") : Chart1.Series(品名_tb.Text & "_1").ChartType = SeriesChartType.Line : Chart1.Series(品名_tb.Text & "_1").IsVisibleInLegend = False
  564. End If
  565. If 長條圖_ch.Checked = True Then
  566. Chart1.Series.Add(品名_tb.Text) : Chart1.Series(品名_tb.Text).ChartType = SeriesChartType.Column
  567. End If
  568. For i As Integer = 0 To 料號_dgv.Rows.Count - 1
  569. Chart1.Series(品名_tb.Text).Points.AddXY(料號_dgv.Rows(i).Cells(表頭(134)).Value.ToString, 料號_dgv.Rows(i).Cells(表頭(26)).Value.ToString)
  570. Next
  571. End If
  572. End Sub
  573. Private Sub 小間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 小間距_ch.Click
  574. 小間距_ch.Checked = True : 中間距_ch.Checked = False : 大間距_ch.Checked = False : MyModule1.間距設定存檔_1() : Set_明細清單()
  575. End Sub
  576. Private Sub 中間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 中間距_ch.Click
  577. 小間距_ch.Checked = False : 中間距_ch.Checked = True : 大間距_ch.Checked = False : MyModule1.間距設定存檔_2() : Set_明細清單()
  578. End Sub
  579. Private Sub 大間距_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 大間距_ch.Click
  580. 小間距_ch.Checked = False : 中間距_ch.Checked = False : 大間距_ch.Checked = True : MyModule1.間距設定存檔_3() : Set_明細清單()
  581. End Sub
  582. Private Sub 物料圖1_pb_Click(sender As Object, e As EventArgs) Handles 物料圖1_pb.Click
  583. If IsNothing(物料圖1_pb.Image) = False Then
  584. 圖片傳遞 = 物料圖1_pb.Image : 圖片放大視窗.ShowDialog()
  585. End If
  586. End Sub
  587. Private Sub 詳細資料2_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 詳細資料2_ch.Click
  588. If 詳細資料2_ch.Checked = True Then : 詳細資料2_ch.Checked = True : Else : 詳細資料2_ch.Checked = False : End If : Set_明細清單()
  589. End Sub
  590. Private Sub 列印成詢價單_bt_Click(sender As Object, e As EventArgs) Handles 列印成詢價單_bt.Click
  591. If 採購單號_tb.Text = "" Then
  592. MsgBox(對話框(2))
  593. Else
  594. xlApp = CType(CreateObject("Excel.Application"), Application)
  595. xlBook = xlApp.Workbooks.Add
  596. xlApp.DisplayAlerts = True
  597. xlBook.Activate()
  598. xlSheet = NewMethod(xlBook)
  599. xlSheet.Activate()
  600. xlApp.Visible = True
  601. xlApp.Application.WindowState = xlMaximized
  602. xlSheet.Cells(2, 1) = 選擇公司_cb.Text : xlSheet.Cells(3, 1) = "MINTA PESANAN HARGA"
  603. xlSheet.Cells(5, 1) = "ORDER TO : " & 廠商_cb.Text : xlSheet.Cells(6, 1) = "ALAMAT : " & 地址_tb.Text : xlSheet.Cells(7, 1) = "Telp : " & 電話_tb.Text
  604. xlSheet.Cells(8, 1) = "Fax : " & 傳真_tb.Text : xlSheet.Cells(9, 1) = "Email : " & 郵件_tb.Text
  605. 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"
  606. xlSheet.Cells(10, 6) = "QTY" : xlSheet.Cells(10, 7) = "UNIT PRICE" : xlSheet.Cells(10, 8) = "TOTAL PRICE"
  607. xlSheet.Cells(7, 5) = "PO NOMOR : " : xlSheet.Cells(7, 7) = 採購單號_tb.Text
  608. xlSheet.Cells(8, 5) = "TGL/BLN/THN : " : xlSheet.Cells(8, 7) = 需求日期_dtp.Value
  609. xlSheet.Cells(9, 5) = "TEMPAT PEMAKAIAN : " : xlSheet.Cells(9, 7) = 使用地點_tb.Text
  610. Dim GGHH As Integer = 0
  611. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  612. xlSheet.Cells(i + 11, 1) = 明細_dgv.Rows(i).Cells("" & 表頭(11) & "").Value : xlSheet.Cells(i + 11, 2) = 明細_dgv.Rows(i).Cells("" & 表頭(12) & "").Value
  613. xlSheet.Cells(i + 11, 3) = 明細_dgv.Rows(i).Cells("" & 表頭(13) & "").Value : xlSheet.Cells(i + 11, 4) = 明細_dgv.Rows(i).Cells("" & 表頭(14) & "").Value
  614. xlSheet.Cells(i + 11, 5) = 明細_dgv.Rows(i).Cells("" & 表頭(16) & "").Value : xlSheet.Cells(i + 11, 6) = 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value
  615. xlSheet.Cells(i + 11, 7) = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value : xlSheet.Cells(i + 11, 8) = 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value
  616. GGHH += 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value
  617. N1 = i + 11
  618. Next i
  619. xlSheet.Cells(N1 + 2, 7) = "TOTAL :" : xlSheet.Cells(N1 + 2, 8) = GGHH
  620. xlSheet.Cells(N1 + 3, 7) = "DISC " & 折扣比_tb.Text & "% :" : xlSheet.Cells(N1 + 3, 8) = 折扣金額_tb.Text
  621. xlSheet.Cells(N1 + 4, 7) = "PPN " & 稅金比_tb.Text & "% :" : xlSheet.Cells(N1 + 4, 8) = 稅金金額_tb.Text
  622. xlSheet.Cells(N1 + 5, 7) = "GRAND TOTAL :" : xlSheet.Cells(N1 + 5, 8) = 總金額_tb.Text
  623. xlSheet.Cells(N1 + 6, 1) = "Bagian Pembelian Barang"
  624. xlSheet.Cells(N1 + 6, 3) = "Direktur Utama"
  625. xlSheet.Cells(N1 + 6, 4) = "Bagian Pemeriksa"
  626. xlSheet.Cells(N1 + 6, 6) = "Bagian Pengisian Harga" : xlSheet.Cells(N1 + 8, 6) = 詢價員_tb.Text : xlSheet.Cells(N1 + 9, 6) = 尋價日期_tb.Text
  627. xlSheet.Cells(N1 + 6, 8) = "Asisten Proyek" : xlSheet.Cells(N1 + 8, 8) = 核對員_tb.Text : xlSheet.Cells(N1 + 9, 8) = 核對日期_tb.Text
  628. AA(xlApp, xlSheet)
  629. xlSheet.PageSetup.PrintArea = ""
  630. xlApp.Cells.Select()
  631. xlSheet.Range("B1").Select()
  632. xlApp.Application.WindowState = xlMinimized
  633. xlSheet.Cells.Select()
  634. xlApp.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="0911274990")
  635. xlApp.ActiveSheet.EnableSelection = 1
  636. MsgBox(對話框(3))
  637. End If
  638. End Sub
  639. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  640. Return CType(xlBook.Worksheets.Add, Worksheet)
  641. End Function
  642. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  643. xlSheet.Cells.Select()
  644. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  645. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  646. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 6 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 24
  647. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 30 : xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 20
  648. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 10 : xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 15
  649. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 15 : xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 30
  650. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 5 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 35
  651. xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("4:4").Select : myExcel.Selection.RowHeight = 5
  652. xlSheet.Rows("5:9").Select : myExcel.Selection.RowHeight = 20 : xlSheet.Rows("10:10").Select : myExcel.Selection.RowHeight = 20
  653. xlSheet.Rows("11:" & N1).Select : myExcel.Selection.RowHeight = 65 : xlSheet.Rows(N1 + 1 & ":" & N1 + 1).Select : myExcel.Selection.RowHeight = 5
  654. xlSheet.Rows(N1 + 2 & ":" & N1 + 5).Select : myExcel.Selection.RowHeight = 17 : xlSheet.Rows(N1 + 6 & ":" & N1 + 6).Select : myExcel.Selection.RowHeight = 35
  655. xlSheet.Rows(N1 + 7 & ":" & N1 + 9).Select : myExcel.Selection.RowHeight = 35
  656. xlSheet.Range("A2:H2").Select()
  657. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  658. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  659. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 26 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  660. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  661. xlSheet.Range("A3:H3").Select()
  662. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  663. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  664. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  665. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  666. xlSheet.Range("A10:H" & N1).Select()
  667. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  668. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  669. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  670. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  671. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  672. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  673. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  674. xlSheet.Range("A" & N1 + 2 & ":H" & N1 + 2).Select()
  675. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  676. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  677. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  678. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  679. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  680. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  681. xlSheet.Range("A" & N1 + 3 & ":H" & N1 + 3).Select()
  682. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  683. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  684. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  685. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  686. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  687. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  688. xlSheet.Range("A" & N1 + 4 & ":H" & N1 + 4).Select()
  689. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  690. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  691. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  692. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  693. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  694. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  695. xlSheet.Range("A" & N1 + 5 & ":H" & N1 + 5).Select()
  696. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  697. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  698. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  699. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  700. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  701. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  702. xlSheet.Range("A" & N1 + 6 & ":B" & N1 + 6).Select()
  703. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  704. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  705. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  706. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  707. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  708. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  709. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  710. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  711. xlSheet.Range("C" & N1 + 6 & ":C" & N1 + 6).Select()
  712. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  713. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  714. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  715. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  716. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  717. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  718. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  719. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  720. xlSheet.Range("D" & N1 + 6 & ":E" & N1 + 6).Select()
  721. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  722. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  723. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  724. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  725. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  726. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  727. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  728. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  729. xlSheet.Range("F" & N1 + 6 & ":G" & N1 + 6).Select()
  730. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  731. .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  732. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  733. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  734. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  735. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  736. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  737. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  738. xlSheet.Range("H" & N1 + 6).Select()
  739. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  740. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  741. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  742. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  743. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  744. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  745. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  746. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  747. xlSheet.Range("A" & N1 + 7 & ":B" & N1 + 9).Select()
  748. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  749. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  750. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  751. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  752. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  753. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  754. xlSheet.Range("C" & N1 + 7 & ":C" & N1 + 9).Select()
  755. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  756. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  757. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  758. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  759. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  760. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  761. xlSheet.Range("D" & N1 + 7 & ":E" & N1 + 9).Select()
  762. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  763. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  764. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  765. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  766. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  767. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  768. xlSheet.Range("F" & N1 + 7 & ":G" & N1 + 9).Select()
  769. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  770. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  771. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  772. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  773. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  774. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  775. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  776. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  777. xlSheet.Range("H" & N1 + 7 & ":H" & N1 + 9).Select()
  778. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  779. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  780. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  781. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  782. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  783. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  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("A10:A" & N1).Select()
  787. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  788. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  789. xlSheet.Range("B11:D" & N1).Select()
  790. With myExcel.Selection
  791. .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  792. .ReadingOrder = xlContext : .MergeCells = False : End With
  793. xlSheet.Range("E11:F" & N1).Select()
  794. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  795. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  796. xlSheet.Range("G11:H" & N1).Select() : myExcel.Selection.NumberFormatLocal = "#,##0"
  797. xlSheet.Range("H" & N1 + 2).Select() : myExcel.Selection.NumberFormatLocal = "#,##0"
  798. xlSheet.Range("H" & N1 + 2 & ":H" & N1 + 5).Select()
  799. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  800. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  801. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  802. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  803. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  804. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  805. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  806. myExcel.ActiveWindow.DisplayGridlines = False
  807. xlSheet.Range("A3:H3").Select()
  808. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  809. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  810. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  811. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  812. xlSheet.Range("G7:G9").Select()
  813. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  814. .ReadingOrder = xlContext : .MergeCells = False : End With
  815. xlSheet.Range("A10:H" & N1).Select()
  816. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  817. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  818. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  819. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  820. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  821. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  822. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  823. xlSheet.Range("A" & N1 + 2 & ":H" & N1 + 5).Select()
  824. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  825. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  826. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  827. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  828. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  829. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  830. xlSheet.Range("A" & N1 + 6 & ":B" & N1 + 9).Select()
  831. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  832. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  833. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  834. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  835. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  836. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  837. xlSheet.Range("C" & N1 + 6 & ":C" & N1 + 9).Select()
  838. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  839. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  840. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  841. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  842. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  843. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  844. xlSheet.Range("D" & N1 + 6 & ":E" & N1 + 9).Select()
  845. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  846. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  847. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  848. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  849. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  850. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  851. xlSheet.Range("F" & N1 + 6 & ":G" & N1 + 9).Select()
  852. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  853. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  854. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  855. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  856. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  857. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  858. xlSheet.Range("H" & N1 + 6 & ":H" & N1 + 9).Select()
  859. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  860. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  861. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  862. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  863. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  864. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  865. xlSheet.Rows("5:9").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.Rows("11:" & N1).Select
  869. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  870. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  871. xlSheet.Range("A10:H10").Select()
  872. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  873. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  874. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  875. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  876. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  877. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  878. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  879. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  880. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  881. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  882. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  883. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  884. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  885. xlSheet.Range("A11:H" & N1).Select()
  886. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  887. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  888. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  889. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  890. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  891. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  892. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  893. xlSheet.Range("B11:D" & N1).Select()
  894. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  895. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  896. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  897. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  898. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  899. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  900. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  901. xlSheet.Range("F11:F" & N1).Select()
  902. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  903. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  904. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  905. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  906. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  907. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  908. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  909. xlSheet.Range("H11:H" & N1).Select()
  910. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  911. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  912. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  913. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  914. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  915. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  916. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  917. xlSheet.Range("A" & N1 + 2 & ":H" & N1 + 5).Select()
  918. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  919. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  920. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  921. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  922. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  923. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  924. xlSheet.Range("H" & N1 + 2 & ":H" & N1 + 5).Select()
  925. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  926. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  927. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  928. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  929. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  930. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  931. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With
  932. xlSheet.Range("G" & N1 + 2 & ":G" & N1 + 5).Select()
  933. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  934. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  935. xlSheet.Range("F" & N1 + 8 & ":G" & N1 + 8).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. xlSheet.Range("F" & N1 + 9 & ":G" & N1 + 9).Select()
  939. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  940. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  941. myExcel.Application.PrintCommunication = False
  942. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$10" : .PrintTitleColumns = "" : End With
  943. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  944. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "" : .RightFooter = ""
  945. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  946. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  947. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  948. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False
  949. .Draft = False : .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = 60 : .OddAndEvenPagesHeaderFooter = False
  950. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True : .EvenPage.LeftHeader.Text = ""
  951. .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = ""
  952. .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = ""
  953. .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  954. End With
  955. myExcel.Application.PrintCommunication = True
  956. End Sub
  957. '-----------------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------
  958. Private Sub 重新整理ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理_tsm.Click
  959. Set_清單1() : Set_清單2()
  960. End Sub
  961. End Class