|
@@ -13,25 +13,36 @@ Public Class 列印_生產進度表
|
13
|
13
|
ReadOnly conn As New SqlConnection
|
14
|
14
|
ReadOnly da As New SqlDataAdapter
|
15
|
15
|
ReadOnly cmd As New SqlCommand
|
16
|
|
- ReadOnly ds As New DataSet
|
|
16
|
+ ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet
|
17
|
17
|
Dim xlApp As Application
|
18
|
18
|
Dim xlBook As Workbook
|
19
|
19
|
Dim xlSheet As Worksheet
|
20
|
20
|
Public Property ThisWorkbook As Object
|
21
|
21
|
Public Property ActiveWorkbook As Object
|
22
|
22
|
Dim N1 As Integer = 0
|
23
|
|
- Private Sub Set_DGV1載入前設定()
|
|
23
|
+ Dim ASS As String
|
|
24
|
+ Private Sub Set_工廠清單()
|
|
25
|
+ 工廠_DGV.DataSource = Nothing : ds1.Clear()
|
|
26
|
+ 工廠_DGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
|
27
|
+ 工廠_DGV.ColumnHeadersHeight = 25
|
|
28
|
+ 工廠_DGV.AllowUserToAddRows = False
|
|
29
|
+ If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
|
30
|
+ SQL1 = "SELECT METOO選擇按鈕.選擇, QQ.生產工廠
|
|
31
|
+ FROM METOO選擇按鈕 RIGHT OUTER JOIN
|
|
32
|
+ (SELECT TOP (100) PERCENT 生產工廠 FROM 訂單控制表 WHERE (CXL = 0) AND (訂單數量 - 出貨數量 > 0)
|
|
33
|
+ GROUP BY 生產工廠 ORDER BY 生產工廠) AS QQ ON METOO選擇按鈕.對應 = QQ.生產工廠"
|
|
34
|
+ cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : 工廠_DGV.DataSource = ds1.Tables(0) : conn.Close()
|
|
35
|
+ 工廠_DGV.Columns(0).FillWeight = 30 : 工廠_DGV.Columns(1).FillWeight = 100
|
|
36
|
+ For i As Integer = 0 To 工廠_DGV.Rows.Count - 1
|
|
37
|
+ 工廠_DGV.Rows(i).Cells("選擇").Value = False
|
|
38
|
+ Next
|
|
39
|
+ End Sub
|
|
40
|
+ Private Sub Set_訂單清單()
|
24
|
41
|
DataGridView1.DataSource = Nothing : ds.Clear()
|
25
|
42
|
DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
26
|
43
|
DataGridView1.ColumnHeadersHeight = 25
|
27
|
44
|
DataGridView1.AllowUserToAddRows = False
|
28
|
45
|
If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
29
|
|
- End Sub
|
30
|
|
- Private Sub Set_DGV1載入後設定()
|
31
|
|
- cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
|
32
|
|
- End Sub
|
33
|
|
- Private Sub Set_訂單清單()
|
34
|
|
- Set_DGV1載入前設定()
|
35
|
46
|
SQL1 = "SELECT 訂單明細表抬頭.下單日 AS 接單日, 訂單控制表.訂單流水號, 訂單控制表.客戶訂單號,
|
36
|
47
|
訂單控制表.GOODBOX AS 型體名稱, 訂單控制表.型體號碼, 訂單控制表.年份季度, 訂單控制表.TVW AS 楦型,
|
37
|
48
|
訂單控制表.APMA確認 AS 顏色, 訂單控制表.訂單數量, 訂單控制表.工廠回復交期 AS 最後交期, 訂單控制表.BUYER,
|
|
@@ -44,79 +55,94 @@ Public Class 列印_生產進度表
|
44
|
55
|
訂單明細表抬頭 ON 訂單控制表.客戶訂單號 = 訂單明細表抬頭.客戶訂單號 AND
|
45
|
56
|
訂單控制表.訂單流水號 = 訂單明細表抬頭.訂單流水號
|
46
|
57
|
WHERE (訂單控制表.CXL = 0 OR
|
47
|
|
- 訂單控制表.CXL IS NULL) AND (訂單控制表.訂單數量 - 訂單控制表.出貨數量 <> 0)
|
|
58
|
+ 訂單控制表.CXL IS NULL) AND (訂單控制表.訂單數量 - 訂單控制表.出貨數量 <> 0) AND (訂單控制表.生產工廠 LIKE '" & ASS & "')
|
48
|
59
|
ORDER BY 訂單控制表.訂單流水號 DESC, 訂單控制表.客戶交期1, 訂單控制表.型體號碼, 顏色, 楦型"
|
49
|
|
- Set_DGV1載入後設定()
|
|
60
|
+ cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close()
|
50
|
61
|
End Sub
|
51
|
|
-
|
52
|
62
|
Private Sub 生產進度表列印_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
63
|
+ ASS = ""
|
53
|
64
|
FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
|
54
|
65
|
CheckBox1.Visible = False : CheckBox3.Visible = False : CheckBox6.Visible = False : CheckBox5.Visible = False : CheckBox4.Visible = False
|
55
|
|
- Set_訂單清單()
|
|
66
|
+ Set_工廠清單()
|
|
67
|
+ End Sub
|
|
68
|
+ Private Sub 工廠_DGV_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 工廠_DGV.CellClick
|
|
69
|
+ If e.RowIndex = -1 Then : Else
|
|
70
|
+ For i As Integer = 0 To 工廠_DGV.Rows.Count - 1
|
|
71
|
+ If e.RowIndex = i Then
|
|
72
|
+ 工廠_DGV.Rows(i).Cells("選擇").Value = True : ASS = 工廠_DGV.Rows(i).Cells("生產工廠").Value.ToString : Set_訂單清單()
|
|
73
|
+ Else
|
|
74
|
+ 工廠_DGV.Rows(i).Cells("選擇").Value = False
|
|
75
|
+ End If
|
|
76
|
+ Next
|
|
77
|
+ End If
|
56
|
78
|
End Sub
|
57
|
79
|
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
|
58
|
|
- xlApp = CType(CreateObject("Excel.Application"), Application)
|
59
|
|
- xlApp.Visible = True
|
60
|
|
- xlApp.DisplayAlerts = True
|
61
|
|
- xlApp.Application.WindowState = xlMaximized
|
62
|
|
- xlBook = xlApp.Workbooks.Add
|
63
|
|
- xlSheet = NewMethod(xlBook)
|
64
|
|
- xlApp.Sheets(1).Select
|
65
|
|
- xlBook.Activate() : xlSheet.Activate()
|
66
|
|
- xlApp.Sheets(1).Name = "SK"
|
67
|
|
- xlSheet.Range("A1").Select()
|
68
|
|
-
|
69
|
|
- xlSheet.Cells(1, 13) = "淺藍色欄位為系統輸出,請勿做任何更改
|
|
80
|
+ If ASS <> "" Then
|
|
81
|
+ xlApp = CType(CreateObject("Excel.Application"), Application)
|
|
82
|
+ xlApp.Visible = True
|
|
83
|
+ xlApp.DisplayAlerts = True
|
|
84
|
+ xlApp.Application.WindowState = xlMaximized
|
|
85
|
+ xlBook = xlApp.Workbooks.Add
|
|
86
|
+ xlSheet = NewMethod(xlBook)
|
|
87
|
+ xlApp.Sheets(1).Select
|
|
88
|
+ xlBook.Activate() : xlSheet.Activate()
|
|
89
|
+ xlApp.Sheets(1).Name = ASS
|
|
90
|
+ xlSheet.Range("A1").Select()
|
|
91
|
+
|
|
92
|
+ xlSheet.Cells(1, 13) = "淺藍色欄位為系統輸出,請勿做任何更改
|
70
|
93
|
淺綠色欄位為巨益辦公室填入"
|
71
|
|
- xlSheet.Cells(2, 14) = "量產樣品" : xlSheet.Cells(2, 16) = "PRODUCTION"
|
72
|
|
- xlSheet.Cells(3, 1) = "接單日" : xlSheet.Cells(3, 2) = "巨益PO#" : xlSheet.Cells(3, 3) = "客戶PO#" : xlSheet.Cells(3, 4) = "型體名稱"
|
73
|
|
- xlSheet.Cells(3, 5) = "型體號碼" : xlSheet.Cells(3, 6) = "年份季度" : xlSheet.Cells(3, 7) = "楦型" : xlSheet.Cells(3, 8) = "顏色"
|
74
|
|
- xlSheet.Cells(3, 9) = "訂單數" : xlSheet.Cells(3, 10) = "最後交期" : xlSheet.Cells(3, 11) = "BUYER" : xlSheet.Cells(3, 12) = "材質"
|
75
|
|
- xlSheet.Cells(3, 13) = "東莞業務備註" : xlSheet.Cells(3, 14) = "手剪全套" : xlSheet.Cells(3, 15) = "斬刀全套"
|
76
|
|
-
|
77
|
|
- xlSheet.Cells(3, 16) = "面料" : xlSheet.Cells(3, 17) = "副料" : xlSheet.Cells(3, 18) = "中底" : xlSheet.Cells(3, 19) = "鞋墊" : xlSheet.Cells(3, 20) = "大底"
|
78
|
|
- xlSheet.Cells(3, 21) = "跟" : xlSheet.Cells(3, 22) = "包裝" : xlSheet.Cells(3, 23) = "裁斷" : xlSheet.Cells(3, 24) = "針車" : xlSheet.Cells(3, 25) = "成型"
|
79
|
|
- xlSheet.Cells(3, 26) = "驗貨" : xlSheet.Cells(3, 27) = "驗貨結果" : xlSheet.Cells(3, 28) = "工廠備註"
|
80
|
|
-
|
81
|
|
- For i As Integer = 0 To DataGridView1.Rows.Count - 1
|
82
|
|
- xlSheet.Cells(i + 4, 1) = DataGridView1.Rows(i).Cells("接單日").Value : xlSheet.Cells(i + 4, 2) = DataGridView1.Rows(i).Cells("訂單流水號").Value
|
83
|
|
- xlSheet.Cells(i + 4, 3) = DataGridView1.Rows(i).Cells("客戶訂單號").Value : xlSheet.Cells(i + 4, 4) = DataGridView1.Rows(i).Cells("型體名稱").Value
|
84
|
|
- xlSheet.Cells(i + 4, 5) = DataGridView1.Rows(i).Cells("型體號碼").Value : xlSheet.Cells(i + 4, 6) = DataGridView1.Rows(i).Cells("年份季度").Value
|
85
|
|
- xlSheet.Cells(i + 4, 7) = DataGridView1.Rows(i).Cells("楦型").Value : xlSheet.Cells(i + 4, 8) = DataGridView1.Rows(i).Cells("顏色").Value
|
86
|
|
- xlSheet.Cells(i + 4, 9) = DataGridView1.Rows(i).Cells("訂單數量").Value : xlSheet.Cells(i + 4, 10) = DataGridView1.Rows(i).Cells("最後交期").Value
|
87
|
|
-
|
88
|
|
- xlSheet.Cells(i + 4, 11) = DataGridView1.Rows(i).Cells("BUYER").Value
|
89
|
|
- xlSheet.Cells(i + 4, 12) = DataGridView1.Rows(i).Cells("材質").Value
|
90
|
|
- xlSheet.Cells(i + 4, 13) = DataGridView1.Rows(i).Cells("東莞業務備註").Value
|
91
|
|
- xlSheet.Cells(i + 4, 14) = DataGridView1.Rows(i).Cells("手剪全套").Value
|
92
|
|
- xlSheet.Cells(i + 4, 15) = DataGridView1.Rows(i).Cells("斬刀全套").Value
|
93
|
|
-
|
94
|
|
- xlSheet.Cells(i + 4, 16) = DataGridView1.Rows(i).Cells("面料").Value : xlSheet.Cells(i + 4, 17) = DataGridView1.Rows(i).Cells("副料").Value
|
95
|
|
- xlSheet.Cells(i + 4, 18) = DataGridView1.Rows(i).Cells("中底").Value : xlSheet.Cells(i + 4, 19) = DataGridView1.Rows(i).Cells("鞋墊").Value
|
96
|
|
- xlSheet.Cells(i + 4, 20) = DataGridView1.Rows(i).Cells("大底").Value : xlSheet.Cells(i + 4, 21) = DataGridView1.Rows(i).Cells("跟").Value
|
97
|
|
- xlSheet.Cells(i + 4, 22) = DataGridView1.Rows(i).Cells("包裝").Value : xlSheet.Cells(i + 4, 23) = DataGridView1.Rows(i).Cells("裁斷").Value
|
98
|
|
- xlSheet.Cells(i + 4, 24) = DataGridView1.Rows(i).Cells("針車").Value : xlSheet.Cells(i + 4, 25) = DataGridView1.Rows(i).Cells("成形").Value
|
99
|
|
- xlSheet.Cells(i + 4, 26) = DataGridView1.Rows(i).Cells("驗貨").Value : xlSheet.Cells(i + 4, 27) = DataGridView1.Rows(i).Cells("驗貨結果").Value
|
100
|
|
- xlSheet.Cells(i + 4, 28) = DataGridView1.Rows(i).Cells("工廠備註").Value
|
101
|
|
- With xlApp.Selection
|
102
|
|
- .Font.Bold = True
|
103
|
|
- End With
|
104
|
|
- N1 = i
|
105
|
|
- Next i
|
106
|
|
-
|
107
|
|
- BB(xlApp, xlSheet)
|
108
|
|
- xlSheet.Range("A4").Select()
|
109
|
|
- If xlApp.Sheets(2).Name = "工作表1" Then
|
110
|
|
- xlApp.Sheets("工作表1").Delete
|
|
94
|
+ xlSheet.Cells(2, 14) = "量產樣品" : xlSheet.Cells(2, 16) = "PRODUCTION"
|
|
95
|
+ xlSheet.Cells(3, 1) = "接單日" : xlSheet.Cells(3, 2) = "巨益PO#" : xlSheet.Cells(3, 3) = "客戶PO#" : xlSheet.Cells(3, 4) = "型體名稱"
|
|
96
|
+ xlSheet.Cells(3, 5) = "型體號碼" : xlSheet.Cells(3, 6) = "年份季度" : xlSheet.Cells(3, 7) = "楦型" : xlSheet.Cells(3, 8) = "顏色"
|
|
97
|
+ xlSheet.Cells(3, 9) = "訂單數" : xlSheet.Cells(3, 10) = "最後交期" : xlSheet.Cells(3, 11) = "BUYER" : xlSheet.Cells(3, 12) = "材質"
|
|
98
|
+ xlSheet.Cells(3, 13) = "東莞業務備註" : xlSheet.Cells(3, 14) = "手剪全套" : xlSheet.Cells(3, 15) = "斬刀全套"
|
|
99
|
+
|
|
100
|
+ xlSheet.Cells(3, 16) = "面料" : xlSheet.Cells(3, 17) = "副料" : xlSheet.Cells(3, 18) = "中底" : xlSheet.Cells(3, 19) = "鞋墊" : xlSheet.Cells(3, 20) = "大底"
|
|
101
|
+ xlSheet.Cells(3, 21) = "跟" : xlSheet.Cells(3, 22) = "包裝" : xlSheet.Cells(3, 23) = "裁斷" : xlSheet.Cells(3, 24) = "針車" : xlSheet.Cells(3, 25) = "成型"
|
|
102
|
+ xlSheet.Cells(3, 26) = "驗貨" : xlSheet.Cells(3, 27) = "驗貨結果" : xlSheet.Cells(3, 28) = "工廠備註"
|
|
103
|
+
|
|
104
|
+ For i As Integer = 0 To DataGridView1.Rows.Count - 1
|
|
105
|
+ xlSheet.Cells(i + 4, 1) = DataGridView1.Rows(i).Cells("接單日").Value : xlSheet.Cells(i + 4, 2) = DataGridView1.Rows(i).Cells("訂單流水號").Value
|
|
106
|
+ xlSheet.Cells(i + 4, 3) = DataGridView1.Rows(i).Cells("客戶訂單號").Value : xlSheet.Cells(i + 4, 4) = DataGridView1.Rows(i).Cells("型體名稱").Value
|
|
107
|
+ xlSheet.Cells(i + 4, 5) = DataGridView1.Rows(i).Cells("型體號碼").Value : xlSheet.Cells(i + 4, 6) = DataGridView1.Rows(i).Cells("年份季度").Value
|
|
108
|
+ xlSheet.Cells(i + 4, 7) = DataGridView1.Rows(i).Cells("楦型").Value : xlSheet.Cells(i + 4, 8) = DataGridView1.Rows(i).Cells("顏色").Value
|
|
109
|
+ xlSheet.Cells(i + 4, 9) = DataGridView1.Rows(i).Cells("訂單數量").Value : xlSheet.Cells(i + 4, 10) = DataGridView1.Rows(i).Cells("最後交期").Value
|
|
110
|
+
|
|
111
|
+ xlSheet.Cells(i + 4, 11) = DataGridView1.Rows(i).Cells("BUYER").Value
|
|
112
|
+ xlSheet.Cells(i + 4, 12) = DataGridView1.Rows(i).Cells("材質").Value
|
|
113
|
+ xlSheet.Cells(i + 4, 13) = DataGridView1.Rows(i).Cells("東莞業務備註").Value
|
|
114
|
+ xlSheet.Cells(i + 4, 14) = DataGridView1.Rows(i).Cells("手剪全套").Value
|
|
115
|
+ xlSheet.Cells(i + 4, 15) = DataGridView1.Rows(i).Cells("斬刀全套").Value
|
|
116
|
+
|
|
117
|
+ xlSheet.Cells(i + 4, 16) = DataGridView1.Rows(i).Cells("面料").Value : xlSheet.Cells(i + 4, 17) = DataGridView1.Rows(i).Cells("副料").Value
|
|
118
|
+ xlSheet.Cells(i + 4, 18) = DataGridView1.Rows(i).Cells("中底").Value : xlSheet.Cells(i + 4, 19) = DataGridView1.Rows(i).Cells("鞋墊").Value
|
|
119
|
+ xlSheet.Cells(i + 4, 20) = DataGridView1.Rows(i).Cells("大底").Value : xlSheet.Cells(i + 4, 21) = DataGridView1.Rows(i).Cells("跟").Value
|
|
120
|
+ xlSheet.Cells(i + 4, 22) = DataGridView1.Rows(i).Cells("包裝").Value : xlSheet.Cells(i + 4, 23) = DataGridView1.Rows(i).Cells("裁斷").Value
|
|
121
|
+ xlSheet.Cells(i + 4, 24) = DataGridView1.Rows(i).Cells("針車").Value : xlSheet.Cells(i + 4, 25) = DataGridView1.Rows(i).Cells("成形").Value
|
|
122
|
+ xlSheet.Cells(i + 4, 26) = DataGridView1.Rows(i).Cells("驗貨").Value : xlSheet.Cells(i + 4, 27) = DataGridView1.Rows(i).Cells("驗貨結果").Value
|
|
123
|
+ xlSheet.Cells(i + 4, 28) = DataGridView1.Rows(i).Cells("工廠備註").Value
|
|
124
|
+ With xlApp.Selection
|
|
125
|
+ .Font.Bold = True
|
|
126
|
+ End With
|
|
127
|
+ N1 = i
|
|
128
|
+ Next i
|
|
129
|
+
|
|
130
|
+ BB(xlApp, xlSheet)
|
|
131
|
+ xlSheet.Range("A4").Select()
|
|
132
|
+ If xlApp.Sheets(2).Name = "工作表1" Then
|
|
133
|
+ xlApp.Sheets("工作表1").Delete
|
|
134
|
+ Else
|
|
135
|
+ xlApp.Sheets("sheet1").Delete
|
|
136
|
+ End If
|
|
137
|
+ xlSheet.Cells(1, 1) = "巨益 量產進度管理表"
|
|
138
|
+ xlSheet.PageSetup.PrintArea = ""
|
|
139
|
+ xlApp.Cells.Select()
|
|
140
|
+ xlApp.Application.WindowState = xlMinimized
|
|
141
|
+ MsgBox("列印完成")
|
|
142
|
+ Me.Close()
|
111
|
143
|
Else
|
112
|
|
- xlApp.Sheets("sheet1").Delete
|
|
144
|
+ MsgBox("請先選擇工廠")
|
113
|
145
|
End If
|
114
|
|
- xlSheet.Cells(1, 1) = "巨益 量產進度管理表"
|
115
|
|
- xlSheet.PageSetup.PrintArea = ""
|
116
|
|
- xlApp.Cells.Select()
|
117
|
|
- xlApp.Application.WindowState = xlMinimized
|
118
|
|
- MsgBox("列印完成")
|
119
|
|
- Me.Close()
|
120
|
146
|
End Sub
|
121
|
147
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
122
|
148
|
Me.Close()
|