暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 零用金支付_對帳表
  4. Dim conn As New SqlConnection : Dim conn1 As New SqlConnection
  5. Dim cmd As New SqlCommand : Dim cmd1 As New SqlCommand
  6. Dim dr As SqlDataReader : Dim dr1 As SqlDataReader
  7. Dim da As New SqlDataAdapter : Dim da1 As New SqlDataAdapter
  8. Dim 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_DGV1載入前設定()
  12. DataGridView1.DataSource = Nothing : ds.Clear()
  13. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  14. DataGridView1.ColumnHeadersHeight = 25
  15. DataGridView1.AllowUserToAddRows = False
  16. DataGridView1.RowTemplate.Height = 35
  17. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  18. End Sub
  19. Private Sub Set_DGV1載入後設定()
  20. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  21. End Sub
  22. Private Sub Set_清單1()
  23. Set_DGV1載入前設定()
  24. SQL1 = "SELECT 零用金支付表.流水號, 零用金支付表.部門, 零用金支付表.申請人, LEFT(零用金支付表.申請日期, 10) AS 申請日期, 零用金支付表.審核人, LEFT(零用金支付表.審核日期, 10) AS 審核日期, " &
  25. "零用金支付表.核准人, LEFT(零用金支付表.核准日期, 10) AS 核准日期, 零用金支付明細.項次, 零用金支付明細.用途, 零用金支付明細.金額, 零用金支付明細.會計 AS 會計作業, " &
  26. "零用金支付明細.出納 AS 出納作業, 零用金支付明細.備註, 零用金支付表.會計, 零用金支付表.作帳日期, 零用金支付表.出納, 零用金支付表.出納日期, 零用金支付明細.現金, 零用金支付明細.備用金, " &
  27. "零用金支付明細.公帳 FROM 零用金支付表 RIGHT OUTER JOIN 零用金支付明細 " &
  28. "ON 零用金支付表.流水號 = 零用金支付明細.流水號 WHERE (零用金支付表.審核人 NOT LIKE N'作廢%') AND (零用金支付表.核准人 NOT LIKE N'') AND (零用金支付表.核准人 NOT LIKE N'作廢%') " &
  29. " " & KKKJJ3 & KKKJJ & KKKJJ2 &
  30. " ORDER BY 零用金支付表.流水號 DESC, 零用金支付明細.項次"
  31. 列印用SQL = SQL1
  32. Set_DGV1載入後設定()
  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 : DataGridView1.Columns(8).Width = 40
  37. DataGridView1.Columns(9).Width = 300 : DataGridView1.Columns(10).Width = 80 : DataGridView1.Columns(11).Width = 72 : DataGridView1.Columns(12).Width = 73 : DataGridView1.Columns(13).Width = 335
  38. DataGridView1.Columns(14).Visible = False : DataGridView1.Columns(15).Width = 80 : DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Width = 80
  39. DataGridView1.Columns(18).Width = 40 : DataGridView1.Columns(19).Width = 50 : DataGridView1.Columns(20).Width = 40
  40. DataGridView1.Columns(10).DefaultCellStyle.Format = "#,##0.00"
  41. DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  42. DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  43. End Sub
  44. Private Sub ComboBox1下拉表單資料載入()
  45. conn.Close()
  46. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  47. SQL1 = "SELECT 年份 FROM 年份清單 ORDER BY 年份 DESC"
  48. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  49. ComboBox1.Items.Clear()
  50. While (dr.Read()) : ComboBox1.Items.Add(dr("年份")) : End While
  51. conn.Close()
  52. End Sub
  53. Private Sub 零用金支付_對帳表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  54. Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  55. ComboBox1下拉表單資料載入()
  56. ComboBox1.Text = Year(Today) : ComboBox2.SelectedIndex = Month(Today) - 1
  57. KKKJJ3 = "AND (零用金支付表.核准日期 LIKE N'" & KKK3 & "/" & KKK4 & "%') "
  58. Label62.Visible = False
  59. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  60. SQL1 = "UPDATE 零用金支付明細 SET 會計 = N'0' WHERE (會計 IS NULL)"
  61. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  62. conn.Close()
  63. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  64. SQL1 = "UPDATE 零用金支付明細 SET 出納 = N'0' WHERE (出納 IS NULL)"
  65. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  66. conn.Close()
  67. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  68. SQL1 = "UPDATE 零用金支付明細 SET 現金 = N'0' WHERE (現金 IS NULL)"
  69. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  70. conn.Close()
  71. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  72. SQL1 = "UPDATE 零用金支付明細 SET 備用金 = N'0' WHERE (備用金 IS NULL)"
  73. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  74. conn.Close()
  75. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  76. SQL1 = "UPDATE 零用金支付明細 SET 公帳 = N'0' WHERE (公帳 IS NULL)"
  77. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  78. conn.Close()
  79. Set_清單1()
  80. End Sub
  81. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  82. If Label62.Visible = True Then : Label62.Visible = False : Else : Label62.Visible = True : End If
  83. End Sub
  84. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  85. If e.RowIndex = -1 Then : Else
  86. Timer1.Enabled = True
  87. End If
  88. End Sub
  89. Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
  90. Dim linePen As New Pen(Color.Blue, 2)
  91. If e.RowIndex = DataGridView1.Rows.Count - 1 Then
  92. Exit Sub
  93. Else
  94. If DataGridView1(0, e.RowIndex).Value.ToString <> DataGridView1(0, e.RowIndex + 1).Value.ToString Then
  95. Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  96. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  97. Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
  98. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  99. Exit Sub
  100. End If
  101. End If
  102. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  103. If DataGridView1(11, i).Value = True And DataGridView1(12, i).Value = True Then
  104. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
  105. ElseIf DataGridView1(11, i).Value = True And DataGridView1(12, i).Value = False Then
  106. DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow
  107. End If
  108. Next
  109. End Sub
  110. Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox6.Click
  111. CheckBox6.Checked = True : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False
  112. KKKJJ = "" : Set_清單1()
  113. End Sub
  114. Private Sub CheckBox8_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox8.Click
  115. CheckBox6.Checked = False : CheckBox8.Checked = True : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False
  116. KKKJJ = " AND (零用金支付明細.會計 = 1)" : Set_清單1()
  117. End Sub
  118. Private Sub CheckBox7_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox7.Click
  119. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = True : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = False
  120. KKKJJ = " AND (零用金支付明細.會計 = 0 OR 零用金支付明細.會計 IS NULL)" : Set_清單1()
  121. End Sub
  122. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.Click
  123. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = True : CheckBox2.Checked = False : CheckBox3.Checked = False
  124. KKKJJ = "" : Set_清單1()
  125. End Sub
  126. Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.Click
  127. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = True : CheckBox3.Checked = False
  128. KKKJJ = " AND (零用金支付明細.出納 = 1)" : Set_清單1()
  129. End Sub
  130. Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.Click
  131. CheckBox6.Checked = False : CheckBox8.Checked = False : CheckBox7.Checked = False : CheckBox1.Checked = False : CheckBox2.Checked = False : CheckBox3.Checked = True
  132. KKKJJ = " AND (零用金支付明細.出納 = 0 OR 零用金支付明細.出納 IS NULL)" : Set_清單1()
  133. End Sub
  134. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  135. PA = InputBox("請輸入要查詢的關鍵字")
  136. KKKJJ2 = " AND (零用金支付表.流水號 LIKE N'%" & PA & "%' OR 零用金支付表.部門 LIKE N'%" & PA & "%' OR 零用金支付表.申請人 LIKE N'%" & PA & "%' OR 零用金支付表.審核人 LIKE N'%" & PA &
  137. "%' OR 零用金支付明細.用途 LIKE N'%" & PA & "%' OR 零用金支付明細.備註 LIKE N'%" & PA & "%')" : Set_清單1()
  138. KKKJJ2 = "" : PA = ""
  139. End Sub
  140. Private Sub Set_日期格式轉換()
  141. DTP = Format(Today(), "yyyy/MM/dd")
  142. End Sub
  143. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  144. Timer1.Enabled = False : Label62.Visible = False
  145. Set_日期格式轉換()
  146. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  147. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  148. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  149. SQL1 = "SELECT 會計, 出納 FROM 零用金支付明細 WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號").Value & "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次").Value & "'"
  150. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  151. If dr.Read() Then
  152. If dr("會計") = False And DataGridView1.Rows(i).Cells("會計作業").Value = True Then
  153. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  154. SQL1 = "UPDATE 零用金支付明細 SET 會計 = N'1' WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號").Value & "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次").Value & "'"
  155. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  156. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  157. SQL1 = "UPDATE 零用金支付表 SET 會計 = N'" & gUserName & "', 作帳日期 = '" & DTP & "' WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號").Value & "'"
  158. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  159. End If
  160. If dr("出納") = False And DataGridView1.Rows(i).Cells("出納作業").Value = True Then
  161. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  162. SQL1 = "UPDATE 零用金支付明細 SET 出納 = N'1' WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號").Value & "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次").Value & "'"
  163. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  164. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  165. SQL1 = "UPDATE 零用金支付表 SET 出納 = N'" & gUserName & "', 出納日期 = '" & DTP & "' WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號").Value & "'"
  166. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  167. End If
  168. End If : conn.Close()
  169. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  170. SQL1 = "UPDATE 零用金支付明細 SET 現金 = '" & DataGridView1.Rows(i).Cells("現金").Value & "', 備用金 = '" & DataGridView1.Rows(i).Cells("備用金").Value &
  171. "', 公帳 = '" & DataGridView1.Rows(i).Cells("公帳").Value & "' WHERE 流水號 LIKE N'" & DataGridView1.Rows(i).Cells("流水號").Value &
  172. "' AND 項次 LIKE N'" & DataGridView1.Rows(i).Cells("項次").Value & "'"
  173. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery() : conn1.Close()
  174. Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  175. MsgBox("存檔完成") : Set_清單1()
  176. End Sub
  177. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  178. If KKK3 = "" Or KKK4 = "" Then
  179. Else
  180. KKKJJ3 = "AND (零用金支付表.核准日期 LIKE N'" & KKK3 & "/" & KKK4 & "%') "
  181. End If
  182. Set_清單1()
  183. End Sub
  184. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  185. 列印_零用金支付明細.ShowDialog()
  186. End Sub
  187. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
  188. KKK3 = ComboBox1.Text
  189. End Sub
  190. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
  191. KKK4 = ComboBox2.Text
  192. End Sub
  193. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  194. ComboBox1下拉表單資料載入()
  195. ComboBox2.Items.Clear()
  196. ComboBox2.Items.Add("01") : ComboBox2.Items.Add("02") : ComboBox2.Items.Add("03") : ComboBox2.Items.Add("04") : ComboBox2.Items.Add("05") : ComboBox2.Items.Add("06")
  197. ComboBox2.Items.Add("07") : ComboBox2.Items.Add("08") : ComboBox2.Items.Add("09") : ComboBox2.Items.Add("10") : ComboBox2.Items.Add("11") : ComboBox2.Items.Add("12")
  198. KKK3 = "" : KKK4 = "" : KKKJJ3 = ""
  199. End Sub
  200. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  201. PA = InputBox("請輸入要查詢的驗證碼。")
  202. KKKJJ2 = " AND (零用金支付表.簽名編碼 LIKE N'" & PA & "')" : Set_清單1()
  203. KKKJJ2 = "" : PA = ""
  204. End Sub
  205. End Class