Ingen beskrivning
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 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. Option Strict Off
  2. Imports System.IO
  3. Public Class 營運成本收支單審核
  4. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet
  5. Private ReadOnly QQW(11) As String
  6. Private II As Integer
  7. Private Sub Set_清單1()
  8. DataGridView2.DataSource = Nothing : ds1.Clear()
  9. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  10. DataGridView2.ColumnHeadersHeight = 25
  11. DataGridView2.AllowUserToAddRows = False
  12. SQL_營運成本收支單審核清單()
  13. da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
  14. DataGridView2.Columns(0).FillWeight = 160 : DataGridView2.Columns(1).FillWeight = 100 : DataGridView2.Columns(2).FillWeight = 100 : DataGridView2.Columns(3).Visible = False
  15. End Sub
  16. Private Sub Set_費用清單()
  17. DataGridView1.DataSource = Nothing : ds.Clear()
  18. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  19. DataGridView1.ColumnHeadersHeight = 25
  20. DataGridView1.AllowUserToAddRows = False
  21. DataGridView1.RowTemplate.Height = 35
  22. SQL_營運成本收支單審核費用清單()
  23. da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  24. DataGridView1.Columns(0).Visible = False : DataGridView1.Columns(1).FillWeight = 80 : DataGridView1.Columns(2).FillWeight = 300 : DataGridView1.Columns(3).FillWeight = 500
  25. DataGridView1.Columns(4).FillWeight = 140 : DataGridView1.Columns(5).FillWeight = 140 : DataGridView1.Columns(6).FillWeight = 140 : DataGridView1.Columns(7).FillWeight = 140
  26. DataGridView1.Columns(8).FillWeight = 140
  27. DataGridView1.Columns(1).ReadOnly = True : DataGridView1.Columns(2).ReadOnly = True : DataGridView1.Columns(3).ReadOnly = True : DataGridView1.Columns(4).ReadOnly = True
  28. DataGridView1.Columns(5).ReadOnly = True : DataGridView1.Columns(6).ReadOnly = True
  29. DataGridView1.Columns(4).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(5).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(6).DefaultCellStyle.Format = "#,##0"
  30. DataGridView1.Columns(7).DefaultCellStyle.Format = "#,##0"
  31. DataGridView1.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  32. DataGridView1.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  33. DataGridView1.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  34. DataGridView1.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  35. DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
  36. TextBox5.Text = "0" : TextBox2.Text = "0" : TextBox6.Text = "0" : TextBox7.Text = "0" : TextBox8.Text = "0"
  37. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  38. TextBox5.Text = Val(TextBox5.Text) + DataGridView1.Rows(i).Cells("現金").Value : TextBox2.Text = Val(TextBox2.Text) + DataGridView1.Rows(i).Cells("支出").Value
  39. TextBox7.Text = Val(TextBox7.Text) + DataGridView1.Rows(i).Cells("零用金").Value : TextBox8.Text = Val(TextBox8.Text) + DataGridView1.Rows(i).Cells("支票").Value
  40. Next i
  41. TextBox6.Text = Val(TextBox7.Text) + Val(TextBox5.Text) - Val(TextBox2.Text)
  42. If Val(TextBox6.Text) > 0 Then : TextBox6.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  43. TextBox5.Text = Format(Val(TextBox5.Text), "#,##0") : TextBox2.Text = Format(Val(TextBox2.Text), "#,##0") : TextBox6.Text = Format(Val(TextBox6.Text), "#,##0")
  44. TextBox7.Text = Format(Val(TextBox7.Text), "#,##0") : TextBox8.Text = Format(Val(TextBox8.Text), "#,##0")
  45. End Sub
  46. Private Sub Set_清單()
  47. DataGridView3.DataSource = Nothing : ds2.Clear()
  48. DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  49. DataGridView3.ColumnHeadersHeight = 25
  50. DataGridView3.AllowUserToAddRows = False
  51. SQL_營運成本收支單審核_圖檔編碼()
  52. da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
  53. DataGridView3.Columns(0).FillWeight = 173 : DataGridView3.Columns(1).Visible = False
  54. If DataGridView3.Rows.Count = 0 Then : Else
  55. TextBox14.Text = DataGridView3(0, 0).Value.ToString : PA = TextBox14.Text
  56. SQL_使用者權限圖片顯示()
  57. While dr.Read() = True
  58. Dim unused As Byte() = New Byte(-1) {}
  59. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  60. Dim oStream As New MemoryStream(bytes)
  61. PictureBox1.Image = Bitmap.FromStream(oStream)
  62. End While
  63. conn.Close() : PictureBox1.SizeMode = 4
  64. For QAZ = 0 To 999
  65. 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
  66. 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)
  67. QQW(9) = Strings.Left(QQW(2), 1) : QQW(10) = Strings.Right(QQW(3), 1) : QQW(11) = Strings.Left(QQW(3), 1)
  68. For RT = 4 To 11
  69. Delay(3)
  70. Dim ran = New Random(DateTime.Now.Millisecond) : Dim NUM1 As Integer = ran.Next(1, 4096)
  71. For I = 0 To 4096 : If NUM1 > 9 Then : NUM1 -= 9 : ElseIf NUM1 < 9 Then : I = 4096 : End If : Next
  72. 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
  73. ElseIf NUM1 = 6 Then : II = RT : 轉換() : ElseIf NUM1 = 7 Then : ElseIf NUM1 = 8 Then : II = RT : 轉換() : ElseIf NUM1 = 9 Then : II = RT : 轉換() : End If
  74. Next
  75. Dim ran1 = New Random(DateTime.Now.Millisecond) : Dim NUM2 As Integer = ran1.Next(1, 4096)
  76. For I = 0 To 4096 : If NUM2 > 99 Then : NUM2 -= 49 : ElseIf NUM2 < 99 Then : I = 4096 : End If : Next
  77. 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
  78. SQL_營運成本收支單審核_簽名編碼() : If dr.Read() = True Then : Else : QAZ = 999 : End If : conn.Close()
  79. Next
  80. End If
  81. End Sub
  82. Private Sub 轉換()
  83. 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"
  84. 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"
  85. ElseIf QQW(II) = "9" Then : QQW(II) = "I" : ElseIf QQW(II) = "0" Then : QQW(II) = "J" : End If
  86. End Sub
  87. Public Sub Delay(ByRef Interval As Double) 'Interval单位为毫秒
  88. Dim time As DateTime = DateTime.Now : Dim Span As Double = Interval * 1234 : While ((DateTime.Now.Ticks - time.Ticks) < Span) : Application.DoEvents() : End While
  89. End Sub
  90. Private Sub 營運費用支付審核_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  91. Me.MdiParent = MAOJI_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  92. RadioButton1.Checked = True : DataGridView2.Visible = True
  93. Set_清單1() : Set_清單()
  94. End Sub
  95. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  96. If e.RowIndex = -1 Then : Else
  97. TextBox1.Text = DataGridView2(0, e.RowIndex).Value.ToString : DateTimePicker1.Value = DataGridView2(1, e.RowIndex).Value.ToString : Set_費用清單()
  98. TextBox3.Text = DataGridView2(3, e.RowIndex).Value.ToString
  99. End If
  100. End Sub
  101. Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
  102. If e.RowIndex = -1 Then : Else
  103. TextBox14.Text = DataGridView3(0, e.RowIndex).Value.ToString : PA = TextBox14.Text
  104. SQL_使用者權限圖片顯示()
  105. While dr.Read() = True
  106. Dim unused As Byte() = New Byte(-1) {}
  107. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  108. Dim oStream As New MemoryStream(bytes)
  109. PictureBox1.Image = Bitmap.FromStream(oStream)
  110. End While
  111. conn.Close()
  112. PictureBox1.SizeMode = 4
  113. For QAZ = 0 To 999
  114. 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
  115. 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)
  116. QQW(9) = Strings.Left(QQW(2), 1) : QQW(10) = Strings.Right(QQW(3), 1) : QQW(11) = Strings.Left(QQW(3), 1)
  117. For RT = 4 To 11
  118. Delay(3)
  119. Dim ran = New Random(DateTime.Now.Millisecond) : Dim NUM1 As Integer = ran.Next(1, 4096)
  120. For I = 0 To 4096 : If NUM1 > 9 Then : NUM1 -= 9 : ElseIf NUM1 < 9 Then : I = 4096 : End If : Next
  121. 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
  122. ElseIf NUM1 = 6 Then : II = RT : 轉換() : ElseIf NUM1 = 7 Then : ElseIf NUM1 = 8 Then : II = RT : 轉換() : ElseIf NUM1 = 9 Then : II = RT : 轉換() : End If
  123. Next
  124. Dim ran1 = New Random(DateTime.Now.Millisecond) : Dim NUM2 As Integer = ran1.Next(1, 4096)
  125. For I = 0 To 4096 : If NUM2 > 99 Then : NUM2 -= 49 : ElseIf NUM2 < 99 Then : I = 4096 : End If : Next
  126. 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
  127. SQL_營運成本收支單審核_簽名編碼() : If dr.Read() = True Then : Else : QAZ = 999 : End If : conn.Close()
  128. Next
  129. End If
  130. End Sub
  131. Private Sub Set_切換格式()
  132. DataGridView1.DataSource = Nothing : ds.Clear() : TextBox1.Text = "" : TextBox3.Text = "" : TextBox5.Text = "" : TextBox2.Text = "" : TextBox6.Text = ""
  133. TextBox7.Text = "" : TextBox8.Text = "" : Set_清單1()
  134. End Sub
  135. Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.Click
  136. RadioButton1.Checked = True : RadioButton2.Checked = False
  137. DataGridView1.DataSource = Nothing : ds.Clear() : TextBox1.Text = "" : TextBox3.Text = "" : TextBox5.Text = "" : TextBox2.Text = "" : TextBox6.Text = ""
  138. Button1.Enabled = True : Button2.Enabled = True : 審核通過ToolStripMenuItem.Enabled = True : 單據作廢ToolStripMenuItem.Enabled = True : Set_切換格式()
  139. End Sub
  140. Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.Click
  141. RadioButton1.Checked = False : RadioButton2.Checked = True
  142. DataGridView1.DataSource = Nothing : ds.Clear() : TextBox1.Text = "" : TextBox3.Text = "" : TextBox5.Text = "" : TextBox2.Text = "" : TextBox6.Text = ""
  143. Button1.Enabled = False : Button2.Enabled = False : 審核通過ToolStripMenuItem.Enabled = False : 單據作廢ToolStripMenuItem.Enabled = False : Set_切換格式()
  144. End Sub
  145. Private Sub Set_日期格式轉換()
  146. DTP = Format(Today(), "yyyy/MM/dd")
  147. End Sub
  148. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  149. If TextBox1.Text = "" Then : MsgBox("請選擇需要審核的單據。")
  150. Else
  151. If CheckBox1.Checked = False Then : Set_日期格式轉換() : Else : DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd") : End If
  152. SQL_營運成本收支單審核_控制表修改() : conn.Close()
  153. SQL_營運成本收支單審核_明細表修改() : conn.Close()
  154. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  155. PA1 = TextBox1.Text : PA2 = DataGridView1.Rows(i).Cells("項次").Value
  156. If DataGridView1.Rows(i).Cells("零用金").Value <> 0 Then : SQL_營運成本收支單審核_明細表_備用金確認() : conn.Close()
  157. ElseIf DataGridView1.Rows(i).Cells("現金").Value <> 0 Then : SQL_營運成本收支單審核_明細表_現金確認() : conn.Close()
  158. ElseIf DataGridView1.Rows(i).Cells("支出").Value <> 0 Then : SQL_營運成本收支單審核_明細表_公帳確認() : conn.Close() : End If
  159. Next
  160. MsgBox("審核完畢。") : TextBox1.Text = "" : TextBox3.Text = "" : DataGridView1.DataSource = Nothing : ds.Clear() : Set_清單1() : Set_清單()
  161. End If
  162. End Sub
  163. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  164. If TextBox1.Text = "" Then : MsgBox("請選擇需要審核的單據。")
  165. Else
  166. PA = InputBox("請輸入作廢原因。")
  167. If PA = "" Then : MsgBox("請輸入作廢原因,不可空白。")
  168. Else
  169. If CheckBox1.Checked = False Then : Set_日期格式轉換() : Else : DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd") : End If
  170. SQL_營運成本收支單審核_控制表作廢() : conn.Close()
  171. MsgBox("審核完畢。") : PA = "" : TextBox1.Text = "" : TextBox3.Text = "" : DataGridView1.DataSource = Nothing : ds.Clear() : Set_清單1()
  172. End If
  173. End If
  174. End Sub
  175. '----------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------------------------------------
  176. Private Sub 重新讀取ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新讀取ToolStripMenuItem.Click
  177. Set_清單1()
  178. End Sub
  179. Private Sub 審核通過ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 審核通過ToolStripMenuItem.Click
  180. Me.Button1.PerformClick()
  181. End Sub
  182. Private Sub 單據作廢ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 單據作廢ToolStripMenuItem.Click
  183. Me.Button2.PerformClick()
  184. End Sub
  185. End Class