설명 없음
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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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("驗收結果").FillWeight = 40
  33. 合約_dgv.Columns("驗收備註").Visible = False : 合約_dgv.Columns("工地驗收備註").Visible = False : 合約_dgv.Columns("驗收完成日期").Visible = False
  34. 合約_dgv.Columns("保固期限").Visible = False : 合約_dgv.Columns("工程名稱_中").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("驗收結果", i).Value) = True Then : 合約_dgv("驗收結果", i).Value = False : End If
  38. Next
  39. If 放大 = True Then
  40. 合約_dgv.Columns("工程名稱_中").Visible = True
  41. Else
  42. 合約_dgv.Columns("工程名稱_中").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).FillWeight = 30 : 報價明細表_dgv.Columns(5).FillWeight = 30
  54. 報價明細表_dgv.Columns(6).FillWeight = 80
  55. 報價明細表_dgv.Columns("合約").DefaultCellStyle.Format = "#,##0" : 報價明細表_dgv.Columns("合約").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  56. 報價明細表_dgv.Columns("實際").DefaultCellStyle.Format = "#,##0" : 報價明細表_dgv.Columns("實際").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  57. 報價明細表_dgv.Columns("差異").DefaultCellStyle.Format = "#,##0" : 報價明細表_dgv.Columns("差異").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  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("實際").Value) = True Then : 報價明細表_dgv.Rows(i).Cells("實際").Value = 0 : End If
  65. If 已驗收_ch.Checked = False Then : 報價明細表_dgv.Rows(i).Cells("差異").Value = 0
  66. Else : 報價明細表_dgv.Rows(i).Cells("差異").Value = 報價明細表_dgv.Rows(i).Cells("實際").Value - 報價明細表_dgv.Rows(i).Cells("合約").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("合約").Value) Then : 報價明細表_dgv.Rows(i).Cells("合約").Style.ForeColor = Color.White : Else
  128. If 報價明細表_dgv.Rows(i).Cells("合約").Value = 0 Then : 報價明細表_dgv.Rows(i).Cells("合約").Style.ForeColor = Color.White
  129. Else : 報價明細表_dgv.Rows(i).Cells("合約").Style.ForeColor = Color.Black : End If : End If
  130. If IsDBNull(報價明細表_dgv.Rows(i).Cells("實際").Value) Then : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.White : Else
  131. If 報價明細表_dgv.Rows(i).Cells("實際").Value = 0 Then : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.White
  132. Else : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.Black : End If : End If
  133. If IsDBNull(報價明細表_dgv.Rows(i).Cells("差異").Value) Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.White : Else
  134. If 報價明細表_dgv.Rows(i).Cells("差異").Value = 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.White
  135. ElseIf 報價明細表_dgv.Rows(i).Cells("差異").Value > 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.Blue
  136. ElseIf 報價明細表_dgv.Rows(i).Cells("差異").Value < 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.Red : End If
  137. End If
  138. Next
  139. End Sub
  140. Private Sub 甲方條件下拉清單讀取()
  141. SQL合約條件讀取() : 合約編號1_cb.Items.Clear() : 合約編號1_cb.Items.Add("") : While (dr.Read()) : 合約編號1_cb.Items.Add(dr("約號甲方")) : End While : conn.Close()
  142. End Sub
  143. Private Sub 執行主管下拉清單讀取()
  144. SQL執行主管下拉() : 工程執行主管_cb.Items.Clear() : 工程執行主管_cb.Items.Add("") : While (dr.Read()) : 工程執行主管_cb.Items.Add(dr("姓名")) : End While : conn.Close()
  145. End Sub
  146. Private Sub 合約驗收單_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  147. Me.MdiParent = HX_PGS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  148. 甲方條件下拉清單讀取() : 執行主管下拉清單讀取() : Set_合約清單() : 合約驗收單_Siz()
  149. If 系統分區控制 = True Then : 驗收完成_bt.BackgroundImage = My.Resources.list_accept : 修改存檔_bt.Visible = True : 解鎖_bt.Visible = True
  150. ElseIf 系統分區控制 = False Then : 驗收完成_bt.BackgroundImage = My.Resources.SAVER : 修改存檔_bt.Visible = False : 解鎖_bt.Visible = False : End If
  151. If 系統分區控制 = True And CInt(登入人級別) <= 5 Then : 解鎖_bt.Enabled = True : Else : 解鎖_bt.Enabled = False : End If
  152. End Sub
  153. Private Sub 合約驗收單_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
  154. MyModule1.虛擬桌面開啟()
  155. End Sub
  156. Private Sub 合約驗收單_Siz()
  157. MyModule1.清單字體大小調整()
  158. 合約_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  159. 報價明細表_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  160. End Sub
  161. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  162. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  163. End Sub
  164. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  165. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  166. End Sub
  167. Private Sub 合約_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 合約_dgv.CellClick
  168. If e.RowIndex = -1 Then : Else
  169. If 放大 = True Then : 縮放2_bt.PerformClick() : End If
  170. 客戶名稱_tb.Text = 合約_dgv("客戶名稱", e.RowIndex).Value.ToString : 合約編號_tb.Text = 合約_dgv("合約編號", e.RowIndex).Value.ToString
  171. 工程名稱_中_tb.Text = 合約_dgv("工程名稱_中", e.RowIndex).Value.ToString : 工程名稱_英_tb.Text = 合約_dgv("工程名稱_英", e.RowIndex).Value.ToString
  172. 立約日期_dtp.Value = 合約_dgv("立約日期", e.RowIndex).Value.ToString : 合約工期_nud.Value = 合約_dgv("工期", e.RowIndex).Value.ToString
  173. 已驗收_ch.Checked = 合約_dgv("驗收結果", e.RowIndex).Value : 保固_cb.Text = 合約_dgv("保固期限", e.RowIndex).Value.ToString
  174. If 系統分區控制 = True Then : 備註_tb.Text = 合約_dgv("驗收備註", e.RowIndex).Value.ToString
  175. Else : 備註_tb.Text = 合約_dgv("工地驗收備註", e.RowIndex).Value.ToString : End If
  176. If 合約_dgv("驗收開始日期", e.RowIndex).Value.ToString = "" Then : 驗收日期_dtp.Value = Today() : 存檔 = False
  177. Else : 驗收日期_dtp.Value = 合約_dgv("驗收開始日期", e.RowIndex).Value.ToString : 存檔 = True : End If
  178. If 合約_dgv("驗收完成日期", e.RowIndex).Value.ToString = "" Then : 驗收完成_dtp.Value = Today() : Else
  179. 驗收完成_dtp.Value = 合約_dgv("驗收完成日期", e.RowIndex).Value.ToString
  180. End If
  181. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  182. 啟動運算 = False : PA = 合約編號_tb.Text : Set_合約報價明細表() : 啟動運算 = True
  183. If IsDBNull(合約_dgv("驗收結果", e.RowIndex).Value) = True Then
  184. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  185. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  186. Else
  187. If 合約_dgv("驗收結果", e.RowIndex).Value = True Then
  188. 立約日期_dtp.Enabled = False : 驗收日期_dtp.Enabled = False : 驗收完成_dtp.Enabled = False : 合約工期_nud.Enabled = False
  189. 工程天數_nud.Enabled = False : 日期差異_nud.Enabled = False : 保固_cb.Enabled = False
  190. Else
  191. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  192. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  193. End If
  194. End If
  195. End If
  196. End Sub
  197. Private Sub 報價明細表_dgv_CellContentCl(sender As Object, e As DataGridViewCellEventArgs) Handles 報價明細表_dgv.CellEndEdit
  198. If 啟動運算 = True Then
  199. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  200. If IsDBNull(報價明細表_dgv.Rows(i).Cells("實際").Value) Then : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.White : Else
  201. If 報價明細表_dgv.Rows(i).Cells("實際").Value = 0 Then : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.White
  202. Else : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.Black : End If : End If
  203. If IsDBNull(報價明細表_dgv.Rows(i).Cells("差異").Value) Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.White : Else
  204. If 報價明細表_dgv.Rows(i).Cells("差異").Value = 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.White
  205. ElseIf 報價明細表_dgv.Rows(i).Cells("差異").Value > 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.Blue
  206. ElseIf 報價明細表_dgv.Rows(i).Cells("差異").Value < 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.Red : End If : End If
  207. 報價明細表_dgv.Rows(i).Cells("差異").Value = 報價明細表_dgv.Rows(i).Cells("實際").Value - 報價明細表_dgv.Rows(i).Cells("合約").Value
  208. Next
  209. End If
  210. End Sub
  211. Private Sub 合約編號1_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 合約編號1_cb.SelectedIndexChanged
  212. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  213. End Sub
  214. Private Sub 工程期1_ch_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 工程期1_ch.SelectedIndexChanged
  215. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  216. End Sub
  217. Private Sub 工程執行主管_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 工程執行主管_cb.SelectedIndexChanged
  218. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  219. End Sub
  220. Private Sub 查詢_bt_Click(sender As Object, e As EventArgs) Handles 查詢_bt.Click
  221. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  222. End Sub
  223. Private Sub 立約日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 立約日期_dtp.ValueChanged
  224. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  225. End Sub
  226. Private Sub 驗收日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 驗收日期_dtp.ValueChanged
  227. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  228. End Sub
  229. Private Sub 修改存檔_bt_Click(sender As Object, e As EventArgs) Handles 修改存檔_bt.Click
  230. If 報價明細表_dgv.Rows.Count < 1 Then
  231. If 系統語言 = "繁體中文" Then : MsgBox("系統中沒有報價單明細,無法存檔!!") : Else : MsgBox("Tidak ada detail kutipan dalam sistem dan tidak dapat diarsipkan!!") : End If : Else
  232. PA = 合約編號_tb.Text : SQL_控制表_驗收確認()
  233. If dr.Read() Then
  234. Dim SS, SS1 As String
  235. If 系統語言 = "繁體中文" Then : SS = "驗收日期為 " : SS1 = " 是否正確??" : Else : SS = "Tanggal penerimaan adalah " : SS1 = " apakah benar atau tidak??" : End If
  236. Dim aa As MsgBoxResult = MsgBox(SS & Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") & SS1, MsgBoxStyle.OkCancel)
  237. If aa = MsgBoxResult.Ok Then : PA1 = Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") : SQL_控制表_驗收修改1()
  238. If 已驗收_ch.Checked = True Then
  239. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  240. PA9 = 報價明細表_dgv.Rows(i).Cells("流水號").Value.ToString : PA1 = 報價明細表_dgv.Rows(i).Cells("實際").Value.ToString
  241. PA2 = 報價明細表_dgv.Rows(i).Cells("REMARKS").Value.ToString
  242. SQL_合約報價明細表_驗收存檔()
  243. Next
  244. End If
  245. If 系統語言 = "繁體中文" Then : MsgBox("修改完成!!") : Else : MsgBox("Modifikasi selesai!!") : End If : PA = "" : Set_合約清單() : 存檔 = True
  246. End If
  247. End If
  248. End If
  249. End Sub
  250. Private Sub 驗收完成_bt_Click(sender As Object, e As EventArgs) Handles 驗收完成_bt.Click
  251. If 合約編號_tb.Text = "" Then
  252. If 系統語言 = "繁體中文" Then : MsgBox("請先選擇要完成驗收的合約!!") : Else : MsgBox("Silakan pilih kontrak terlebih dahulu!!") : End If : Else
  253. If 系統分區控制 = True Then
  254. If 存檔 = False Then
  255. If 系統語言 = "繁體中文" Then : MsgBox("該合約沒有開始驗收,所以無法完成驗收!!")
  256. Else : MsgBox("Kontrak belum memulai penerimaan, jadi penerimaan tidak dapat diselesaikan!!") : End If : Else
  257. If 保固_cb.Text = "" Then
  258. If 系統語言 = "繁體中文" Then : MsgBox("沒有保固期限,無法存檔!!") : Else : MsgBox("Tidak ada masa garansi dan tidak dapat diarsipkan!!") : End If : Else
  259. If 驗收日期_dtp.Value > 驗收完成_dtp.Value Then
  260. If 系統語言 = "繁體中文" Then : MsgBox("驗收完成日不可能小於驗收開始日期!!")
  261. Else : MsgBox("Tanggal penyelesaian penerimaan tidak boleh kurang dari tanggal mulai penerimaan!!") : End If : Else
  262. Dim SS, SS1 As String
  263. If 系統語言 = "繁體中文" Then : SS = "驗收完成日期為 " : SS1 = " 是否正確??"
  264. Else : SS = "Tanggal penyelesaian penerimaan adalah " : SS1 = " apakah benar atau tidak??" : End If
  265. Dim aa As MsgBoxResult = MsgBox(SS & Strings.Format(驗收完成_dtp.Value, "yyyy/MM/dd") & SS1, MsgBoxStyle.OkCancel)
  266. If aa = MsgBoxResult.Ok Then
  267. 修改存檔_bt.PerformClick()
  268. PA = 合約編號_tb.Text : PA1 = Strings.Format(驗收完成_dtp.Value, "yyyy/MM/dd") : PA2 = "1" : PA3 = 備註_tb.Text : PA4 = 保固_cb.Text
  269. SQL_控制表_驗收修改2() : PA = "" : 存檔 = False
  270. If 系統語言 = "繁體中文" Then : MsgBox("驗收回報完成!!") : Else : MsgBox("Laporan penerimaan selesai!!") : End If
  271. If 立約日期_dtp.Enabled = True Then : 解鎖_bt.PerformClick() : End If
  272. End If
  273. End If
  274. End If
  275. End If
  276. Else
  277. PA = 合約編號_tb.Text : PA3 = 備註_tb.Text : SQL_控制表_驗收修改3() : PA = ""
  278. If 系統語言 = "繁體中文" Then : MsgBox("備註存檔完成!!") : Else : MsgBox("Arsip selesai!!") : End If
  279. End If
  280. End If
  281. End Sub
  282. Private Sub 縮放2_bt_Click(sender As Object, e As EventArgs) Handles 縮放2_bt.Click
  283. Dim NX, NY As Integer : NX = 合約_dgv.Size.Width : NY = 合約_dgv.Size.Height
  284. If 放大 = True Then
  285. 合約_dgv.Size = New System.Drawing.Point(NX - 400, NY) : 放大 = False : 合約_dgv.Columns("工程名稱_中").Visible = False
  286. Else
  287. 合約_dgv.Size = New System.Drawing.Point(NX + 400, NY) : 放大 = True : 合約_dgv.Columns("工程名稱_中").Visible = True
  288. End If
  289. End Sub
  290. Private Sub 解鎖_bt_Click(sender As Object, e As EventArgs) Handles 解鎖_bt.Click
  291. If 合約編號_tb.Text = "" Then
  292. If 系統語言 = "繁體中文" Then : MsgBox("沒有資料!!") : Else : MsgBox("Tidak ada Informasi!!") : End If : Else
  293. If 立約日期_dtp.Enabled = True Then
  294. 立約日期_dtp.Enabled = False : 驗收日期_dtp.Enabled = False : 驗收完成_dtp.Enabled = False : 合約工期_nud.Enabled = False
  295. 工程天數_nud.Enabled = False : 日期差異_nud.Enabled = False : 保固_cb.Enabled = False
  296. Else
  297. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  298. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  299. End If
  300. End If
  301. End Sub
  302. Private Sub 詳細資料2_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 詳細資料2_ch.Click
  303. If 詳細資料2_ch.Checked = True Then : 詳細資料2_ch.Checked = True : Else : 詳細資料2_ch.Checked = False : End If : Set_合約報價明細表()
  304. End Sub
  305. Private Sub 列印_bt_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  306. If 報價明細表_dgv.Rows.Count < 1 Then
  307. If 系統語言 = "繁體中文" Then : MsgBox("系統中沒有報價單明細,無法列印驗收單!!")
  308. Else : MsgBox("Tidak ada rincian kutipan dalam sistem, dan daftar penerimaan tidak dapat dicetak!!") : End If : Else
  309. Dim 列印 As Boolean : PA = 合約編號_tb.Text : SQL_控制表_驗收確認()
  310. If dr.Read() Then
  311. If dr("驗收開始日期").ToString = "" Then
  312. Dim SS, SS1 As String
  313. If 系統語言 = "繁體中文" Then : SS = "驗收日期為 " : SS1 = " 是否正確??" : Else : SS = "Tanggal penerimaan adalah " : SS1 = " apakah benar atau tidak??" : End If
  314. Dim aa As MsgBoxResult = MsgBox(SS & Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") & SS1, MsgBoxStyle.OkCancel)
  315. If aa = MsgBoxResult.Ok Then : PA1 = Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") : SQL_控制表_驗收修改1() : 列印 = True : Else : 列印 = False : End If
  316. Else : 列印 = True : End If
  317. End If
  318. If 列印 = True Then
  319. If 合約編號_tb.Text = "" Then : If 系統語言 = "繁體中文" Then : MsgBox("沒有選擇合約,無法列印!!") : Else : MsgBox("Tidak ada Informasi!!") : End If : Else
  320. xlApp = CType(CreateObject("Excel.Application"), Application)
  321. xlApp.Visible = True
  322. xlApp.DisplayAlerts = True
  323. xlApp.Application.WindowState = xlMaximized
  324. xlBook = xlApp.Workbooks.Add
  325. '----------------------------------------------------------------------------------------------------------------------
  326. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select : xlApp.Sheets(1).Name = "工程驗收單"
  327. xlBook.Activate() : xlSheet.Activate()
  328. xlSheet.Cells(2, 1) = "工程驗收單"
  329. xlSheet.Cells(3, 1) = "業主名稱 :" & 客戶名稱_tb.Text : xlSheet.Cells(3, 6) = "NO. " & 合約編號_tb.Text
  330. xlSheet.Cells(4, 1) = "工程項目 : " & 工程名稱_中_tb.Text & " " & 工程名稱_英_tb.Text : xlSheet.Cells(4, 6) = Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd")
  331. 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"
  332. xlSheet.Cells(6, 4) = "合約" & vbCrLf & "Contract A" : xlSheet.Cells(6, 5) = "實際" & vbCrLf & "Actual B" : xlSheet.Cells(6, 6) = "差異" & vbCrLf & "Difference C=B-A"
  333. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  334. xlSheet.Cells(7 + i, 1) = 報價明細表_dgv("ITEM", i).Value.ToString : xlSheet.Cells(7 + i, 2) = 報價明細表_dgv("DESCRIPTION", i).Value.ToString
  335. xlSheet.Cells(7 + i, 3) = 報價明細表_dgv("UNIT", i).Value.ToString : xlSheet.Cells(7 + i, 7) = 報價明細表_dgv("REMARKS", i).Value.ToString
  336. If CInt(報價明細表_dgv("實際", i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 5) = 報價明細表_dgv("實際", i).Value.ToString : End If
  337. If CInt(報價明細表_dgv("差異", i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 6) = 報價明細表_dgv("差異", i).Value.ToString : End If
  338. If CInt(報價明細表_dgv("合約", i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 4) = 報價明細表_dgv("合約", i).Value.ToString : End If
  339. NB1 = i
  340. Next
  341. xlSheet.Cells(7 + NB1 + 2, 2) = " 甲方代表簽字" : xlSheet.Cells(7 + NB1 + 2, 5) = "承包商簽字"
  342. xlSheet.Cells(7 + NB1 + 3, 2) = "Representatives of Party A :" : xlSheet.Cells(7 + NB1 + 3, 5) = "Contracting company signing:"
  343. AA(xlApp, xlSheet)
  344. If Strings.Left(合約編號_tb.Text, 2) = "HX" Then : CC(xlApp, xlSheet) : Else : DD(xlApp, xlSheet) : End If : FF(xlApp, xlSheet)
  345. xlApp.Sheets(2).Delete
  346. xlSheet.PageSetup.PrintArea = ""
  347. xlApp.Cells.Select()
  348. xlApp.Application.WindowState = xlMinimized
  349. If 系統語言 = "繁體中文" Then : MsgBox("列印完成!!") : Else : MsgBox("cetak selesai!!") : End If : Set_合約清單()
  350. End If
  351. End If
  352. End If
  353. End Sub
  354. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  355. Return CType(xlBook.Worksheets.Add, Worksheet)
  356. End Function
  357. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  358. xlSheet.Cells.Select()
  359. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  360. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  361. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 95
  362. xlSheet.Rows("2:2").Select
  363. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 18 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  364. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  365. xlSheet.Rows("3:4").Select
  366. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  367. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  368. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 6 : xlSheet.Columns("D:F").Select : myExcel.Selection.ColumnWidth = 10
  369. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 20 : xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 6
  370. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 75
  371. xlSheet.Range("A2:G2").Select()
  372. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  373. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  374. xlSheet.Range("A3:E3").Select()
  375. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  376. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  377. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  378. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  379. xlSheet.Range("A4:E4").Select()
  380. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  381. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  382. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  383. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  384. xlSheet.Range("F3:G3").Select()
  385. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  386. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  387. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  388. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  389. xlSheet.Range("F4:G4").Select()
  390. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  391. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  392. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  393. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  394. xlSheet.Range("A5:A6").Select()
  395. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  396. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  397. xlSheet.Range("B5:B6").Select()
  398. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  399. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  400. xlSheet.Range("C5:C6").Select()
  401. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  402. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  403. xlSheet.Range("D5:F5").Select()
  404. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  405. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  406. xlSheet.Range("G5:G6").Select()
  407. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  408. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  409. xlSheet.Range("D6:F6").Select()
  410. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  411. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  412. xlSheet.Range("B7:B" & 7 + NB1 + 1).Select()
  413. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  414. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  415. xlSheet.Rows("7:" & 7 + NB1 + 1).Select : myExcel.Selection.RowHeight = 25
  416. xlSheet.Range("A5:G" & 7 + NB1 + 1).Select()
  417. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  418. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  419. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  420. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  421. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  422. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  423. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  424. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  425. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  426. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  427. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  428. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  429. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  430. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  431. myExcel.ActiveWindow.DisplayGridlines = False
  432. xlSheet.Range("E" & 7 + NB1 + 2 & ":G" & 7 + NB1 + 2).Select()
  433. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  434. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  435. xlSheet.Range("E" & 7 + NB1 + 3 & ":G" & 7 + NB1 + 3).Select()
  436. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  437. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  438. xlSheet.Rows(7 + NB1 + 4 & ":" & 7 + NB1 + 4).Select : myExcel.Selection.RowHeight = 70
  439. xlSheet.Range("A" & 7 + NB1 + 2 & ":G" & 7 + NB1 + 4).Select()
  440. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  441. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  442. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  443. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  444. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  445. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  446. xlSheet.Range("A7:A" & 7 + NB1 + 1).Select()
  447. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  448. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  449. xlSheet.Range("C7:D" & 7 + NB1 + 1).Select()
  450. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  451. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  452. xlSheet.Range("G7:G" & 7 + NB1 + 1).Select()
  453. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  454. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  455. End Sub
  456. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  457. Clipboard.SetDataObject(PictureBox1.Image)
  458. xlSheet.Range("A1").Select()
  459. myExcel.ActiveSheet.Pictures.Paste.Select
  460. myExcel.Selection.ShapeRange.Height = 93
  461. myExcel.Selection.ShapeRange.IncrementLeft(0)
  462. myExcel.Selection.ShapeRange.IncrementTop(0)
  463. End Sub
  464. Private Sub DD(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  465. Clipboard.SetDataObject(PictureBox2.Image)
  466. xlSheet.Range("A1").Select()
  467. myExcel.ActiveSheet.Pictures.Paste.Select
  468. myExcel.Selection.ShapeRange.Height = 93
  469. myExcel.Selection.ShapeRange.IncrementLeft(0)
  470. myExcel.Selection.ShapeRange.IncrementTop(0)
  471. End Sub
  472. Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  473. myExcel.Application.PrintCommunication = False : With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$6" : .PrintTitleColumns = "" : End With
  474. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  475. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  476. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  477. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  478. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  479. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Draft = False
  480. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False
  481. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  482. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  483. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  484. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  485. End With : myExcel.Application.PrintCommunication = True
  486. End Sub
  487. End Class