説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

營運成本收支單一覽表.vb 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.IO
  4. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  5. Imports Microsoft.Office.Interop.Excel.Constants
  6. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  7. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  8. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  9. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  10. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  11. Imports Microsoft.Office.Interop.Excel.XlWindowState
  12. Imports Microsoft.Office.Interop.Excel
  13. Public Class 營運成本收支單一覽表
  14. ReadOnly conn As New SqlConnection
  15. ReadOnly da As New SqlDataAdapter
  16. ReadOnly cmd As New SqlCommand
  17. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet
  18. Dim dr As SqlDataReader
  19. Dim DTP As String : Dim N1 As Integer : Dim N2 As Integer
  20. Dim xlApp As Application
  21. Dim xlBook As Workbook
  22. Dim xlSheet As Worksheet
  23. Private Sub Set_清單1()
  24. DataGridView4.DataSource = Nothing : ds1.Clear()
  25. DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  26. DataGridView4.ColumnHeadersHeight = 25
  27. DataGridView4.AllowUserToAddRows = False
  28. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  29. SQL1 = "SELECT 支付單號 AS 收支單號, 申請人, 申請日期, 審核人, 審核日期, 核准圖檔, 簽名編碼 FROM 公帳控制表
  30. WHERE (審核人 NOT LIKE '') AND (審核人 NOT LIKE '作廢%') AND
  31. 審核日期 BETWEEN '" & Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd") & "' AND '" & Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd") & "'
  32. ORDER BY 審核日期 DESC"
  33. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : DataGridView4.DataSource = ds1.Tables(0) : conn.Close()
  34. DataGridView4.Columns(0).FillWeight = 160 : DataGridView4.Columns(1).Visible = False : DataGridView4.Columns(2).FillWeight = 100 : DataGridView4.Columns(3).Visible = False
  35. DataGridView4.Columns(4).FillWeight = 100 : DataGridView4.Columns(5).Visible = False : DataGridView4.Columns(6).Visible = False
  36. End Sub
  37. Private Sub Set_清單2()
  38. DataGridView2.DataSource = Nothing : ds2.Clear()
  39. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  40. DataGridView2.ColumnHeadersHeight = 25
  41. DataGridView2.AllowUserToAddRows = False
  42. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  43. SQL1 = "SELECT LEFT(公帳控制表.審核日期, 7) AS 日期, 會計科目.第一階 AS 主項, 會計科目.第二階 AS 子項,
  44. 會計科目.會計科目 AS 子細項, SUM(公帳流水帳.零用金) AS 零用金, SUM(公帳流水帳.支票數)
  45. AS 支票, SUM(Cast(公帳流水帳.收入 AS money)) AS 現金, SUM(Cast(公帳流水帳.支出 AS money)) AS 支出, 公帳流水帳.銀行 AS 幣別, 公帳流水帳.匯率
  46. FROM 公帳控制表 RIGHT OUTER JOIN
  47. 公帳流水帳 ON 公帳控制表.支付單號 = 公帳流水帳.支付單號 RIGHT OUTER JOIN
  48. 會計科目 ON 公帳流水帳.類別 = 會計科目.編號
  49. WHERE (公帳控制表.審核日期 BETWEEN '" & Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd") & "' AND '" & Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd") & "')
  50. GROUP BY 會計科目.第一階, 會計科目.第二階, 會計科目.會計科目, LEFT(會計科目.編號, 7),
  51. LEFT(公帳控制表.審核日期, 7), 公帳流水帳.銀行, 公帳流水帳.匯率
  52. ORDER BY 幣別, LEFT(公帳控制表.審核日期, 7), LEFT(會計科目.編號, 7)"
  53. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView2.DataSource = ds2.Tables(0) : conn.Close()
  54. DataGridView2.Columns(0).FillWeight = 100 : DataGridView2.Columns(1).FillWeight = 140 : DataGridView2.Columns(2).FillWeight = 140 : DataGridView2.Columns(3).FillWeight = 140
  55. DataGridView2.Columns(4).FillWeight = 100 : DataGridView2.Columns(5).FillWeight = 100 : DataGridView2.Columns(6).FillWeight = 100 : DataGridView2.Columns(7).FillWeight = 100
  56. DataGridView2.Columns(8).FillWeight = 100 : DataGridView2.Columns(9).FillWeight = 100
  57. DataGridView2.Columns(6).DefaultCellStyle.Format = "#,##0.00" : DataGridView2.Columns(7).DefaultCellStyle.Format = "#,##0.00" : DataGridView2.Columns(4).DefaultCellStyle.Format = "#,##0.00"
  58. DataGridView2.Columns(5).DefaultCellStyle.Format = "#,##0.00"
  59. DataGridView2.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView2.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  60. DataGridView2.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView2.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  61. DataGridView2.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView2.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  62. DataGridView2.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView2.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  63. DataGridView2.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView2.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  64. DataGridView2.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView2.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  65. DataGridView2.Columns(0).ReadOnly = True : DataGridView2.Columns(1).ReadOnly = True : DataGridView2.Columns(2).ReadOnly = True : DataGridView2.Columns(3).ReadOnly = True
  66. DataGridView2.Columns(4).ReadOnly = True : DataGridView2.Columns(5).ReadOnly = True : DataGridView2.Columns(6).ReadOnly = True : DataGridView2.Columns(7).ReadOnly = True
  67. End Sub
  68. Private Sub Set_費用清單()
  69. 明細_dgv.DataSource = Nothing : ds.Clear()
  70. 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  71. 明細_dgv.ColumnHeadersHeight = 25
  72. 明細_dgv.AllowUserToAddRows = False
  73. 明細_dgv.RowTemplate.Height = 35
  74. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  75. SQL1 = "SELECT 公帳流水帳.支付單號, 公帳流水帳.項次, 會計科目.會計科目, 公帳流水帳.明細 AS 用途,
  76. Cast(公帳流水帳.零用金 AS money) AS 零用金, Cast(公帳流水帳.支票數 AS money) AS 支票, Cast(公帳流水帳.收入 AS money) AS 現金,
  77. Cast(公帳流水帳.支出 AS money) AS 支出, 公帳流水帳.備註 AS 票期, 公帳流水帳.匯率, 公帳流水帳.銀行 AS 幣別, 公帳流水帳.類別, 公帳流水帳.流水號
  78. FROM 公帳流水帳 INNER JOIN
  79. 會計科目 ON 公帳流水帳.類別 = 會計科目.編號
  80. WHERE (公帳流水帳.支付單號 LIKE '" & TextBox1.Text & "')
  81. ORDER BY 公帳流水帳.項次"
  82. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : 明細_dgv.DataSource = ds.Tables(0) : conn.Close()
  83. 明細_dgv.Columns(0).Visible = False : 明細_dgv.Columns(1).FillWeight = 80 : 明細_dgv.Columns(2).FillWeight = 300 : 明細_dgv.Columns(3).FillWeight = 500
  84. 明細_dgv.Columns(4).FillWeight = 140 : 明細_dgv.Columns(5).FillWeight = 140 : 明細_dgv.Columns(6).FillWeight = 140 : 明細_dgv.Columns(7).FillWeight = 140
  85. 明細_dgv.Columns(8).FillWeight = 140 : 明細_dgv.Columns(9).FillWeight = 140 : 明細_dgv.Columns(10).FillWeight = 140 : 明細_dgv.Columns(11).Visible = False
  86. 明細_dgv.Columns(12).Visible = False
  87. 明細_dgv.Columns(1).ReadOnly = True : 明細_dgv.Columns(2).ReadOnly = True : 明細_dgv.Columns(9).ReadOnly = True : 明細_dgv.Columns(10).ReadOnly = True
  88. 明細_dgv.Columns(4).DefaultCellStyle.Format = "#,##0.00" : 明細_dgv.Columns(5).DefaultCellStyle.Format = "#,##0.00" : 明細_dgv.Columns(6).DefaultCellStyle.Format = "#,##0.00"
  89. 明細_dgv.Columns(7).DefaultCellStyle.Format = "#,##0.00"
  90. 明細_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  91. 明細_dgv.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  92. 明細_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  93. 明細_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  94. 明細_dgv.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  95. 明細_dgv.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  96. 明細_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  97. 明細_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  98. TextBox5.Text = "0.00" : TextBox7.Text = "0.00" : TextBox6.Text = "0.00" : TextBox10.Text = "0.00" : TextBox11.Text = "0.00"
  99. TextBox2.Text = "0.00" : TextBox8.Text = "0.00" : TextBox15.Text = "0.00" : TextBox12.Text = "0.00" : TextBox9.Text = "0.00"
  100. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  101. If 明細_dgv.Rows(i).Cells("幣別").Value = "台幣現金" Then
  102. TextBox5.Text = Val(TextBox5.Text) + 明細_dgv.Rows(i).Cells("現金").Value
  103. TextBox7.Text = Val(TextBox7.Text) + 明細_dgv.Rows(i).Cells("支出").Value
  104. TextBox10.Text = Val(TextBox10.Text) + 明細_dgv.Rows(i).Cells("零用金").Value
  105. TextBox11.Text = Val(TextBox11.Text) + 明細_dgv.Rows(i).Cells("支票").Value
  106. End If
  107. If 明細_dgv.Rows(i).Cells("幣別").Value = "人民幣現金" Then
  108. TextBox15.Text = Val(TextBox15.Text) + 明細_dgv.Rows(i).Cells("現金").Value
  109. TextBox12.Text = Val(TextBox12.Text) + 明細_dgv.Rows(i).Cells("支出").Value
  110. TextBox2.Text = Val(TextBox2.Text) + 明細_dgv.Rows(i).Cells("零用金").Value
  111. TextBox8.Text = Val(TextBox8.Text) + 明細_dgv.Rows(i).Cells("支票").Value
  112. End If
  113. Next i
  114. TextBox6.Text = Val(TextBox10.Text) + Val(TextBox5.Text) - Val(TextBox7.Text) : TextBox9.Text = Val(TextBox2.Text) + Val(TextBox15.Text) - Val(TextBox12.Text)
  115. If Val(TextBox6.Text) > 0 Then : TextBox6.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  116. If Val(TextBox9.Text) > 0 Then : TextBox9.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  117. TextBox5.Text = Strings.Format(Val(TextBox5.Text), "#,##0.00") : TextBox7.Text = Strings.Format(Val(TextBox7.Text), "#,##0.00") : TextBox6.Text = Strings.Format(Val(TextBox6.Text), "#,##0.00")
  118. TextBox10.Text = Strings.Format(Val(TextBox10.Text), "#,##0.00") : TextBox11.Text = Strings.Format(Val(TextBox11.Text), "#,##0.00")
  119. TextBox2.Text = Strings.Format(Val(TextBox2.Text), "#,##0.00") : TextBox8.Text = Strings.Format(Val(TextBox8.Text), "#,##0.00") : TextBox15.Text = Strings.Format(Val(TextBox15.Text), "#,##0.00")
  120. TextBox12.Text = Strings.Format(Val(TextBox12.Text), "#,##0.00") : TextBox9.Text = Strings.Format(Val(TextBox9.Text), "#,##0.00")
  121. End Sub
  122. Private Sub 日期格式()
  123. If 會計月_ch.Checked = True Then
  124. '-------------日期一----------------------------------------------------------------------------------------
  125. DTP = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 8) & "01" : 開始日期_dtp.Value = DTP
  126. 開始日期_dtp.Value = 開始日期_dtp.Value.AddMonths(-1)
  127. DTP = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 8) & "26" : 開始日期_dtp.Value = DTP
  128. '-------------日期二----------------------------------------------------------------------------------------
  129. DTP = Strings.Left(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 8) & "25" : 結束日期_dtp.Value = DTP
  130. Else
  131. '-------------日期一----------------------------------------------------------------------------------------
  132. 開始日期_dtp.Value = 開始日期_dtp.Value.AddMonths(1)
  133. DTP = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 8) & "01" : 開始日期_dtp.Value = DTP
  134. '-------------日期二----------------------------------------------------------------------------------------
  135. DTP = Strings.Left(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 8) & "01" : 結束日期_dtp.Value = DTP
  136. 結束日期_dtp.Value = 結束日期_dtp.Value.AddMonths(1) : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(-1)
  137. End If
  138. End Sub
  139. Private Sub 營運費用支付單一覽表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  140. Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  141. DTP = Strings.Left(Strings.Format(Today(), "yyyy/MM/dd"), 8) & "01"
  142. 開始日期_dtp.Value = DTP : 結束日期_dtp.Value = Today()
  143. 日期格式() : DataGridView2.Visible = False : RadioButton1.Checked = True
  144. End Sub
  145. Private Sub DataGridView4_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView4.CellClick
  146. If e.RowIndex = -1 Then : Else
  147. TextBox1.Text = DataGridView4(0, e.RowIndex).Value.ToString : TextBox13.Text = DataGridView4(6, e.RowIndex).Value.ToString
  148. TextBox3.Text = DataGridView4(1, e.RowIndex).Value.ToString : DateTimePicker1.Value = DataGridView4(2, e.RowIndex).Value.ToString
  149. TextBox4.Text = DataGridView4(3, e.RowIndex).Value.ToString : DateTimePicker2.Value = DataGridView4(4, e.RowIndex).Value.ToString
  150. TextBox14.Text = DataGridView4(5, e.RowIndex).Value.ToString
  151. Set_費用清單()
  152. End If
  153. End Sub
  154. Private Sub DataGridView2_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView2.RowPostPaint
  155. Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) : Dim linePen2 As New Pen(Color.Green, 2)
  156. If e.RowIndex = DataGridView2.Rows.Count - 1 Then
  157. Exit Sub
  158. Else
  159. If DataGridView2(0, e.RowIndex).Value.ToString <> DataGridView2(0, e.RowIndex + 1).Value.ToString Then
  160. Dim startX As Integer = IIf(DataGridView2.RowHeadersVisible, DataGridView2.RowHeadersWidth, 0)
  161. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  162. Dim endX As Integer = startX + DataGridView2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView2.HorizontalScrollingOffset
  163. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  164. Exit Sub
  165. End If
  166. If DataGridView2(8, e.RowIndex).Value.ToString <> DataGridView2(8, e.RowIndex + 1).Value.ToString Then
  167. Dim startX As Integer = IIf(DataGridView2.RowHeadersVisible, DataGridView2.RowHeadersWidth, 0)
  168. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  169. Dim endX As Integer = startX + DataGridView2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView2.HorizontalScrollingOffset
  170. e.Graphics.DrawLine(linePen2, startX, startY, endX, startY)
  171. Exit Sub
  172. End If
  173. If DataGridView2(1, e.RowIndex).Value.ToString <> DataGridView2(1, e.RowIndex + 1).Value.ToString Then
  174. Dim startX As Integer = IIf(DataGridView2.RowHeadersVisible, DataGridView2.RowHeadersWidth, 0)
  175. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  176. Dim endX As Integer = startX + DataGridView2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView2.HorizontalScrollingOffset
  177. e.Graphics.DrawLine(linePen1, startX, startY, endX, startY)
  178. Exit Sub
  179. End If
  180. End If
  181. End Sub
  182. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  183. DTP = Strings.Format(Today(), "yyyy/MM/dd")
  184. 開始日期_dtp.Value = DTP : 結束日期_dtp.Value = DTP
  185. End Sub
  186. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  187. DTP = Strings.Left(Strings.Format(Today(), "yyyy/MM/dd"), 8) & "01"
  188. 開始日期_dtp.Value = DTP : 結束日期_dtp.Value = Today()
  189. End Sub
  190. Private Sub 彙總計算()
  191. If RadioButton1.Checked = False And RadioButton2.Checked = True Then
  192. TextBox5.Text = "0.00" : TextBox7.Text = "0.00" : TextBox6.Text = "0.00" : TextBox10.Text = "0.00" : TextBox11.Text = "0.00"
  193. TextBox2.Text = "0.00" : TextBox8.Text = "0.00" : TextBox15.Text = "0.00" : TextBox12.Text = "0.00" : TextBox9.Text = "0.00"
  194. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  195. If DataGridView2.Rows(i).Cells("幣別").Value = "台幣現金" Then
  196. TextBox5.Text = Val(TextBox5.Text) + DataGridView2.Rows(i).Cells("現金").Value
  197. TextBox7.Text = Val(TextBox7.Text) + DataGridView2.Rows(i).Cells("支出").Value
  198. TextBox10.Text = Val(TextBox10.Text) + DataGridView2.Rows(i).Cells("零用金").Value
  199. TextBox11.Text = Val(TextBox11.Text) + DataGridView2.Rows(i).Cells("支票").Value
  200. End If
  201. If DataGridView2.Rows(i).Cells("幣別").Value = "人民幣現金" Then
  202. If DataGridView2.Rows(i).Cells("主項").Value <> "上月結存" Then
  203. TextBox15.Text = Val(TextBox15.Text) + DataGridView2.Rows(i).Cells("現金").Value
  204. TextBox12.Text = Val(TextBox12.Text) + DataGridView2.Rows(i).Cells("支出").Value
  205. TextBox2.Text = Val(TextBox2.Text) + DataGridView2.Rows(i).Cells("零用金").Value
  206. TextBox8.Text = Val(TextBox8.Text) + DataGridView2.Rows(i).Cells("支票").Value
  207. End If
  208. End If
  209. Next i
  210. TextBox6.Text = Val(TextBox10.Text) + Val(TextBox5.Text) - Val(TextBox7.Text) : TextBox9.Text = Val(TextBox2.Text) + Val(TextBox15.Text) - Val(TextBox12.Text)
  211. If Val(TextBox6.Text) > 0 Then : TextBox6.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  212. If Val(TextBox9.Text) > 0 Then : TextBox9.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  213. TextBox5.Text = Strings.Format(Val(TextBox5.Text), "#,##0.00") : TextBox7.Text = Strings.Format(Val(TextBox7.Text), "#,##0.00") : TextBox6.Text = Strings.Format(Val(TextBox6.Text), "#,##0.00")
  214. TextBox10.Text = Strings.Format(Val(TextBox10.Text), "#,##0.00") : TextBox11.Text = Strings.Format(Val(TextBox11.Text), "#,##0.00")
  215. TextBox2.Text = Strings.Format(Val(TextBox2.Text), "#,##0.00") : TextBox8.Text = Strings.Format(Val(TextBox8.Text), "#,##0.00") : TextBox15.Text = Strings.Format(Val(TextBox15.Text), "#,##0.00")
  216. TextBox12.Text = Strings.Format(Val(TextBox12.Text), "#,##0.00") : TextBox9.Text = Strings.Format(Val(TextBox9.Text), "#,##0.00")
  217. End If
  218. End Sub
  219. Private Sub 上個月_bt_Click(sender As Object, e As EventArgs) Handles 上個月_bt.Click
  220. If 會計月_ch.Checked = True Then
  221. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
  222. 開始日期_dtp.Value = 中間日期_dtp.Value
  223. 結束日期_dtp.Value = 中間日期_dtp.Value
  224. Else
  225. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
  226. 開始日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
  227. 結束日期_dtp.Value = 中間日期_dtp.Value
  228. End If
  229. 日期格式()
  230. End Sub
  231. Private Sub 下個月_bt_Click(sender As Object, e As EventArgs) Handles 下個月_bt.Click
  232. If 會計月_ch.Checked = True Then
  233. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(1)
  234. 開始日期_dtp.Value = 中間日期_dtp.Value
  235. 結束日期_dtp.Value = 中間日期_dtp.Value
  236. Else
  237. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(1)
  238. 開始日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
  239. 結束日期_dtp.Value = 中間日期_dtp.Value
  240. End If
  241. 日期格式()
  242. End Sub
  243. Private Sub DateTimePicker4_ValueChanged(sender As Object, e As EventArgs) Handles 開始日期_dtp.ValueChanged
  244. Set_清單1() : Set_清單2() : 彙總計算()
  245. End Sub
  246. Private Sub DateTimePicker3_ValueChanged(sender As Object, e As EventArgs) Handles 結束日期_dtp.ValueChanged
  247. Set_清單1() : Set_清單2() : 彙總計算()
  248. End Sub
  249. Private Sub 會計月_CheckedChanged(sender As Object, e As EventArgs) Handles 會計月_ch.Click
  250. 會計月_ch.Checked = True : 一般月_ch.Checked = False : 日期格式()
  251. End Sub
  252. Private Sub 一般月_CheckedChanged(sender As Object, e As EventArgs) Handles 一般月_ch.Click
  253. 會計月_ch.Checked = False : 一般月_ch.Checked = True : 日期格式()
  254. End Sub
  255. Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.Click
  256. 明細_dgv.Visible = True : DataGridView2.Visible = False : RadioButton1.Checked = True : RadioButton2.Checked = False
  257. TextBox5.Text = "0.00" : TextBox7.Text = "0.00" : TextBox6.Text = "0.00" : TextBox10.Text = "0.00" : TextBox11.Text = "0.00" : DataGridView4.Enabled = True
  258. End Sub
  259. Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.Click
  260. 明細_dgv.Visible = False : DataGridView2.Visible = True : RadioButton1.Checked = False : RadioButton2.Checked = True
  261. TextBox1.Text = "" : TextBox3.Text = "" : TextBox4.Text = "" : 明細_dgv.DataSource = Nothing : ds.Clear() : DataGridView4.Enabled = False
  262. 彙總計算()
  263. End Sub
  264. Private Sub TextBox14_TextChanged(sender As Object, e As EventArgs) Handles TextBox14.TextChanged
  265. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  266. SQL1 = "SELECT 簽名檔圖片 FROM GCM主管簽名檔管理 WHERE 圖片流水號 LIKE '" & TextBox14.Text & "'"
  267. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  268. While dr.Read() = True
  269. Dim unused As Byte() = New Byte(-1) {}
  270. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  271. Dim oStream As New MemoryStream(bytes)
  272. PictureBox1.Image = Bitmap.FromStream(oStream)
  273. End While
  274. conn.Close()
  275. PictureBox1.SizeMode = 4
  276. End Sub
  277. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  278. xlApp = CType(CreateObject("Excel.Application"), Application)
  279. xlBook = xlApp.Workbooks.Add
  280. xlApp.DisplayAlerts = True
  281. xlBook.Activate()
  282. xlSheet = NewMethod(xlBook)
  283. xlSheet.Activate()
  284. xlApp.Visible = True
  285. xlApp.Application.WindowState = xlMaximized
  286. xlSheet.Cells(1, 1) = "年度" : xlSheet.Cells(1, 2) = Year(Today) - 1911
  287. If RadioButton1.Checked = True And RadioButton2.Checked = False Then
  288. xlSheet.Cells(1, 3) = "工巧明智能企業有限公司-營運費用收支明細表"
  289. xlSheet.Cells(2, 1) = "收款日期" : xlSheet.Cells(2, 2) = "會計科目" : xlSheet.Cells(2, 3) = "客戶或用途"
  290. xlSheet.Cells(2, 4) = "零用金" : xlSheet.Cells(2, 5) = "支票" : xlSheet.Cells(2, 6) = "現金" : xlSheet.Cells(2, 7) = "支出" : xlSheet.Cells(2, 8) = "現金餘額" : xlSheet.Cells(2, 9) = "票期"
  291. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  292. xlSheet.Cells(i + 3, 1) = DateTimePicker1.Value : xlSheet.Cells(i + 3, 2) = 明細_dgv.Rows(i).Cells("會計科目").Value
  293. xlSheet.Cells(i + 3, 3) = 明細_dgv.Rows(i).Cells("用途").Value : xlSheet.Cells(i + 3, 4) = 明細_dgv.Rows(i).Cells("零用金").Value
  294. xlSheet.Cells(i + 3, 5) = 明細_dgv.Rows(i).Cells("支票").Value : xlSheet.Cells(i + 3, 6) = 明細_dgv.Rows(i).Cells("現金").Value
  295. xlSheet.Cells(i + 3, 7) = 明細_dgv.Rows(i).Cells("支出").Value : xlSheet.Cells(i + 3, 9) = 明細_dgv.Rows(i).Cells("票期").Value
  296. If i = 0 Then
  297. xlSheet.Cells(i + 3, 8) = "=D3+F3-G3"
  298. Else
  299. xlSheet.Cells(i + 3, 8) = "=H" & i + 2 & "+D" & i + 3 & "+F" & i + 3 & "-G" & i + 3 & ""
  300. End If
  301. With xlApp.Selection
  302. .Font.Bold = True
  303. End With
  304. N1 = i + 3 : N2 = i + 3
  305. Next i
  306. xlSheet.Cells(N1 + 1, 3) = "以下空白" : xlSheet.Cells(N1 + 3, 1) = "簽核(點交)" : xlSheet.Cells(N1 + 3, 7) = "製表 : " & TextBox3.Text & " - " & DateTimePicker1.Value
  307. xlSheet.Cells(N1 + 2, 4) = "=SUM(D3:D" & N1 + 1 & ")" : xlSheet.Cells(N1 + 2, 5) = "=SUM(E3:E" & N1 + 1 & ")" : xlSheet.Cells(N1 + 2, 6) = "=SUM(F3:F" & N1 + 1 & ")"
  308. xlSheet.Cells(N1 + 2, 7) = "=SUM(G3:G" & N1 + 1 & ")" : xlSheet.Cells(N1 + 2, 8) = "=H" & N1 : xlSheet.Cells(N1 + 2, 1) = "合計"
  309. AA(xlApp, xlSheet) : BB(xlApp, xlSheet)
  310. ElseIf RadioButton1.Checked = False And RadioButton2.Checked = True Then
  311. xlSheet.Cells(1, 3) = "工巧明智能企業有限公司-營運費用收支彙總簡表"
  312. xlSheet.Cells(2, 1) = "日期" : xlSheet.Cells(2, 2) = "主項" : xlSheet.Cells(2, 3) = "子項" : xlSheet.Cells(2, 4) = "子細項" : xlSheet.Cells(2, 5) = "零用金"
  313. xlSheet.Cells(2, 6) = "支票" : xlSheet.Cells(2, 7) = "現金" : xlSheet.Cells(2, 8) = "支出" : xlSheet.Cells(2, 9) = "現金餘額"
  314. For i As Integer = 0 To DataGridView2.Rows.Count - 1
  315. xlSheet.Cells(i + 3, 1) = DataGridView2.Rows(i).Cells("日期").Value
  316. xlSheet.Cells(i + 3, 2) = DataGridView2.Rows(i).Cells("主項").Value
  317. xlSheet.Cells(i + 3, 3) = DataGridView2.Rows(i).Cells("子項").Value
  318. xlSheet.Cells(i + 3, 4) = DataGridView2.Rows(i).Cells("子細項").Value
  319. xlSheet.Cells(i + 3, 5) = DataGridView2.Rows(i).Cells("零用金").Value
  320. xlSheet.Cells(i + 3, 6) = DataGridView2.Rows(i).Cells("支票").Value
  321. xlSheet.Cells(i + 3, 7) = DataGridView2.Rows(i).Cells("現金").Value
  322. xlSheet.Cells(i + 3, 8) = DataGridView2.Rows(i).Cells("支出").Value
  323. If i = 0 Then
  324. xlSheet.Cells(i + 3, 9) = "=E3+G3-H3"
  325. Else
  326. xlSheet.Cells(i + 3, 9) = "=I" & i + 2 & "+E" & i + 3 & "+G" & i + 3 & "-H" & i + 3 & ""
  327. End If
  328. With xlApp.Selection
  329. .Font.Bold = True
  330. End With
  331. N1 = i + 3 : N2 = i + 3
  332. Next i
  333. xlSheet.Cells(N1 + 1, 2) = "以下空白" : xlSheet.Cells(N1 + 3, 1) = "簽核" : xlSheet.Cells(N1 + 3, 5) = "製表 : " & gUserName & " - " & Today()
  334. xlSheet.Cells(N1 + 2, 5) = "=SUM(E3:E" & N1 + 1 & ")" : xlSheet.Cells(N1 + 2, 6) = "=SUM(F3:F" & N1 + 1 & ")" : xlSheet.Cells(N1 + 2, 7) = "=SUM(G3:G" & N1 + 1 & ")"
  335. xlSheet.Cells(N1 + 2, 8) = "=SUM(H3:H" & N1 + 1 & ")" : xlSheet.Cells(N1 + 2, 9) = "=I" & N1 : xlSheet.Cells(N1 + 2, 1) = "合計"
  336. CC(xlApp, xlSheet)
  337. End If
  338. xlSheet.PageSetup.PrintArea = ""
  339. xlApp.Cells.Select()
  340. xlSheet.Range("B1").Select()
  341. xlApp.Application.WindowState = xlMinimized
  342. xlSheet.Cells.Select()
  343. xlApp.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="0911274990")
  344. xlApp.ActiveSheet.EnableSelection = 1
  345. MsgBox("列印完成。")
  346. End Sub
  347. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  348. Return CType(xlBook.Worksheets.Add, Worksheet)
  349. End Function
  350. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  351. xlSheet.Cells.Select()
  352. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  353. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  354. End With
  355. xlSheet.Columns("A:A").Select : myExcel.Selection.NumberFormatLocal = "m/d;@"
  356. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  357. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  358. End With
  359. xlSheet.Range("B1").Select()
  360. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  361. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  362. End With
  363. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 25
  364. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 30
  365. xlSheet.Columns("D:H").Select : myExcel.Selection.ColumnWidth = 10 : myExcel.Selection.NumberFormatLocal = "#,##0;[紅色]-#,##0"
  366. xlSheet.Columns("I:I").Select : myExcel.Selection.ColumnWidth = 10 : myExcel.Selection.NumberFormatLocal = "[$-zh-TW]e/m/d;@"
  367. xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 25
  368. xlSheet.Range("A2:I2").Select()
  369. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  370. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  371. End With
  372. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  373. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  374. End With
  375. xlSheet.Range("A2:I" & N1 + 2).Select() : myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  376. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  377. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  378. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  379. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  380. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  381. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  382. myExcel.ActiveWindow.DisplayGridlines = False
  383. xlSheet.Rows("3:" & N1 + 2).Select : myExcel.Selection.RowHeight = 20
  384. xlSheet.Rows(N1 + 3 & ":" & N1 + 3).Select : myExcel.Selection.RowHeight = 40
  385. xlSheet.Columns("I:I").Select
  386. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  387. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  388. End With
  389. xlSheet.Range("A" & N1 + 2 & ":C" & N1 + 2).Select() : 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
  392. End With
  393. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 25
  394. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 14 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  395. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  396. End With
  397. End Sub
  398. Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  399. Clipboard.SetDataObject(PictureBox1.Image)
  400. xlSheet.Range("B" & N2 + 3).Select()
  401. myExcel.ActiveSheet.Pictures.Paste.Select
  402. myExcel.Selection.ShapeRange.Height = 43
  403. myExcel.Selection.ShapeRange.IncrementTop(3)
  404. End Sub
  405. Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  406. xlSheet.Cells.Select()
  407. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  408. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  409. End With
  410. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 8
  411. xlSheet.Columns("B:C").Select : myExcel.Selection.ColumnWidth = 15
  412. xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 20
  413. xlSheet.Columns("E:I").Select : myExcel.Selection.ColumnWidth = 10 : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  414. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 25
  415. xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 25
  416. xlSheet.Rows("3:" & N1 + 2).Select : myExcel.Selection.RowHeight = 20
  417. xlSheet.Rows(N1 + 3 & ":" & N1 + 3).Select : myExcel.Selection.RowHeight = 40
  418. xlSheet.Rows("2:2").Select
  419. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  420. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  421. End With
  422. xlSheet.Range("A1").Select()
  423. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  424. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  425. End With
  426. xlSheet.Range("B1").Select()
  427. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  428. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  429. End With
  430. xlSheet.Rows("1:1").Select
  431. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  432. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  433. End With
  434. xlSheet.Range("A2:I" & N1 + 2).Select() : myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  435. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  436. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  437. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  438. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  439. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  440. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  441. xlSheet.Range("A" & N1 + 2 & ":D" & N1 + 2).Select() : myExcel.Selection.Merge
  442. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  443. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True
  444. End With
  445. xlSheet.Columns("E:I").Select : myExcel.Selection.NumberFormatLocal = "#,##0.00;[紅色]-#,##0.00"
  446. myExcel.ActiveWindow.DisplayGridlines = False
  447. End Sub
  448. '----------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------------------------------------
  449. Private Sub 重新讀取ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新讀取ToolStripMenuItem.Click
  450. Set_清單1() : Set_清單2() : 彙總計算()
  451. End Sub
  452. End Class