Açıklama Yok
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 57KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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 ds1, ds6, ds14 As New DataSet
  13. Dim 物料規格 As String
  14. Dim 啟動運算, 放大 As Boolean
  15. Dim NB1 As Integer
  16. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  17. Dim 存檔 As Boolean
  18. Private Sub Set_合約清單()
  19. 合約_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 : PA45 = 工程執行主管_cb.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).Visible = False : 合約_dgv.Columns(25).Visible = False : 合約_dgv.Columns(26).Visible = False : 合約_dgv.Columns(27).Visible = False
  32. 合約_dgv.Columns(28).Visible = False : 合約_dgv.Columns(29).FillWeight = 50 : 合約_dgv.Columns(31).Visible = False : 合約_dgv.Columns(表頭(5)).FillWeight = 40
  33. 合約_dgv.Columns("驗收備註").Visible = False : 合約_dgv.Columns("工地驗收備註").Visible = False : 合約_dgv.Columns("驗收完成日期").Visible = False
  34. 合約_dgv.Columns("保固期限").Visible = False : 合約_dgv.Columns(表頭(2)).FillWeight = 300
  35. 合約_dgv.Columns(29).DefaultCellStyle.Format = "#,##0" : 合約_dgv.Columns(29).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  36. For i As Integer = 0 To 合約_dgv.Rows.Count - 1
  37. If IsDBNull(合約_dgv(表頭(5), i).Value) = True Then : 合約_dgv(表頭(5), i).Value = False : End If
  38. Next
  39. If 放大 = True Then
  40. 合約_dgv.Columns(表頭(2)).Visible = True
  41. Else
  42. 合約_dgv.Columns(表頭(2)).Visible = False
  43. End If
  44. End Sub
  45. Private Sub Set_合約報價明細表()
  46. 報價明細表_dgv.DataSource = Nothing : ds14.Clear()
  47. 報價明細表_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  48. 報價明細表_dgv.ColumnHeadersHeight = 40 : 報價明細表_dgv.AllowUserToAddRows = False : 報價明細表_dgv.RowTemplate.Height = 25
  49. 報價明細表_dgv.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.False
  50. SQL_合約驗收明細表()
  51. da.Fill(ds14) : 報價明細表_dgv.DataSource = ds14.Tables(0) : conn.Close()
  52. 報價明細表_dgv.Columns(0).FillWeight = 25 : 報價明細表_dgv.Columns(1).FillWeight = 270 : 報價明細表_dgv.Columns(2).FillWeight = 30
  53. 報價明細表_dgv.Columns(3).FillWeight = 30 : 報價明細表_dgv.Columns(4).Visible = False : 報價明細表_dgv.Columns(5).Visible = False
  54. 報價明細表_dgv.Columns(6).Visible = False
  55. 報價明細表_dgv.Columns(表頭(6)).DefaultCellStyle.Format = "#,##0" : 報價明細表_dgv.Columns(表頭(6)).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  56. 報價明細表_dgv.Columns(表頭(7)).DefaultCellStyle.Format = "#,##0" : 報價明細表_dgv.Columns(表頭(7)).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  57. 報價明細表_dgv.Columns(表頭(8)).DefaultCellStyle.Format = "#,##0" : 報價明細表_dgv.Columns(表頭(8)).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  58. 報價明細表_dgv.Columns("UNIT").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  59. 報價明細表_dgv.Columns(0).ReadOnly = True : 報價明細表_dgv.Columns(1).ReadOnly = True : 報價明細表_dgv.Columns(2).ReadOnly = True
  60. 報價明細表_dgv.Columns(3).ReadOnly = True : 報價明細表_dgv.Columns(5).ReadOnly = True
  61. 報價明細表_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  62. For I As Integer = 7 To 47 : 報價明細表_dgv.Columns(I).Visible = False : Next
  63. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  64. If IsDBNull(報價明細表_dgv.Rows(i).Cells(表頭(7)).Value) = True Then : 報價明細表_dgv.Rows(i).Cells(表頭(7)).Value = 0 : End If
  65. If 已驗收_ch.Checked = False Then : 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value = 0
  66. Else : 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value = 報價明細表_dgv.Rows(i).Cells(表頭(7)).Value - 報價明細表_dgv.Rows(i).Cells(表頭(6)).Value : End If
  67. If 報價明細表_dgv.Rows(i).Cells("料號").Value.ToString = "" Then
  68. 報價明細表_dgv.Rows(i).Cells("D1").Value = False : 報價明細表_dgv.Rows(i).Cells("D2").Value = False : 報價明細表_dgv.Rows(i).Cells("D3").Value = False
  69. 報價明細表_dgv.Rows(i).Cells("D4").Value = False : 報價明細表_dgv.Rows(i).Cells("D5").Value = False : 報價明細表_dgv.Rows(i).Cells("D6").Value = False
  70. 報價明細表_dgv.Rows(i).Cells("D7").Value = False : 報價明細表_dgv.Rows(i).Cells("D8").Value = False
  71. End If
  72. If 報價明細表_dgv.Rows(i).Cells("料號").Value.ToString <> "" Then
  73. If 報價明細表_dgv.Rows(i).Cells("預設").Value = True Then
  74. 報價明細表_dgv.Rows(i).Cells("D1").Value = 報價明細表_dgv.Rows(i).Cells("S1").Value : 報價明細表_dgv.Rows(i).Cells("D2").Value = 報價明細表_dgv.Rows(i).Cells("S2").Value
  75. 報價明細表_dgv.Rows(i).Cells("D3").Value = 報價明細表_dgv.Rows(i).Cells("S3").Value : 報價明細表_dgv.Rows(i).Cells("D4").Value = 報價明細表_dgv.Rows(i).Cells("S4").Value
  76. 報價明細表_dgv.Rows(i).Cells("D5").Value = 報價明細表_dgv.Rows(i).Cells("S5").Value : 報價明細表_dgv.Rows(i).Cells("D6").Value = 報價明細表_dgv.Rows(i).Cells("S6").Value
  77. 報價明細表_dgv.Rows(i).Cells("D7").Value = 報價明細表_dgv.Rows(i).Cells("S7").Value : 報價明細表_dgv.Rows(i).Cells("D8").Value = 報價明細表_dgv.Rows(i).Cells("S8").Value
  78. End If
  79. Dim ZA1, ZA2, ZA3, ZA4, ZA5, ZA6, ZA7, ZA8 As String : 物料規格 = ""
  80. If 詳細資料2_ch.Checked = True Then
  81. If 報價明細表_dgv.Rows(i).Cells("A1").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D1").Value = True Then
  82. ZA1 = 報價明細表_dgv.Rows(i).Cells("AA1").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A1").Value.ToString : 物料規格 = ZA1 : End If : End If
  83. If 報價明細表_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D2").Value = True Then
  84. ZA2 = 報價明細表_dgv.Rows(i).Cells("AA2").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then
  85. 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If : End If
  86. If 報價明細表_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D3").Value = True Then
  87. ZA3 = 報價明細表_dgv.Rows(i).Cells("AA3").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then
  88. 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If : End If
  89. If 報價明細表_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D4").Value = True Then
  90. ZA4 = 報價明細表_dgv.Rows(i).Cells("AA4").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then
  91. 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If : End If
  92. If 報價明細表_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D5").Value = True Then
  93. ZA5 = 報價明細表_dgv.Rows(i).Cells("AA5").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then
  94. 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If : End If
  95. If 報價明細表_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D6").Value = True Then
  96. ZA6 = 報價明細表_dgv.Rows(i).Cells("AA6").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then
  97. 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If : End If
  98. If 報價明細表_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D7").Value = True Then
  99. ZA7 = 報價明細表_dgv.Rows(i).Cells("AA7").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then
  100. 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If : End If
  101. If 報價明細表_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D8").Value = True Then
  102. ZA8 = 報價明細表_dgv.Rows(i).Cells("AA8").Value.ToString & "=" & 報價明細表_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then
  103. 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If : End If
  104. Else
  105. If 報價明細表_dgv.Rows(i).Cells("A1").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D1").Value = True Then
  106. ZA1 = 報價明細表_dgv.Rows(i).Cells("A1").Value.ToString : 物料規格 = ZA1 : End If : End If
  107. If 報價明細表_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D2").Value = True Then
  108. ZA2 = 報價明細表_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If : End If
  109. If 報價明細表_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D3").Value = True Then
  110. ZA3 = 報價明細表_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If : End If
  111. If 報價明細表_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D4").Value = True Then
  112. ZA4 = 報價明細表_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If : End If
  113. If 報價明細表_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D5").Value = True Then
  114. ZA5 = 報價明細表_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If : End If
  115. If 報價明細表_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D6").Value = True Then
  116. ZA6 = 報價明細表_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If : End If
  117. If 報價明細表_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D7").Value = True Then
  118. ZA7 = 報價明細表_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If : End If
  119. If 報價明細表_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : If 報價明細表_dgv.Rows(i).Cells("D8").Value = True Then
  120. ZA8 = 報價明細表_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If : End If
  121. End If
  122. If 報價明細表_dgv.Rows(i).Cells("料號").Value.ToString <> "" Then
  123. 報價明細表_dgv.Rows(i).Cells("DESCRIPTION").Value = 報價明細表_dgv.Rows(i).Cells("品名").Value.ToString & " " & 物料規格
  124. End If
  125. End If : 報價明細表_dgv.Rows(i).Cells("預設").Value = False
  126. '------------數字為0隱藏-----------------------------------------------------------------------------------------------
  127. If IsDBNull(報價明細表_dgv.Rows(i).Cells(表頭(6)).Value) Then
  128. 報價明細表_dgv.Rows(i).Cells(表頭(6)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(6)).Style.BackColor
  129. Else
  130. If 報價明細表_dgv.Rows(i).Cells(表頭(6)).Value = 0 Then
  131. 報價明細表_dgv.Rows(i).Cells(表頭(6)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(6)).Style.BackColor
  132. Else
  133. If 深色風格 = False Then
  134. 報價明細表_dgv.Rows(i).Cells(表頭(6)).Style.ForeColor = Color.Black
  135. Else
  136. 報價明細表_dgv.Rows(i).Cells(表頭(6)).Style.ForeColor = Color.White
  137. End If
  138. End If
  139. End If
  140. If IsDBNull(報價明細表_dgv.Rows(i).Cells(表頭(7)).Value) Then
  141. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.BackColor
  142. Else
  143. If 報價明細表_dgv.Rows(i).Cells(表頭(7)).Value = 0 Then
  144. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.BackColor
  145. Else
  146. If 深色風格 = False Then
  147. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = Color.Black
  148. Else
  149. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = Color.White
  150. End If
  151. End If
  152. End If
  153. If IsDBNull(報價明細表_dgv.Rows(i).Cells(表頭(8)).Value) Then
  154. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.BackColor
  155. Else
  156. If 深色風格 = False Then
  157. If 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value = 0 Then
  158. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.BackColor
  159. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value > 0 Then
  160. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.Blue
  161. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value < 0 Then
  162. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.Red
  163. End If
  164. Else
  165. If 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value = 0 Then
  166. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.BackColor
  167. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value > 0 Then
  168. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.LightBlue
  169. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value < 0 Then
  170. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.LightPink
  171. End If
  172. End If
  173. End If
  174. Next
  175. End Sub
  176. Private Sub 甲方條件下拉清單讀取()
  177. SQL合約條件讀取() : 合約編號1_cb.Items.Clear() : 合約編號1_cb.Items.Add("") : While (dr.Read()) : 合約編號1_cb.Items.Add(dr("約號甲方")) : End While : conn.Close()
  178. End Sub
  179. Private Sub 執行主管下拉清單讀取()
  180. SQL執行主管下拉() : 工程執行主管_cb.Items.Clear() : 工程執行主管_cb.Items.Add("") : While (dr.Read()) : 工程執行主管_cb.Items.Add(dr("姓名")) : End While : conn.Close()
  181. End Sub
  182. Private Sub 語言轉換讀取()
  183. If 系統語言 = "繁體中文" Then : 語言 = "CH" : ElseIf 系統語言 = "English" Then : 語言 = "EN" : ElseIf 系統語言 = "Indonesian" Then : 語言 = "IN" : End If
  184. Me.Text = 系統語言字典("H001-105-" & 語言) : Label7.Text = 系統語言字典("H104-106-" & 語言) : Label11.Text = 系統語言字典("H110-118-" & 語言)
  185. 工程執行主管_lb.Text = 系統語言字典("H101-109-" & 語言) : Label2.Text = 系統語言字典("G000-156-" & 語言) : Label372.Text = 系統語言字典("H112-100-" & 語言)
  186. Label375.Text = 系統語言字典("G000-215-" & 語言) : Label378.Text = 系統語言字典("G000-216-" & 語言) : Label8.Text = 系統語言字典("H902-117-" & 語言)
  187. 已驗收_ch.Text = 系統語言字典("H904-111-" & 語言) : Label1.Text = 系統語言字典("G000-157-" & 語言) : Label414.Text = 系統語言字典("H109-100-" & 語言)
  188. Label5.Text = 系統語言字典("H110-100-" & 語言) : Label4.Text = 系統語言字典("H110-122-" & 語言) : Label3.Text = 系統語言字典("H110-120-" & 語言)
  189. Label6.Text = 系統語言字典("H110-124-" & 語言) : Label9.Text = 系統語言字典("H110-123-" & 語言) : Label12.Text = 系統語言字典("H110-125-" & 語言)
  190. 表頭(1) = 系統語言字典("H501-152-" & 語言) : 表頭(2) = 系統語言字典("H112-118-" & 語言) : 表頭(3) = 系統語言字典("H110-122-" & 語言)
  191. 表頭(4) = 系統語言字典("G000-157-" & 語言) : 表頭(5) = 系統語言字典("H110-129-" & 語言) : 表頭(6) = 系統語言字典("H506-167-" & 語言)
  192. 表頭(7) = 系統語言字典("H109-105-" & 語言) : 表頭(8) = 系統語言字典("H109-106-" & 語言) : 詳細資料2_ch.Text = 系統語言字典("H211-100-" & 語言)
  193. End Sub
  194. Private Sub 工程材料表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  195. Me.MdiParent = HX_PGS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  196. 風格() : H(407) = True : 介面 = "H407" : 語言轉換讀取() : 顯示說明(999, False)
  197. 甲方條件下拉清單讀取() : 執行主管下拉清單讀取() : Set_合約清單() : 工程材料表_Siz() : Panel1.SendToBack()
  198. End Sub
  199. Private Sub 合約驗收單_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
  200. MyMod.虛擬桌面開啟()
  201. End Sub
  202. Private Sub 工程材料表_Siz()
  203. MyMod.清單字體大小調整()
  204. 合約_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  205. 報價明細表_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  206. End Sub
  207. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  208. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  209. End Sub
  210. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  211. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  212. End Sub
  213. Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click
  214. 介面 = "H407" : 語言轉換讀取() : Set_合約清單() : Set_合約報價明細表()
  215. End Sub
  216. Private Sub 合約_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 合約_dgv.CellClick
  217. If e.RowIndex = -1 Then : Else
  218. If 放大 = True Then : 縮放2_bt.PerformClick() : End If
  219. 客戶名稱_tb.Text = 合約_dgv("客戶名稱", e.RowIndex).Value.ToString : 合約編號_tb.Text = 合約_dgv(表頭(1), e.RowIndex).Value.ToString
  220. 工程名稱_中_tb.Text = 合約_dgv(表頭(2), e.RowIndex).Value.ToString : 工程名稱_英_tb.Text = 合約_dgv("工程名稱_英", e.RowIndex).Value.ToString
  221. 立約日期_dtp.Value = 合約_dgv("立約日期", e.RowIndex).Value.ToString : 合約工期_nud.Value = 合約_dgv("工期", e.RowIndex).Value.ToString
  222. 已驗收_ch.Checked = 合約_dgv(表頭(5), e.RowIndex).Value : 保固_cb.Text = 合約_dgv("保固期限", e.RowIndex).Value.ToString
  223. If 系統分區控制 = True Then : 備註_tb.Text = 合約_dgv("驗收備註", e.RowIndex).Value.ToString
  224. Else : 備註_tb.Text = 合約_dgv("工地驗收備註", e.RowIndex).Value.ToString : End If
  225. If 合約_dgv("驗收開始日期", e.RowIndex).Value.ToString = "" Then : 驗收日期_dtp.Value = Today() : 存檔 = False
  226. Else : 驗收日期_dtp.Value = 合約_dgv("驗收開始日期", e.RowIndex).Value.ToString : 存檔 = True : End If
  227. If 合約_dgv("驗收完成日期", e.RowIndex).Value.ToString = "" Then : 驗收完成_dtp.Value = Today() : Else
  228. 驗收完成_dtp.Value = 合約_dgv("驗收完成日期", e.RowIndex).Value.ToString
  229. End If
  230. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  231. 啟動運算 = False : PA = 合約編號_tb.Text : Set_合約報價明細表() : 啟動運算 = True
  232. If IsDBNull(合約_dgv(表頭(5), e.RowIndex).Value) = True Then
  233. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  234. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  235. Else
  236. If 合約_dgv(表頭(5), e.RowIndex).Value = True Then
  237. 立約日期_dtp.Enabled = False : 驗收日期_dtp.Enabled = False : 驗收完成_dtp.Enabled = False : 合約工期_nud.Enabled = False
  238. 工程天數_nud.Enabled = False : 日期差異_nud.Enabled = False : 保固_cb.Enabled = False
  239. Else
  240. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  241. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  242. End If
  243. End If
  244. End If
  245. End Sub
  246. Private Sub 報價明細表_dgv_CellContentCl(sender As Object, e As DataGridViewCellEventArgs) Handles 報價明細表_dgv.CellEndEdit
  247. If 啟動運算 = True Then
  248. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  249. If IsDBNull(報價明細表_dgv.Rows(i).Cells(表頭(7)).Value) Then
  250. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.BackColor
  251. Else
  252. If 報價明細表_dgv.Rows(i).Cells(表頭(7)).Value = 0 Then
  253. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.BackColor
  254. Else
  255. If 深色風格 = False Then
  256. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = Color.Black
  257. Else
  258. 報價明細表_dgv.Rows(i).Cells(表頭(7)).Style.ForeColor = Color.White
  259. End If
  260. End If
  261. End If
  262. If IsDBNull(報價明細表_dgv.Rows(i).Cells(表頭(8)).Value) Then
  263. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.BackColor
  264. Else
  265. If 深色風格 = False Then
  266. If 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value = 0 Then : 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.BackColor
  267. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value > 0 Then
  268. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.Blue
  269. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value < 0 Then
  270. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.Red
  271. End If
  272. Else
  273. If 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value = 0 Then
  274. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.BackColor
  275. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value > 0 Then
  276. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.LightBlue
  277. ElseIf 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value < 0 Then
  278. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Style.ForeColor = Color.LightPink
  279. End If
  280. End If
  281. End If
  282. 報價明細表_dgv.Rows(i).Cells(表頭(8)).Value = 報價明細表_dgv.Rows(i).Cells(表頭(7)).Value - 報價明細表_dgv.Rows(i).Cells(表頭(6)).Value
  283. Next
  284. End If
  285. End Sub
  286. Private Sub 合約編號1_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 合約編號1_cb.SelectedIndexChanged
  287. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  288. End Sub
  289. Private Sub 合約編號1_cb_Click(sender As Object, e As EventArgs) Handles 合約編號1_cb.Click
  290. CB選擇清單(合約編號1_cb)
  291. End Sub
  292. Private Sub 工程期1_ch_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 工程期1_ch.SelectedIndexChanged
  293. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  294. End Sub
  295. Private Sub 工程執行主管_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 工程執行主管_cb.SelectedIndexChanged
  296. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  297. End Sub
  298. Private Sub 工程執行主管_cb_Click(sender As Object, e As EventArgs) Handles 工程執行主管_cb.Click
  299. CB選擇清單(工程執行主管_cb)
  300. End Sub
  301. Private Sub 保固_cb_Click(sender As Object, e As EventArgs) Handles 保固_cb.Click
  302. CB選擇清單(保固_cb)
  303. End Sub
  304. Private Sub 查詢_bt_Click(sender As Object, e As EventArgs) Handles 查詢_bt.Click
  305. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  306. End Sub
  307. Private Sub 立約日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 立約日期_dtp.ValueChanged
  308. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  309. End Sub
  310. Private Sub 驗收日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 驗收日期_dtp.ValueChanged
  311. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  312. End Sub
  313. Private Sub 縮放2_bt_Click(sender As Object, e As EventArgs) Handles 縮放2_bt.Click
  314. Dim NX, NY As Integer : NX = 合約_dgv.Size.Width : NY = 合約_dgv.Size.Height
  315. If 放大 = True Then
  316. 合約_dgv.Size = New System.Drawing.Point(NX - 400, NY) : 放大 = False : 合約_dgv.Columns(表頭(2)).Visible = False
  317. Else
  318. 合約_dgv.Size = New System.Drawing.Point(NX + 400, NY) : 放大 = True : 合約_dgv.Columns(表頭(2)).Visible = True
  319. End If
  320. End Sub
  321. Private Sub 詳細資料2_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 詳細資料2_ch.Click
  322. If 詳細資料2_ch.Checked = True Then : 詳細資料2_ch.Checked = True : Else : 詳細資料2_ch.Checked = False : End If : Set_合約報價明細表()
  323. End Sub
  324. Private Sub 列印_bt_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  325. If 報價明細表_dgv.Rows.Count < 1 Then : MGB(系統語言字典("H109-104-" & 語言), 1) : Else
  326. If 合約編號_tb.Text = "" Then : MGB(系統語言字典("H104-112-" & 語言), 1) : Else
  327. xlApp = CType(CreateObject("Excel.Application"), Application)
  328. xlApp.Visible = True
  329. xlApp.DisplayAlerts = True
  330. xlApp.Application.WindowState = xlMaximized
  331. xlBook = xlApp.Workbooks.Add
  332. '----------------------------------------------------------------------------------------------------------------------
  333. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select : xlApp.Sheets(1).Name = "工程材料單"
  334. xlBook.Activate() : xlSheet.Activate()
  335. xlSheet.Cells(2, 1) = "工程材料單"
  336. xlSheet.Cells(3, 1) = "業主名稱 :" & 客戶名稱_tb.Text : xlSheet.Cells(3, 6) = "NO. " & 合約編號_tb.Text
  337. xlSheet.Cells(4, 1) = "工程項目 : " & 工程名稱_中_tb.Text & " " & 工程名稱_英_tb.Text : xlSheet.Cells(4, 6) = Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd")
  338. xlSheet.Cells(5, 1) = "ITEM" : xlSheet.Cells(5, 2) = "DESCRIPTION" : xlSheet.Cells(5, 3) = "UNIT" : xlSheet.Cells(5, 4) = "Q'TY" : xlSheet.Cells(5, 7) = "UNIT"
  339. xlSheet.Cells(6, 4) = "合約" & vbCrLf & "Contract" : xlSheet.Cells(6, 5) = "已備料" & vbCrLf & "Siap" : xlSheet.Cells(6, 6) = "需採購" & vbCrLf & "Perlu Membeli"
  340. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  341. xlSheet.Cells(7 + i, 1) = 報價明細表_dgv("ITEM", i).Value.ToString : xlSheet.Cells(7 + i, 2) = 報價明細表_dgv("DESCRIPTION", i).Value.ToString
  342. xlSheet.Cells(7 + i, 3) = 報價明細表_dgv("UNIT", i).Value.ToString : xlSheet.Cells(7 + i, 7) = 報價明細表_dgv("REMARKS", i).Value.ToString
  343. If CInt(報價明細表_dgv(表頭(7), i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 5) = 報價明細表_dgv(表頭(7), i).Value.ToString : End If
  344. If CInt(報價明細表_dgv(表頭(8), i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 6) = 報價明細表_dgv(表頭(8), i).Value.ToString : End If
  345. If CInt(報價明細表_dgv(表頭(6), i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 4) = 報價明細表_dgv(表頭(6), i).Value.ToString : End If
  346. NB1 = i
  347. Next
  348. xlSheet.Cells(7 + NB1 + 2, 2) = " 甲方代表簽字" : xlSheet.Cells(7 + NB1 + 2, 5) = "承包商簽字"
  349. xlSheet.Cells(7 + NB1 + 3, 2) = "Representatives of Party A :" : xlSheet.Cells(7 + NB1 + 3, 5) = "Contracting company signing:"
  350. AA(xlApp, xlSheet)
  351. If Strings.Left(合約編號_tb.Text, 2) = "HX" Then : CC(xlApp, xlSheet) : Else : DD(xlApp, xlSheet) : End If : FF(xlApp, xlSheet)
  352. xlApp.Sheets(2).Delete : xlSheet.PageSetup.PrintArea = ""
  353. '-------------轉換成PDF---------------------------------------------------------------------
  354. Dim SERT As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
  355. xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, SERT & "\" & 合約編號_tb.Text & "工程材料單.pdf", XlFixedFormatQuality.xlQualityStandard, True)
  356. '-------------關閉EXCEL---------------------------------------------------------------------
  357. xlApp.Cells.Select() : xlApp.Application.WindowState = xlMinimized
  358. xlBook.Close(False)
  359. Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
  360. Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
  361. Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
  362. xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect()
  363. '-------------開啟PDF---------------------------------------------------------------------
  364. Dim pdfFilePath As String = SERT & "\" & 合約編號_tb.Text & "工程材料單.pdf"
  365. If IsChromeInstalled() Then
  366. Try
  367. Dim chromeProcess As New Process()
  368. chromeProcess.StartInfo.FileName = "chrome"
  369. chromeProcess.StartInfo.Arguments = """" & pdfFilePath & """"
  370. chromeProcess.Start()
  371. Catch ex As Exception
  372. End Try
  373. Else
  374. Try
  375. System.Diagnostics.Process.Start("""" & pdfFilePath & """")
  376. Catch ex As Exception
  377. End Try
  378. End If
  379. MGB(系統語言字典("H508-121-" & 語言), 1) : Set_合約清單()
  380. End If
  381. End If
  382. End Sub
  383. ' 檢查系統是否已安裝 Google Chrome
  384. Private Function IsChromeInstalled() As Boolean
  385. Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
  386. If key IsNot Nothing Then
  387. For Each subkeyName As String In key.GetSubKeyNames()
  388. Dim subkey As Microsoft.Win32.RegistryKey = key.OpenSubKey(subkeyName)
  389. Dim displayName As Object = subkey.GetValue("DisplayName")
  390. If displayName IsNot Nothing AndAlso displayName.ToString().Contains("Google Chrome") Then
  391. Return True
  392. End If
  393. Next
  394. End If
  395. Return False
  396. End Function
  397. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  398. Return CType(xlBook.Worksheets.Add, Worksheet)
  399. End Function
  400. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  401. xlSheet.Cells.Select()
  402. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  403. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  404. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 95
  405. xlSheet.Rows("2:2").Select
  406. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 18 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  407. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  408. xlSheet.Rows("3:4").Select
  409. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  410. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  411. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 6 : xlSheet.Columns("D:F").Select : myExcel.Selection.ColumnWidth = 10
  412. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 20 : xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 6
  413. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 75
  414. xlSheet.Range("A2:G2").Select()
  415. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  416. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  417. xlSheet.Range("A3:E3").Select()
  418. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  419. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  420. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  421. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  422. xlSheet.Range("A4:E4").Select()
  423. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  424. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  425. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  426. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  427. xlSheet.Range("F3:G3").Select()
  428. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  429. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  430. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  431. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  432. xlSheet.Range("F4:G4").Select()
  433. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  434. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  435. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  436. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  437. xlSheet.Range("A5:A6").Select()
  438. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  439. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  440. xlSheet.Range("B5:B6").Select()
  441. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  442. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  443. xlSheet.Range("C5:C6").Select()
  444. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  445. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  446. xlSheet.Range("D5:F5").Select()
  447. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  448. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  449. xlSheet.Range("G5:G6").Select()
  450. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  451. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  452. xlSheet.Range("D6:F6").Select()
  453. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  454. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  455. xlSheet.Range("B7:B" & 7 + NB1 + 1).Select()
  456. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  457. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  458. xlSheet.Rows("7:" & 7 + NB1 + 1).Select : myExcel.Selection.RowHeight = 25
  459. xlSheet.Range("A5:G" & 7 + NB1 + 1).Select()
  460. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  461. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  462. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  463. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  464. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  465. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  466. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  467. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  468. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  469. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  470. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  471. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  472. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  473. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  474. myExcel.ActiveWindow.DisplayGridlines = False
  475. xlSheet.Range("E" & 7 + NB1 + 2 & ":G" & 7 + NB1 + 2).Select()
  476. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  477. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  478. xlSheet.Range("E" & 7 + NB1 + 3 & ":G" & 7 + NB1 + 3).Select()
  479. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  480. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  481. xlSheet.Rows(7 + NB1 + 4 & ":" & 7 + NB1 + 4).Select : myExcel.Selection.RowHeight = 70
  482. xlSheet.Range("A" & 7 + NB1 + 2 & ":G" & 7 + NB1 + 4).Select()
  483. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  484. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  485. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  486. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  487. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  488. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  489. xlSheet.Range("A7:A" & 7 + NB1 + 1).Select()
  490. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  491. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  492. xlSheet.Range("C7:D" & 7 + NB1 + 1).Select()
  493. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  494. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  495. xlSheet.Range("G7:G" & 7 + NB1 + 1).Select()
  496. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  497. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  498. xlSheet.Range("A3:E4").Select()
  499. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  500. .ShrinkToFit = False : .ReadingOrder = xlContext : End With
  501. xlSheet.Range("B7:B" & 7 + NB1 + 1).Select()
  502. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  503. .ShrinkToFit = False : .ReadingOrder = xlContext : End With
  504. Dim 攔寬 As Single
  505. xlSheet.Rows("3:3").Select : xlSheet.Rows("3:3").EntireRow.AutoFit
  506. 攔寬 = xlSheet.Rows("3:3").RowHeight
  507. xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 攔寬 + 20
  508. xlSheet.Rows("4:4").Select : xlSheet.Rows("4:4").EntireRow.AutoFit
  509. 攔寬 = xlSheet.Rows("4:4").RowHeight
  510. xlSheet.Rows("4:4").Select : myExcel.Selection.RowHeight = 攔寬 + 20
  511. xlSheet.Rows("7:" & 7 + NB1 + 1).Select : xlSheet.Rows("7:" & 7 + NB1 + 1).EntireRow.AutoFit
  512. For i As Integer = 7 To 7 + NB1 + 1
  513. xlSheet.Rows(i & ":" & i).Select
  514. 攔寬 = xlSheet.Rows(i & ":" & i).RowHeight
  515. xlSheet.Rows(i & ":" & i).Select : myExcel.Selection.RowHeight = 攔寬 + 20
  516. Next
  517. End Sub
  518. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  519. Clipboard.SetDataObject(PictureBox1.Image)
  520. xlSheet.Range("A1").Select()
  521. myExcel.ActiveSheet.Pictures.Paste.Select
  522. myExcel.Selection.ShapeRange.Height = 93
  523. myExcel.Selection.ShapeRange.IncrementLeft(50)
  524. myExcel.Selection.ShapeRange.IncrementTop(0)
  525. End Sub
  526. Private Sub DD(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  527. Clipboard.SetDataObject(PictureBox2.Image)
  528. xlSheet.Range("A1").Select()
  529. myExcel.ActiveSheet.Pictures.Paste.Select
  530. myExcel.Selection.ShapeRange.Height = 93
  531. myExcel.Selection.ShapeRange.IncrementLeft(50)
  532. myExcel.Selection.ShapeRange.IncrementTop(0)
  533. End Sub
  534. Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  535. If Strings.Left(合約編號_tb.Text, 2) = "HX" Then
  536. myExcel.ActiveSheet.PageSetup.CenterHeaderPicture.Filename =
  537. Str01 & "\HXBWLOG.png"
  538. Else
  539. myExcel.ActiveSheet.PageSetup.CenterHeaderPicture.Filename =
  540. Str01 & "\PGSBWLOG.png"
  541. End If
  542. myExcel.Application.PrintCommunication = False : With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$6" : .PrintTitleColumns = "" : End With
  543. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  544. With myExcel.ActiveSheet.PageSetup : .LeftHeader = ""
  545. .CenterHeader = "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "&G"
  546. .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  547. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  548. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  549. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  550. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Draft = False
  551. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False
  552. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  553. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  554. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  555. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  556. End With : myExcel.Application.PrintCommunication = True
  557. End Sub
  558. Private Sub 風格()
  559. If 深色風格 = False Then
  560. Me.BackColor = SystemColors.Control
  561. 工程執行主管_lb.ForeColor = Color.FromArgb(192, 0, 0) : Label372.ForeColor = Color.FromArgb(192, 0, 0) : Label375.ForeColor = Color.FromArgb(192, 0, 0)
  562. Label378.ForeColor = Color.FromArgb(192, 0, 0)
  563. Label1.ForeColor = Color.Green : Label414.ForeColor = Color.Green : Label3.ForeColor = Color.Green : Label4.ForeColor = Color.Green
  564. Label6.ForeColor = Color.Green : 已驗收_ch.ForeColor = Color.Green
  565. Label5.ForeColor = Color.Blue : Label8.ForeColor = Color.Blue : Label9.ForeColor = Color.Blue : Label12.ForeColor = Color.Blue
  566. Label2.ForeColor = Color.Black : Label7.ForeColor = Color.Black : Label11.ForeColor = Color.Black : 詳細資料2_ch.ForeColor = Color.Black
  567. 合約編號1_cb.BackColor = Color.White : 合約編號1_cb.ForeColor = Color.Blue : 工程執行主管_cb.BackColor = Color.White : 工程執行主管_cb.ForeColor = Color.Blue
  568. 保固_cb.BackColor = Color.White : 保固_cb.ForeColor = Color.Blue
  569. 關鍵字搜尋_tb.BackColor = Color.White : 關鍵字搜尋_tb.ForeColor = Color.Black : 合約編號_tb.BackColor = Color.White : 合約編號_tb.ForeColor = Color.Black
  570. 客戶名稱_tb.BackColor = Color.White : 客戶名稱_tb.ForeColor = Color.Black : 工程名稱_中_tb.BackColor = Color.White : 工程名稱_中_tb.ForeColor = Color.Black
  571. 工程名稱_英_tb.BackColor = Color.White : 工程名稱_英_tb.ForeColor = Color.Black : 備註_tb.BackColor = Color.White : 備註_tb.ForeColor = Color.Black
  572. 語轉扭_bt.BackColor = Color.White : 語轉扭_bt.ForeColor = Color.Black : 查詢_bt.BackColor = Color.White : 查詢_bt.ForeColor = Color.Black
  573. 縮放2_bt.BackColor = Color.White : 縮放2_bt.ForeColor = Color.Black : 列印_bt.BackColor = Color.White : 列印_bt.ForeColor = Color.Black
  574. 合約_dgv.EnableHeadersVisualStyles = True : 合約_dgv.BackgroundColor = Color.White : 合約_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
  575. 合約_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightPink
  576. 合約_dgv.DefaultCellStyle.BackColor = Color.White : 合約_dgv.DefaultCellStyle.ForeColor = Color.Black
  577. 報價明細表_dgv.EnableHeadersVisualStyles = True : 報價明細表_dgv.BackgroundColor = Color.White : 報價明細表_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
  578. 報價明細表_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightPink
  579. 報價明細表_dgv.DefaultCellStyle.BackColor = Color.White : 報價明細表_dgv.DefaultCellStyle.ForeColor = Color.Black
  580. Else
  581. Me.BackColor = Color.Black
  582. 工程執行主管_lb.ForeColor = Color.LightPink : Label372.ForeColor = Color.LightPink : Label375.ForeColor = Color.LightPink
  583. Label378.ForeColor = Color.LightPink
  584. Label1.ForeColor = Color.LightGreen : Label414.ForeColor = Color.LightGreen : Label3.ForeColor = Color.LightGreen : Label4.ForeColor = Color.LightGreen
  585. Label6.ForeColor = Color.LightGreen : 已驗收_ch.ForeColor = Color.LightGreen
  586. Label5.ForeColor = Color.LightBlue : Label8.ForeColor = Color.LightBlue : Label9.ForeColor = Color.LightBlue : Label12.ForeColor = Color.LightBlue
  587. Label2.ForeColor = Color.White : Label7.ForeColor = Color.White : Label11.ForeColor = Color.White : 詳細資料2_ch.ForeColor = Color.White
  588. Label2.BackColor = Color.Black : Label11.BackColor = Color.Black
  589. 合約編號1_cb.BackColor = Color.DimGray : 合約編號1_cb.ForeColor = Color.LightBlue : 工程執行主管_cb.BackColor = Color.DimGray : 工程執行主管_cb.ForeColor = Color.LightBlue
  590. 保固_cb.BackColor = Color.DimGray : 保固_cb.ForeColor = Color.LightBlue
  591. 關鍵字搜尋_tb.BackColor = Color.DimGray : 關鍵字搜尋_tb.ForeColor = Color.White : 合約編號_tb.BackColor = Color.DimGray : 合約編號_tb.ForeColor = Color.White
  592. 客戶名稱_tb.BackColor = Color.DimGray : 客戶名稱_tb.ForeColor = Color.White : 工程名稱_中_tb.BackColor = Color.DimGray : 工程名稱_中_tb.ForeColor = Color.White
  593. 工程名稱_英_tb.BackColor = Color.DimGray : 工程名稱_英_tb.ForeColor = Color.White : 備註_tb.BackColor = Color.DimGray : 備註_tb.ForeColor = Color.White
  594. 語轉扭_bt.BackColor = Color.DimGray : 語轉扭_bt.ForeColor = Color.White : 查詢_bt.BackColor = Color.DimGray : 查詢_bt.ForeColor = Color.White
  595. 縮放2_bt.BackColor = Color.DimGray : 縮放2_bt.ForeColor = Color.White : 列印_bt.BackColor = Color.DimGray : 列印_bt.ForeColor = Color.White
  596. 合約_dgv.EnableHeadersVisualStyles = False : 合約_dgv.BackgroundColor = Color.DimGray : 合約_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
  597. 合約_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 合約_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.DimGray
  598. 合約_dgv.DefaultCellStyle.BackColor = Color.Black : 合約_dgv.DefaultCellStyle.ForeColor = Color.White
  599. 報價明細表_dgv.EnableHeadersVisualStyles = False : 報價明細表_dgv.BackgroundColor = Color.DimGray : 報價明細表_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
  600. 報價明細表_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 報價明細表_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.DimGray
  601. 報價明細表_dgv.DefaultCellStyle.BackColor = Color.Black : 報價明細表_dgv.DefaultCellStyle.ForeColor = Color.White
  602. End If
  603. End Sub
  604. End Class