暫無描述
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 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. Option Strict Off
  2. Public Class 支票收支單申請
  3. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet
  4. Dim 新項次 As String : Dim NUM1 As Integer
  5. Private Sub Set_清單1()
  6. DataGridView2.DataSource = Nothing : ds1.Clear()
  7. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  8. DataGridView2.ColumnHeadersHeight = 25
  9. DataGridView2.AllowUserToAddRows = False
  10. SQL_支票收支單申請清單()
  11. da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close()
  12. DataGridView2.Columns(0).FillWeight = 145 : DataGridView2.Columns(1).FillWeight = 100 : DataGridView2.Columns(2).Visible = False : DataGridView2.Columns(3).Visible = False
  13. DataGridView2.Columns(4).FillWeight = 75
  14. End Sub
  15. Private Sub Set_費用清單()
  16. DataGridView1.DataSource = Nothing : ds.Clear()
  17. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  18. DataGridView1.ColumnHeadersHeight = 40
  19. DataGridView1.AllowUserToAddRows = False
  20. DataGridView1.RowTemplate.Height = 35
  21. SQL_支票收支單申請費用清單()
  22. da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  23. DataGridView1.Columns(0).Visible = False : DataGridView1.Columns(1).FillWeight = 80 : DataGridView1.Columns(2).FillWeight = 140 : DataGridView1.Columns(3).FillWeight = 300
  24. DataGridView1.Columns(4).FillWeight = 120 : DataGridView1.Columns(5).FillWeight = 120 : DataGridView1.Columns(6).Visible = False : DataGridView1.Columns(7).Visible = False
  25. DataGridView1.Columns(8).FillWeight = 200 : DataGridView1.Columns(9).Visible = False : DataGridView1.Columns(10).FillWeight = 110 : DataGridView1.Columns(11).Visible = False
  26. DataGridView1.Columns(12).FillWeight = 200 : DataGridView1.Columns(13).FillWeight = 150 : DataGridView1.Columns(14).FillWeight = 150 : DataGridView1.Columns(15).FillWeight = 150
  27. DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Visible = False : DataGridView1.Columns(18).Visible = False : DataGridView1.Columns(19).Visible = False
  28. DataGridView1.Columns(20).FillWeight = 100 : DataGridView1.Columns(21).Visible = False
  29. DataGridView1.Columns(1).ReadOnly = True : DataGridView1.Columns(2).ReadOnly = True : DataGridView1.Columns(10).ReadOnly = True : DataGridView1.Columns(4).ReadOnly = True
  30. DataGridView1.Columns(5).ReadOnly = True : DataGridView1.Columns(20).ReadOnly = True
  31. DataGridView1.Columns(4).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(5).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(6).DefaultCellStyle.Format = "#,##0"
  32. DataGridView1.Columns(7).DefaultCellStyle.Format = "#,##0"
  33. DataGridView1.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  34. DataGridView1.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(2).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  35. DataGridView1.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  36. DataGridView1.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  37. DataGridView1.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  38. DataGridView1.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  39. DataGridView1.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  40. DataGridView1.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  41. DataGridView1.Columns(13).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(13).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  42. DataGridView1.Columns(14).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(14).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  43. DataGridView1.Columns(15).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(15).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  44. DataGridView1.Columns(20).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(20).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  45. DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
  46. TextBox5.Text = "0" : TextBox2.Text = "0" : TextBox6.Text = "0" : TextBox7.Text = "0" : TextBox8.Text = "0"
  47. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  48. TextBox5.Text = Val(TextBox5.Text) + DataGridView1.Rows(i).Cells("現金").Value : TextBox2.Text = Val(TextBox2.Text) + DataGridView1.Rows(i).Cells("支出").Value
  49. TextBox7.Text = Val(TextBox7.Text) + DataGridView1.Rows(i).Cells("開票").Value : TextBox8.Text = Val(TextBox8.Text) + DataGridView1.Rows(i).Cells("收票").Value
  50. If DataGridView1.Rows(i).Cells("開票").Value <> 0 And DataGridView1.Rows(i).Cells("收票").Value = 0 Then
  51. DataGridView1.Rows(i).Cells("狀態").Value = "開票"
  52. ElseIf DataGridView1.Rows(i).Cells("開票").Value = 0 And DataGridView1.Rows(i).Cells("收票").Value <> 0 Then
  53. DataGridView1.Rows(i).Cells("狀態").Value = "收票"
  54. End If
  55. Next i
  56. TextBox6.Text = Val(TextBox8.Text) - Val(TextBox7.Text)
  57. If Val(TextBox6.Text) > 0 Then : TextBox6.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  58. TextBox5.Text = Format(Val(TextBox5.Text), "#,##0") : TextBox2.Text = Format(Val(TextBox2.Text), "#,##0") : TextBox6.Text = Format(Val(TextBox6.Text), "#,##0")
  59. TextBox7.Text = Format(Val(TextBox7.Text), "#,##0") : TextBox8.Text = Format(Val(TextBox8.Text), "#,##0")
  60. End Sub
  61. Private Sub ComboBox1下拉表單資料載入()
  62. PA = ComboBox4.Text : SQL_會計科目_第三階_只含流動票務()
  63. ComboBox1.Items.Clear() : ComboBox6.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("會計科目")) : ComboBox6.Items.Add(dr("編號")) : End While : conn.Close()
  64. If ComboBox1.Items.Count <> 0 Then : ComboBox1.SelectedIndex = 0 : End If
  65. End Sub
  66. Private Sub ComboBox2下拉表單資料載入()
  67. SQL_會計科目_第一階_只含流動票務()
  68. ComboBox5.Items.Clear() : ComboBox2.Items.Clear() : While (dr.Read()) : ComboBox5.Items.Add(dr("第一階")) : ComboBox2.Items.Add(dr("編號")) : End While : conn.Close()
  69. End Sub
  70. Private Sub ComboBox3下拉表單資料載入()
  71. PA = ComboBox2.Text : SQL_會計科目_第二階_只含流動票務()
  72. ComboBox3.Items.Clear() : ComboBox4.Items.Clear() : While (dr.Read()) : ComboBox3.Items.Add(dr("第二階")) : ComboBox4.Items.Add(dr("編號")) : End While : conn.Close() : PA = ""
  73. End Sub
  74. Private Sub ComboBox7下拉表單資料載入_收票()
  75. SQL_支票收支單申請_兌現科目_下拉清單一()
  76. ComboBox8.Items.Clear() : ComboBox10.Items.Clear() : While (dr.Read()) : ComboBox8.Items.Add(dr("會計科目")) : ComboBox10.Items.Add(dr("編號")) : End While : conn.Close()
  77. End Sub
  78. Private Sub ComboBox7下拉表單資料載入_開票()
  79. SQL_支票收支單申請_兌現科目_下拉清單二()
  80. ComboBox8.Items.Clear() : ComboBox10.Items.Clear() : While (dr.Read()) : ComboBox8.Items.Add(dr("會計科目")) : ComboBox10.Items.Add(dr("編號")) : End While : conn.Close()
  81. End Sub
  82. Private Sub ComboBox9下拉表單資料載入_收票()
  83. SQL_支票收支單申請_付款銀行_下拉清單()
  84. ComboBox9.Items.Clear() : While (dr.Read()) : ComboBox9.Items.Add(dr("付款銀行")) : End While : conn.Close()
  85. End Sub
  86. Private Sub ComboBox9下拉表單資料載入_開票()
  87. SQL_支票收支單申請_兌現科目_下拉清單一()
  88. ComboBox9.Items.Clear() : While (dr.Read()) : ComboBox9.Items.Add(dr("會計科目")) : End While : conn.Close()
  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. DateTimePicker2.Visible = False : 複製單據開單ToolStripMenuItem.Enabled = False : ComboBox6.Visible = False : ComboBox10.Visible = False
  93. TextBox2.Visible = False : TextBox5.Visible = False : Label8.Visible = False : Label5.Visible = False : TextBox10.Enabled = False : TextBox11.Enabled = False
  94. DataGridView2.Visible = True : Set_清單1() : ComboBox2下拉表單資料載入()
  95. End Sub
  96. Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.TextChanged
  97. ComboBox2.SelectedIndex = ComboBox5.SelectedIndex : TextBox9.Text = "" : ComboBox3下拉表單資料載入() : ComboBox1下拉表單資料載入()
  98. End Sub
  99. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.TextChanged
  100. ComboBox5.SelectedIndex = ComboBox2.SelectedIndex : ComboBox3下拉表單資料載入() : ComboBox1下拉表單資料載入()
  101. End Sub
  102. Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.TextChanged
  103. ComboBox4.SelectedIndex = ComboBox3.SelectedIndex : ComboBox1下拉表單資料載入()
  104. End Sub
  105. Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.TextChanged
  106. ComboBox3.SelectedIndex = ComboBox4.SelectedIndex : ComboBox1下拉表單資料載入()
  107. End Sub
  108. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
  109. ComboBox6.SelectedIndex = ComboBox1.SelectedIndex
  110. End Sub
  111. Private Sub ComboBox6_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox6.SelectedIndexChanged
  112. ComboBox1.SelectedIndex = ComboBox6.SelectedIndex
  113. End Sub
  114. Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox8.SelectedIndexChanged
  115. ComboBox10.SelectedIndex = ComboBox8.SelectedIndex
  116. End Sub
  117. Private Sub ComboBox10_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox10.SelectedIndexChanged
  118. ComboBox8.SelectedIndex = ComboBox10.SelectedIndex
  119. End Sub
  120. Private Sub ComboBox7_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
  121. If ComboBox7.Text = "收票" Then
  122. ComboBox7下拉表單資料載入_收票() : ComboBox5.SelectedIndex = 0 : ComboBox3.SelectedIndex = 1 : ComboBox1.SelectedIndex = 0 : ComboBox9.Text = "" : ComboBox9下拉表單資料載入_收票()
  123. Else
  124. ComboBox7下拉表單資料載入_開票() : ComboBox5.SelectedIndex = 1 : ComboBox3.SelectedIndex = 1 : ComboBox1.SelectedIndex = 0 : ComboBox9.Text = "" : ComboBox9下拉表單資料載入_開票()
  125. End If
  126. End Sub
  127. Private Sub TextBox9_TextChanged(sender As Object, e As EventArgs) Handles TextBox9.TextChanged
  128. PA = TextBox9.Text : SQL_會計科目_關鍵字_只含流動票務()
  129. ComboBox1.Items.Clear() : ComboBox6.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("會計科目")) : ComboBox6.Items.Add(dr("編號")) : End While : conn.Close()
  130. If ComboBox1.Items.Count <> 0 Then : ComboBox1.SelectedIndex = 0 : End If : PA = ""
  131. End Sub
  132. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  133. If Label62.Visible = True Then : Label62.Visible = False : Else : Label62.Visible = True : End If
  134. End Sub
  135. Private Sub DataGridView1_CellContentCl(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
  136. TextBox5.Text = "0" : TextBox2.Text = "0" : TextBox6.Text = "0" : TextBox7.Text = "0" : TextBox8.Text = "0"
  137. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  138. TextBox5.Text = Val(TextBox5.Text) + DataGridView1.Rows(i).Cells("現金").Value : TextBox2.Text = Val(TextBox2.Text) + DataGridView1.Rows(i).Cells("支出").Value
  139. TextBox7.Text = Val(TextBox7.Text) + DataGridView1.Rows(i).Cells("開票").Value : TextBox8.Text = Val(TextBox8.Text) + DataGridView1.Rows(i).Cells("收票").Value
  140. If DataGridView1.Rows(i).Cells("開票").Value <> 0 And DataGridView1.Rows(i).Cells("收票").Value = 0 Then
  141. DataGridView1.Rows(i).Cells("狀態").Value = "開票"
  142. ElseIf DataGridView1.Rows(i).Cells("開票").Value = 0 And DataGridView1.Rows(i).Cells("收票").Value <> 0 Then
  143. DataGridView1.Rows(i).Cells("狀態").Value = "收票"
  144. End If
  145. Next i
  146. TextBox6.Text = Val(TextBox8.Text) - Val(TextBox7.Text)
  147. If Val(TextBox6.Text) > 0 Then : TextBox6.ForeColor = Color.Blue : Else : TextBox6.ForeColor = Color.Red : End If
  148. TextBox5.Text = Format(Val(TextBox5.Text), "#,##0") : TextBox2.Text = Format(Val(TextBox2.Text), "#,##0") : TextBox6.Text = Format(Val(TextBox6.Text), "#,##0")
  149. TextBox7.Text = Format(Val(TextBox7.Text), "#,##0") : TextBox8.Text = Format(Val(TextBox8.Text), "#,##0")
  150. Dim EU1 As String : Dim EU2 As String : Dim EU3 As String
  151. EU1 = DataGridView1("到期日", e.RowIndex).Value.ToString : EU2 = DataGridView1("預定兌現日", e.RowIndex).Value.ToString : EU3 = DataGridView1("開收票日", e.RowIndex).Value.ToString
  152. If EU1 = "" Then : Else : DateTimePicker2.Text = EU1 : DataGridView1.Rows(e.RowIndex).Cells("到期日").Value = Format(DateTimePicker2.Value, "yyyy/MM/dd") : End If
  153. If EU2 = "" Then : Else : DateTimePicker2.Text = EU2 : DataGridView1.Rows(e.RowIndex).Cells("預定兌現日").Value = Format(DateTimePicker2.Value, "yyyy/MM/dd") : End If
  154. If EU3 = "" Then : Else : DateTimePicker2.Text = EU3 : DataGridView1.Rows(e.RowIndex).Cells("開收票日").Value = Format(DateTimePicker2.Value, "yyyy/MM/dd") : End If
  155. End Sub
  156. Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  157. If e.RowIndex = -1 Then : Else
  158. TextBox1.Text = DataGridView2(0, e.RowIndex).Value.ToString : DateTimePicker1.Value = DataGridView2(1, e.RowIndex).Value.ToString : Set_費用清單()
  159. TextBox3.Text = DataGridView2(3, e.RowIndex).Value.ToString
  160. '-------------------------------------------------------------------------------------------------------------------------------------------------------------
  161. TextBox15.Text = DataGridView1("發票人帳號", 0).Value.ToString : TextBox14.Text = DataGridView1("用途", 0).Value.ToString
  162. TextBox4.Text = DataGridView1("項次", 0).Value.ToString : TextBox9.Text = DataGridView1("會計科目", 0).Value.ToString
  163. ComboBox7.Text = DataGridView1("狀態", 0).Value.ToString : ComboBox1.Text = DataGridView1("會計科目", 0).Value.ToString
  164. ComboBox10.Text = DataGridView1("兌現科目", 0).Value.ToString : ComboBox9.Text = DataGridView1("付款銀行", 0).Value.ToString
  165. TextBox10.Text = DataGridView1("倉儲單號", 0).Value.ToString : TextBox12.Text = DataGridView1("支票號碼", 0).Value.ToString
  166. TextBox13.Text = DataGridView1("開票人", 0).Value.ToString : TextBox16.Text = DataGridView1("備註", 0).Value.ToString
  167. If DataGridView1("到期日", 0).Value.ToString = "" Then : Else : DateTimePicker3.Value = DataGridView1("到期日", 0).Value.ToString : End If
  168. If DataGridView1("預定兌現日", 0).Value.ToString = "" Then : Else : DateTimePicker4.Value = DataGridView1("預定兌現日", 0).Value.ToString : End If
  169. If DataGridView1("開收票日", 0).Value.ToString = "" Then : Else : DateTimePicker5.Value = DataGridView1("開收票日", 0).Value.ToString : End If
  170. If ComboBox7.Text = "開票" Then : NumericUpDown1.Value = DataGridView1("開票", 0).Value : Else : NumericUpDown1.Value = DataGridView1("收票", 0).Value : End If
  171. 客戶供應商資料()
  172. '-------------------------------------------------------------------------------------------------------------------------------------------------------------
  173. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  174. If DataGridView1.Rows(i).Cells("開票").Value <> 0 And DataGridView1.Rows(i).Cells("收票").Value = 0 Then
  175. DataGridView1.Rows(i).Cells("狀態").Value = "開票"
  176. ElseIf DataGridView1.Rows(i).Cells("開票").Value = 0 And DataGridView1.Rows(i).Cells("收票").Value <> 0 Then
  177. DataGridView1.Rows(i).Cells("狀態").Value = "收票"
  178. End If
  179. Next i
  180. End If
  181. End Sub
  182. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  183. If e.RowIndex = -1 Then : Else
  184. TextBox15.Text = DataGridView1("發票人帳號", e.RowIndex).Value.ToString : TextBox14.Text = DataGridView1("用途", e.RowIndex).Value.ToString
  185. TextBox4.Text = DataGridView1("項次", e.RowIndex).Value.ToString : TextBox9.Text = DataGridView1("會計科目", e.RowIndex).Value.ToString
  186. ComboBox7.Text = DataGridView1("狀態", e.RowIndex).Value.ToString : ComboBox1.Text = DataGridView1("會計科目", e.RowIndex).Value.ToString
  187. ComboBox10.Text = DataGridView1("兌現科目", e.RowIndex).Value.ToString : ComboBox9.Text = DataGridView1("付款銀行", e.RowIndex).Value.ToString
  188. TextBox10.Text = DataGridView1("倉儲單號", e.RowIndex).Value.ToString : TextBox12.Text = DataGridView1("支票號碼", e.RowIndex).Value.ToString
  189. TextBox13.Text = DataGridView1("開票人", e.RowIndex).Value.ToString : TextBox16.Text = DataGridView1("備註", e.RowIndex).Value.ToString
  190. If DataGridView1("到期日", e.RowIndex).Value.ToString = "" Then : Else : DateTimePicker3.Value = DataGridView1("到期日", e.RowIndex).Value.ToString : End If
  191. If DataGridView1("預定兌現日", e.RowIndex).Value.ToString = "" Then : Else : DateTimePicker4.Value = DataGridView1("預定兌現日", e.RowIndex).Value.ToString : End If
  192. If DataGridView1("開收票日", e.RowIndex).Value.ToString = "" Then : Else : DateTimePicker5.Value = DataGridView1("開收票日", e.RowIndex).Value.ToString : End If
  193. If ComboBox7.Text = "開票" Then
  194. NumericUpDown1.Value = DataGridView1("開票", e.RowIndex).Value
  195. Else
  196. NumericUpDown1.Value = DataGridView1("收票", e.RowIndex).Value
  197. End If
  198. 客戶供應商資料()
  199. End If
  200. End Sub
  201. Private Sub 客戶供應商資料()
  202. PA = TextBox10.Text : SQL_支票收支單客戶供應商查詢()
  203. If (dr.Read()) Then
  204. If ComboBox7.Text = "開票" Then
  205. TextBox11.Text = dr("供應商") : conn.Close()
  206. Else
  207. TextBox11.Text = dr("客戶編號")
  208. If TextBox11.Text = "CI00000000" Then
  209. conn.Close()
  210. SQL_支票收支單申請_客戶資料_零售()
  211. If (dr.Read()) Then
  212. TextBox11.Text = dr("客戶名稱") : conn.Close()
  213. End If
  214. Else
  215. TextBox11.Text = dr("客戶") : conn.Close()
  216. End If
  217. End If
  218. Else
  219. TextBox11.Text = ""
  220. End If
  221. End Sub
  222. Private Sub Set_切換格式()
  223. DataGridView1.DataSource = Nothing : ds.Clear() : TextBox1.Text = "" : TextBox3.Text = "" : TextBox4.Text = "" : TextBox5.Text = "" : TextBox2.Text = "" : TextBox6.Text = ""
  224. TextBox7.Text = "" : TextBox8.Text = "" : ComboBox1下拉表單資料載入() : Set_清單1()
  225. End Sub
  226. Private Sub 存檔()
  227. PA4 = TextBox1.Text
  228. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  229. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  230. PA1 = DataGridView1.Rows(i).Cells("用途").Value : NU1 = DataGridView1.Rows(i).Cells("支出").Value : PA2 = DataGridView1.Rows(i).Cells("備註").Value
  231. PA3 = DataGridView1.Rows(i).Cells("科目編號").Value : NU2 = DataGridView1.Rows(i).Cells("現金").Value : NU3 = DataGridView1.Rows(i).Cells("開票").Value
  232. NU4 = DataGridView1.Rows(i).Cells("收票").Value : PA5 = DataGridView1.Rows(i).Cells("項次").Value : PA6 = DataGridView1.Rows(i).Cells("狀態").Value : PA7 = gUserName
  233. PA8 = DataGridView1.Rows(i).Cells("發票人帳號").Value.ToString : PA9 = DataGridView1.Rows(i).Cells("兌現科目").Value.ToString : PA10 = DataGridView1.Rows(i).Cells("付款銀行").Value.ToString
  234. PA11 = DataGridView1.Rows(i).Cells("倉儲單號").Value.ToString : PA12 = DataGridView1.Rows(i).Cells("支票號碼").Value.ToString : PA13 = DataGridView1.Rows(i).Cells("開票人").Value.ToString
  235. PA14 = DataGridView1.Rows(i).Cells("到期日").Value.ToString : PA15 = DataGridView1.Rows(i).Cells("預定兌現日").Value.ToString : PA16 = DataGridView1.Rows(i).Cells("開收票日").Value.ToString
  236. SQL_支票收支單申請修改() : conn.Close()
  237. Next : MAOJI_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  238. End Sub
  239. Private Sub 單筆存檔()
  240. DTP = Format(DateTimePicker3.Value, "yyyy/MM/dd") : DTP1 = Format(DateTimePicker4.Value, "yyyy/MM/dd") : DTP2 = Format(DateTimePicker5.Value, "yyyy/MM/dd")
  241. If ComboBox7.Text = "開票" Then : NU3 = NumericUpDown1.Value : NU4 = 0 : Else : NU4 = NumericUpDown1.Value : NU3 = 0 : End If
  242. PA4 = TextBox1.Text : PA1 = TextBox14.Text : NU1 = 0 : PA2 = TextBox16.Text : PA3 = ComboBox6.Text : NU2 = 0 : PA5 = TextBox4.Text : PA6 = ComboBox7.Text : PA7 = gUserName
  243. PA8 = TextBox15.Text : PA9 = ComboBox10.Text : PA10 = ComboBox9.Text : PA11 = TextBox10.Text : PA12 = TextBox12.Text : PA13 = TextBox13.Text : PA14 = DTP : PA15 = DTP1 : PA16 = DTP2
  244. SQL_支票收支單申請修改() : conn.Close()
  245. End Sub
  246. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  247. Timer1.Enabled = False : Label62.Visible = False
  248. 開立支票收支群組單號ToolStripMenuItem.Enabled = True : DataGridView2.Enabled = True
  249. 單筆存檔() : Set_費用清單() : MsgBox("存檔完成。")
  250. End Sub
  251. Private Sub Set_日期格式轉換()
  252. If CheckBox1.Checked = False Then : DTP = Format(Today(), "yyyy/MM/dd") : DTP1 = Format(Today(), "yyyyMMdd")
  253. Else : DTP1 = Format(DateTimePicker1.Value, "yyyyMMdd") : DTP = Format(DateTimePicker1.Value, "yyyy/MM/dd") : End If
  254. End Sub
  255. Private Sub 開立零用金支付單()
  256. Dim NUM1 As Integer : Timer1.Enabled = True
  257. Set_日期格式轉換()
  258. For i As Integer = 1 To 999
  259. NUM1 = 0 + i
  260. If NUM1 < 10 Then : TextBox1.Text = "OE-" & DTP1 & "-00" & NUM1
  261. ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox1.Text = "OE-" & DTP1 & "-0" & NUM1
  262. ElseIf NUM1 > 99 Then : TextBox1.Text = "OE-" & DTP1 & "-" & NUM1 : End If : PA = TextBox1.Text
  263. SQL_營運成本收支單申請_支付單號流水號()
  264. If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close()
  265. Next
  266. SQL_支票收支單申請_營運成本控制表新增() : TextBox3.Text = gUserName
  267. End Sub
  268. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  269. Set_日期格式轉換() : 開立零用金支付單() : 開立支票收支群組單號ToolStripMenuItem.Enabled = False : DataGridView2.Enabled = False : 票據資料存檔ToolStripMenuItem.Enabled = True
  270. 複製單據開單ToolStripMenuItem.Enabled = False : 開立支票收支群組單號ToolStripMenuItem.Enabled = True : Button2.Enabled = True : 新增一筆空白支票ToolStripMenuItem.Enabled = True
  271. 刪除一筆支票資料資料ToolStripMenuItem.Enabled = True : 刪除選中的支票收支單ToolStripMenuItem.Enabled = True
  272. Set_清單1()
  273. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  274. PA1 = TextBox1.Text : PA2 = DataGridView1.Rows(i).Cells("項次").Value : PA3 = DataGridView1.Rows(i).Cells("科目編號").Value : PA4 = DataGridView1.Rows(i).Cells("用途").Value
  275. NU1 = DataGridView1.Rows(i).Cells("支出").Value : PA5 = DataGridView1.Rows(i).Cells("備註").Value : NU2 = DataGridView1.Rows(i).Cells("現金").Value
  276. NU3 = DataGridView1.Rows(i).Cells("開票").Value : NU4 = DataGridView1.Rows(i).Cells("收票").Value : PA6 = DataGridView1.Rows(i).Cells("狀態").Value : PA7 = gUserName
  277. PA8 = DataGridView1.Rows(i).Cells("發票人帳號").Value : PA9 = DataGridView1.Rows(i).Cells("兌現科目").Value : PA10 = DataGridView1.Rows(i).Cells("付款銀行").Value
  278. PA11 = DataGridView1.Rows(i).Cells("倉儲單號").Value : PA12 = DataGridView1.Rows(i).Cells("支票號碼").Value : PA13 = DataGridView1.Rows(i).Cells("開票人").Value
  279. PA14 = DataGridView1.Rows(i).Cells("到期日").Value : PA15 = DataGridView1.Rows(i).Cells("預定兌現日").Value : PA16 = DataGridView1.Rows(i).Cells("開收票日").Value
  280. SQL_支票收支單申請複製單據新增()
  281. Next : Set_費用清單() : MsgBox("複製單據開立完成。")
  282. End Sub
  283. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  284. Timer1.Enabled = False : Label62.Visible = False
  285. 開立支票收支群組單號ToolStripMenuItem.Enabled = True : DataGridView2.Enabled = True
  286. 存檔() : Set_清單1() : MsgBox("申請完成,請通知主管審核。")
  287. End Sub
  288. '----------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------------------------------------
  289. Private Sub 重新讀取ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新讀取ToolStripMenuItem.Click
  290. Set_清單1() : Set_切換格式()
  291. End Sub
  292. Private Sub 開立零用金支付單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 開立支票收支群組單號ToolStripMenuItem.Click
  293. 開立零用金支付單()
  294. 開立支票收支群組單號ToolStripMenuItem.Enabled = False : DataGridView2.Enabled = False
  295. DataGridView1.DataSource = Nothing : ds.Clear() : conn.Close() : Set_清單1()
  296. End Sub
  297. Private Sub 刪除選中的零用金支付單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 刪除選中的支票收支單ToolStripMenuItem.Click
  298. Dim aa As MsgBoxResult = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  299. If aa = MsgBoxResult.Ok Then
  300. PA1 = TextBox1.Text : SQL_營運成本控制表刪除() : conn.Close() : SQL_營運成本明細表刪除() : conn.Close()
  301. TextBox1.Text = "" : TextBox3.Text = "" : TextBox4.Text = "" : DataGridView1.DataSource = Nothing : ds.Clear() : Set_清單1()
  302. End If
  303. End Sub
  304. Private Sub 刪除支付單中選中的資料ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 刪除一筆支票資料資料ToolStripMenuItem.Click
  305. If TextBox4.Text = "" Then : MsgBox("未選擇需要刪除的資料。")
  306. Else
  307. 存檔() : PA1 = TextBox1.Text : PA2 = TextBox4.Text : SQL_營運成本明細表刪除單筆() : conn.Close() : Set_費用清單() : Dim NUM1 As Integer = 0
  308. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  309. NUM1 += 1 : If NUM1 < 10 Then : 新項次 = "0" & NUM1 : ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 : End If
  310. PA1 = 新項次 : PA2 = TextBox1.Text : PA3 = DataGridView1.Rows(i).Cells("項次").Value
  311. SQL_營運成本明細表項次修改() : conn.Close()
  312. Next : Set_費用清單()
  313. End If
  314. End Sub
  315. Private Sub 新增一筆資料ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 新增一筆空白支票ToolStripMenuItem.Click
  316. If ComboBox6.Text = "" Then : MsgBox("沒有選擇會計科目。")
  317. Else
  318. If ComboBox7.Text = "" Then : MsgBox("請確定狀態要收票還是開票。")
  319. Else
  320. If TextBox1.Text = "" Then : 開立零用金支付單() : End If
  321. Set_日期格式轉換() : 存檔() : PA = TextBox1.Text
  322. SQL_營運成本明細表項次新增查詢()
  323. If dr.Read() Then : 新項次 = dr("項次") : Else : 新項次 = "00" : End If : conn.Close() : NUM1 = Double.Parse(新項次) + 1
  324. If NUM1 < 10 Then : 新項次 = "0" & NUM1
  325. ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 : End If
  326. PA1 = TextBox1.Text : PA2 = 新項次 : PA3 = ComboBox6.Text : PA4 = "" : NU1 = 0 : PA5 = "" : NU2 = 0 : NU3 = 0 : NU4 = 0 : PA6 = ComboBox7.Text : PA7 = gUserName
  327. SQL_營運成本明細表新增() : Set_費用清單()
  328. End If
  329. End If
  330. End Sub
  331. Private Sub 申請完成ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 票據資料存檔ToolStripMenuItem.Click
  332. Me.Button2.PerformClick()
  333. End Sub
  334. Private Sub 複製單據開單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 複製單據開單ToolStripMenuItem.Click
  335. Me.Button1.PerformClick()
  336. End Sub
  337. End Class