No Description
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 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.IO
  4. Public Class 營運成本收支單審核
  5. ReadOnly conn As New SqlConnection
  6. ReadOnly da As New SqlDataAdapter
  7. ReadOnly cmd As New SqlCommand
  8. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet
  9. Dim dr As SqlDataReader
  10. Private ReadOnly QQW(11) As String
  11. Dim DTP As String : Dim WWEE As String : Private II As Integer
  12. Private Sub Set_清單1()
  13. DataGridView2.DataSource = Nothing : ds1.Clear()
  14. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  15. DataGridView2.ColumnHeadersHeight = 25
  16. DataGridView2.AllowUserToAddRows = False
  17. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  18. If RadioButton1.Checked = True And RadioButton2.Checked = False Then
  19. WWEE = "WHERE (審核人 LIKE '') "
  20. ElseIf RadioButton1.Checked = False And RadioButton2.Checked = True Then
  21. WWEE = "WHERE (審核人 LIKE '作廢%') "
  22. End If
  23. SQL1 = "SELECT 支付單號 AS 收支單號, 申請日期, 審核日期, 申請人 FROM 公帳控制表 " & WWEE & " ORDER BY 支付單號 DESC"
  24. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
  25. DataGridView2.Columns(0).FillWeight = 160 : DataGridView2.Columns(1).FillWeight = 100 : DataGridView2.Columns(2).FillWeight = 100 : DataGridView2.Columns(3).Visible = False
  26. End Sub
  27. Private Sub Set_費用清單()
  28. DataGridView1.DataSource = Nothing : ds.Clear()
  29. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  30. DataGridView1.ColumnHeadersHeight = 25
  31. DataGridView1.AllowUserToAddRows = False
  32. DataGridView1.RowTemplate.Height = 35
  33. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  34. SQL1 = "SELECT 公帳流水帳.支付單號, 公帳流水帳.項次, 會計科目.會計科目, 公帳流水帳.明細 AS 用途,
  35. Cast(公帳流水帳.零用金 AS money) AS 零用金, Cast(公帳流水帳.支票數 AS money) AS 支票, Cast(公帳流水帳.收入 AS money) AS 現金,
  36. Cast(公帳流水帳.支出 AS money) AS 支出, 公帳流水帳.備註 AS 票期, 公帳流水帳.匯率, 公帳流水帳.銀行 AS 幣別, 公帳流水帳.類別, 公帳流水帳.流水號
  37. FROM 公帳流水帳 INNER JOIN
  38. 會計科目 ON 公帳流水帳.類別 = 會計科目.編號
  39. WHERE (公帳流水帳.支付單號 LIKE '" & TextBox1.Text & "')
  40. ORDER BY 公帳流水帳.項次"
  41. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  42. DataGridView1.Columns(0).Visible = False : DataGridView1.Columns(1).FillWeight = 80 : DataGridView1.Columns(2).FillWeight = 300 : DataGridView1.Columns(3).FillWeight = 500
  43. DataGridView1.Columns(4).FillWeight = 140 : DataGridView1.Columns(5).FillWeight = 140 : DataGridView1.Columns(6).FillWeight = 140 : DataGridView1.Columns(7).FillWeight = 140
  44. DataGridView1.Columns(8).FillWeight = 140 : DataGridView1.Columns(9).FillWeight = 140 : DataGridView1.Columns(10).FillWeight = 140 : DataGridView1.Columns(11).Visible = False
  45. DataGridView1.Columns(12).Visible = False
  46. DataGridView1.Columns(1).ReadOnly = True : DataGridView1.Columns(2).ReadOnly = True : DataGridView1.Columns(9).ReadOnly = True : DataGridView1.Columns(10).ReadOnly = True
  47. DataGridView1.Columns(4).DefaultCellStyle.Format = "#,##0.00" : DataGridView1.Columns(5).DefaultCellStyle.Format = "#,##0.00" : DataGridView1.Columns(6).DefaultCellStyle.Format = "#,##0.00"
  48. DataGridView1.Columns(7).DefaultCellStyle.Format = "#,##0.00" : DataGridView1.Columns(8).DefaultCellStyle.Format = "#,##0.00"
  49. DataGridView1.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  50. DataGridView1.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  51. DataGridView1.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  52. DataGridView1.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  53. DataGridView1.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  54. DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  55. DataGridView1.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  56. DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
  57. TextBox5.Text = "0" : TextBox2.Text = "0" : TextBox6.Text = "0" : TextBox7.Text = "0" : TextBox8.Text = "0"
  58. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  59. TextBox5.Text = Val(TextBox5.Text) + DataGridView1.Rows(i).Cells("現金").Value : TextBox2.Text = Val(TextBox2.Text) + DataGridView1.Rows(i).Cells("支出").Value
  60. TextBox7.Text = Val(TextBox7.Text) + DataGridView1.Rows(i).Cells("零用金").Value : TextBox8.Text = Val(TextBox8.Text) + DataGridView1.Rows(i).Cells("支票").Value
  61. Next i
  62. TextBox6.Text = Val(TextBox7.Text) + Val(TextBox5.Text) - Val(TextBox2.Text)
  63. If Val(TextBox6.Text) > 0 Then : TextBox6.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  64. TextBox5.Text = Format(Val(TextBox5.Text), "#,##0.00") : TextBox2.Text = Format(Val(TextBox2.Text), "#,##0.00") : TextBox6.Text = Format(Val(TextBox6.Text), "#,##0.00")
  65. TextBox7.Text = Format(Val(TextBox7.Text), "#,##0.00") : TextBox8.Text = Format(Val(TextBox8.Text), "#,##0.00")
  66. End Sub
  67. Private Sub Set_清單()
  68. DataGridView3.DataSource = Nothing : ds2.Clear()
  69. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  70. DataGridView3.ColumnHeadersHeight = 25
  71. DataGridView3.AllowUserToAddRows = False
  72. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  73. SQL1 = "SELECT 圖片流水號 AS 圖檔編碼, 簽名檔人名 FROM GCM主管簽名檔管理 ORDER BY 圖片流水號 DESC"
  74. cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
  75. DataGridView3.Columns(0).FillWeight = 173 : DataGridView3.Columns(1).Visible = False
  76. If DataGridView3.Rows.Count = 0 Then : Else
  77. TextBox14.Text = DataGridView3(0, 0).Value.ToString
  78. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  79. SQL1 = "SELECT 簽名檔圖片 FROM GCM主管簽名檔管理 WHERE 圖片流水號 LIKE '" & TextBox14.Text & "'"
  80. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  81. While dr.Read() = True
  82. Dim unused As Byte() = New Byte(-1) {}
  83. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  84. Dim oStream As New MemoryStream(bytes)
  85. PictureBox1.Image = Bitmap.FromStream(oStream)
  86. End While
  87. conn.Close()
  88. PictureBox1.SizeMode = 4
  89. For QAZ = 0 To 999
  90. QQW(0) = Strings.Right(DataGridView3(0, 0).Value.ToString, 2) : QQW(1) = Strings.Right(Year(Today), 2) : QQW(2) = Strings.Left(Year(Today), 2) : QQW(3) = Month(Today) + 9
  91. QQW(4) = Strings.Right(QQW(0), 1) : QQW(5) = Strings.Left(QQW(0), 1) : QQW(6) = Strings.Right(QQW(1), 1) : QQW(7) = Strings.Left(QQW(1), 1) : QQW(8) = Strings.Right(QQW(2), 1)
  92. QQW(9) = Strings.Left(QQW(2), 1) : QQW(10) = Strings.Right(QQW(3), 1) : QQW(11) = Strings.Left(QQW(3), 1)
  93. For RT = 4 To 11
  94. Delay(3)
  95. Dim ran = New Random(DateTime.Now.Millisecond) : Dim NUM1 As Integer = ran.Next(1, 4096)
  96. For I = 0 To 4096 : If NUM1 > 9 Then : NUM1 -= 9 : ElseIf NUM1 < 9 Then : I = 4096 : End If : Next
  97. If NUM1 = 1 Then : II = RT : 轉換() : ElseIf NUM1 = 2 Then : II = RT : 轉換() : ElseIf NUM1 = 3 Then : ElseIf NUM1 = 4 Then : II = RT : 轉換() : ElseIf NUM1 = 5 Then
  98. ElseIf NUM1 = 6 Then : II = RT : 轉換() : ElseIf NUM1 = 7 Then : ElseIf NUM1 = 8 Then : II = RT : 轉換() : ElseIf NUM1 = 9 Then : II = RT : 轉換() : End If
  99. Next
  100. Dim ran1 = New Random(DateTime.Now.Millisecond) : Dim NUM2 As Integer = ran1.Next(1, 4096)
  101. For I = 0 To 4096 : If NUM2 > 99 Then : NUM2 -= 49 : ElseIf NUM2 < 99 Then : I = 4096 : End If : Next
  102. TextBox13.Text = QQW(11) & "2" & QQW(9) & "7" & QQW(7) & "0" & QQW(5) & QQW(4) & "1" & QQW(6) & "3" & QQW(8) & "9" & QQW(10) & NUM2
  103. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  104. SQL1 = "SELECT 簽名編碼 FROM 公帳控制表 WHERE 簽名編碼 LIKE '" & TextBox13.Text & "'"
  105. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  106. If dr.Read() = True Then : Else : QAZ = 999 : End If : conn.Close()
  107. Next
  108. End If
  109. End Sub
  110. Private Sub 轉換()
  111. If QQW(II) = "1" Then : QQW(II) = "A" : ElseIf QQW(II) = "2" Then : QQW(II) = "B" : ElseIf QQW(II) = "3" Then : QQW(II) = "C" : ElseIf QQW(II) = "4" Then : QQW(II) = "D"
  112. ElseIf QQW(II) = "5" Then : QQW(II) = "E" : ElseIf QQW(II) = "6" Then : QQW(II) = "F" : ElseIf QQW(II) = "7" Then : QQW(II) = "G" : ElseIf QQW(II) = "8" Then : QQW(II) = "H"
  113. ElseIf QQW(II) = "9" Then : QQW(II) = "I" : ElseIf QQW(II) = "0" Then : QQW(II) = "J"
  114. End If
  115. End Sub
  116. Public Sub Delay(ByRef Interval As Double) 'Interval单位为毫秒
  117. Dim time As DateTime = DateTime.Now : Dim Span As Double = Interval * 1234 : While ((DateTime.Now.Ticks - time.Ticks) < Span) : Application.DoEvents() : End While
  118. End Sub
  119. Private Sub 營運費用支付審核_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  120. Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  121. RadioButton1.Checked = True : DataGridView2.Visible = True
  122. Set_清單1() : Set_清單()
  123. End Sub
  124. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  125. If e.RowIndex = -1 Then : Else
  126. TextBox1.Text = DataGridView2(0, e.RowIndex).Value.ToString : DateTimePicker1.Value = DataGridView2(1, e.RowIndex).Value.ToString : Set_費用清單()
  127. TextBox3.Text = DataGridView2(3, e.RowIndex).Value.ToString
  128. End If
  129. End Sub
  130. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
  131. If e.RowIndex = -1 Then : Else
  132. TextBox14.Text = DataGridView3(0, e.RowIndex).Value.ToString
  133. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  134. SQL1 = "SELECT 簽名檔圖片 FROM GCM主管簽名檔管理 WHERE 圖片流水號 LIKE '" & TextBox14.Text & "'"
  135. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  136. While dr.Read() = True
  137. Dim unused As Byte() = New Byte(-1) {}
  138. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  139. Dim oStream As New MemoryStream(bytes)
  140. PictureBox1.Image = Bitmap.FromStream(oStream)
  141. End While
  142. conn.Close()
  143. PictureBox1.SizeMode = 4
  144. For QAZ = 0 To 999
  145. QQW(0) = Strings.Right(DataGridView3(0, e.RowIndex).Value.ToString, 2) : QQW(1) = Strings.Right(Year(Today), 2) : QQW(2) = Strings.Left(Year(Today), 2) : QQW(3) = Month(Today) + 9
  146. QQW(4) = Strings.Right(QQW(0), 1) : QQW(5) = Strings.Left(QQW(0), 1) : QQW(6) = Strings.Right(QQW(1), 1) : QQW(7) = Strings.Left(QQW(1), 1) : QQW(8) = Strings.Right(QQW(2), 1)
  147. QQW(9) = Strings.Left(QQW(2), 1) : QQW(10) = Strings.Right(QQW(3), 1) : QQW(11) = Strings.Left(QQW(3), 1)
  148. For RT = 4 To 11
  149. Delay(3)
  150. Dim ran = New Random(DateTime.Now.Millisecond) : Dim NUM1 As Integer = ran.Next(1, 4096)
  151. For I = 0 To 4096 : If NUM1 > 9 Then : NUM1 -= 9 : ElseIf NUM1 < 9 Then : I = 4096 : End If : Next
  152. If NUM1 = 1 Then : II = RT : 轉換() : ElseIf NUM1 = 2 Then : II = RT : 轉換() : ElseIf NUM1 = 3 Then : ElseIf NUM1 = 4 Then : II = RT : 轉換() : ElseIf NUM1 = 5 Then
  153. ElseIf NUM1 = 6 Then : II = RT : 轉換() : ElseIf NUM1 = 7 Then : ElseIf NUM1 = 8 Then : II = RT : 轉換() : ElseIf NUM1 = 9 Then : II = RT : 轉換() : End If
  154. Next
  155. Dim ran1 = New Random(DateTime.Now.Millisecond) : Dim NUM2 As Integer = ran1.Next(1, 4096)
  156. For I = 0 To 4096 : If NUM2 > 99 Then : NUM2 -= 49 : ElseIf NUM2 < 99 Then : I = 4096 : End If : Next
  157. TextBox13.Text = QQW(11) & "2" & QQW(9) & "7" & QQW(7) & "0" & QQW(5) & QQW(4) & "1" & QQW(6) & "3" & QQW(8) & "9" & QQW(10) & NUM2
  158. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  159. SQL1 = "SELECT 簽名編碼 FROM 公帳控制表 WHERE 簽名編碼 LIKE '" & TextBox13.Text & "'"
  160. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  161. If dr.Read() = True Then : Else : QAZ = 999 : End If : conn.Close()
  162. Next
  163. End If
  164. End Sub
  165. Private Sub Set_切換格式()
  166. DataGridView1.DataSource = Nothing : ds.Clear() : TextBox1.Text = "" : TextBox3.Text = "" : TextBox5.Text = "" : TextBox2.Text = "" : TextBox6.Text = ""
  167. TextBox7.Text = "" : TextBox8.Text = "" : Set_清單1()
  168. End Sub
  169. Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.Click
  170. RadioButton1.Checked = True : RadioButton2.Checked = False
  171. DataGridView1.DataSource = Nothing : ds.Clear() : TextBox1.Text = "" : TextBox3.Text = "" : TextBox5.Text = "" : TextBox2.Text = "" : TextBox6.Text = ""
  172. Button1.Enabled = True : Button2.Enabled = True : 審核通過ToolStripMenuItem.Enabled = True : 單據作廢ToolStripMenuItem.Enabled = True : Set_切換格式()
  173. End Sub
  174. Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.Click
  175. RadioButton1.Checked = False : RadioButton2.Checked = True
  176. DataGridView1.DataSource = Nothing : ds.Clear() : TextBox1.Text = "" : TextBox3.Text = "" : TextBox5.Text = "" : TextBox2.Text = "" : TextBox6.Text = ""
  177. Button1.Enabled = False : Button2.Enabled = False : 審核通過ToolStripMenuItem.Enabled = False : 單據作廢ToolStripMenuItem.Enabled = False : Set_切換格式()
  178. End Sub
  179. Private Sub Set_日期格式轉換()
  180. DTP = Format(Today(), "yyyy/MM/dd")
  181. End Sub
  182. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  183. If TextBox1.Text = "" Then
  184. MsgBox("請選擇需要審核的單據。")
  185. Else
  186. If CheckBox1.Checked = False Then
  187. Set_日期格式轉換()
  188. Else
  189. DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd")
  190. End If
  191. conn.Close()
  192. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  193. SQL1 = "UPDATE 公帳控制表 SET 審核人 = N'" & gUserName & "', 審核日期 = N'" & DTP & "', 核准圖檔 = N'" & TextBox14.Text & "', 簽名編碼 = N'" & TextBox13.Text &
  194. "', 出納 = '" & gUserName & "', 出納日期 = N'" & DTP & "'
  195. WHERE (支付單號 = N'" & TextBox1.Text & "')"
  196. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  197. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  198. SQL1 = "UPDATE 公帳流水帳 SET 出納 = '1', 出納日期 = N'" & DTP & "'
  199. WHERE (支付單號 LIKE '" & TextBox1.Text & "')"
  200. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  201. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  202. If DataGridView1.Rows(i).Cells("零用金").Value <> 0 Then
  203. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  204. SQL1 = "UPDATE 公帳流水帳 SET 備用金 = N'1' WHERE (支付單號 LIKE '" & TextBox1.Text & "' AND 項次 LIKE '" & DataGridView1.Rows(i).Cells("項次").Value & "')"
  205. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  206. ElseIf DataGridView1.Rows(i).Cells("現金").Value <> 0 Then
  207. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  208. SQL1 = "UPDATE 公帳流水帳 SET 現金 = N'1' WHERE (支付單號 LIKE '" & TextBox1.Text & "' AND 項次 LIKE '" & DataGridView1.Rows(i).Cells("項次").Value & "')"
  209. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  210. ElseIf DataGridView1.Rows(i).Cells("支出").Value <> 0 Then
  211. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  212. SQL1 = "UPDATE 公帳流水帳 SET 公帳 = N'1' WHERE (支付單號 LIKE '" & TextBox1.Text & "' AND 項次 LIKE '" & DataGridView1.Rows(i).Cells("項次").Value & "')"
  213. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  214. End If
  215. Next
  216. MsgBox("審核完畢。")
  217. TextBox1.Text = "" : TextBox3.Text = ""
  218. DataGridView1.DataSource = Nothing : ds.Clear()
  219. Set_清單1() : Set_清單()
  220. End If
  221. End Sub
  222. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  223. If TextBox1.Text = "" Then
  224. MsgBox("請選擇需要審核的單據。")
  225. Else
  226. PA = InputBox("請輸入作廢原因。")
  227. If PA = "" Then
  228. MsgBox("請輸入作廢原因,不可空白。")
  229. Else
  230. If CheckBox1.Checked = False Then
  231. Set_日期格式轉換()
  232. Else
  233. DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd")
  234. End If
  235. conn.Close()
  236. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  237. SQL1 = "UPDATE 公帳控制表 SET 審核人 = N'作廢-" & gUserName & "', 審核日期 = N'" & DTP & "', 備註 = N'" & PA & "' WHERE (支付單號 = N'" & TextBox1.Text & "')"
  238. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery()
  239. conn.Close()
  240. MsgBox("審核完畢。") : PA = ""
  241. TextBox1.Text = "" : TextBox3.Text = ""
  242. DataGridView1.DataSource = Nothing : ds.Clear()
  243. Set_清單1()
  244. End If
  245. End If
  246. End Sub
  247. '----------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------------------------------------
  248. Private Sub 重新讀取ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新讀取ToolStripMenuItem.Click
  249. Set_清單1()
  250. End Sub
  251. Private Sub 審核通過ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 審核通過ToolStripMenuItem.Click
  252. Me.Button1.PerformClick()
  253. End Sub
  254. Private Sub 單據作廢ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 單據作廢ToolStripMenuItem.Click
  255. Me.Button2.PerformClick()
  256. End Sub
  257. End Class