|
@@ -10,20 +10,20 @@ Imports Microsoft.Office.Interop.Excel.XlWindowState
|
10
|
10
|
Public Class 列印_訂單價格利潤表
|
11
|
11
|
ReadOnly ds As New DataSet
|
12
|
12
|
Private Sub Set_DGV1載入前設定()
|
13
|
|
- DataGridView1.DataSource = Nothing : ds.Clear()
|
14
|
|
- DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
15
|
|
- DataGridView1.ColumnHeadersHeight = 25
|
16
|
|
- DataGridView1.AllowUserToAddRows = False
|
|
13
|
+ 利潤表_dgv.DataSource = Nothing : ds.Clear()
|
|
14
|
+ 利潤表_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
|
15
|
+ 利潤表_dgv.ColumnHeadersHeight = 25
|
|
16
|
+ 利潤表_dgv.AllowUserToAddRows = False
|
17
|
17
|
ConnOpen()
|
18
|
18
|
End Sub
|
19
|
19
|
Private Sub Set_DGV1載入後設定()
|
20
|
|
- CmdSet_For_DGV() : da.SelectCommand.CommandTimeout = 900 : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
|
|
20
|
+ CmdSet_For_DGV() : da.SelectCommand.CommandTimeout = 900 : da.Fill(ds) : 利潤表_dgv.DataSource = ds.Tables(0) : conn.Close()
|
21
|
21
|
End Sub
|
22
|
22
|
Private Sub Set_訂單清單()
|
23
|
23
|
Set_DGV1載入前設定() : SQL_訂單價格利潤表() : Set_DGV1載入後設定()
|
24
|
24
|
End Sub
|
25
|
25
|
Private Sub Set_格式設定()
|
26
|
|
- DataGridView1.Visible = False
|
|
26
|
+ 利潤表_dgv.Visible = False
|
27
|
27
|
End Sub
|
28
|
28
|
Private Sub 列印_訂單價格利潤表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
29
|
29
|
FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
|
|
@@ -89,56 +89,48 @@ Public Class 列印_訂單價格利潤表
|
89
|
89
|
xlSheet.Cells(3, 31) = "ItemNumber"
|
90
|
90
|
xlSheet.Cells(3, 32) = "審核"
|
91
|
91
|
xlSheet.Cells(3, 33) = "Vionic Po#"
|
92
|
|
- xlSheet.Cells(3, 34) = "Material"
|
93
|
|
- xlSheet.Cells(3, 35) = "Material Description"
|
94
|
|
- xlSheet.Cells(3, 36) = "Colorway"
|
95
|
|
- xlSheet.Cells(3, 37) = "Ship Mode"
|
96
|
|
- xlSheet.Cells(3, 38) = "Company code"
|
97
|
|
- xlSheet.Cells(3, 39) = "Final Customer Ship To"
|
98
|
|
- xlSheet.Cells(3, 40) = "Customer Data"
|
|
92
|
+ xlSheet.Cells(3, 34) = "Ship Mode"
|
|
93
|
+ xlSheet.Cells(3, 35) = "Company code"
|
|
94
|
+ xlSheet.Cells(3, 36) = "Final Customer Ship To"
|
99
|
95
|
AA(xlApp, xlSheet)
|
100
|
|
- For i As Integer = 0 To DataGridView1.Rows.Count - 1
|
101
|
|
- xlSheet.Cells(i + 4, 1) = DataGridView1.Rows(i).Cells("訂單流水號").Value
|
102
|
|
- xlSheet.Cells(i + 4, 2) = DataGridView1.Rows(i).Cells("年份季度").Value
|
103
|
|
- xlSheet.Cells(i + 4, 3) = DataGridView1.Rows(i).Cells("力威訂單號").Value
|
104
|
|
- xlSheet.Cells(i + 4, 4) = DataGridView1.Rows(i).Cells("形體號").Value
|
105
|
|
- xlSheet.Cells(i + 4, 5) = DataGridView1.Rows(i).Cells("顏色").Value
|
106
|
|
- xlSheet.Cells(i + 4, 6) = DataGridView1.Rows(i).Cells("ProductID").Value
|
|
96
|
+ For i As Integer = 0 To 利潤表_dgv.Rows.Count - 1
|
|
97
|
+ xlSheet.Cells(i + 4, 1) = 利潤表_dgv.Rows(i).Cells("訂單流水號").Value
|
|
98
|
+ xlSheet.Cells(i + 4, 2) = 利潤表_dgv.Rows(i).Cells("年份季度").Value
|
|
99
|
+ xlSheet.Cells(i + 4, 3) = 利潤表_dgv.Rows(i).Cells("力威訂單號").Value
|
|
100
|
+ xlSheet.Cells(i + 4, 4) = 利潤表_dgv.Rows(i).Cells("形體號").Value
|
|
101
|
+ xlSheet.Cells(i + 4, 5) = 利潤表_dgv.Rows(i).Cells("顏色").Value
|
|
102
|
+ xlSheet.Cells(i + 4, 6) = 利潤表_dgv.Rows(i).Cells("ProductID").Value
|
107
|
103
|
|
108
|
|
- xlSheet.Cells(i + 4, 7) = DataGridView1.Rows(i).Cells("楦型").Value
|
109
|
|
- xlSheet.Cells(i + 4, 8) = DataGridView1.Rows(i).Cells("Quantity").Value
|
110
|
|
- xlSheet.Cells(i + 4, 9) = DataGridView1.Rows(i).Cells("客戶交期").Value
|
|
104
|
+ xlSheet.Cells(i + 4, 7) = 利潤表_dgv.Rows(i).Cells("楦型").Value
|
|
105
|
+ xlSheet.Cells(i + 4, 8) = 利潤表_dgv.Rows(i).Cells("數量").Value
|
|
106
|
+ xlSheet.Cells(i + 4, 9) = 利潤表_dgv.Rows(i).Cells("客戶交期").Value
|
111
|
107
|
xlSheet.Cells(i + 4, 10) = "=T" & i + 4 & "+U" & i + 4 & "+V" & i + 4 & "+W" & i + 4 & "+X" & i + 4 & "+Y" & i + 4 & "+Z" & i + 4 & "+AA" & i + 4 & "/AD" & i + 4 & "-AB" & i + 4
|
112
|
108
|
xlSheet.Cells(i + 4, 11) = "=H" & i + 4 & "*J" & i + 4 & ""
|
113
|
|
- xlSheet.Cells(i + 4, 12) = DataGridView1.Rows(i).Cells("備註").Value
|
114
|
|
- xlSheet.Cells(i + 4, 13) = DataGridView1.Rows(i).Cells("工廠").Value
|
115
|
|
- xlSheet.Cells(i + 4, 14) = DataGridView1.Rows(i).Cells("訂單種類").Value
|
116
|
|
- xlSheet.Cells(i + 4, 15) = DataGridView1.Rows(i).Cells("FTYPrice").Value
|
|
109
|
+ xlSheet.Cells(i + 4, 12) = 利潤表_dgv.Rows(i).Cells("備註").Value
|
|
110
|
+ xlSheet.Cells(i + 4, 13) = 利潤表_dgv.Rows(i).Cells("工廠").Value
|
|
111
|
+ xlSheet.Cells(i + 4, 14) = 利潤表_dgv.Rows(i).Cells("訂單種類").Value
|
|
112
|
+ xlSheet.Cells(i + 4, 15) = 利潤表_dgv.Rows(i).Cells("FTYPrice").Value
|
117
|
113
|
xlSheet.Cells(i + 4, 16) = "=K" & i + 4 & "-(H" & i + 4 & "*O" & i + 4 & ")"
|
118
|
114
|
xlSheet.Cells(i + 4, 17) = "=(K" & i + 4 & "-(H" & i + 4 & "*O" & i + 4 & "))/2"
|
119
|
115
|
xlSheet.Cells(i + 4, 18) = "=(K" & i + 4 & "-(H" & i + 4 & "*O" & i + 4 & "))/2"
|
120
|
116
|
xlSheet.Cells(i + 4, 19) = "=IF(K" & i + 4 & "=0,0,(K" & i + 4 & "-H" & i + 4 & "*O" & i + 4 & ")/K" & i + 4 & ")"
|
121
|
|
- xlSheet.Cells(i + 4, 20) = DataGridView1.Rows(i).Cells("BasicPrice").Value
|
122
|
|
- xlSheet.Cells(i + 4, 21) = DataGridView1.Rows(i).Cells("Polybag").Value
|
123
|
|
- xlSheet.Cells(i + 4, 22) = DataGridView1.Rows(i).Cells("FOOTorPET").Value
|
124
|
|
- xlSheet.Cells(i + 4, 23) = DataGridView1.Rows(i).Cells("Tooling").Value
|
125
|
|
- xlSheet.Cells(i + 4, 24) = DataGridView1.Rows(i).Cells("RubberBand").Value
|
126
|
|
- xlSheet.Cells(i + 4, 25) = DataGridView1.Rows(i).Cells("JHOOK").Value
|
127
|
|
- xlSheet.Cells(i + 4, 26) = DataGridView1.Rows(i).Cells("WaterResistant").Value
|
128
|
|
- xlSheet.Cells(i + 4, 27) = DataGridView1.Rows(i).Cells("P16VAT").Value
|
129
|
|
- xlSheet.Cells(i + 4, 28) = DataGridView1.Rows(i).Cells("EXWsaving").Value
|
|
117
|
+ xlSheet.Cells(i + 4, 20) = 利潤表_dgv.Rows(i).Cells("BasicPrice").Value
|
|
118
|
+ xlSheet.Cells(i + 4, 21) = 利潤表_dgv.Rows(i).Cells("Polybag").Value
|
|
119
|
+ xlSheet.Cells(i + 4, 22) = 利潤表_dgv.Rows(i).Cells("FOOTorPET").Value
|
|
120
|
+ xlSheet.Cells(i + 4, 23) = 利潤表_dgv.Rows(i).Cells("Tooling").Value
|
|
121
|
+ xlSheet.Cells(i + 4, 24) = 利潤表_dgv.Rows(i).Cells("RubberBand").Value
|
|
122
|
+ xlSheet.Cells(i + 4, 25) = 利潤表_dgv.Rows(i).Cells("JHOOK").Value
|
|
123
|
+ xlSheet.Cells(i + 4, 26) = 利潤表_dgv.Rows(i).Cells("WaterResistant").Value
|
|
124
|
+ xlSheet.Cells(i + 4, 27) = 利潤表_dgv.Rows(i).Cells("P16VAT").Value
|
|
125
|
+ xlSheet.Cells(i + 4, 28) = 利潤表_dgv.Rows(i).Cells("EXWsaving").Value
|
130
|
126
|
xlSheet.Cells(i + 4, 29) = "=W" & i + 4 & "*H" & i + 4 & ""
|
131
|
|
- xlSheet.Cells(i + 4, 30) = DataGridView1.Rows(i).Cells("Exchange").Value
|
132
|
|
- xlSheet.Cells(i + 4, 31) = DataGridView1.Rows(i).Cells("ItemNumber").Value
|
133
|
|
- xlSheet.Cells(i + 4, 32) = DataGridView1.Rows(i).Cells("審核").Value
|
134
|
|
- xlSheet.Cells(i + 4, 33) = DataGridView1.Rows(i).Cells("客戶訂單號").Value
|
135
|
|
- xlSheet.Cells(i + 4, 34) = DataGridView1.Rows(i).Cells("Material").Value
|
136
|
|
- xlSheet.Cells(i + 4, 35) = DataGridView1.Rows(i).Cells("MaterialDescription").Value
|
137
|
|
- xlSheet.Cells(i + 4, 36) = DataGridView1.Rows(i).Cells("Colorway").Value
|
138
|
|
- xlSheet.Cells(i + 4, 37) = DataGridView1.Rows(i).Cells("SalesOrder").Value
|
139
|
|
- xlSheet.Cells(i + 4, 38) = DataGridView1.Rows(i).Cells("CustomerName").Value
|
140
|
|
- xlSheet.Cells(i + 4, 39) = DataGridView1.Rows(i).Cells("最終運送").Value
|
141
|
|
- xlSheet.Cells(i + 4, 40) = DataGridView1.Rows(i).Cells("CustomerData").Value
|
|
127
|
+ xlSheet.Cells(i + 4, 30) = 利潤表_dgv.Rows(i).Cells("Exchange").Value
|
|
128
|
+ xlSheet.Cells(i + 4, 31) = 利潤表_dgv.Rows(i).Cells("ItemNumber").Value
|
|
129
|
+ xlSheet.Cells(i + 4, 32) = 利潤表_dgv.Rows(i).Cells("審核").Value
|
|
130
|
+ xlSheet.Cells(i + 4, 33) = 利潤表_dgv.Rows(i).Cells("客戶訂單號").Value
|
|
131
|
+ xlSheet.Cells(i + 4, 34) = 利潤表_dgv.Rows(i).Cells("SalesOrder").Value
|
|
132
|
+ xlSheet.Cells(i + 4, 35) = 利潤表_dgv.Rows(i).Cells("CustomerName").Value
|
|
133
|
+ xlSheet.Cells(i + 4, 36) = 利潤表_dgv.Rows(i).Cells("最終運送").Value
|
142
|
134
|
With xlApp.Selection
|
143
|
135
|
.Font.Bold = True
|
144
|
136
|
End With
|
|
@@ -180,10 +172,9 @@ Public Class 列印_訂單價格利潤表
|
180
|
172
|
xlSheet.Columns("AB:AB").Select : myExcel.Selection.ColumnWidth = 9 : xlSheet.Columns("AC:AC").Select : myExcel.Selection.ColumnWidth = 8
|
181
|
173
|
xlSheet.Columns("AD:AD").Select : myExcel.Selection.ColumnWidth = 11 : xlSheet.Columns("AE:AE").Select : myExcel.Selection.ColumnWidth = 11
|
182
|
174
|
xlSheet.Columns("AF:AF").Select : myExcel.Selection.ColumnWidth = 13 : xlSheet.Columns("AG:AG").Select : myExcel.Selection.ColumnWidth = 13
|
183
|
|
- xlSheet.Columns("AH:AH").Select : myExcel.Selection.ColumnWidth = 15 : xlSheet.Columns("AI:AI").Select : myExcel.Selection.ColumnWidth = 30
|
184
|
|
- xlSheet.Columns("AJ:AJ").Select : myExcel.Selection.ColumnWidth = 12 : xlSheet.Columns("AK:AK").Select : myExcel.Selection.ColumnWidth = 14
|
185
|
|
- xlSheet.Columns("AL:AL").Select : myExcel.Selection.ColumnWidth = 8 : xlSheet.Columns("AM:AM").Select : myExcel.Selection.ColumnWidth = 75
|
186
|
|
- xlSheet.Columns("AN:AN").Select : myExcel.Selection.ColumnWidth = 105
|
|
175
|
+ xlSheet.Columns("AH:AH").Select : myExcel.Selection.ColumnWidth = 14 : xlSheet.Columns("AI:AI").Select : myExcel.Selection.ColumnWidth = 8
|
|
176
|
+ xlSheet.Columns("AJ:AJ").Select : myExcel.Selection.ColumnWidth = 75
|
|
177
|
+
|
187
|
178
|
|
188
|
179
|
xlSheet.Cells.Select()
|
189
|
180
|
With myExcel.Selection.Font
|
|
@@ -269,7 +260,7 @@ Public Class 列印_訂單價格利潤表
|
269
|
260
|
xlSheet.Range("T1:AC3").Select() : With myExcel.Selection.Interior
|
270
|
261
|
.Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent6 : .TintAndShade = 0.399975585192419 : .PatternTintAndShade = 0 : End With
|
271
|
262
|
|
272
|
|
- xlSheet.Range("A1:AN3").Select() : myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
|
|
263
|
+ xlSheet.Range("A1:AJ3").Select() : myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
|
273
|
264
|
With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
|
274
|
265
|
With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
|
275
|
266
|
With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
|
|
@@ -280,10 +271,10 @@ Public Class 列印_訂單價格利潤表
|
280
|
271
|
xlSheet.Rows("3:3").Select : myExcel.Selection.AutoFilter
|
281
|
272
|
|
282
|
273
|
Dim M As Integer = 4
|
283
|
|
- For M = 4 To DataGridView1.Rows.Count + 2
|
|
274
|
+ For M = 4 To 利潤表_dgv.Rows.Count + 2
|
284
|
275
|
M += 1
|
285
|
276
|
Next M
|
286
|
|
- 位置1 = "A4:AN" & M
|
|
277
|
+ 位置1 = "A4:AJ" & M
|
287
|
278
|
xlSheet.Range(位置1).Select() : myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
|
288
|
279
|
With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
|
289
|
280
|
With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
|
|
@@ -297,7 +288,7 @@ Public Class 列印_訂單價格利潤表
|
297
|
288
|
.ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
|
298
|
289
|
End With : myExcel.Selection.Merge
|
299
|
290
|
|
300
|
|
- xlSheet.Range("AM4:AN" & M).Select()
|
|
291
|
+ xlSheet.Range("AJ4:AJ" & M).Select()
|
301
|
292
|
With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
|
302
|
293
|
.IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
|
303
|
294
|
|