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 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. Option Strict Off
  2. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  3. Imports Microsoft.Office.Interop.Excel.Constants
  4. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  5. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  6. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  7. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  8. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  9. Imports Microsoft.Office.Interop.Excel.XlWindowState
  10. Imports Microsoft.Office.Interop.Excel
  11. Public Class 業務佣金計算
  12. ReadOnly ds As New DataSet
  13. Dim 新項次 As String
  14. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet : Dim N1 As Integer
  15. Private Sub Set_業務佣金清單()
  16. DataGridView1.DataSource = Nothing : ds.Clear() : DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing : DataGridView1.ColumnHeadersHeight = 25
  17. DataGridView1.AllowUserToAddRows = False : DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText : DataGridView1.MultiSelect = True
  18. SQL_業務佣金計算清單()
  19. da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
  20. DataGridView1.Columns(0).FillWeight = 100 : DataGridView1.Columns(1).FillWeight = 80 : DataGridView1.Columns(2).FillWeight = 80 : DataGridView1.Columns(3).FillWeight = 250
  21. DataGridView1.Columns(4).FillWeight = 80 : DataGridView1.Columns(5).FillWeight = 80 : DataGridView1.Columns(6).FillWeight = 80 : DataGridView1.Columns(7).FillWeight = 80
  22. DataGridView1.Columns(8).FillWeight = 80 : DataGridView1.Columns(9).FillWeight = 60 : DataGridView1.Columns(10).FillWeight = 60 : DataGridView1.Columns(11).Visible = False
  23. DataGridView1.Columns(4).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(5).DefaultCellStyle.Format = "#,##0"
  24. DataGridView1.Columns(7).DefaultCellStyle.Format = "#,##0.0" : DataGridView1.Columns(8).DefaultCellStyle.Format = "#,##0"
  25. DataGridView1.Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(0).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  26. DataGridView1.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  27. DataGridView1.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(2).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  28. DataGridView1.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  29. DataGridView1.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  30. DataGridView1.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  31. DataGridView1.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  32. DataGridView1.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  33. TextBox1.Text = "0"
  34. For I As Integer = 0 To 9 : DataGridView1.Columns(I).ReadOnly = True : Next
  35. For I As Integer = 0 To DataGridView1.Rows.Count - 1
  36. If DataGridView1.Rows(I).Cells("已立帳").Value.ToString = "" Then : DataGridView1.Rows(I).Cells("已立帳").Value = False : End If
  37. DataGridView1.Rows(I).Cells("選擇").Value = False : TextBox1.Text = Val(TextBox1.Text) + DataGridView1.Rows(I).Cells("佣金").Value
  38. Next
  39. TextBox1.Text = Strings.Format(Val(TextBox1.Text), "#,##0")
  40. End Sub
  41. Private Sub ComboBox2下拉表單資料載入()
  42. SQL_銷售業務人員清單()
  43. ComboBox2.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("業務")) : End While : conn.Close()
  44. End Sub
  45. Private Sub ComboBox1下拉表單資料載入()
  46. SQL_會計科目_第一階_不含流動票務()
  47. ComboBox5.Items.Clear() : ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox5.Items.Add(dr("第一階")) : ComboBox1.Items.Add(dr("編號")) : End While : conn.Close()
  48. End Sub
  49. Private Sub ComboBox3下拉表單資料載入()
  50. PA = ComboBox1.Text : SQL_會計科目_第二階_不含流動票務()
  51. ComboBox3.Items.Clear() : ComboBox4.Items.Clear() : While (dr.Read()) : ComboBox3.Items.Add(dr("第二階")) : ComboBox4.Items.Add(dr("編號")) : End While : conn.Close() : PA = ""
  52. End Sub
  53. Private Sub ComboBox6下拉表單資料載入()
  54. PA = ComboBox4.Text : SQL_會計科目_第三階_不含流動票務()
  55. ComboBox7.Items.Clear() : ComboBox6.Items.Clear() : While (dr.Read()) : ComboBox7.Items.Add(dr("會計科目")) : ComboBox6.Items.Add(dr("編號")) : End While : conn.Close()
  56. If ComboBox7.Items.Count <> 0 Then : ComboBox7.SelectedIndex = 0 : End If
  57. End Sub
  58. Private Sub 日期格式()
  59. If 會計月.Checked = True Then
  60. '-------------日期一----------------------------------------------------------------------------------------
  61. DTP = Strings.Left(Strings.Format(DateTimePicker1.Value, "yyyy/MM/dd"), 8) & "01" : DateTimePicker1.Value = DTP
  62. DateTimePicker1.Value = DateTimePicker1.Value.AddMonths(-1)
  63. DTP = Strings.Left(Strings.Format(DateTimePicker1.Value, "yyyy/MM/dd"), 8) & "26" : DateTimePicker1.Value = DTP
  64. '-------------日期二----------------------------------------------------------------------------------------
  65. DTP = Strings.Left(Strings.Format(DateTimePicker2.Value, "yyyy/MM/dd"), 8) & "25" : DateTimePicker2.Value = DTP
  66. Else
  67. '-------------日期一----------------------------------------------------------------------------------------
  68. DateTimePicker1.Value = DateTimePicker1.Value.AddMonths(1)
  69. DTP = Strings.Left(Strings.Format(DateTimePicker1.Value, "yyyy/MM/dd"), 8) & "01" : DateTimePicker1.Value = DTP
  70. '-------------日期二----------------------------------------------------------------------------------------
  71. DTP = Strings.Left(Strings.Format(DateTimePicker2.Value, "yyyy/MM/dd"), 8) & "01" : DateTimePicker2.Value = DTP
  72. DateTimePicker2.Value = DateTimePicker2.Value.AddMonths(1) : DateTimePicker2.Value = DateTimePicker2.Value.AddDays(-1)
  73. End If
  74. End Sub
  75. Private Sub 業務佣金計算_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  76. Me.MdiParent = MAOJI_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  77. ComboBox6.Visible = False : TextBox2.Visible = False : DateTimePicker4.Visible = False
  78. ComboBox1下拉表單資料載入() : ComboBox3下拉表單資料載入() : ComboBox6下拉表單資料載入() : ComboBox2下拉表單資料載入() : ComboBox2.SelectedIndex = 0 : 日期格式() : Set_業務佣金清單()
  79. End Sub
  80. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  81. If e.RowIndex = -1 Then : Else
  82. TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("單據編號").Value
  83. End If
  84. End Sub
  85. Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
  86. Dim linePen As New Pen(Color.Blue, 2)
  87. If e.RowIndex = DataGridView1.Rows.Count - 1 Then : Exit Sub
  88. Else
  89. If DataGridView1(0, e.RowIndex).Value.ToString <> DataGridView1(0, e.RowIndex + 1).Value.ToString Then
  90. Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0)
  91. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  92. Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
  93. e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
  94. End If
  95. End If
  96. End Sub
  97. Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.TextChanged
  98. ComboBox1.SelectedIndex = ComboBox5.SelectedIndex : TextBox9.Text = "" : ComboBox3下拉表單資料載入() : ComboBox6下拉表單資料載入()
  99. End Sub
  100. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.TextChanged
  101. ComboBox5.SelectedIndex = ComboBox1.SelectedIndex : ComboBox3下拉表單資料載入() : ComboBox6下拉表單資料載入()
  102. End Sub
  103. Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.TextChanged
  104. ComboBox4.SelectedIndex = ComboBox3.SelectedIndex : ComboBox6下拉表單資料載入()
  105. End Sub
  106. Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.TextChanged
  107. ComboBox3.SelectedIndex = ComboBox4.SelectedIndex : ComboBox6下拉表單資料載入()
  108. End Sub
  109. Private Sub ComboBox7_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
  110. ComboBox6.SelectedIndex = ComboBox7.SelectedIndex
  111. End Sub
  112. Private Sub ComboBox6_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox6.SelectedIndexChanged
  113. ComboBox7.SelectedIndex = ComboBox6.SelectedIndex
  114. End Sub
  115. Private Sub TextBox9_TextChanged(sender As Object, e As EventArgs) Handles TextBox9.TextChanged
  116. PA = TextBox9.Text : SQL_會計科目_關鍵字_不含流動票務()
  117. ComboBox7.Items.Clear() : ComboBox6.Items.Clear() : While (dr.Read()) : ComboBox7.Items.Add(dr("會計科目")) : ComboBox6.Items.Add(dr("編號")) : End While : conn.Close()
  118. If ComboBox7.Items.Count <> 0 Then : ComboBox7.SelectedIndex = 0 : End If : PA = ""
  119. End Sub
  120. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  121. If 會計月.Checked = True Then
  122. DateTimePicker4.Value = DateTimePicker4.Value.AddMonths(-1)
  123. DateTimePicker1.Value = DateTimePicker4.Value
  124. DateTimePicker2.Value = DateTimePicker4.Value
  125. Else
  126. DateTimePicker4.Value = DateTimePicker4.Value.AddMonths(-1)
  127. DateTimePicker1.Value = DateTimePicker4.Value.AddMonths(-1)
  128. DateTimePicker2.Value = DateTimePicker4.Value
  129. End If
  130. 日期格式() : Set_業務佣金清單()
  131. End Sub
  132. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  133. If 會計月.Checked = True Then
  134. DateTimePicker4.Value = DateTimePicker4.Value.AddMonths(1)
  135. DateTimePicker1.Value = DateTimePicker4.Value
  136. DateTimePicker2.Value = DateTimePicker4.Value
  137. Else
  138. DateTimePicker4.Value = DateTimePicker4.Value.AddMonths(1)
  139. DateTimePicker1.Value = DateTimePicker4.Value.AddMonths(-1)
  140. DateTimePicker2.Value = DateTimePicker4.Value
  141. End If
  142. 日期格式() : Set_業務佣金清單()
  143. End Sub
  144. Private Sub 會計月_CheckedChanged(sender As Object, e As EventArgs) Handles 會計月.Click
  145. 會計月.Checked = True : 一般月.Checked = False : 日期格式() : Set_業務佣金清單()
  146. End Sub
  147. Private Sub 一般月_CheckedChanged(sender As Object, e As EventArgs) Handles 一般月.Click
  148. 會計月.Checked = False : 一般月.Checked = True : 日期格式() : Set_業務佣金清單()
  149. End Sub
  150. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
  151. Set_業務佣金清單()
  152. End Sub
  153. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  154. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  155. If TextBox3.Text = DataGridView1.Rows(i).Cells("單據編號").Value.ToString Then
  156. DataGridView1.Rows(i).Cells("選擇").Value = True
  157. End If
  158. Next i
  159. End Sub
  160. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  161. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : DataGridView1.Rows(i).Cells("選擇").Value = True : Next i
  162. End Sub
  163. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  164. For i As Integer = 0 To DataGridView1.Rows.Count - 1 : DataGridView1.Rows(i).Cells("選擇").Value = False : Next i
  165. End Sub
  166. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  167. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  168. If TextBox3.Text = DataGridView1.Rows(i).Cells("單據編號").Value.ToString Then
  169. DataGridView1.Rows(i).Cells("已立帳").Value = False
  170. End If
  171. Next i
  172. End Sub
  173. Private Sub Set_日期格式轉換()
  174. If CheckBox1.Checked = False Then : DTP = Strings.Format(Today(), "yyyy/MM/dd") : DTP1 = Strings.Format(Today(), "yyyyMMdd")
  175. Else : DTP1 = Strings.Format(DateTimePicker3.Value, "yyyyMMdd") : DTP = Strings.Format(DateTimePicker3.Value, "yyyy/MM/dd") : End If
  176. End Sub
  177. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  178. Dim 確認 As Boolean = False
  179. If ComboBox6.Text = "" Then : MsgBox("請選擇會計科目。")
  180. Else
  181. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  182. If DataGridView1.Rows(i).Cells("選擇").Value = True Then
  183. 確認 = True : Exit For
  184. End If
  185. Next
  186. If 確認 = False Then : MsgBox("沒有選擇任何一筆要轉收支帳的佣金明細。")
  187. Else
  188. Dim NUM1 As Integer : Set_日期格式轉換()
  189. For ii As Integer = 1 To 999
  190. NUM1 = 0 + ii
  191. If NUM1 < 10 Then : TextBox2.Text = "OE-" & DTP1 & "-00" & NUM1
  192. ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox2.Text = "OE-" & DTP1 & "-0" & NUM1
  193. ElseIf NUM1 > 99 Then : TextBox2.Text = "OE-" & DTP1 & "-" & NUM1 : End If : PA = TextBox2.Text
  194. SQL_營運成本收支單申請_支付單號流水號()
  195. If dr.Read() Then : Else : ii = 999 : End If
  196. Next
  197. SQL_營運成本控制表新增()
  198. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  199. 資料數 = DataGridView1.Rows.Count : MyModule1.進度條()
  200. If DataGridView1.Rows(i).Cells("已立帳").Value = False Then
  201. If DataGridView1.Rows(i).Cells("選擇").Value = True Then
  202. SQL_營運成本明細表項次新增查詢()
  203. If dr.Read() Then : 新項次 = dr("項次") : Else : 新項次 = "00" : End If : conn.Close() : NUM1 = Double.Parse(新項次) + 1
  204. If NUM1 < 10 Then : 新項次 = "0" & NUM1
  205. ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 : End If
  206. PA1 = TextBox2.Text : PA2 = 新項次 : PA3 = ComboBox6.Text : PA6 = DataGridView1.Rows(i).Cells("資料流水號").Value
  207. PA4 = DataGridView1.Rows(i).Cells("簡稱").Value & "-" & DataGridView1.Rows(i).Cells("品名").Value & "-" & DataGridView1.Rows(i).Cells("業務").Value & "業務佣金"
  208. NU1 = DataGridView1.Rows(i).Cells("佣金").Value : PA5 = "" : NU2 = 0 : NU3 = 0 : NU4 = 0 : PA6 = "付現" : PA7 = gUserName
  209. SQL_營運成本明細表新增() : SQL_業務佣金計算表_轉立收支單修改()
  210. End If
  211. End If
  212. Next i : MAOJI_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  213. MsgBox("財務收支單(傳票)申請完成,請通知主管審核。") : Set_業務佣金清單()
  214. End If
  215. End If
  216. End Sub
  217. Private Sub 列印()
  218. N1 = 0
  219. xlSheet.Cells(1, 1) = DateTimePicker1.Value & " 到 " & DateTimePicker2.Value & " " & ComboBox2.Text & " 業務佣金費用"
  220. xlSheet.Cells(2, 1) = "單據編號" : xlSheet.Cells(2, 2) = "出貨日期" : xlSheet.Cells(2, 3) = "客戶" : xlSheet.Cells(2, 4) = "品名" : xlSheet.Cells(2, 5) = "售價"
  221. xlSheet.Cells(2, 6) = "數量" : xlSheet.Cells(2, 7) = "比例" : xlSheet.Cells(2, 8) = "佣金"
  222. For i As Integer = 0 To DataGridView1.Rows.Count - 1
  223. xlSheet.Cells(i + 3, 1) = DataGridView1.Rows(i).Cells("單據編號").Value : xlSheet.Cells(i + 3, 2) = DataGridView1.Rows(i).Cells("出貨日期").Value
  224. xlSheet.Cells(i + 3, 3) = DataGridView1.Rows(i).Cells("簡稱").Value : xlSheet.Cells(i + 3, 4) = DataGridView1.Rows(i).Cells("品名").Value
  225. xlSheet.Cells(i + 3, 5) = DataGridView1.Rows(i).Cells("售價").Value : xlSheet.Cells(i + 3, 6) = DataGridView1.Rows(i).Cells("數量").Value
  226. xlSheet.Cells(i + 3, 7) = DataGridView1.Rows(i).Cells("比例").Value : xlSheet.Cells(i + 3, 8) = DataGridView1.Rows(i).Cells("佣金").Value
  227. N1 = i + 3
  228. Next
  229. xlSheet.Cells(N1 + 2, 7) = "合計" : xlSheet.Cells(N1 + 2, 8) = "=SUM(H3:H" & N1 & ")"
  230. End Sub
  231. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  232. ComboBox2下拉表單資料載入()
  233. xlApp = CType(CreateObject("Excel.Application"), Application)
  234. xlBook = xlApp.Workbooks.Add
  235. xlApp.DisplayAlerts = True
  236. xlApp.Visible = True
  237. xlApp.Application.WindowState = xlMaximized
  238. For i As Integer = 1 To ComboBox2.Items.Count - 1
  239. ComboBox2.SelectedIndex = i
  240. If DataGridView1.Rows.Count = 0 Then : Else
  241. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Name = ComboBox2.Text : 列印() : AA(xlApp, xlSheet)
  242. End If
  243. Next
  244. xlSheet.PageSetup.PrintArea = ""
  245. xlApp.Cells.Select()
  246. xlSheet.Range("B1").Select()
  247. xlApp.Application.WindowState = xlMinimized
  248. xlSheet.Cells.Select()
  249. MsgBox("列印完成。")
  250. End Sub
  251. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  252. Return CType(xlBook.Worksheets.Add, Worksheet)
  253. End Function
  254. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  255. xlSheet.Cells.Select()
  256. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  257. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  258. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 25
  259. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 17
  260. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  261. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  262. xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 9
  263. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  264. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  265. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 9
  266. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  267. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  268. xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 35
  269. xlSheet.Columns("E:F").Select : myExcel.Selection.NumberFormatLocal = "#,##0_ ;[紅色]-#,##0 "
  270. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  271. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  272. xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 6
  273. xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 6
  274. xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 10
  275. xlSheet.Columns("G:G").Select : myExcel.Selection.NumberFormatLocal = "#,##0.0_ ;[紅色]-#,##0.0 "
  276. xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 12 : myExcel.Selection.NumberFormatLocal = "#,##0_ ;[紅色]-#,##0 "
  277. xlSheet.Range("A1:H1").Select()
  278. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  279. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  280. xlSheet.Range("A1:H" & N1 & "").Select()
  281. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  282. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  283. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  284. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  285. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  286. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  287. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  288. myExcel.ActiveWindow.DisplayGridlines = False
  289. xlSheet.Rows("3:3").Select : myExcel.ActiveWindow.FreezePanes = True
  290. xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 25
  291. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlTop : .WrapText = False : .Orientation = 0 : .AddIndent = False
  292. .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.AutoFilter
  293. End Sub
  294. '-----------------------------滑鼠右鍵------------------------------------------------------------------------------------------------------------------------------------------
  295. Private Sub 重新整理ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理ToolStripMenuItem.Click
  296. ComboBox1下拉表單資料載入() : ComboBox3下拉表單資料載入() : ComboBox6下拉表單資料載入() : ComboBox2下拉表單資料載入() : ComboBox2.SelectedIndex = 0 : 日期格式() : Set_業務佣金清單()
  297. End Sub
  298. Private Sub 依據單號全部選擇ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 依據單號全部選擇ToolStripMenuItem.Click
  299. Me.Button3.PerformClick()
  300. End Sub
  301. Private Sub 依據單號取消立帳ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 依據單號取消立帳ToolStripMenuItem.Click
  302. Me.Button6.PerformClick()
  303. End Sub
  304. Private Sub 全部選擇ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 全部選擇ToolStripMenuItem.Click
  305. Me.Button13.PerformClick()
  306. End Sub
  307. Private Sub 全部取消ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 全部取消ToolStripMenuItem.Click
  308. Me.Button12.PerformClick()
  309. End Sub
  310. Private Sub 列印成EXCELToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 列印成EXCELToolStripMenuItem.Click
  311. Me.Button5.PerformClick()
  312. End Sub
  313. Private Sub 開立收支單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 開立收支單ToolStripMenuItem.Click
  314. Me.Button4.PerformClick()
  315. End Sub
  316. End Class