|
|
|
|
8
|
Imports Microsoft.Office.Interop.Excel.XlWindowState
|
8
|
Imports Microsoft.Office.Interop.Excel.XlWindowState
|
9
|
Imports Microsoft.Office.Interop.Excel
|
9
|
Imports Microsoft.Office.Interop.Excel
|
10
|
Public Class 業績運費明細表
|
10
|
Public Class 業績運費明細表
|
11
|
- ReadOnly ds As New DataSet : Dim N1 As Integer
|
|
|
|
|
11
|
+ ReadOnly ds As New DataSet : Dim N1, 總數 As Integer : Dim 首次開啟 As Boolean
|
12
|
Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
|
12
|
Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
|
13
|
Private Sub Set_清單1()
|
13
|
Private Sub Set_清單1()
|
14
|
運費明細表_dgv.DataSource = Nothing : ds.Clear()
|
14
|
運費明細表_dgv.DataSource = Nothing : ds.Clear()
|
|
|
|
|
27
|
運費明細表_dgv.EditMode = DataGridViewEditMode.EditOnEnter
|
27
|
運費明細表_dgv.EditMode = DataGridViewEditMode.EditOnEnter
|
28
|
運費明細表_dgv.Columns(0).ReadOnly = True : 運費明細表_dgv.Columns(1).ReadOnly = True : 運費明細表_dgv.Columns(2).ReadOnly = True : 運費明細表_dgv.Columns(3).ReadOnly = True
|
28
|
運費明細表_dgv.Columns(0).ReadOnly = True : 運費明細表_dgv.Columns(1).ReadOnly = True : 運費明細表_dgv.Columns(2).ReadOnly = True : 運費明細表_dgv.Columns(3).ReadOnly = True
|
29
|
運費明細表_dgv.Columns(5).ReadOnly = True
|
29
|
運費明細表_dgv.Columns(5).ReadOnly = True
|
30
|
-
|
|
|
31
|
- 計算()
|
|
|
|
|
30
|
+ 總數 = 運費明細表_dgv.Rows.Count - 1
|
|
|
31
|
+ '計算()
|
32
|
End Sub
|
32
|
End Sub
|
33
|
Private Sub 計算()
|
33
|
Private Sub 計算()
|
34
|
NUD1.Value = 0 : NUD2.Value = 0
|
34
|
NUD1.Value = 0 : NUD2.Value = 0
|
35
|
- For I As Integer = 0 To 運費明細表_dgv.Rows.Count - 1
|
|
|
|
|
35
|
+ For I As Integer = 0 To 總數
|
36
|
If IsDBNull(運費明細表_dgv.Rows(I).Cells("運費已付").Value) = True Then
|
36
|
If IsDBNull(運費明細表_dgv.Rows(I).Cells("運費已付").Value) = True Then
|
37
|
運費明細表_dgv.Rows(I).Cells("運費已付").Value = False
|
37
|
運費明細表_dgv.Rows(I).Cells("運費已付").Value = False
|
38
|
End If
|
38
|
End If
|
|
|
|
|
56
|
End Sub
|
56
|
End Sub
|
57
|
Private Sub 業績運費明細表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
57
|
Private Sub 業績運費明細表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
58
|
Me.MdiParent = YD_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
|
58
|
Me.MdiParent = YD_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
|
59
|
- 日期格式() : Set_清單1()
|
|
|
|
|
59
|
+ 首次開啟 = True
|
|
|
60
|
+ 日期格式() : Set_清單1() : 計算()
|
60
|
If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
|
61
|
If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
|
61
|
字體_NUD.Value = 9
|
62
|
字體_NUD.Value = 9
|
62
|
ElseIf YD_ERP_SYS.Size.Width <= 1440 And YD_ERP_SYS.Size.Height <= 900 Then
|
63
|
ElseIf YD_ERP_SYS.Size.Width <= 1440 And YD_ERP_SYS.Size.Height <= 900 Then
|
63
|
字體_NUD.Value = 8
|
64
|
字體_NUD.Value = 8
|
64
|
End If
|
65
|
End If
|
65
|
End Sub
|
66
|
End Sub
|
|
|
67
|
+ Private Sub 業績運費明細表_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
|
|
|
68
|
+ 首次開啟 = False
|
|
|
69
|
+ End Sub
|
66
|
Private Sub 業績獎金彙總表_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
|
70
|
Private Sub 業績獎金彙總表_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
|
67
|
If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
|
71
|
If YD_ERP_SYS.Size.Width > 1440 And YD_ERP_SYS.Size.Height > 900 Then
|
68
|
字體_NUD.Value = 9
|
72
|
字體_NUD.Value = 9
|
|
|
|
|
102
|
End Try
|
106
|
End Try
|
103
|
End Sub
|
107
|
End Sub
|
104
|
Private Sub 運費明細表_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 運費明細表_dgv.CellEnter
|
108
|
Private Sub 運費明細表_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles 運費明細表_dgv.CellEnter
|
105
|
- 計算()
|
|
|
|
|
109
|
+ If 首次開啟 = False Then
|
|
|
110
|
+ 計算()
|
|
|
111
|
+ End If
|
106
|
End Sub
|
112
|
End Sub
|
107
|
Private Sub 上個月_bt_Click(sender As Object, e As EventArgs) Handles 上個月_bt.Click
|
113
|
Private Sub 上個月_bt_Click(sender As Object, e As EventArgs) Handles 上個月_bt.Click
|
108
|
中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
|
114
|
中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
|
109
|
開始日期_dtp.Value = 中間日期_dtp.Value
|
115
|
開始日期_dtp.Value = 中間日期_dtp.Value
|
110
|
結束日期_dtp.Value = 中間日期_dtp.Value
|
116
|
結束日期_dtp.Value = 中間日期_dtp.Value
|
111
|
- 日期格式() : Set_清單1()
|
|
|
|
|
117
|
+ 日期格式() : Set_清單1() : 計算()
|
112
|
End Sub
|
118
|
End Sub
|
113
|
Private Sub 下個月_bt_Click(sender As Object, e As EventArgs) Handles 下個月_bt.Click
|
119
|
Private Sub 下個月_bt_Click(sender As Object, e As EventArgs) Handles 下個月_bt.Click
|
114
|
中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(1)
|
120
|
中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(1)
|
115
|
開始日期_dtp.Value = 中間日期_dtp.Value
|
121
|
開始日期_dtp.Value = 中間日期_dtp.Value
|
116
|
結束日期_dtp.Value = 中間日期_dtp.Value
|
122
|
結束日期_dtp.Value = 中間日期_dtp.Value
|
117
|
- 日期格式() : Set_清單1()
|
|
|
|
|
123
|
+ 日期格式() : Set_清單1() : 計算()
|
118
|
End Sub
|
124
|
End Sub
|
119
|
Private Sub 字體_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 字體_NUD.ValueChanged
|
125
|
Private Sub 字體_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 字體_NUD.ValueChanged
|
120
|
運費明細表_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
|
126
|
運費明細表_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
|
|
|
|
|
127
|
PA = 運費明細表_dgv.Rows(I).Cells("單號").Value : PA1 = 運費明細表_dgv.Rows(I).Cells("運費已付").Value : PA2 = 運費明細表_dgv.Rows(I).Cells("備註").Value
|
133
|
PA = 運費明細表_dgv.Rows(I).Cells("單號").Value : PA1 = 運費明細表_dgv.Rows(I).Cells("運費已付").Value : PA2 = 運費明細表_dgv.Rows(I).Cells("備註").Value
|
128
|
SQL_業績運費_修正()
|
134
|
SQL_業績運費_修正()
|
129
|
Next : YD_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
|
135
|
Next : YD_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
|
130
|
- MsgBox("存檔完成!!!") : Set_清單1()
|
|
|
|
|
136
|
+ MsgBox("存檔完成!!!") : Set_清單1() : 計算()
|
131
|
Catch ex As Exception
|
137
|
Catch ex As Exception
|
132
|
MsgBox(ex.Message)
|
138
|
MsgBox(ex.Message)
|
133
|
End Try
|
139
|
End Try
|
|
|
|
|
189
|
xlSheet.Range("D5:D" & N1 + 5).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
|
195
|
xlSheet.Range("D5:D" & N1 + 5).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
|
190
|
xlSheet.Range("B" & N1 + 6).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
|
196
|
xlSheet.Range("B" & N1 + 6).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
|
191
|
xlSheet.Range("D" & N1 + 6).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
|
197
|
xlSheet.Range("D" & N1 + 6).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
|
192
|
- xlSheet.Range("F" & N1 + 6).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
|
|
|
|
|
198
|
+ xlSheet.Range("F" & N1 + 6).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "#,##0_ ;[紅色]-#,##0 "
|
193
|
With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
|
199
|
With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
|
194
|
.IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
|
200
|
.IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
|
195
|
|
201
|
|
|
|
|
|
220
|
myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
|
226
|
myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone
|
221
|
myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
|
227
|
myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
|
222
|
|
228
|
|
223
|
- xlSheet.Range("A20:G" & N1 + 5).Select()
|
|
|
|
|
229
|
+ xlSheet.Range("A" & N1 + 5 & ":G" & N1 + 5).Select()
|
224
|
myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
|
230
|
myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
|
225
|
myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
|
231
|
myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
|
226
|
With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
|
232
|
With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
|