Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

財務_對帳表.vb 41KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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 System.Data.SqlClient
  11. Public Class 財務_對帳表
  12. ReadOnly conn1 As New SqlConnection
  13. ReadOnly cmd As New SqlCommand : ReadOnly cmd1 As New SqlCommand
  14. ReadOnly ds, ds1, ds2 As New DataSet
  15. Dim N2 As Integer
  16. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  17. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  18. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  19. Dim 位置1 As String
  20. Private Sub Set_清單1()
  21. 明細_dgv.DataSource = Nothing : ds.Clear()
  22. 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  23. 明細_dgv.ColumnHeadersHeight = 25
  24. 明細_dgv.AllowUserToAddRows = False
  25. 明細_dgv.RowTemplate.Height = 30
  26. If 只有收入_cb.Checked = False And 只有支出_cb.Checked = False Then : SQL3 = ""
  27. ElseIf 只有收入_cb.Checked = True And 只有支出_cb.Checked = False Then : SQL3 = " AND (Cast(公帳流水帳.支出 AS money) = 0)"
  28. ElseIf 只有收入_cb.Checked = False And 只有支出_cb.Checked = True Then : SQL3 = " AND (Cast(公帳流水帳.收入 AS money) = 0)" : End If
  29. If 全部_ch.Checked = True And 含稅_ch.Checked = False And 非稅_ch.Checked = False Then : SQL2 = "" & SQL3
  30. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = True And 非稅_ch.Checked = False Then : SQL2 = " AND (公帳流水帳.含稅 = 1)" & SQL3
  31. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = False And 非稅_ch.Checked = True Then : SQL2 = " AND (公帳流水帳.含稅 = 0 OR 公帳流水帳.含稅 IS NULL)" & SQL3 : End If
  32. If 公司編號_cb.Text = "全部" Or 公司編號_cb.Text = "" Then : PA51 = "" : Else : PA51 = " AND (公帳控制表.公司編號 LIKE N'" & 公司編號_cb.Text & "')" : End If
  33. SQL_營運成本收支單對帳表()
  34. da.Fill(ds) : 明細_dgv.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  35. If 視窗2_pl.Visible = True Then
  36. Set_特別計算() : 剃除預設() : 剃除計算()
  37. End If
  38. End Sub
  39. Private Sub Set_grid()
  40. 明細_dgv.Columns(0).FillWeight = 120 : 明細_dgv.Columns(1).FillWeight = 60 : 明細_dgv.Columns(2).FillWeight = 80 : 明細_dgv.Columns(3).FillWeight = 60
  41. 明細_dgv.Columns(4).FillWeight = 80 : 明細_dgv.Columns(5).FillWeight = 50 : 明細_dgv.Columns(6).FillWeight = 150 : 明細_dgv.Columns(7).FillWeight = 300
  42. 明細_dgv.Columns(8).FillWeight = 70 : 明細_dgv.Columns(9).FillWeight = 70 : 明細_dgv.Columns(10).FillWeight = 70 : 明細_dgv.Columns(11).FillWeight = 70
  43. 明細_dgv.Columns(12).FillWeight = 70 : 明細_dgv.Columns(13).FillWeight = 50 : 明細_dgv.Columns(14).FillWeight = 70 : 明細_dgv.Columns(15).FillWeight = 50
  44. 明細_dgv.Columns(16).FillWeight = 70 : 明細_dgv.Columns(17).Visible = False : 明細_dgv.Columns(18).Visible = False : 明細_dgv.Columns(19).Visible = False
  45. 明細_dgv.Columns(20).Visible = False : 明細_dgv.Columns(21).FillWeight = 50 : 明細_dgv.Columns(22).FillWeight = 50
  46. If 隱藏申請審核資訊_cb.Checked = False Then
  47. 明細_dgv.Columns(1).Visible = True : 明細_dgv.Columns(2).Visible = True : 明細_dgv.Columns(3).Visible = True : 明細_dgv.Columns(4).Visible = True
  48. Else
  49. 明細_dgv.Columns(1).Visible = False : 明細_dgv.Columns(2).Visible = False : 明細_dgv.Columns(3).Visible = False : 明細_dgv.Columns(4).Visible = False
  50. End If
  51. If 隱藏作帳點交資訊_cb.Checked = False Then
  52. 明細_dgv.Columns(13).Visible = True : 明細_dgv.Columns(14).Visible = True : 明細_dgv.Columns(15).Visible = True : 明細_dgv.Columns(16).Visible = True
  53. Else
  54. 明細_dgv.Columns(13).Visible = False : 明細_dgv.Columns(14).Visible = False : 明細_dgv.Columns(15).Visible = False : 明細_dgv.Columns(16).Visible = False
  55. End If
  56. 明細_dgv.Columns(8).Visible = False : 明細_dgv.Columns(9).Visible = False : 明細_dgv.Columns(21).Visible = False : 明細_dgv.Columns(22).Visible = False
  57. 明細_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(9).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(10).DefaultCellStyle.Format = "#,##0"
  58. 明細_dgv.Columns(11).DefaultCellStyle.Format = "#,##0"
  59. 明細_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  60. 明細_dgv.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  61. 明細_dgv.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  62. 明細_dgv.Columns(11).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(11).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  63. 明細_dgv.Columns(21).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(21).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  64. 明細_dgv.Columns(22).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(22).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  65. 支出1_tb.Text = "0" : 現金1_tb.Text = "0" : 損益1_tb.Text = "0" : 零用金1_tb.Text = "0" : 已兌現支票1_tb.Text = "0" : 未兌現支票1_tb.Text = "0"
  66. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  67. 現金1_tb.Text = Val(現金1_tb.Text) + 明細_dgv.Rows(i).Cells("收入").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  68. 支出1_tb.Text = Val(支出1_tb.Text) + 明細_dgv.Rows(i).Cells("支出").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  69. 零用金1_tb.Text = Val(零用金1_tb.Text) + 明細_dgv.Rows(i).Cells("零用金").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  70. If 明細_dgv(9, i).Value <> 0 And 明細_dgv(18, i).Value = True Then
  71. 已兌現支票1_tb.Text = Val(已兌現支票1_tb.Text) + 明細_dgv.Rows(i).Cells("支票").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  72. ElseIf 明細_dgv(9, i).Value <> 0 And 明細_dgv(18, i).Value = False Then
  73. 未兌現支票1_tb.Text = Val(未兌現支票1_tb.Text) + 明細_dgv.Rows(i).Cells("支票").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  74. End If
  75. If 明細_dgv("幣別", i).Value = "台幣現金" Then : 明細_dgv("幣別", i).Value = "台幣" : Else : 明細_dgv("幣別", i).Value = "人民幣" : End If
  76. Next i
  77. 損益1_tb.Text = Val(已兌現支票1_tb.Text) + Val(零用金1_tb.Text) + Val(現金1_tb.Text) - Val(支出1_tb.Text)
  78. If Val(損益1_tb.Text) > 0 Then : 損益1_tb.ForeColor = Color.Blue : Else : 損益1_tb.ForeColor = Color.Red : End If
  79. 支出1_tb.Text = Strings.Format(Val(支出1_tb.Text), "#,##0")
  80. 損益1_tb.Text = Strings.Format(Val(損益1_tb.Text), "#,##0")
  81. 現金1_tb.Text = Strings.Format(Val(現金1_tb.Text), "#,##0")
  82. 零用金1_tb.Text = Strings.Format(Val(零用金1_tb.Text), "#,##0")
  83. 已兌現支票1_tb.Text = Strings.Format(Val(已兌現支票1_tb.Text), "#,##0")
  84. 未兌現支票1_tb.Text = Strings.Format(Val(未兌現支票1_tb.Text), "#,##0")
  85. End Sub
  86. Private Sub ComboBox1下拉表單資料載入()
  87. conn.Close()
  88. SQL_營運成本收支單對帳表_查詢最後一筆年份清單() : 查詢日期_cb.Items.Clear()
  89. While (dr.Read()) : 查詢日期_cb.Items.Add(dr("年份")) : End While
  90. conn.Close()
  91. End Sub
  92. Private Sub 載入公司編號cb()
  93. SQL_公司編號_下拉清單() : 公司編號_cb.Items.Clear() : 公司編號_cb.Items.Add("全部")
  94. While (dr.Read()) : 公司編號_cb.Items.Add(dr("公司編號")) : End While : conn.Close()
  95. End Sub
  96. Private Sub 營運成本收支單_對帳表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  97. Me.MdiParent = ICS_ASMS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  98. 視窗2_pl.Visible = False : Panel1.SendToBack() : 載入公司編號cb()
  99. 現金_tb.Text = "0" : 支出_tb.Text = "0" : 損益_tb.Text = "0" : 零用金_tb.Text = "0" : 已兌現支票_tb.Text = "0" : 未兌現支票_tb.Text = "0"
  100. 現金1_tb.Text = "0" : 支出1_tb.Text = "0" : 損益1_tb.Text = "0" : 零用金1_tb.Text = "0" : 已兌現支票1_tb.Text = "0" : 未兌現支票1_tb.Text = "0"
  101. SQL_營運成本收支單對帳表_修改會計() : conn.Close() : SQL_營運成本收支單對帳表_修改出納() : conn.Close() : SQL_營運成本收支單對帳表_修改現金() : conn.Close()
  102. SQL_營運成本收支單對帳表_修改備用金() : conn.Close() : SQL_營運成本收支單對帳表_修改公帳() : conn.Close() : SQL_營運成本收支單對帳表_修改支票() : conn.Close()
  103. SQL_營運成本收支單對帳表_修改日期() : conn.Close() : SQL_營運成本收支單對帳表_修改出納日期() : conn.Close()
  104. ComboBox1下拉表單資料載入()
  105. 查詢日期_cb.Text = Year(Today) : 查詢日期1_cb.SelectedIndex = Month(Today) - 1
  106. PA20 = "" : PA19 = "" : PA18 = "" : PA17 = 查詢日期_cb.Text : PA16 = 查詢日期1_cb.Text
  107. PA20 = "AND (公帳控制表.申請日期 LIKE N'" & PA17 & "/" & PA16 & "%') "
  108. If ICS_ASMS_ERP_SYS.Size.Width > 1440 And ICS_ASMS_ERP_SYS.Size.Height > 900 Then : 字體_NUD.Value = 9 : 隱藏申請審核資訊_cb.Checked = False
  109. ElseIf ICS_ASMS_ERP_SYS.Size.Width <= 1440 And ICS_ASMS_ERP_SYS.Size.Height <= 900 Then : 字體_NUD.Value = 7.6 : 隱藏申請審核資訊_cb.Checked = True : End If
  110. If 公司 = True Then
  111. Else
  112. 公司編號_lb.Visible = False : 公司編號_cb.Visible = False
  113. End If
  114. End Sub
  115. Private Sub 營運成本收支單_對帳表_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
  116. If ICS_ASMS_ERP_SYS.Size.Width > 1440 And ICS_ASMS_ERP_SYS.Size.Height > 900 Then : 字體_NUD.Value = 9 : 隱藏申請審核資訊_cb.Checked = False
  117. ElseIf ICS_ASMS_ERP_SYS.Size.Width <= 1440 And ICS_ASMS_ERP_SYS.Size.Height <= 900 Then : 字體_NUD.Value = 7.6 : 隱藏申請審核資訊_cb.Checked = True : End If
  118. End Sub
  119. Dim 已超出 As Boolean
  120. Private Sub 明細_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 明細_dgv.MouseUp
  121. If 明細_dgv.SelectedCells.Count = 1 Then : 已超出 = False : End If
  122. If 明細_dgv.SelectedCells.Count > 0 Then
  123. If 明細_dgv.SelectedCells(0).ColumnIndex >= 8 And 明細_dgv.SelectedCells(0).ColumnIndex <= 11 Then
  124. If 已超出 = False Then
  125. Dim x As Double = 0
  126. For i As Integer = 0 To 明細_dgv.SelectedCells.Count - 1
  127. x += Val(明細_dgv.Rows(明細_dgv.SelectedCells.Item(i).RowIndex).Cells(明細_dgv.SelectedCells.Item(i).ColumnIndex).Value)
  128. Next i : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(x, "#,##0")
  129. Else : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0") : End If
  130. Else : 已超出 = True : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0")
  131. End If
  132. End If
  133. End Sub
  134. Private Sub 全部_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 全部_ch.Click
  135. 全部_ch.Checked = True : 含稅_ch.Checked = False : 非稅_ch.Checked = False : Set_清單1()
  136. End Sub
  137. Private Sub 含稅_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 含稅_ch.Click
  138. 全部_ch.Checked = False : 含稅_ch.Checked = True : 非稅_ch.Checked = False : Set_清單1()
  139. End Sub
  140. Private Sub 非稅_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 非稅_ch.Click
  141. 全部_ch.Checked = False : 含稅_ch.Checked = False : 非稅_ch.Checked = True : Set_清單1()
  142. End Sub
  143. Private Sub 清除查詢資料_bt_Click(sender As Object, e As EventArgs) Handles 清除查詢資料_bt.Click
  144. ComboBox1下拉表單資料載入()
  145. 查詢日期1_cb.Items.Clear()
  146. 查詢日期1_cb.Items.Add("01") : 查詢日期1_cb.Items.Add("02") : 查詢日期1_cb.Items.Add("03") : 查詢日期1_cb.Items.Add("04") : 查詢日期1_cb.Items.Add("05") : 查詢日期1_cb.Items.Add("06")
  147. 查詢日期1_cb.Items.Add("07") : 查詢日期1_cb.Items.Add("08") : 查詢日期1_cb.Items.Add("09") : 查詢日期1_cb.Items.Add("10") : 查詢日期1_cb.Items.Add("11") : 查詢日期1_cb.Items.Add("12")
  148. PA17 = "" : PA16 = "" : PA20 = ""
  149. 明細_dgv.DataSource = Nothing : ds.Clear()
  150. Set_清單1()
  151. End Sub
  152. Private Sub 對帳記錄存檔_bt_Click(sender As Object, e As EventArgs) Handles 對帳記錄存檔_bt.Click
  153. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  154. PA15 = 明細_dgv.Rows(i).Cells("現金點交").Value : PA14 = 明細_dgv.Rows(i).Cells("零用金點交").Value
  155. PA13 = 明細_dgv.Rows(i).Cells("支出點交").Value : PA12 = 明細_dgv.Rows(i).Cells("支票兌現").Value
  156. PA11 = 明細_dgv.Rows(i).Cells("收支單號").Value : PA10 = 明細_dgv.Rows(i).Cells("項次").Value
  157. 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條()
  158. SQL_營運成本收支單對帳表_修改對帳記錄存檔() : conn1.Close()
  159. Next
  160. MsgBox("存檔完成。") : Set_清單1() : ICS_ASMS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  161. End Sub
  162. Private Sub 總金額計算()
  163. Dim FFGG As Integer = 0 : Dim GGHH As Integer = 0 : Dim HHJJ As Integer = 0 : Dim JJKK As Integer = 0 : Dim KKLL As Integer = 0
  164. 現金_tb.Text = "0" : 支出_tb.Text = "0" : 損益_tb.Text = "0" : 零用金_tb.Text = "0" : 已兌現支票_tb.Text = "0" : 未兌現支票_tb.Text = "0"
  165. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  166. If 明細_dgv.Rows(i).Cells("收支單號").Value = 收支單號_tb.Text Then
  167. FFGG = Val(FFGG) + 明細_dgv.Rows(i).Cells("收入").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  168. GGHH = Val(GGHH) + 明細_dgv.Rows(i).Cells("支出").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  169. HHJJ = Val(HHJJ) + 明細_dgv.Rows(i).Cells("零用金").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  170. If 明細_dgv(9, i).Value <> 0 And 明細_dgv(18, i).Value = True Then
  171. JJKK = Val(JJKK) + 明細_dgv.Rows(i).Cells("支票").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  172. ElseIf 明細_dgv(9, i).Value <> 0 And 明細_dgv(18, i).Value = False Then
  173. KKLL = Val(KKLL) + 明細_dgv.Rows(i).Cells("支票").Value * 明細_dgv.Rows(i).Cells("匯率").Value
  174. End If
  175. End If
  176. Next i
  177. 現金_tb.Text = FFGG : 支出_tb.Text = GGHH : 零用金_tb.Text = HHJJ : 已兌現支票_tb.Text = JJKK : 未兌現支票_tb.Text = KKLL
  178. 損益_tb.Text = JJKK + HHJJ + FFGG - GGHH
  179. If Val(損益_tb.Text) > 0 Then : 損益_tb.ForeColor = Color.Blue : Else : 損益_tb.ForeColor = Color.Red : End If
  180. 現金_tb.Text = Strings.Format(Val(現金_tb.Text), "#,##0") : 支出_tb.Text = Strings.Format(Val(支出_tb.Text), "#,##0") : 損益_tb.Text = Strings.Format(Val(損益_tb.Text), "#,##0")
  181. 零用金_tb.Text = Strings.Format(Val(零用金_tb.Text), "#,##0")
  182. 已兌現支票_tb.Text = Strings.Format(Val(已兌現支票_tb.Text), "#,##0")
  183. 未兌現支票_tb.Text = Strings.Format(Val(未兌現支票_tb.Text), "#,##0")
  184. End Sub
  185. Private Sub 明細_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細_dgv.CellClick
  186. If e.RowIndex = -1 Then : Else
  187. 收支單號_tb.Text = 明細_dgv.Rows(e.RowIndex).Cells("收支單號").Value : 總金額計算()
  188. End If
  189. End Sub
  190. Private Sub 明細_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 明細_dgv.RowPostPaint
  191. Dim linePen As New Pen(Color.Blue, 2)
  192. If e.RowIndex = 明細_dgv.Rows.Count - 1 Then
  193. Exit Sub
  194. Else
  195. If 明細_dgv(0, e.RowIndex).Value.ToString <> 明細_dgv(0, e.RowIndex + 1).Value.ToString Then
  196. Dim startX As Integer = IIf(明細_dgv.RowHeadersVisible, 明細_dgv.RowHeadersWidth, 0)
  197. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  198. Dim endX As Integer = startX + 明細_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 明細_dgv.HorizontalScrollingOffset
  199. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  200. Exit Sub
  201. End If
  202. End If
  203. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  204. If 明細_dgv(9, i).Value <> 0 And 明細_dgv(18, i).Value = True Then
  205. 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
  206. ElseIf 明細_dgv(9, i).Value <> 0 And 明細_dgv(18, i).Value = False Then
  207. 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow
  208. End If
  209. Next
  210. End Sub
  211. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 查詢日期_cb.SelectedIndexChanged
  212. PA17 = 查詢日期_cb.Text
  213. If PA17 = "" Or PA16 = "" Then
  214. Else : PA20 = "AND (公帳控制表.申請日期 LIKE N'" & PA17 & "/" & PA16 & "%') " : Set_清單1()
  215. End If
  216. End Sub
  217. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 查詢日期1_cb.SelectedIndexChanged
  218. PA16 = 查詢日期1_cb.Text
  219. If PA17 = "" Or PA16 = "" Then
  220. Else : PA20 = "AND (公帳控制表.申請日期 LIKE N'" & PA17 & "/" & PA16 & "%') " : Set_清單1()
  221. End If
  222. End Sub
  223. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles 只顯示支票資料_cb.Click
  224. If 只顯示支票資料_cb.Checked = False Then : PA19 = "" : Set_清單1()
  225. Else : PA19 = " AND (公帳流水帳.支票數 <> 0) " : Set_清單1()
  226. End If
  227. End Sub
  228. Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles 隱藏申請審核資訊_cb.Click
  229. Set_grid()
  230. End Sub
  231. Private Sub CheckBox5_CheckedChanged(sender As Object, e As EventArgs) Handles 隱藏作帳點交資訊_cb.Click
  232. Set_grid()
  233. End Sub
  234. Private Sub 只有收入_cb_CheckedChanged(sender As Object, e As EventArgs) Handles 只有收入_cb.Click
  235. If 只有收入_cb.Checked = True Then
  236. 只有收入_cb.Checked = True : 只有支出_cb.Checked = False
  237. Else
  238. 只有收入_cb.Checked = False : 只有支出_cb.Checked = False
  239. End If : Set_清單1()
  240. End Sub
  241. Private Sub 只有支出_cb_CheckedChanged(sender As Object, e As EventArgs) Handles 只有支出_cb.Click
  242. If 只有支出_cb.Checked = True Then
  243. 只有收入_cb.Checked = False : 只有支出_cb.Checked = True
  244. Else
  245. 只有收入_cb.Checked = False : 只有支出_cb.Checked = False
  246. End If : Set_清單1()
  247. End Sub
  248. '-----------------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------
  249. 'Private Sub BBBToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BBBToolStripMenuItem.Click
  250. ' MsgBox("待開發。")
  251. ' '列印_零用金支付明細.ShowDialog()
  252. 'End Sub
  253. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 關鍵字查詢_bt.Click
  254. PA = InputBox("請輸入要查詢的關鍵字。")
  255. PA18 = " AND (公帳控制表.支付單號 LIKE N'%" & PA & "%' OR 公帳控制表.申請人 LIKE N'%" & PA & "%' OR 公帳控制表.審核人 LIKE N'%" & PA &
  256. "%' OR 公帳流水帳.明細 LIKE N'%" & PA & "%' OR 公帳控制表.備註 LIKE N'%" & PA & "%' OR 公帳流水帳.備註 LIKE N'%" & PA & "%')" : Set_清單1()
  257. PA18 = "" : PA = ""
  258. End Sub
  259. '-----------------------------EXCEL--------------------------------------------------------------------------------------------------------------------------------------
  260. Private Shared Function NewMethod(xlBook As Microsoft.Office.Interop.Excel.Workbook) As Microsoft.Office.Interop.Excel.Worksheet
  261. Return CType(xlBook.Worksheets.Add, Microsoft.Office.Interop.Excel.Worksheet)
  262. End Function
  263. Private Sub 匯出EXCEL_bt_Click(sender As Object, e As EventArgs) Handles 匯出EXCEL_bt.Click
  264. xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
  265. xlApp.Visible = True
  266. xlApp.DisplayAlerts = True
  267. xlApp.Application.WindowState = xlMaximized
  268. xlBook = xlApp.Workbooks.Add
  269. xlSheet = NewMethod(xlBook)
  270. xlBook.Activate()
  271. xlSheet.Activate()
  272. xlSheet.Cells(1, 1) = "XXXX-營運費用收支明細表" : xlSheet.Cells(2, 1) = "收支單號 " : xlSheet.Cells(2, 2) = "申請人" : xlSheet.Cells(2, 3) = "申請日期 "
  273. xlSheet.Cells(2, 4) = "審核人" : xlSheet.Cells(2, 5) = "審核日期" : xlSheet.Cells(2, 6) = "項次" : xlSheet.Cells(2, 7) = "會計科目 " : xlSheet.Cells(2, 8) = "用途與內容"
  274. xlSheet.Cells(2, 9) = "零用金" : xlSheet.Cells(2, 10) = "支票" : xlSheet.Cells(2, 11) = "收入" : xlSheet.Cells(2, 12) = "支出"
  275. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  276. xlSheet.Cells(i + 3, 1) = 明細_dgv.Rows(i).Cells("收支單號").Value : xlSheet.Cells(i + 3, 2) = 明細_dgv.Rows(i).Cells("申請人").Value
  277. xlSheet.Cells(i + 3, 3) = 明細_dgv.Rows(i).Cells("申請日期").Value : xlSheet.Cells(i + 3, 4) = 明細_dgv.Rows(i).Cells("審核人").Value
  278. xlSheet.Cells(i + 3, 5) = 明細_dgv.Rows(i).Cells("審核日期").Value : xlSheet.Cells(i + 3, 6) = 明細_dgv.Rows(i).Cells("項次").Value
  279. xlSheet.Cells(i + 3, 7) = 明細_dgv.Rows(i).Cells("會計科目").Value : xlSheet.Cells(i + 3, 8) = 明細_dgv.Rows(i).Cells("用途與內容").Value
  280. xlSheet.Cells(i + 3, 9) = 明細_dgv.Rows(i).Cells("零用金").Value : xlSheet.Cells(i + 3, 10) = 明細_dgv.Rows(i).Cells("支票").Value
  281. xlSheet.Cells(i + 3, 11) = 明細_dgv.Rows(i).Cells("收入").Value : xlSheet.Cells(i + 3, 12) = 明細_dgv.Rows(i).Cells("支出").Value
  282. N2 = i + 3
  283. Next i
  284. xlSheet.Cells(N2 + 1, 8) = "合計"
  285. xlSheet.Cells(N2 + 1, 9) = "=SUM(I3:I" & N2 & ")" : xlSheet.Cells(N2 + 1, 10) = "=SUM(J3:J" & N2 & ")"
  286. xlSheet.Cells(N2 + 1, 11) = "=SUM(K3:K" & N2 & ")" : xlSheet.Cells(N2 + 1, 12) = "=SUM(L3:L" & N2 & ")"
  287. '--------------------------------------彙總-----------------------------
  288. xlSheet.Cells(N2 + 2, 8) = "彙總"
  289. xlSheet.Cells(N2 + 2, 9) = "=I" & N2 + 1 & "+J" & N2 + 1 & "+K" & N2 + 1 & "-L" & N2 + 1 & ""
  290. BB(xlApp, xlSheet) : xlSheet.Cells(2, 12) = "支出"
  291. xlSheet.PageSetup.PrintArea = ""
  292. xlApp.Cells.Select()
  293. xlApp.Application.WindowState = xlMinimized
  294. MsgBox("列印完成!!!")
  295. End Sub
  296. Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
  297. xlSheet.Cells.Select()
  298. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  299. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  300. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 15 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 9
  301. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 9 : xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 9
  302. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 9 : xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 5
  303. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  304. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  305. End With
  306. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 20 : xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 35
  307. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  308. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  309. End With
  310. xlSheet.Columns("I:L").Select : myExcel.Selection.ColumnWidth = 9 : myExcel.Selection.Style = "Comma"
  311. myExcel.Selection.NumberFormatLocal = "_-* #,##0.0_-;-* #,##0.0_-;_-* ""-""??_-;_-@_-"
  312. myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
  313. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 35 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 30
  314. With myExcel.Selection : .VerticalAlignment = xlTop : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  315. .ReadingOrder = xlContext : .MergeCells = False : End With
  316. myExcel.Selection.AutoFilter
  317. xlSheet.Rows("1:1").Select
  318. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
  319. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  320. xlSheet.Range("A1:L1").Select()
  321. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  322. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  323. xlSheet.Rows("3:3").Select : myExcel.ActiveWindow.FreezePanes = True : xlSheet.Range("A1:L2").Select()
  324. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  325. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  326. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  327. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  328. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  329. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  330. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  331. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  332. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  333. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  334. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  335. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  336. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  337. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  338. xlSheet.Range("A3:L" & N2).Select()
  339. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  340. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  341. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  342. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  343. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  344. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  345. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  346. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  347. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  348. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  349. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  350. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
  351. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  352. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  353. xlSheet.Range("L2").Select() : myExcel.Selection.ClearContents
  354. xlSheet.Range("A2:L2").Select()
  355. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlTop : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  356. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  357. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 14 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  358. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  359. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  360. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  361. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent6 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
  362. xlSheet.Range("A1:L1").Select() : myExcel.Selection.Font.Size = 11
  363. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 22 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
  364. .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  365. End Sub
  366. Private Sub 字體_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 字體_NUD.ValueChanged
  367. 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
  368. End Sub
  369. '----------------------自創視窗滑鼠拖曳功能---------------------------------------------------------------------------------------------------------
  370. Dim OldX, OldY As Long : Dim drag As Boolean
  371. Private Sub CanceL2_bt_Click(sender As Object, e As EventArgs) Handles CanceL2_bt.Click
  372. If 視窗2_pl.Visible = False Then
  373. 視窗2_pl.Visible = True : 視窗2_pl.BringToFront()
  374. Else : 視窗2_pl.Visible = False
  375. For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("備註").Value = "" : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White : Next
  376. End If
  377. End Sub
  378. Private Sub 視窗2_pl_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 視窗2_pl.MouseDown
  379. If e.Button = MouseButtons.Left Then : OldX = e.X : OldY = e.Y : drag = True : End If
  380. End Sub
  381. Private Sub 視窗2_pl_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 視窗2_pl.MouseMove
  382. If drag Then : 視窗2_pl.Left = 視窗2_pl.Left + e.X - OldX : 視窗2_pl.Top = 視窗2_pl.Top + e.Y - OldY : End If
  383. End Sub
  384. Private Sub 視窗2_pl_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 視窗2_pl.MouseUp
  385. drag = False
  386. End Sub
  387. Private Sub Set_特別計算()
  388. 剔除存檔_dgv.DataSource = Nothing : ds2.Clear()
  389. 剔除存檔_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  390. 剔除存檔_dgv.ColumnHeadersHeight = 25 : 剔除存檔_dgv.AllowUserToAddRows = False : 剔除存檔_dgv.RowTemplate.Height = 25
  391. SQL_剔除存檔()
  392. da.Fill(ds2) : 剔除存檔_dgv.DataSource = ds2.Tables(0) : conn.Close()
  393. 會科_dgv.DataSource = Nothing : ds1.Clear()
  394. 會科_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  395. 會科_dgv.ColumnHeadersHeight = 25 : 會科_dgv.AllowUserToAddRows = False : 會科_dgv.RowTemplate.Height = 25
  396. PA = 查詢日期_cb.Text & "/" & 查詢日期1_cb.Text : SQL_剔除會科()
  397. da.Fill(ds1) : 會科_dgv.DataSource = ds1.Tables(0) : conn.Close()
  398. 會科_dgv.Columns(0).FillWeight = 30 : 會科_dgv.Columns(2).Visible = False
  399. 會科_dgv.Columns(3).DefaultCellStyle.Format = "#,##0"
  400. 會科_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  401. 會科_dgv.Columns(3).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  402. For i As Integer = 0 To 會科_dgv.Rows.Count - 1
  403. 會科_dgv.Rows(i).Cells("選擇").Value = False
  404. For II As Integer = 0 To 剔除存檔_dgv.Rows.Count - 1
  405. If 會科_dgv.Rows(i).Cells("會計科目").Value.ToString = 剔除存檔_dgv.Rows(II).Cells("剔除會科").Value.ToString Then : 會科_dgv.Rows(i).Cells("選擇").Value = True : End If
  406. Next
  407. 會科_dgv.Rows(i).Cells("金額").Value = "0"
  408. For II As Integer = 0 To 明細_dgv.Rows.Count - 1
  409. If 會科_dgv.Rows(i).Cells("會計科目").Value.ToString = 明細_dgv.Rows(II).Cells("會計科目").Value.ToString Then
  410. 會科_dgv.Rows(i).Cells("金額").Value += 明細_dgv.Rows(II).Cells("收入").Value.ToString
  411. 會科_dgv.Rows(i).Cells("金額").Value += 明細_dgv.Rows(II).Cells("支出").Value.ToString
  412. End If
  413. Next
  414. Next
  415. End Sub
  416. Private Sub 特別計算_bt_Click_1(sender As Object, e As EventArgs) Handles 特別計算_bt.Click
  417. If 視窗2_pl.Visible = True Then : 視窗2_pl.Visible = False
  418. For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("備註").Value = "" : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White : Next
  419. Else : 視窗2_pl.Visible = True : 視窗2_pl.BringToFront() : Set_特別計算() : 剃除預設() : 剃除計算() : End If
  420. End Sub
  421. Private Sub 會科_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 會科_dgv.CellClick
  422. If e.RowIndex = -1 Then : Else
  423. If 會科_dgv.Rows(e.RowIndex).Cells("選擇").Value = False Then : 會科_dgv.Rows(e.RowIndex).Cells("選擇").Value = True
  424. Else : 會科_dgv.Rows(e.RowIndex).Cells("選擇").Value = False : End If
  425. End If
  426. End Sub
  427. Private Sub 存檔_bt_Click(sender As Object, e As EventArgs) Handles 存檔_bt.Click
  428. For i As Integer = 0 To 會科_dgv.Rows.Count - 1
  429. If 會科_dgv.Rows(i).Cells("選擇").Value = True Then
  430. PA1 = 會科_dgv.Rows(i).Cells("會計科目").Value.ToString : SQL_剔除存檔比對() : If dr.Read Then : Else : SQL_剔除存檔新增() : End If
  431. End If
  432. Next : 剃除預設() : 剃除計算()
  433. End Sub
  434. Private Sub 剃除計算_bt_Click(sender As Object, e As EventArgs) Handles 剃除計算_bt.Click
  435. For i As Integer = 0 To 明細_dgv.Rows.Count - 1 : 明細_dgv.Rows(i).Cells("備註").Value = "" : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White : Next
  436. 剃除預設() : 剃除計算()
  437. End Sub
  438. Private Sub 公司編號_cb_Click(sender As Object, e As EventArgs) Handles 公司編號_cb.Click
  439. CB選擇清單(公司編號_cb, 公司編號_cb.Text)
  440. End Sub
  441. Private Sub 公司編號_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 公司編號_cb.SelectedIndexChanged
  442. Set_清單1() : 支出_tb.Text = "" : 損益_tb.Text = "" : 現金_tb.Text = "" : 收支單號_tb.Text = ""
  443. End Sub
  444. Private Sub 剃除預設()
  445. For i As Integer = 0 To 會科_dgv.Rows.Count - 1
  446. For II As Integer = 0 To 明細_dgv.Rows.Count - 1
  447. If 會科_dgv.Rows(i).Cells("會計科目").Value.ToString = 明細_dgv.Rows(II).Cells("會計科目").Value.ToString And 會科_dgv.Rows(i).Cells("選擇").Value = True Then
  448. 明細_dgv.Rows(II).Cells("備註").Value = "剔除" : 明細_dgv.Rows(II).DefaultCellStyle.BackColor = Color.LightBlue
  449. End If
  450. Next
  451. Next
  452. End Sub
  453. Private Sub 剃除計算()
  454. 剔除後收入_tb.Text = "0" : 剔除後支出_tb.Text = "0" : 剔除後總和_tb.Text = "0"
  455. For I As Integer = 0 To 明細_dgv.Rows.Count - 1
  456. If 明細_dgv.Rows(I).Cells("備註").Value.ToString <> "剔除" Then
  457. 剔除後收入_tb.Text = Strings.Format(CInt(剔除後收入_tb.Text) + CInt(明細_dgv.Rows(I).Cells("收入").Value.ToString), "#,##0")
  458. 剔除後支出_tb.Text = Strings.Format(CInt(剔除後支出_tb.Text) + CInt(明細_dgv.Rows(I).Cells("支出").Value.ToString), "#,##0")
  459. End If
  460. Next : 剔除後總和_tb.Text = Strings.Format(CInt(剔除後支出_tb.Text) - CInt(剔除後收入_tb.Text), "#,##0")
  461. End Sub
  462. Private Sub 明細_dgv_CellDoubleClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細_dgv.CellDoubleClick
  463. If e.RowIndex = -1 Then : Else
  464. If 視窗2_pl.Visible = True Then
  465. If 明細_dgv.Rows(e.RowIndex).Cells("備註").Value.ToString <> "剔除" Then
  466. 明細_dgv.Rows(e.RowIndex).Cells("備註").Value = "剔除" : 明細_dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.LightBlue
  467. ElseIf 明細_dgv.Rows(e.RowIndex).Cells("備註").Value.ToString = "剔除" Then
  468. 明細_dgv.Rows(e.RowIndex).Cells("備註").Value = "" : 明細_dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.White
  469. End If : 剃除計算()
  470. End If
  471. End If
  472. End Sub
  473. Private Sub 關鍵字查詢_bt_MouseEnter(sender As Object, e As EventArgs) Handles 關鍵字查詢_bt.MouseEnter
  474. ToolTip1.SetToolTip(Me.關鍵字查詢_bt, "關鍵字查詢")
  475. End Sub
  476. Private Sub 清除查詢資料_bt_MouseEnter(sender As Object, e As EventArgs) Handles 清除查詢資料_bt.MouseEnter
  477. ToolTip1.SetToolTip(Me.清除查詢資料_bt, "清除查詢資料")
  478. End Sub
  479. Private Sub 匯出EXCEL_bt_MouseEnter(sender As Object, e As EventArgs) Handles 匯出EXCEL_bt.MouseEnter
  480. ToolTip1.SetToolTip(Me.匯出EXCEL_bt, "匯出EXCEL")
  481. End Sub
  482. End Class