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

零用金支付_對帳表.vb 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 零用金支付_對帳表
  4. ReadOnly conn As New SqlConnection : ReadOnly conn1 As New SqlConnection
  5. ReadOnly cmd As New SqlCommand : ReadOnly cmd1 As New SqlCommand
  6. Dim dr As SqlDataReader
  7. ReadOnly da As New SqlDataAdapter : ReadOnly da1 As New SqlDataAdapter
  8. ReadOnly ds As New DataSet
  9. Dim KKKJJ As String : Dim KKKJJ2 As String : Dim KKKJJ3 As String : Dim KKK3 As String : Dim KKK4 As String
  10. Dim DTP As String
  11. Private Sub Set_清單1()
  12. DataGridView1.DataSource = Nothing : ds.Clear()
  13. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  14. DataGridView1.ColumnHeadersHeight = 60
  15. DataGridView1.AllowUserToAddRows = False
  16. DataGridView1.RowTemplate.Height = 50
  17. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  18. SQL1 = "SELECT 零用金支付表.流水號 AS [流水號 Nomor seri], 零用金支付表.部門 AS [部門 Departemen],
  19. 零用金支付表.申請人 AS [申請人 Pemohon], LEFT(零用金支付表.申請日期, 10) AS [申請日期 Tanggal Aplikasi],
  20. 零用金支付表.審核人 AS [審核人 Peninjau], LEFT(零用金支付表.審核日期, 10) AS [審核日期 Tanggal Peninjau],
  21. 零用金支付表.核准人 AS [核准人 Setuju], LEFT(零用金支付表.核准日期, 10) AS [核准日期 Tanggal Setuju],
  22. 零用金支付明細.項次 AS [項次 Item], 零用金支付明細.用途 AS [用途 Konten],
  23. 零用金支付明細.金額 AS [金額 Jumlah], 零用金支付明細.會計 AS [會計作業 Akuntansi],
  24. 零用金支付明細.出納 AS [出納作業 kasir], 零用金支付明細.備註 AS [備註 Komentar],
  25. 零用金支付表.會計, 零用金支付表.作帳日期 AS [作帳日期 Tanggal rekonsiliasi],
  26. 零用金支付表.出納, 零用金支付表.出納日期 AS [出納日期 Tanggal pelunasan],
  27. 零用金支付明細.現金, 零用金支付明細.備用金, 零用金支付明細.公帳
  28. FROM 零用金支付表 RIGHT OUTER JOIN 零用金支付明細 ON 零用金支付表.流水號 = 零用金支付明細.流水號
  29. WHERE (零用金支付表.審核人 NOT LIKE N'作廢%') AND (零用金支付表.核准人 NOT LIKE N'') AND (零用金支付表.核准人 NOT LIKE N'作廢%') " & KKKJJ3 & KKKJJ & KKKJJ2 & "
  30. ORDER BY 零用金支付表.流水號 DESC, 零用金支付明細.項次"
  31. 列印用SQL = SQL1
  32. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  33. End Sub
  34. Private Sub Set_grid()
  35. DataGridView1.Columns(0).Width = 120 : DataGridView1.Columns(1).Width = 120 : DataGridView1.Columns(2).Width = 65 : DataGridView1.Columns(3).Width = 80
  36. DataGridView1.Columns(4).Width = 65 : DataGridView1.Columns(5).Width = 80 : DataGridView1.Columns(6).Width = 65 : DataGridView1.Columns(7).Width = 80
  37. DataGridView1.Columns(8).Width = 50 : DataGridView1.Columns(9).Width = 300 : DataGridView1.Columns(10).Width = 80 : DataGridView1.Columns(11).Width = 72
  38. DataGridView1.Columns(12).Width = 73 : DataGridView1.Columns(13).Width = 335
  39. DataGridView1.Columns(14).Visible = False : DataGridView1.Columns(15).Width = 80 : DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Width = 80
  40. DataGridView1.Columns(18).Width = 40 : DataGridView1.Columns(19).Width = 50 : DataGridView1.Columns(20).Width = 40
  41. DataGridView1.Columns(10).DefaultCellStyle.Format = "#,##0"
  42. DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  43. DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  44. End Sub
  45. Private Sub ComboBox1下拉表單資料載入()
  46. conn.Close()
  47. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  48. SQL1 = "SELECT 年份 FROM 年份清單 ORDER BY 年份 DESC"
  49. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  50. ComboBox1.Items.Clear()
  51. While (dr.Read()) : ComboBox1.Items.Add(dr("年份")) : End While
  52. conn.Close()
  53. End Sub
  54. Private Sub 零用金支付_對帳表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  55. Me.MdiParent = HX_PGS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  56. ComboBox1下拉表單資料載入()
  57. ComboBox1.Text = Year(Today) : ComboBox2.SelectedIndex = Month(Today) - 1
  58. KKKJJ3 = "AND (零用金支付表.核准日期 LIKE N'" & KKK3 & "/" & KKK4 & "%') "
  59. Label62.Visible = False
  60. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  61. SQL1 = "UPDATE 零用金支付明細 SET 會計 = N'0' WHERE (會計 IS NULL)"
  62. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  63. conn.Close()
  64. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  65. SQL1 = "UPDATE 零用金支付明細 SET 出納 = N'0' WHERE (出納 IS NULL)"
  66. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  67. conn.Close()
  68. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  69. SQL1 = "UPDATE 零用金支付明細 SET 現金 = N'0' WHERE (現金 IS NULL)"
  70. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  71. conn.Close()
  72. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  73. SQL1 = "UPDATE 零用金支付明細 SET 備用金 = N'0' WHERE (備用金 IS NULL)"
  74. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  75. conn.Close()
  76. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  77. SQL1 = "UPDATE 零用金支付明細 SET 公帳 = N'0' WHERE (公帳 IS NULL)"
  78. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  79. conn.Close()
  80. Set_清單1()
  81. End Sub
  82. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  83. timeNow = 0
  84. HX_PGS_ERP_SYS.Timer1.Enabled = False
  85. HX_PGS_ERP_SYS.Timer1.Enabled = True
  86. End Sub
  87. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  88. timeNow = 0
  89. HX_PGS_ERP_SYS.Timer1.Enabled = False
  90. HX_PGS_ERP_SYS.Timer1.Enabled = True
  91. End Sub
  92. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  93. If Label62.Visible = True Then : Label62.Visible = False : Else : Label62.Visible = True : End If
  94. End Sub
  95. Private Sub 總金額計算()
  96. Dim FFGG As Integer = 0
  97. TextBox7.Text = "0"
  98. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  99. If DataGridView1.Rows(i).Cells("流水號 Nomor seri").Value = TextBox1.Text Then
  100. FFGG = Val(FFGG) + DataGridView1.Rows(i).Cells("金額 Jumlah").Value
  101. End If
  102. Next i
  103. TextBox7.Text = FFGG
  104. TextBox7.Text = Strings.Format(Val(TextBox7.Text), "#,##0")
  105. End Sub
  106. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  107. If e.RowIndex = -1 Then : Else
  108. TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("流水號 Nomor seri").Value
  109. Timer1.Enabled = True
  110. 總金額計算()
  111. End If
  112. End Sub
  113. Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
  114. Dim linePen As New Pen(Color.Blue, 2)
  115. If e.RowIndex = DataGridView1.Rows.Count - 1 Then
  116. Exit Sub
  117. Else
  118. If DataGridView1(0, e.RowIndex).Value.ToString <> DataGridView1(0, e.RowIndex + 1).Value.ToString Then
  119. Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  120. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  121. Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
  122. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  123. Exit Sub
  124. End If
  125. End If
  126. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  127. If DataGridView1(11, i).Value = True And DataGridView1(12, i).Value = True Then
  128. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
  129. ElseIf DataGridView1(11, i).Value = True And DataGridView1(12, i).Value = False Then
  130. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow
  131. End If
  132. Next
  133. End Sub
  134. Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox6.Click
  135. CheckBox6.Checked = True : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False
  136. KKKJJ = "" : Set_清單1()
  137. End Sub
  138. Private Sub CheckBox8_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox8.Click
  139. CheckBox6.Checked = False : CheckBox8.Checked = True : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False
  140. KKKJJ = " AND (零用金支付明細.會計 = 1)" : Set_清單1()
  141. End Sub
  142. Private Sub CheckBox7_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox7.Click
  143. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = True : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False
  144. KKKJJ = " AND (零用金支付明細.會計 = 0 OR 零用金支付明細.會計 IS NULL)" : Set_清單1()
  145. End Sub
  146. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click
  147. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = True : CheckBox2.Checked = False : CheckBox3.Checked = False
  148. KKKJJ = "" : Set_清單1()
  149. End Sub
  150. Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click
  151. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = True : CheckBox3.Checked = False
  152. KKKJJ = " AND (零用金支付明細.出納 = 1)" : Set_清單1()
  153. End Sub
  154. Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.Click
  155. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = True
  156. KKKJJ = " AND (零用金支付明細.出納 = 0 OR 零用金支付明細.出納 IS NULL)" : Set_清單1()
  157. End Sub
  158. Private Sub Set_日期格式轉換()
  159. DTP = Format(Today(), "yyyy/MM/dd")
  160. End Sub
  161. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
  162. KKK3 = ComboBox1.Text
  163. If KKK3 = "" Or KKK4 = "" Then
  164. Else
  165. KKKJJ3 = "AND (零用金支付表.核准日期 LIKE N'" & KKK3 & "/" & KKK4 & "%') "
  166. Set_清單1()
  167. End If
  168. End Sub
  169. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
  170. KKK4 = ComboBox2.Text
  171. If KKK3 = "" Or KKK4 = "" Then
  172. Else
  173. KKKJJ3 = "AND (零用金支付表.核准日期 LIKE N'" & KKK3 & "/" & KKK4 & "%') "
  174. Set_清單1()
  175. End If
  176. End Sub
  177. '-----------------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------
  178. Private Sub 對帳記錄存檔ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 對帳記錄存檔ToolStripMenuItem.Click
  179. Timer1.Enabled = False : Label62.Visible = False
  180. Set_日期格式轉換()
  181. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  182. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  183. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  184. SQL1 = "SELECT 會計, 出納 FROM 零用金支付明細
  185. WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號 Nomor seri").Value & "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次 Item").Value & "'"
  186. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  187. If dr.Read() Then
  188. If dr("會計") = False And DataGridView1.Rows(i).Cells("會計作業").Value = True Then
  189. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  190. SQL1 = "UPDATE 零用金支付明細 SET 會計 = N'1'
  191. WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號 Nomor seri").Value & "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次 Item").Value & "'"
  192. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  193. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  194. SQL1 = "UPDATE 零用金支付表 SET 會計 = N'" & gUserName & "', 作帳日期 = '" & DTP & "'
  195. WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號 Nomor seri").Value & "'"
  196. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  197. End If
  198. If dr("出納") = False And DataGridView1.Rows(i).Cells("出納作業 kasir").Value = True Then
  199. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  200. SQL1 = "UPDATE 零用金支付明細 SET 出納 = N'1'
  201. WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號 Nomor seri").Value & "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次 Item").Value & "'"
  202. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  203. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  204. SQL1 = "UPDATE 零用金支付表 SET 出納 = N'" & gUserName & "', 出納日期 = '" & DTP & "'
  205. WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號 Nomor seri").Value & "'"
  206. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  207. End If
  208. End If : conn.Close()
  209. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  210. SQL1 = "UPDATE 零用金支付明細 SET 現金 = '" & DataGridView1.Rows(i).Cells("現金").Value & "', 備用金 = '" & DataGridView1.Rows(i).Cells("備用金").Value &
  211. "', 公帳 = '" & DataGridView1.Rows(i).Cells("公帳").Value & "' WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號 Nomor seri").Value &
  212. "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次 Item").Value & "'"
  213. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  214. Next
  215. MsgBox("存檔完成。 Archiving completed") : Set_清單1() : HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  216. End Sub
  217. Private Sub 關鍵字查詢ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 關鍵字查詢ToolStripMenuItem.Click
  218. PA = InputBox("請輸入要查詢的關鍵字/Please enter keywords to query")
  219. KKKJJ2 = " AND (零用金支付表.流水號 LIKE N'%" & PA & "%' OR 零用金支付表.部門 LIKE N'%" & PA & "%' OR 零用金支付表.申請人 LIKE N'%" & PA & "%' OR 零用金支付表.審核人 LIKE N'%" & PA &
  220. "%' OR 零用金支付明細.用途 LIKE N'%" & PA & "%' OR 零用金支付明細.備註 LIKE N'%" & PA & "%')" : Set_清單1()
  221. KKKJJ2 = "" : PA = ""
  222. End Sub
  223. Private Sub AAAToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AAAToolStripMenuItem.Click
  224. PA = InputBox("請掃描單據上的二維碼/Please scan the QR code on the document")
  225. KKKJJ2 = " AND (零用金支付表.簽名編碼 LIKE N'" & PA & "')" : Set_清單1()
  226. KKKJJ2 = "" : PA = ""
  227. End Sub
  228. Private Sub BBBToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BBBToolStripMenuItem.Click
  229. MsgBox("待開發。 Untuk dikembangkan.")
  230. ' 列印_零用金支付明細.ShowDialog()
  231. End Sub
  232. Private Sub 清除ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 清除ToolStripMenuItem.Click
  233. ComboBox1下拉表單資料載入()
  234. ComboBox2.Items.Clear()
  235. ComboBox2.Items.Add("01") : ComboBox2.Items.Add("02") : ComboBox2.Items.Add("03") : ComboBox2.Items.Add("04") : ComboBox2.Items.Add("05") : ComboBox2.Items.Add("06")
  236. ComboBox2.Items.Add("07") : ComboBox2.Items.Add("08") : ComboBox2.Items.Add("09") : ComboBox2.Items.Add("10") : ComboBox2.Items.Add("11") : ComboBox2.Items.Add("12")
  237. KKK3 = "" : KKK4 = "" : KKKJJ3 = ""
  238. End Sub
  239. End Class