Sin descripción
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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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 = GCM_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. End Sub
  155. Private Sub 合約驗收單_Siz()
  156. MyModule1.清單字體大小調整()
  157. 合約_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  158. 報價明細表_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", GCM_ERP_SYS.字體_NUD.Value)
  159. End Sub
  160. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  161. timeNow = 0 : GCM_ERP_SYS.Timer1.Enabled = False : GCM_ERP_SYS.Timer1.Enabled = True
  162. End Sub
  163. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  164. timeNow = 0 : GCM_ERP_SYS.Timer1.Enabled = False : GCM_ERP_SYS.Timer1.Enabled = True
  165. End Sub
  166. Private Sub 合約_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 合約_dgv.CellClick
  167. If e.RowIndex = -1 Then : Else
  168. If 放大 = True Then : 縮放2_bt.PerformClick() : End If
  169. 客戶名稱_tb.Text = 合約_dgv("客戶名稱", e.RowIndex).Value.ToString : 合約編號_tb.Text = 合約_dgv("合約編號", e.RowIndex).Value.ToString
  170. 工程名稱_中_tb.Text = 合約_dgv("工程名稱_中", e.RowIndex).Value.ToString : 工程名稱_英_tb.Text = 合約_dgv("工程名稱_英", e.RowIndex).Value.ToString
  171. 立約日期_dtp.Value = 合約_dgv("立約日期", e.RowIndex).Value.ToString : 合約工期_nud.Value = 合約_dgv("工期", e.RowIndex).Value.ToString
  172. 已驗收_ch.Checked = 合約_dgv("驗收結果", e.RowIndex).Value : 保固_cb.Text = 合約_dgv("保固期限", e.RowIndex).Value.ToString
  173. If 系統分區控制 = True Then : 備註_tb.Text = 合約_dgv("驗收備註", e.RowIndex).Value.ToString
  174. Else : 備註_tb.Text = 合約_dgv("工地驗收備註", e.RowIndex).Value.ToString : End If
  175. If 合約_dgv("驗收開始日期", e.RowIndex).Value.ToString = "" Then : 驗收日期_dtp.Value = Today() : 存檔 = False
  176. Else : 驗收日期_dtp.Value = 合約_dgv("驗收開始日期", e.RowIndex).Value.ToString : 存檔 = True : End If
  177. If 合約_dgv("驗收完成日期", e.RowIndex).Value.ToString = "" Then : 驗收完成_dtp.Value = Today() : Else
  178. 驗收完成_dtp.Value = 合約_dgv("驗收完成日期", e.RowIndex).Value.ToString
  179. End If
  180. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  181. 啟動運算 = False : PA = 合約編號_tb.Text : Set_合約報價明細表() : 啟動運算 = True
  182. If IsDBNull(合約_dgv("驗收結果", e.RowIndex).Value) = True Then
  183. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  184. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  185. Else
  186. If 合約_dgv("驗收結果", e.RowIndex).Value = True Then
  187. 立約日期_dtp.Enabled = False : 驗收日期_dtp.Enabled = False : 驗收完成_dtp.Enabled = False : 合約工期_nud.Enabled = False
  188. 工程天數_nud.Enabled = False : 日期差異_nud.Enabled = False : 保固_cb.Enabled = False
  189. Else
  190. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  191. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  192. End If
  193. End If
  194. End If
  195. End Sub
  196. Private Sub 報價明細表_dgv_CellContentCl(sender As Object, e As DataGridViewCellEventArgs) Handles 報價明細表_dgv.CellEndEdit
  197. If 啟動運算 = True Then
  198. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  199. If IsDBNull(報價明細表_dgv.Rows(i).Cells("實際").Value) Then : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.White : Else
  200. If 報價明細表_dgv.Rows(i).Cells("實際").Value = 0 Then : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.White
  201. Else : 報價明細表_dgv.Rows(i).Cells("實際").Style.ForeColor = Color.Black : End If : End If
  202. If IsDBNull(報價明細表_dgv.Rows(i).Cells("差異").Value) Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.White : Else
  203. If 報價明細表_dgv.Rows(i).Cells("差異").Value = 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.White
  204. ElseIf 報價明細表_dgv.Rows(i).Cells("差異").Value > 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.Blue
  205. ElseIf 報價明細表_dgv.Rows(i).Cells("差異").Value < 0 Then : 報價明細表_dgv.Rows(i).Cells("差異").Style.ForeColor = Color.Red : End If : End If
  206. 報價明細表_dgv.Rows(i).Cells("差異").Value = 報價明細表_dgv.Rows(i).Cells("實際").Value - 報價明細表_dgv.Rows(i).Cells("合約").Value
  207. Next
  208. End If
  209. End Sub
  210. Private Sub 合約編號1_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 合約編號1_cb.SelectedIndexChanged
  211. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  212. End Sub
  213. Private Sub 工程期1_ch_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 工程期1_ch.SelectedIndexChanged
  214. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  215. End Sub
  216. Private Sub 工程執行主管_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 工程執行主管_cb.SelectedIndexChanged
  217. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  218. End Sub
  219. Private Sub 查詢_bt_Click(sender As Object, e As EventArgs) Handles 查詢_bt.Click
  220. PA = 關鍵字搜尋_tb.Text : Set_合約清單()
  221. End Sub
  222. Private Sub 立約日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 立約日期_dtp.ValueChanged
  223. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  224. End Sub
  225. Private Sub 驗收日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 驗收日期_dtp.ValueChanged
  226. 工程天數_nud.Value = DateDiff("d", 立約日期_dtp.Value, 驗收日期_dtp.Value) : 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  227. End Sub
  228. Private Sub 合約工期_nud_ValueChanged(sender As Object, e As EventArgs) Handles 合約工期_nud.ValueChanged
  229. 日期差異_nud.Value = 合約工期_nud.Value - 工程天數_nud.Value
  230. End Sub
  231. Private Sub 修改存檔_bt_Click(sender As Object, e As EventArgs) Handles 修改存檔_bt.Click
  232. If 報價明細表_dgv.Rows.Count < 1 Then
  233. If 系統語言 = "繁體中文" Then : MsgBox("系統中沒有報價單明細,無法存檔!!") : Else : MsgBox("There are no quotation details in the system and cannot be archived!!") : End If : Else
  234. PA = 合約編號_tb.Text : SQL_控制表_驗收確認()
  235. If dr.Read() Then
  236. Dim SS, SS1 As String
  237. If 系統語言 = "繁體中文" Then : SS = "驗收日期為 " : SS1 = " 是否正確??" : Else : SS = "Acceptance date is " : SS1 = " is it right or not??" : End If
  238. Dim aa As MsgBoxResult = MsgBox(SS & Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") & SS1, MsgBoxStyle.OkCancel)
  239. If aa = MsgBoxResult.Ok Then : PA1 = Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") : PA5 = 合約工期_nud.Value : SQL_控制表_驗收修改1()
  240. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  241. PA9 = 報價明細表_dgv.Rows(i).Cells("流水號").Value.ToString : PA1 = 報價明細表_dgv.Rows(i).Cells("實際").Value.ToString
  242. PA2 = 報價明細表_dgv.Rows(i).Cells("REMARKS").Value.ToString
  243. SQL_合約報價明細表_驗收存檔()
  244. Next
  245. If 系統語言 = "繁體中文" Then : MsgBox("修改完成!!") : Else : MsgBox("Modification complete!!") : 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("Please select the contract to complete the acceptance first!!") : End If : Else
  253. 系統分區控制 = True
  254. If 系統分區控制 = True Then
  255. If 存檔 = False Then
  256. If 系統語言 = "繁體中文" Then : MsgBox("該合約沒有開始驗收,所以無法完成驗收!!")
  257. Else : MsgBox("The contract has not started acceptance, so the acceptance cannot be completed!!") : End If : Else
  258. If 保固_cb.Text = "" Then
  259. If 系統語言 = "繁體中文" Then : MsgBox("沒有保固期限,無法存檔!!") : Else : MsgBox("No warranty period, no archive!!") : End If : Else
  260. If 驗收日期_dtp.Value > 驗收完成_dtp.Value Then
  261. If 系統語言 = "繁體中文" Then : MsgBox("驗收完成日不可能小於驗收開始日期!!")
  262. Else : MsgBox("The acceptance completion date cannot be less than the acceptance start date!!") : End If : Else
  263. Dim SS, SS1 As String
  264. If 系統語言 = "繁體中文" Then : SS = "驗收完成日期為 " : SS1 = " 是否正確??"
  265. Else : SS = "Acceptance completion date is " : SS1 = " is it right or not??" : End If
  266. Dim aa As MsgBoxResult = MsgBox(SS & Strings.Format(驗收完成_dtp.Value, "yyyy/MM/dd") & SS1, MsgBoxStyle.OkCancel)
  267. If aa = MsgBoxResult.Ok Then
  268. 修改存檔_bt.PerformClick()
  269. PA = 合約編號_tb.Text : PA1 = Strings.Format(驗收完成_dtp.Value, "yyyy/MM/dd") : PA2 = "1" : PA3 = 備註_tb.Text : PA4 = 保固_cb.Text
  270. PA5 = 合約工期_nud.Value
  271. SQL_控制表_驗收修改2() : PA = "" : 存檔 = False
  272. If 系統語言 = "繁體中文" Then : MsgBox("驗收回報完成!!") : Else : MsgBox("Acceptance return completed!!") : End If
  273. If 立約日期_dtp.Enabled = True Then : 解鎖_bt.PerformClick() : End If
  274. End If
  275. End If
  276. End If
  277. End If
  278. Else
  279. PA = 合約編號_tb.Text : PA3 = 備註_tb.Text : SQL_控制表_驗收修改3() : PA = ""
  280. If 系統語言 = "繁體中文" Then : MsgBox("備註存檔完成!!") : Else : MsgBox("Remarks Archive Complete!!") : End If
  281. End If
  282. End If : Set_合約清單()
  283. End Sub
  284. Private Sub 縮放2_bt_Click(sender As Object, e As EventArgs) Handles 縮放2_bt.Click
  285. Dim NX, NY As Integer : NX = 合約_dgv.Size.Width : NY = 合約_dgv.Size.Height
  286. If 放大 = True Then
  287. 合約_dgv.Size = New System.Drawing.Point(NX - 400, NY) : 放大 = False : 合約_dgv.Columns("工程名稱_中").Visible = False
  288. Else
  289. 合約_dgv.Size = New System.Drawing.Point(NX + 400, NY) : 放大 = True : 合約_dgv.Columns("工程名稱_中").Visible = True
  290. End If
  291. End Sub
  292. Private Sub 解鎖_bt_Click(sender As Object, e As EventArgs) Handles 解鎖_bt.Click
  293. If 合約編號_tb.Text = "" Then
  294. If 系統語言 = "繁體中文" Then : MsgBox("沒有資料!!") : Else : MsgBox("no information!!") : End If : Else
  295. If 立約日期_dtp.Enabled = True Then
  296. 立約日期_dtp.Enabled = False : 驗收日期_dtp.Enabled = False : 驗收完成_dtp.Enabled = False : 合約工期_nud.Enabled = False
  297. 工程天數_nud.Enabled = False : 日期差異_nud.Enabled = False : 保固_cb.Enabled = False
  298. Else
  299. 立約日期_dtp.Enabled = True : 驗收日期_dtp.Enabled = True : 驗收完成_dtp.Enabled = True : 合約工期_nud.Enabled = True
  300. 工程天數_nud.Enabled = True : 日期差異_nud.Enabled = True : 保固_cb.Enabled = True
  301. End If
  302. End If
  303. End Sub
  304. Private Sub 詳細資料2_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 詳細資料2_ch.Click
  305. If 詳細資料2_ch.Checked = True Then : 詳細資料2_ch.Checked = True : Else : 詳細資料2_ch.Checked = False : End If : Set_合約報價明細表()
  306. End Sub
  307. Private Sub 列印_bt_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  308. If 報價明細表_dgv.Rows.Count < 1 Then
  309. If 系統語言 = "繁體中文" Then : MsgBox("系統中沒有報價單明細,無法列印驗收單!!")
  310. Else : MsgBox("There is no quotation details in the system, and the acceptance list cannot be printed!!") : End If : Else
  311. Dim 列印 As Boolean : PA = 合約編號_tb.Text : SQL_控制表_驗收確認()
  312. If dr.Read() Then
  313. If dr("驗收開始日期").ToString = "" Then
  314. Dim SS, SS1 As String
  315. If 系統語言 = "繁體中文" Then : SS = "驗收日期為 " : SS1 = " 是否正確??" : Else : SS = "Acceptance completion date is " : SS1 = " is it right or not??" : End If
  316. Dim aa As MsgBoxResult = MsgBox(SS & Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") & SS1, MsgBoxStyle.OkCancel)
  317. If aa = MsgBoxResult.Ok Then : PA1 = Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd") : PA5 = 合約工期_nud.Value : SQL_控制表_驗收修改1()
  318. 列印 = True : Else : 列印 = False : End If
  319. Else : 列印 = True : End If
  320. End If
  321. If 列印 = True Then
  322. If 合約編號_tb.Text = "" Then : If 系統語言 = "繁體中文" Then : MsgBox("沒有選擇合約,無法列印!!") : Else : MsgBox("No contract selected, can't print!!") : End If : Else
  323. xlApp = CType(CreateObject("Excel.Application"), Application)
  324. xlApp.Visible = True
  325. xlApp.DisplayAlerts = True
  326. xlApp.Application.WindowState = xlMaximized
  327. xlBook = xlApp.Workbooks.Add
  328. '----------------------------------------------------------------------------------------------------------------------
  329. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select : xlApp.Sheets(1).Name = "工程驗收單"
  330. xlBook.Activate() : xlSheet.Activate()
  331. xlSheet.Cells(2, 1) = "工程驗收單"
  332. xlSheet.Cells(3, 1) = "業主名稱 :" & 客戶名稱_tb.Text : xlSheet.Cells(3, 6) = "NO. " & 合約編號_tb.Text
  333. xlSheet.Cells(4, 1) = "工程項目 : " & 工程名稱_中_tb.Text & " " & 工程名稱_英_tb.Text : xlSheet.Cells(4, 6) = Strings.Format(驗收日期_dtp.Value, "yyyy/MM/dd")
  334. 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"
  335. xlSheet.Cells(6, 4) = "合約" & vbCrLf & "Contract A" : xlSheet.Cells(6, 5) = "實際" & vbCrLf & "Actual B" : xlSheet.Cells(6, 6) = "差異" & vbCrLf & "Difference C=B-A"
  336. For i As Integer = 0 To 報價明細表_dgv.Rows.Count - 1
  337. xlSheet.Cells(7 + i, 1) = 報價明細表_dgv("ITEM", i).Value.ToString : xlSheet.Cells(7 + i, 2) = 報價明細表_dgv("DESCRIPTION", i).Value.ToString
  338. xlSheet.Cells(7 + i, 3) = 報價明細表_dgv("UNIT", i).Value.ToString : xlSheet.Cells(7 + i, 7) = 報價明細表_dgv("REMARKS", i).Value.ToString
  339. If CInt(報價明細表_dgv("實際", i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 5) = 報價明細表_dgv("實際", i).Value.ToString : End If
  340. If CInt(報價明細表_dgv("差異", i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 6) = 報價明細表_dgv("差異", i).Value.ToString : End If
  341. If CInt(報價明細表_dgv("合約", i).Value.ToString) = 0 Then : Else : xlSheet.Cells(7 + i, 4) = 報價明細表_dgv("合約", i).Value.ToString : End If
  342. NB1 = i
  343. Next
  344. xlSheet.Cells(7 + NB1 + 2, 2) = " 甲方代表簽字" : xlSheet.Cells(7 + NB1 + 2, 5) = "承包商簽字"
  345. xlSheet.Cells(7 + NB1 + 3, 2) = "Representatives of Party A :" : xlSheet.Cells(7 + NB1 + 3, 5) = "Contracting company signing:"
  346. AA(xlApp, xlSheet)
  347. If Strings.Left(合約編號_tb.Text, 2) = "HX" Then : CC(xlApp, xlSheet) : Else : DD(xlApp, xlSheet) : End If : FF(xlApp, xlSheet)
  348. xlApp.Sheets(2).Delete
  349. xlSheet.PageSetup.PrintArea = ""
  350. xlApp.Cells.Select()
  351. xlApp.Application.WindowState = xlMinimized
  352. If 系統語言 = "繁體中文" Then : MsgBox("列印完成!!") : Else : MsgBox("Printing is complete!!") : End If : Set_合約清單()
  353. End If
  354. End If
  355. End If
  356. End Sub
  357. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  358. Return CType(xlBook.Worksheets.Add, Worksheet)
  359. End Function
  360. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  361. xlSheet.Cells.Select()
  362. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  363. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  364. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 95
  365. xlSheet.Rows("2:2").Select
  366. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 18 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  367. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  368. xlSheet.Rows("3:4").Select
  369. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  370. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  371. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 6 : xlSheet.Columns("D:F").Select : myExcel.Selection.ColumnWidth = 10
  372. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 20 : xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 6
  373. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 75
  374. xlSheet.Range("A2:G2").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. xlSheet.Range("A3:E3").Select()
  378. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  379. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  380. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  381. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  382. xlSheet.Range("A4:E4").Select()
  383. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  384. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  385. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  386. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  387. xlSheet.Range("F3:G3").Select()
  388. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  389. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  390. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  391. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  392. xlSheet.Range("F4:G4").Select()
  393. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  394. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  395. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  396. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With
  397. xlSheet.Range("A5:A6").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("B5:B6").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("C5:C6").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("D5:F5").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("G5:G6").Select()
  410. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  411. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  412. xlSheet.Range("D6:F6").Select()
  413. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  414. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  415. xlSheet.Range("B7:B" & 7 + NB1 + 1).Select()
  416. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  417. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  418. xlSheet.Rows("7:" & 7 + NB1 + 1).Select : myExcel.Selection.RowHeight = 25
  419. xlSheet.Range("A5:G" & 7 + NB1 + 1).Select()
  420. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  421. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  422. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  423. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  424. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  425. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  426. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  427. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  428. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  429. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  430. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  431. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  432. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  433. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  434. myExcel.ActiveWindow.DisplayGridlines = False
  435. xlSheet.Range("E" & 7 + NB1 + 2 & ":G" & 7 + NB1 + 2).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.Range("E" & 7 + NB1 + 3 & ":G" & 7 + NB1 + 3).Select()
  439. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  440. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  441. xlSheet.Rows(7 + NB1 + 4 & ":" & 7 + NB1 + 4).Select : myExcel.Selection.RowHeight = 70
  442. xlSheet.Range("A" & 7 + NB1 + 2 & ":G" & 7 + NB1 + 4).Select()
  443. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  444. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  445. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  446. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  447. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  448. myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  449. xlSheet.Range("A7:A" & 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("C7:D" & 7 + NB1 + 1).Select()
  453. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  454. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  455. xlSheet.Range("G7:G" & 7 + NB1 + 1).Select()
  456. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  457. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  458. End Sub
  459. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  460. Clipboard.SetDataObject(PictureBox1.Image)
  461. xlSheet.Range("A1").Select()
  462. myExcel.ActiveSheet.Pictures.Paste.Select
  463. myExcel.Selection.ShapeRange.Height = 93
  464. myExcel.Selection.ShapeRange.IncrementLeft(0)
  465. myExcel.Selection.ShapeRange.IncrementTop(0)
  466. End Sub
  467. Private Sub DD(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  468. Clipboard.SetDataObject(PictureBox2.Image)
  469. xlSheet.Range("A1").Select()
  470. myExcel.ActiveSheet.Pictures.Paste.Select
  471. myExcel.Selection.ShapeRange.Height = 93
  472. myExcel.Selection.ShapeRange.IncrementLeft(0)
  473. myExcel.Selection.ShapeRange.IncrementTop(0)
  474. End Sub
  475. Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  476. myExcel.Application.PrintCommunication = False : With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$6" : .PrintTitleColumns = "" : End With
  477. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  478. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  479. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  480. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  481. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  482. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Draft = False
  483. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False
  484. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  485. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  486. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  487. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  488. End With : myExcel.Application.PrintCommunication = True
  489. End Sub
  490. End Class