暫無描述
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 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. Option Strict Off
  2. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  3. Imports Microsoft.Office.Interop.Excel.Constants
  4. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  5. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  6. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  7. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  8. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  9. Imports Microsoft.Office.Interop.Excel.XlWindowState
  10. Imports Microsoft.Office.Interop.Excel
  11. Public Class 附錄合約
  12. ReadOnly ds8 As New DataSet
  13. Dim 放大 As Boolean
  14. Dim ESTR As String
  15. Dim EDR As Integer = 0
  16. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  17. Dim 對話框(7) As String
  18. Private Sub Set_合約清單()
  19. Dim ds6 As New DataSet : 合約_dgv.DataSource = Nothing : ds6.Clear()
  20. 合約_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  21. 合約_dgv.ColumnHeadersHeight = 25 : 合約_dgv.AllowUserToAddRows = False
  22. PA46 = 合約編號1_cb.Text : PA47 = 工程期1_ch.Text
  23. SQL_合約清單()
  24. da.Fill(ds6) : 合約_dgv.DataSource = ds6.Tables(0) : conn.Close()
  25. 合約_dgv.Columns(0).FillWeight = 160 : 合約_dgv.Columns(1).Visible = False : 合約_dgv.Columns(2).Visible = False : 合約_dgv.Columns(3).Visible = False
  26. 合約_dgv.Columns(4).Visible = False : 合約_dgv.Columns(5).Visible = False : 合約_dgv.Columns(6).Visible = False : 合約_dgv.Columns(7).Visible = False
  27. 合約_dgv.Columns(8).Visible = False : 合約_dgv.Columns(9).Visible = False : 合約_dgv.Columns(10).Visible = False : 合約_dgv.Columns(11).Visible = False
  28. 合約_dgv.Columns(12).Visible = False : 合約_dgv.Columns(13).Visible = False : 合約_dgv.Columns(14).Visible = False : 合約_dgv.Columns(15).Visible = False
  29. 合約_dgv.Columns(16).Visible = False : 合約_dgv.Columns(17).Visible = False : 合約_dgv.Columns(18).Visible = False : 合約_dgv.Columns(19).Visible = False
  30. 合約_dgv.Columns(20).Visible = False : 合約_dgv.Columns(21).Visible = False : 合約_dgv.Columns(22).Visible = False : 合約_dgv.Columns(23).Visible = False
  31. 合約_dgv.Columns(24).FillWeight = 100 : 合約_dgv.Columns(25).Visible = False : 合約_dgv.Columns(26).Visible = False : 合約_dgv.Columns(27).Visible = False
  32. 合約_dgv.Columns(28).Visible = False : 合約_dgv.Columns("工程").FillWeight = 300 : 合約_dgv.Columns("Project").FillWeight = 300
  33. 合約_dgv.Columns(0).ReadOnly = True : 合約_dgv.Columns("工程").ReadOnly = True : 合約_dgv.Columns("Project").ReadOnly = True
  34. If 系統語言 = "繁體中文" Then
  35. If 放大 = True Then : 合約_dgv.Columns("工程").Visible = True : Else : 合約_dgv.Columns("工程").Visible = False : End If
  36. Else
  37. If 放大 = True Then : 合約_dgv.Columns("Project").Visible = True : Else : 合約_dgv.Columns("Project").Visible = False : End If
  38. End If
  39. End Sub
  40. Private Sub Set_附錄清單()
  41. Dim ds1 As New DataSet
  42. 合約附錄_dgv.DataSource = Nothing : ds1.Clear()
  43. 合約附錄_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  44. 合約附錄_dgv.ColumnHeadersHeight = 25 : 合約附錄_dgv.AllowUserToAddRows = False
  45. SQL_附錄合約_清單查詢()
  46. da.Fill(ds1) : 合約附錄_dgv.DataSource = ds1.Tables(0) : conn.Close()
  47. 合約附錄_dgv.Columns(0).Visible = False : 合約附錄_dgv.Columns(1).FillWeight = 160 : 合約附錄_dgv.Columns(2).Visible = False : 合約附錄_dgv.Columns(3).Visible = False
  48. 合約附錄_dgv.Columns(4).Visible = False : 合約附錄_dgv.Columns(5).Visible = False : 合約附錄_dgv.Columns(6).Visible = False : 合約附錄_dgv.Columns(7).FillWeight = 70
  49. End Sub
  50. Private Sub 甲方條件下拉清單讀取()
  51. SQL合約條件讀取() : 合約編號1_cb.Items.Clear() : 合約編號1_cb.Items.Add("") : While (dr.Read()) : 合約編號1_cb.Items.Add(dr("約號甲方")) : End While : conn.Close()
  52. End Sub
  53. Private Sub 語言轉換讀取()
  54. If 系統語言 = "繁體中文" Then : 語言 = "CH" : ElseIf 系統語言 = "English" Then : 語言 = "EN" : ElseIf 系統語言 = "Indonesian" Then : 語言 = "IN" : End If
  55. Me.Text = 系統語言字典("H001-163-" & 語言) : ToolTip1.ToolTipTitle = 系統語言字典("G000-108-" & 語言) : 表頭(116) = 系統語言字典("G000-157-" & 語言)
  56. 表頭(134) = 系統語言字典("H501-152-" & 語言) : 表頭(99) = 系統語言字典("H104-100-" & 語言) : 表頭(179) = 系統語言字典("H307-106-" & 語言)
  57. 工程名稱_中_lb.Text = 系統語言字典("G000-215-" & 語言) : 工程名稱_英_lb.Text = 系統語言字典("G000-216-" & 語言) : 不列印金額_ch.Text = 系統語言字典("H104-101-" & 語言)
  58. 甲方_lb.Text = 系統語言字典("H110-118-" & 語言) : 立約日期_lb.Text = 系統語言字典("H104-102-" & 語言) : 合約附錄停用_ch.Text = 系統語言字典("H104-103-" & 語言)
  59. 合約編號_lb.Text = 系統語言字典("H506-160-" & 語言) : 其他內容_lb.Text = 系統語言字典("H104-104-" & 語言) : 附錄編號_lb.Text = 系統語言字典("H104-105-" & 語言)
  60. 客戶名稱_lb.Text = 系統語言字典("H112-100-" & 語言) : 搜尋_lb.Text = 系統語言字典("H104-106-" & 語言) : 原合约金额_lb.Text = 系統語言字典("H104-107-" & 語言)
  61. 追加减_lb.Text = 系統語言字典("H104-108-" & 語言) : 總金額_lb.Text = 系統語言字典("H104-109-" & 語言) : 對話框(0) = 系統語言字典("H110-111-" & 語言)
  62. 對話框(1) = 系統語言字典("H104-110-" & 語言) : 對話框(2) = 系統語言字典("H104-111-" & 語言) : 對話框(3) = 系統語言字典("G000-119-" & 語言)
  63. 對話框(4) = 系統語言字典("H104-112-" & 語言) : 對話框(5) = 系統語言字典("H104-113-" & 語言) : 對話框(6) = 系統語言字典("H104-114-" & 語言)
  64. 對話框(7) = 系統語言字典("H508-121-" & 語言)
  65. End Sub
  66. Private Sub 縮放2_rbt_MouseEnter(sender As Object, e As EventArgs) Handles 縮放2_rbt.MouseEnter
  67. ToolTip1.SetToolTip(Me.縮放2_rbt, 系統語言字典("G000-198-" & 語言))
  68. End Sub
  69. Private Sub 查詢_rbt_MouseEnter(sender As Object, e As EventArgs) Handles 查詢_rbt.MouseEnter
  70. ToolTip1.SetToolTip(Me.查詢_rbt, 系統語言字典("G000-113-" & 語言))
  71. End Sub
  72. Private Sub 新增資料_rbt_MouseEnter(sender As Object, e As EventArgs) Handles 新增資料_rbt.MouseEnter
  73. ToolTip1.SetToolTip(Me.新增資料_rbt, 系統語言字典("H104-115-" & 語言))
  74. End Sub
  75. Private Sub 存檔_rbt_MouseEnter(sender As Object, e As EventArgs) Handles 存檔_rbt.MouseEnter
  76. ToolTip1.SetToolTip(Me.存檔_rbt, 系統語言字典("G000-110-" & 語言))
  77. End Sub
  78. Private Sub 列印_rbt_MouseEnter(sender As Object, e As EventArgs) Handles 列印_rbt.MouseEnter
  79. ToolTip1.SetToolTip(Me.列印_rbt, 系統語言字典("G000-114-" & 語言))
  80. End Sub
  81. Private Sub 刪除_rbt_MouseEnter(sender As Object, e As EventArgs) Handles 刪除_rbt.MouseEnter
  82. ToolTip1.SetToolTip(Me.刪除_rbt, 系統語言字典("G000-112-" & 語言))
  83. End Sub
  84. Private Sub 附錄合約_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  85. H(104) = True : 介面 = "H104" : 語言轉換讀取() : 風格() : 顯示說明(999, True)
  86. End Sub
  87. Private Sub 附錄合約_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  88. 甲方條件下拉清單讀取() : Set_合約清單() : Set_附錄清單() : 合約報價單_Siz()
  89. End Sub
  90. Private Sub 合約報價單_Siz()
  91. MyMod.清單字體大小調整()
  92. 合約_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  93. 合約附錄_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  94. End Sub
  95. Private Sub 附錄合約_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
  96. H(104) = False
  97. End Sub
  98. Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click
  99. 介面 = "H104" : 語言轉換讀取() : Set_合約清單() : Set_附錄清單()
  100. End Sub
  101. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  102. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  103. End Sub
  104. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  105. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  106. End Sub
  107. Private Sub 合約_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 合約_dgv.CellClick
  108. If e.RowIndex = -1 Then : Else
  109. 客戶名稱_tb.Text = 合約_dgv("客戶名稱", e.RowIndex).Value.ToString : 合約編號_rtb.Text = 合約_dgv(表頭(134), e.RowIndex).Value.ToString
  110. 工程名稱_中_rtb.Text = 合約_dgv("工程", e.RowIndex).Value.ToString : 工程名稱_英_rtb.Text = 合約_dgv("Project", e.RowIndex).Value.ToString
  111. NUD3.Text = Strings.Format(CLng(合約_dgv("工程總價", e.RowIndex).Value), "#,##0") : NUD_2.Value = 0 : 其他內容_tb.Text = ""
  112. PA = 合約編號_rtb.Text : Set_附錄清單() : If 放大 = True Then : 縮放2_rbt.PerformClick() : End If
  113. End If
  114. End Sub
  115. Private Sub 合約附錄_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 合約附錄_dgv.CellClick
  116. NUD3.Text = Strings.Format(CLng(合約附錄_dgv("原金額", e.RowIndex).Value), "#,##0")
  117. 附錄編號_rtb.Text = 合約附錄_dgv(表頭(99), e.RowIndex).Value.ToString : 其他內容_tb.Text = 合約附錄_dgv("其他內容", e.RowIndex).Value.ToString
  118. 合約附錄停用_ch.Checked = 合約附錄_dgv(表頭(179), e.RowIndex).Value : NUD_2.Value = 合約附錄_dgv("追加減", e.RowIndex).Value.ToString
  119. End Sub
  120. Private Sub 合約編號1_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 合約編號1_cb.SelectedIndexChanged
  121. Set_合約清單()
  122. End Sub
  123. Private Sub 合約編號1_cb_Click(sender As Object, e As EventArgs) Handles 合約編號1_cb.Click
  124. CB選擇清單(合約編號1_cb)
  125. End Sub
  126. Private Sub 工程期1_ch_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 工程期1_ch.SelectedIndexChanged
  127. Set_合約清單()
  128. End Sub
  129. Private Sub 查詢_rbt_Click(sender As Object, e As EventArgs) Handles 查詢_rbt.Click
  130. PA = 關鍵字搜尋_rtb.Text : Set_合約清單()
  131. End Sub
  132. Private Sub 新增資料_rbt_Click(sender As Object, e As EventArgs) Handles 新增資料_rbt.Click
  133. If 合約編號_rtb.Text = "" Then : MGB(對話框(0), 1) : Else
  134. SQL_附錄合約_最後一筆資料()
  135. If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("附錄編號").ToString, 9)) : Else : EDR = 0 : End If
  136. conn.Close() : EDR += 1
  137. If EDR < 10 Then : ESTR = "HP" & "00000000" & EDR
  138. ElseIf EDR > 9 And EDR < 100 Then : ESTR = "HP" & "0000000" & EDR
  139. ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "HP" & "000000" & EDR
  140. ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "HP" & "00000" & EDR
  141. ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "HP" & "0000" & EDR
  142. ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "HP" & "000" & EDR
  143. ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "HP" & "00" & EDR
  144. ElseIf EDR > 9999999 And EDR < 10000000 Then : ESTR = "HP" & "0" & EDR
  145. ElseIf EDR > 99999999 Then : ESTR = "HP" & EDR : End If
  146. 附錄編號_rtb.Text = ESTR : NUD_2.Value = 0 : 其他內容_tb.Text = ""
  147. End If
  148. End Sub
  149. Private Sub 刪除_rbt_Click(sender As Object, e As EventArgs) Handles 刪除_rbt.Click
  150. If 合約編號_rtb.Text = "" Then : MGB(對話框(0), 1) : Else
  151. If 附錄編號_rtb.Text = "" Then : MGB(對話框(1), 1) : Else
  152. PA1 = 附錄編號_rtb.Text : SQL_附錄合約_刪除() : Set_附錄清單() : MGB(對話框(2), 1)
  153. End If
  154. End If
  155. End Sub
  156. Private Sub 存檔_rbt_Click(sender As Object, e As EventArgs) Handles 存檔_rbt.Click
  157. If 合約編號_rtb.Text = "" Then : MGB(對話框(0), 1) : Else
  158. If 附錄編號_rtb.Text = "" Then : MGB(對話框(1), 1) : Else
  159. PA = 合約編號_rtb.Text : PA1 = 附錄編號_rtb.Text : PA2 = Strings.Format(立約日期_dtp.Value, "yyyy/MM/dd")
  160. PA3 = Strings.Format(CLng(NUD3.Text), "#,##0") : PA4 = NUD_2.Value
  161. PA5 = Strings.Format(CLng(NUD1.Text), "#,##0") : PA6 = 其他內容_tb.Text : BL1 = 合約附錄停用_ch.Checked
  162. SQL_附錄合約_最後一筆資料1() : If dr.Read() Then : SQL_附錄合約_修改() : Else : SQL_附錄合約_新增() : End If : Set_附錄清單()
  163. MGB(對話框(3), 1)
  164. End If
  165. End If
  166. End Sub
  167. Private Sub NUD3_TextChanged(sender As Object, e As EventArgs) Handles NUD3.TextChanged
  168. NUD1.Text = Strings.Format(CLng(NUD3.Text) + NUD_2.Value)
  169. NUD3.Text = Strings.Format(CLng(NUD3.Text), "#,##0")
  170. End Sub
  171. Private Sub NUD_2_ValueChanged(sender As Object, e As EventArgs) Handles NUD_2.ValueChanged
  172. NUD1.Text = Strings.Format(CLng(NUD3.Text) + NUD_2.Value)
  173. End Sub
  174. Private Sub NUD1_TextChanged(sender As Object, e As EventArgs) Handles NUD1.TextChanged
  175. If NUD1.Text = "" Then : NUD1.Text = "0" : End If
  176. NUD1.Text = Strings.Format(CLng(NUD1.Text), "#,##0")
  177. End Sub
  178. Private Sub 縮放2_rbt_Click(sender As Object, e As EventArgs) Handles 縮放2_rbt.Click
  179. Dim NX, NY As Integer : NX = 合約_dgv.Size.Width : NY = 合約_dgv.Size.Height
  180. If 放大 = True Then
  181. 合約_dgv.Size = New System.Drawing.Point(NX - 400, NY) : 放大 = False
  182. If 系統語言 = "繁體中文" Then : 合約_dgv.Columns("工程").Visible = False : Else : 合約_dgv.Columns("Project").Visible = False : End If
  183. Else
  184. 合約_dgv.Size = New System.Drawing.Point(NX + 400, NY) : 放大 = True
  185. If 系統語言 = "繁體中文" Then : 合約_dgv.Columns("工程").Visible = True : Else : 合約_dgv.Columns("Project").Visible = False : End If
  186. End If
  187. End Sub
  188. Private Sub 列印_rbt_Click(sender As Object, e As EventArgs) Handles 列印_rbt.Click
  189. If 合約編號_rtb.Text = "" Then : MGB(對話框(4), 1) : Else
  190. If 附錄編號_rtb.Text = "" Then : MGB(對話框(5), 1) : Else
  191. If 合約附錄停用_ch.Checked = True Then : MGB(對話框(6), 1) : Else
  192. xlApp = CType(CreateObject("Excel.Application"), Application)
  193. xlApp.Visible = True
  194. xlApp.DisplayAlerts = True
  195. xlApp.Application.WindowState = xlMaximized
  196. xlBook = xlApp.Workbooks.Add
  197. '----------------------------------------------------------------------------------------------------------------------
  198. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select : xlApp.Sheets(1).Name = "合約附錄"
  199. xlBook.Activate() : xlSheet.Activate()
  200. xlSheet.Cells(2, 1) = "附錄合約" : xlSheet.Cells(3, 1) = "Appendix contract" : xlSheet.Cells(4, 1) = "編號(No) : " & 合約編號_rtb.Text
  201. xlSheet.Cells(5, 1) = 工程名稱_中_rtb.Text : xlSheet.Cells(6, 1) = 工程名稱_英_rtb.Text
  202. xlSheet.Cells(7, 1) = "日期(Date) : " & Strings.Format(立約日期_dtp.Value, "yyyy/MM/dd")
  203. Dim BF As String
  204. If Strings.Left(合約編號_rtb.Text, 2) = "HX" Then : BF = "PT HONG XHE INDUSTRIAL" : Else : BF = "PT PUNCAK GEMILANG SEMESTA"
  205. End If
  206. xlSheet.Cells(8, 1) = "根據 " & 合約編號_rtb.Text & " 號合同,雙方為A方 " & 客戶名稱_tb.Text & " 和B方 " & BF
  207. xlSheet.Cells(9, 1) = "According to the contract of " & 合約編號_rtb.Text & ", both parties are " & 客戶名稱_tb.Text & " of Party A and " & BF
  208. If 不列印金額_ch.Checked = False Then
  209. xlSheet.Cells(11, 1) = "雙方同意此 " & 合約編號_rtb.Text & " 號合同工程款变更为:"
  210. xlSheet.Cells(12, 1) = "The parties agree that the contract amount of this " & 合約編號_rtb.Text & " will be changed to: "
  211. xlSheet.Cells(13, 1) = "1、原合约金额(含税) :" & Strings.Format(CLng(NUD3.Text), "#,##0") & " RP"
  212. xlSheet.Cells(14, 1) = " Original contract amount (including tax): " & Strings.Format(CLng(NUD3.Text), "#,##0") & " RP"
  213. xlSheet.Cells(16, 1) = "2、追加/追减金额(含税) :" & Strings.Format(NUD_2.Value, "#,##0") & " RP"
  214. xlSheet.Cells(17, 1) = " Additional/reduction amount (including tax): " & Strings.Format(NUD_2.Value, "#,##0") & " RP"
  215. xlSheet.Cells(19, 1) = "3、结算总金額(含税) : " & Strings.Format(CLng(NUD1.Text), "#,##0") & " RP"
  216. xlSheet.Cells(20, 1) = " Total settlement amount (including tax): " & Strings.Format(CLng(NUD1.Text), "#,##0") & " RP"
  217. xlSheet.Cells(22, 1) = 其他內容_tb.Text
  218. xlSheet.Cells(24, 1) = "此份附錄合同立成02份(中,英文版),A方執01份、B方執01份,在法律上均具同時等價值。 "
  219. xlSheet.Cells(25, 1) = "This appendix has a contract of 02 copies (in Chinese and English), with A party holding 01 copies and Party B holding 01 copies, which are legally equivalent"
  220. xlSheet.Cells(27, 1) = "Party A (A方)" : xlSheet.Cells(27, 3) = "Party B (B方)"
  221. Else
  222. xlSheet.Cells(11, 1) = 其他內容_tb.Text
  223. xlSheet.Cells(13, 1) = "此份附錄合同立成02份(中,英文版),A方執01份、B方執01份,在法律上均具同時等價值。 "
  224. xlSheet.Cells(14, 1) = "This appendix has a contract of 02 copies (in Chinese and English), with A party holding 01 copies and Party B holding 01 copies, which are legally equivalent"
  225. xlSheet.Cells(16, 1) = "Party A (A方)" : xlSheet.Cells(27, 3) = "Party B (B方)"
  226. End If
  227. AA(xlApp, xlSheet)
  228. If Strings.Left(合約編號_rtb.Text, 2) = "HX" Then : CC(xlApp, xlSheet) : Else : DD(xlApp, xlSheet) : End If : FF(xlApp, xlSheet)
  229. xlApp.Sheets(2).Delete : xlSheet.PageSetup.PrintArea = ""
  230. '-------------轉換成PDF---------------------------------------------------------------------
  231. Dim SERT As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
  232. xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, SERT & "\" & 合約編號_rtb.Text & "附錄合約.pdf", XlFixedFormatQuality.xlQualityStandard, True)
  233. '-------------關閉EXCEL---------------------------------------------------------------------
  234. xlApp.Cells.Select() : xlApp.Application.WindowState = xlMinimized
  235. xlBook.Close(False)
  236. Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
  237. Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
  238. Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
  239. xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect()
  240. '-------------開啟PDF---------------------------------------------------------------------
  241. Dim pdfFilePath As String = SERT & "\" & 合約編號_rtb.Text & "附錄合約.pdf"
  242. If IsChromeInstalled() Then
  243. Try
  244. Dim chromeProcess As New Process()
  245. chromeProcess.StartInfo.FileName = "chrome"
  246. chromeProcess.StartInfo.Arguments = """" & pdfFilePath & """"
  247. chromeProcess.Start()
  248. Catch ex As Exception
  249. End Try
  250. Else
  251. Try
  252. System.Diagnostics.Process.Start("""" & pdfFilePath & """")
  253. Catch ex As Exception
  254. End Try
  255. End If
  256. MGB(對話框(7), 1)
  257. End If
  258. End If
  259. End If
  260. End Sub
  261. ' 檢查系統是否已安裝 Google Chrome
  262. Private Function IsChromeInstalled() As Boolean
  263. Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
  264. If key IsNot Nothing Then
  265. For Each subkeyName As String In key.GetSubKeyNames()
  266. Dim subkey As Microsoft.Win32.RegistryKey = key.OpenSubKey(subkeyName)
  267. Dim displayName As Object = subkey.GetValue("DisplayName")
  268. If displayName IsNot Nothing AndAlso displayName.ToString().Contains("Google Chrome") Then
  269. Return True
  270. End If
  271. Next
  272. End If
  273. Return False
  274. End Function
  275. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  276. Return CType(xlBook.Worksheets.Add, Worksheet)
  277. End Function
  278. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  279. xlSheet.Cells.Select()
  280. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  281. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  282. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 95
  283. xlSheet.Columns("A:C").Select : myExcel.Selection.ColumnWidth = 40
  284. xlSheet.Range("A2:C2").Select()
  285. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  286. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  287. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 22 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  288. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  289. xlSheet.Range("A3:C3").Select()
  290. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  291. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  292. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 22 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  293. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  294. myExcel.Selection.Font.Underline = xlUnderlineStyleSingle
  295. xlSheet.Range("A4:C4").Select()
  296. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  297. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  298. xlSheet.Range("A5:C5").Select()
  299. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  300. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  301. xlSheet.Range("A6:C6").Select()
  302. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  303. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  304. xlSheet.Range("A7:C7").Select()
  305. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  306. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  307. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  308. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  309. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  310. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  311. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  312. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  313. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  314. xlSheet.Range("A8:C8").Select()
  315. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  316. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  317. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  318. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  319. xlSheet.Rows("8:8").Select : myExcel.Selection.RowHeight = 45
  320. xlSheet.Range("A9:C9").Select()
  321. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  322. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  323. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  324. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  325. xlSheet.Rows("9:9").Select : myExcel.Selection.RowHeight = 45
  326. If 不列印金額_ch.Checked = False Then
  327. xlSheet.Range("A11:C11").Select()
  328. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  329. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  330. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  331. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  332. xlSheet.Rows("11:11").Select : myExcel.Selection.RowHeight = 15.75
  333. xlSheet.Range("A12:C12").Select()
  334. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  335. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  336. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  337. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  338. xlSheet.Rows("12:12").Select : myExcel.Selection.RowHeight = 15.75
  339. xlSheet.Range("A13:C13").Select()
  340. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  341. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  342. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  343. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  344. xlSheet.Rows("13:13").Select : myExcel.Selection.RowHeight = 15.75
  345. xlSheet.Range("A14:C14").Select()
  346. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  347. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  348. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  349. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  350. xlSheet.Rows("14:14").Select : myExcel.Selection.RowHeight = 15.75
  351. xlSheet.Range("A16:C16").Select()
  352. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  353. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  354. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  355. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  356. xlSheet.Rows("16:16").Select : myExcel.Selection.RowHeight = 15.75
  357. xlSheet.Range("A17:C17").Select()
  358. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  359. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  360. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  361. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  362. xlSheet.Rows("17:17").Select : myExcel.Selection.RowHeight = 15.75
  363. xlSheet.Range("A19:C19").Select()
  364. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  365. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  366. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  367. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  368. xlSheet.Rows("19:19").Select : myExcel.Selection.RowHeight = 15.75
  369. xlSheet.Range("A20:C20").Select()
  370. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  371. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  372. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  373. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  374. xlSheet.Rows("20:20").Select : myExcel.Selection.RowHeight = 15.75
  375. xlSheet.Range("A22:C22").Select()
  376. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  377. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  378. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  379. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  380. xlSheet.Rows("22:22").Select : myExcel.Selection.RowHeight = 250
  381. xlSheet.Range("A24:C24").Select()
  382. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  383. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  384. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  385. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  386. xlSheet.Rows("24:24").Select : myExcel.Selection.RowHeight = 15.75
  387. xlSheet.Range("A25:C25").Select()
  388. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  389. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  390. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  391. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  392. xlSheet.Rows("25:25").Select : myExcel.Selection.RowHeight = 35
  393. xlSheet.Range("A27:C27").Select()
  394. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  395. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  396. xlSheet.Rows("28:28").Select : myExcel.Selection.RowHeight = 90
  397. xlSheet.Range("A28").Select()
  398. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  399. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  400. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  401. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  402. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  403. xlSheet.Range("C28").Select()
  404. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  405. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  406. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  407. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  408. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  409. xlSheet.Rows("10:10").Select : myExcel.Selection.RowHeight = 8 : xlSheet.Rows("15:15").Select : myExcel.Selection.RowHeight = 8
  410. xlSheet.Rows("18:18").Select : myExcel.Selection.RowHeight = 8 : xlSheet.Rows("21:21").Select : myExcel.Selection.RowHeight = 8
  411. Else
  412. xlSheet.Range("A11:C11").Select()
  413. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  414. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  415. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlTop : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  416. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  417. xlSheet.Rows("11:11").Select : myExcel.Selection.RowHeight = 400
  418. xlSheet.Range("A13:C13").Select()
  419. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  420. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  421. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False
  422. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  423. xlSheet.Rows("13:13").Select : myExcel.Selection.RowHeight = 15.75
  424. xlSheet.Range("A14:C14").Select()
  425. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  426. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  427. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  428. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  429. xlSheet.Rows("14:14").Select : myExcel.Selection.RowHeight = 35
  430. xlSheet.Range("A16:C16").Select()
  431. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  432. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  433. xlSheet.Rows("17:17").Select : myExcel.Selection.RowHeight = 90
  434. xlSheet.Range("A17").Select()
  435. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  436. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  437. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  438. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  439. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  440. xlSheet.Range("C17").Select()
  441. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  442. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  443. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  444. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
  445. myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  446. End If
  447. myExcel.ActiveWindow.DisplayGridlines = False
  448. xlSheet.Range("D1").Select()
  449. End Sub
  450. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  451. Clipboard.SetDataObject(PictureBox1.Image)
  452. xlSheet.Range("A1").Select()
  453. myExcel.ActiveSheet.Pictures.Paste.Select
  454. myExcel.Selection.ShapeRange.Height = 93
  455. myExcel.Selection.ShapeRange.IncrementLeft(0)
  456. myExcel.Selection.ShapeRange.IncrementTop(0)
  457. End Sub
  458. Private Sub DD(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  459. Clipboard.SetDataObject(PictureBox2.Image)
  460. xlSheet.Range("A1").Select()
  461. myExcel.ActiveSheet.Pictures.Paste.Select
  462. myExcel.Selection.ShapeRange.Height = 93
  463. myExcel.Selection.ShapeRange.IncrementLeft(0)
  464. myExcel.Selection.ShapeRange.IncrementTop(0)
  465. End Sub
  466. Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  467. If Strings.Left(合約編號_rtb.Text, 2) = "HX" Then
  468. myExcel.ActiveSheet.PageSetup.CenterHeaderPicture.Filename =
  469. Str01 & "\HXBWLOG.png"
  470. Else
  471. myExcel.ActiveSheet.PageSetup.CenterHeaderPicture.Filename =
  472. Str01 & "\PGSBWLOG.png"
  473. End If
  474. myExcel.Application.PrintCommunication = False : With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "" : .PrintTitleColumns = "" : End With
  475. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  476. With myExcel.ActiveSheet.PageSetup : .LeftHeader = ""
  477. .CenterHeader = "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "&G"
  478. .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  479. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  480. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  481. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  482. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Draft = False
  483. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False
  484. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  485. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  486. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  487. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  488. End With : myExcel.Application.PrintCommunication = True
  489. End Sub
  490. Private Sub 風格()
  491. If 深色風格 = False Then
  492. Me.BackColor = Color.Linen
  493. 合約編號1_cb.BackColor = Color.White : 合約編號1_cb.ForeColor = Color.Black : 客戶名稱_tb.BackColor = Color.White : 客戶名稱_tb.ForeColor = Color.Black
  494. 其他內容_tb.BackColor = Color.LightCyan : 其他內容_tb.ForeColor = Color.Black : 關鍵字搜尋_rtb.BackColor = Color.Transparent : 關鍵字搜尋_rtb.ForeColor = Color.Black
  495. 附錄編號_rtb.BackColor = Color.Transparent : 附錄編號_rtb.ForeColor = Color.Black : 合約編號_rtb.BackColor = Color.Transparent : 合約編號_rtb.ForeColor = Color.Black
  496. 工程名稱_中_rtb.BackColor = Color.Transparent : 工程名稱_中_rtb.ForeColor = Color.Black : 工程名稱_英_rtb.BackColor = Color.Transparent : 工程名稱_英_rtb.ForeColor = Color.Black
  497. NUD3.BackColor = Color.White : NUD3.ForeColor = Color.Black : NUD_2.BackColor = Color.White : NUD_2.ForeColor = Color.Black
  498. NUD1.BackColor = Color.White : NUD1.ForeColor = Color.Black
  499. 搜尋_lb.ForeColor = Color.Black : 甲方_lb.ForeColor = Color.Black : 不列印金額_ch.ForeColor = Color.Black : 附錄編號_lb.ForeColor = Color.Black
  500. 合約編號_lb.ForeColor = Color.Black : 合約附錄停用_ch.ForeColor = Color.Black : Label8.ForeColor = Color.Black : Label6.ForeColor = Color.Black
  501. 其他內容_lb.ForeColor = Color.Black
  502. 立約日期_lb.ForeColor = Color.Green : 原合约金额_lb.ForeColor = Color.Green : 總金額_lb.ForeColor = Color.Green : 追加减_lb.ForeColor = Color.Green
  503. 工程名稱_中_lb.ForeColor = Color.Firebrick : 工程名稱_英_lb.ForeColor = Color.Firebrick : 客戶名稱_lb.ForeColor = Color.Firebrick
  504. 合約_dgv.EnableHeadersVisualStyles = True : 合約_dgv.BackgroundColor = Color.White : 合約_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
  505. 合約_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue ' Silver
  506. 合約_dgv.DefaultCellStyle.BackColor = Color.White : 合約_dgv.DefaultCellStyle.ForeColor = Color.Black
  507. 合約附錄_dgv.EnableHeadersVisualStyles = True : 合約附錄_dgv.BackgroundColor = Color.White : 合約_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
  508. 合約附錄_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue
  509. 合約附錄_dgv.DefaultCellStyle.BackColor = Color.White : 合約附錄_dgv.DefaultCellStyle.ForeColor = Color.Black
  510. Else
  511. Me.BackColor = Color.Black
  512. 合約編號1_cb.BackColor = Color.DimGray : 合約編號1_cb.ForeColor = Color.White : 客戶名稱_tb.BackColor = Color.DimGray : 客戶名稱_tb.ForeColor = Color.White
  513. 其他內容_tb.BackColor = Color.DimGray : 其他內容_tb.ForeColor = Color.White : 關鍵字搜尋_rtb.BackColor = Color.DimGray : 關鍵字搜尋_rtb.ForeColor = Color.White
  514. 附錄編號_rtb.BackColor = Color.DimGray : 附錄編號_rtb.ForeColor = Color.White : 合約編號_rtb.BackColor = Color.DimGray : 合約編號_rtb.ForeColor = Color.White
  515. 工程名稱_中_rtb.BackColor = Color.DimGray : 工程名稱_中_rtb.ForeColor = Color.White : 工程名稱_英_rtb.BackColor = Color.DimGray : 工程名稱_英_rtb.ForeColor = Color.White
  516. NUD3.BackColor = Color.DimGray : NUD3.ForeColor = Color.White : NUD_2.BackColor = Color.DimGray : NUD_2.ForeColor = Color.White
  517. NUD1.BackColor = Color.DimGray : NUD1.ForeColor = Color.White
  518. 搜尋_lb.ForeColor = Color.White : 甲方_lb.ForeColor = Color.White : 不列印金額_ch.ForeColor = Color.White : 附錄編號_lb.ForeColor = Color.White
  519. 合約編號_lb.ForeColor = Color.White : 合約附錄停用_ch.ForeColor = Color.White : Label8.ForeColor = Color.White : Label6.ForeColor = Color.White
  520. 其他內容_lb.ForeColor = Color.White
  521. 立約日期_lb.ForeColor = Color.GreenYellow : 原合约金额_lb.ForeColor = Color.GreenYellow : 總金額_lb.ForeColor = Color.GreenYellow : 追加减_lb.ForeColor = Color.GreenYellow
  522. 工程名稱_中_lb.ForeColor = Color.LightCoral : 工程名稱_英_lb.ForeColor = Color.LightCoral : 客戶名稱_lb.ForeColor = Color.LightCoral
  523. 合約_dgv.EnableHeadersVisualStyles = False : 合約_dgv.BackgroundColor = Color.DimGray : 合約_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
  524. 合約_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 合約_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.DimGray
  525. 合約_dgv.DefaultCellStyle.BackColor = Color.DimGray : 合約_dgv.DefaultCellStyle.ForeColor = Color.White
  526. 合約附錄_dgv.EnableHeadersVisualStyles = False : 合約附錄_dgv.BackgroundColor = Color.DimGray : 合約附錄_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
  527. 合約附錄_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 合約附錄_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.DimGray
  528. 合約附錄_dgv.DefaultCellStyle.BackColor = Color.DimGray : 合約附錄_dgv.DefaultCellStyle.ForeColor = Color.White
  529. End If
  530. End Sub
  531. End Class