|
@@ -21,18 +21,12 @@ Public Class 樣品物料調料單申請
|
21
|
21
|
Dim xlBook As Workbook
|
22
|
22
|
Dim xlSheet As Worksheet
|
23
|
23
|
Dim 位置1 As String : Dim N1 As Integer
|
24
|
|
- Private Sub Set_DGV1載入前設定()
|
25
|
|
- DataGridView1.DataSource = Nothing : ds.Clear()
|
26
|
|
- DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
27
|
|
- DataGridView1.ColumnHeadersHeight = 25
|
28
|
|
- DataGridView1.AllowUserToAddRows = False
|
29
|
|
- If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
30
|
|
- End Sub
|
31
|
|
- Private Sub Set_DGV1載入後設定()
|
32
|
|
- cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
|
33
|
|
- End Sub
|
34
|
24
|
Private Sub Set_清單()
|
35
|
|
- Set_DGV1載入前設定()
|
|
25
|
+ 調料單_dgv.DataSource = Nothing : ds.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
|
36
|
30
|
If PA = "" Then
|
37
|
31
|
SQL1 = "SELECT 樣品物料調料單抬頭.調料單號, 供應商清單.廠商, 樣品物料調料單抬頭.客戶, 樣品物料調料單抬頭.SHOW年,
|
38
|
32
|
樣品物料調料單抬頭.SHOW月, 樣品物料調料單抬頭.日期, 樣品物料調料單抬頭.發件人, 樣品物料調料單抬頭.收件人,
|
|
@@ -47,17 +41,18 @@ Public Class 樣品物料調料單申請
|
47
|
41
|
樣品物料調料單抬頭.制表人, 樣品物料調料單抬頭.核准簽名, 樣品物料調料單抬頭.供應商編號
|
48
|
42
|
FROM 樣品物料調料單抬頭 INNER JOIN
|
49
|
43
|
供應商清單 ON 樣品物料調料單抬頭.供應商編號 = 供應商清單.供應商編碼
|
50
|
|
- WHERE (樣品物料調料單抬頭.核准簽名 LIKE '') AND ((樣品物料調料單抬頭.調料單號 LIKE N'%" & PA & "%') OR (供應商清單.廠商 LIKE N'%" & PA & "%') OR (樣品物料調料單抬頭.客戶 LIKE N'%" & PA & "%') OR
|
|
44
|
+ WHERE (樣品物料調料單抬頭.核准簽名 LIKE '') AND ((樣品物料調料單抬頭.調料單號 LIKE N'%" & PA & "%') OR (供應商清單.廠商 LIKE N'%" & PA & "%') OR
|
|
45
|
+ (樣品物料調料單抬頭.客戶 LIKE N'%" & PA & "%') OR
|
51
|
46
|
(樣品物料調料單抬頭.SHOW年 LIKE N'%" & PA & "%') OR (樣品物料調料單抬頭.SHOW月 LIKE N'%" & PA & "%') OR (樣品物料調料單抬頭.日期 LIKE N'%" & PA & "%') OR
|
52
|
47
|
(樣品物料調料單抬頭.發件人 LIKE N'%" & PA & "%') OR (樣品物料調料單抬頭.收件人 LIKE N'%" & PA & "%') OR (樣品物料調料單抬頭.制表人 LIKE N'%" & PA & "%'))
|
53
|
48
|
ORDER BY 樣品物料調料單抬頭.SHOW年, 樣品物料調料單抬頭.SHOW月"
|
54
|
49
|
End If
|
55
|
|
- Set_DGV1載入後設定()
|
|
50
|
+ cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds) : 調料單_dgv.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
|
56
|
51
|
End Sub
|
57
|
52
|
Private Sub Set_grid()
|
58
|
|
- DataGridView1.Columns(0).Width = 110 : DataGridView1.Columns(1).Width = 130 : DataGridView1.Columns(2).Width = 130 : DataGridView1.Columns(3).Width = 70 : DataGridView1.Columns(4).Width = 70
|
59
|
|
- DataGridView1.Columns(5).Visible = False : DataGridView1.Columns(6).Visible = False : DataGridView1.Columns(7).Visible = False : DataGridView1.Columns(8).Visible = False
|
60
|
|
- DataGridView1.Columns(9).Visible = False : DataGridView1.Columns(10).Visible = False
|
|
53
|
+ 調料單_dgv.Columns(0).Width = 110 : 調料單_dgv.Columns(1).Width = 130 : 調料單_dgv.Columns(2).Width = 130 : 調料單_dgv.Columns(3).Width = 70 : 調料單_dgv.Columns(4).Width = 70
|
|
54
|
+ 調料單_dgv.Columns(5).Visible = False : 調料單_dgv.Columns(6).Visible = False : 調料單_dgv.Columns(7).Visible = False : 調料單_dgv.Columns(8).Visible = False
|
|
55
|
+ 調料單_dgv.Columns(9).Visible = False : 調料單_dgv.Columns(10).Visible = False
|
61
|
56
|
End Sub
|
62
|
57
|
Private Sub Set_使用者清單()
|
63
|
58
|
DataGridView2.DataSource = Nothing : ds1.Clear()
|
|
@@ -70,7 +65,8 @@ Public Class 樣品物料調料單申請
|
70
|
65
|
cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close() : Set_grid1()
|
71
|
66
|
End Sub
|
72
|
67
|
Private Sub Set_grid1()
|
73
|
|
- DataGridView2.Columns(0).Visible = False : DataGridView2.Columns(1).Width = 80 : DataGridView2.Columns(2).Width = 200 : DataGridView2.Columns(3).Width = 200 : DataGridView2.Columns(4).Width = 200
|
|
68
|
+ DataGridView2.Columns(0).Visible = False : DataGridView2.Columns(1).Width = 80 : DataGridView2.Columns(2).Width = 200 : DataGridView2.Columns(3).Width = 200
|
|
69
|
+ DataGridView2.Columns(4).Width = 200
|
74
|
70
|
DataGridView2.Columns(5).Width = 80 : DataGridView2.Columns(6).Width = 80 : DataGridView2.Columns(7).Width = 80 : DataGridView2.Columns(8).Width = 80 : DataGridView2.Columns(9).Width = 305
|
75
|
71
|
DataGridView2.Columns(8).DefaultCellStyle.Format = "#,##0.00" : DataGridView2.Columns(6).DefaultCellStyle.Format = "#,##0.00" : DataGridView2.Columns(7).DefaultCellStyle.Format = "#,##0.00"
|
76
|
72
|
DataGridView2.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView2.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
|
|
@@ -88,10 +84,18 @@ Public Class 樣品物料調料單申請
|
88
|
84
|
Private Sub ComboBox1下拉表單資料載入()
|
89
|
85
|
conn.Close()
|
90
|
86
|
If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
91
|
|
- SQL1 = "SELECT 廠商, 供應商編碼 FROM 供應商清單 WHERE 公司傳真3 LIKE '" & ComboBox18.Text & "' AND 停用 = 0 ORDER BY 廠商"
|
|
87
|
+ SQL1 = "SELECT 廠商, 供應商編碼 FROM 供應商清單 WHERE 公司傳真3 LIKE '" & 廠商類別_cb.Text & "' AND 停用 = 0 ORDER BY 廠商"
|
|
88
|
+ cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
|
|
89
|
+ 供應商_cb.Items.Clear() : 供應商編碼_cb.Items.Clear()
|
|
90
|
+ While (dr.Read()) : 供應商_cb.Items.Add(dr("廠商")) : 供應商編碼_cb.Items.Add(dr("供應商編碼")) : End While : conn.Close()
|
|
91
|
+ End Sub
|
|
92
|
+ Private Sub ComboBox下拉表單資料載入()
|
|
93
|
+ conn.Close()
|
|
94
|
+ If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
|
95
|
+ SQL1 = "SELECT 廠商, 供應商編碼 FROM 供應商清單 WHERE 停用 = 0 ORDER BY 廠商"
|
92
|
96
|
cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
|
93
|
|
- ComboBox1.Items.Clear() : ComboBox2.Items.Clear()
|
94
|
|
- While (dr.Read()) : ComboBox1.Items.Add(dr("廠商")) : ComboBox2.Items.Add(dr("供應商編碼")) : End While : conn.Close()
|
|
97
|
+ 供應商_cb.Items.Clear() : 供應商編碼_cb.Items.Clear()
|
|
98
|
+ While (dr.Read()) : 供應商_cb.Items.Add(dr("廠商")) : 供應商編碼_cb.Items.Add(dr("供應商編碼")) : End While : conn.Close()
|
95
|
99
|
End Sub
|
96
|
100
|
Private Sub ComboBox3下拉表單資料載入()
|
97
|
101
|
conn.Close()
|
|
@@ -120,7 +124,7 @@ Public Class 樣品物料調料單申請
|
120
|
124
|
If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
121
|
125
|
SQL1 = "SELECT 公司傳真3 AS 類別 FROM 供應商清單 GROUP BY 公司傳真3 ORDER BY 公司傳真3"
|
122
|
126
|
cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
|
123
|
|
- ComboBox18.Items.Clear() : While (dr.Read()) : ComboBox18.Items.Add(dr("類別")) : End While : conn.Close()
|
|
127
|
+ 廠商類別_cb.Items.Clear() : While (dr.Read()) : 廠商類別_cb.Items.Add(dr("類別")) : End While : conn.Close()
|
124
|
128
|
End Sub
|
125
|
129
|
Private Sub Set_日期格式轉換()
|
126
|
130
|
DTP = Strings.Format(DateTimePicker1.Value, "yyyy/MM/dd") : DTP1 = Strings.Format(Today(), "yyyyMMdd")
|
|
@@ -141,13 +145,14 @@ Public Class 樣品物料調料單申請
|
141
|
145
|
cmd.CommandText = SQL1 : cmd.Connection = conn : cmd.ExecuteNonQuery() : conn.Close()
|
142
|
146
|
End If
|
143
|
147
|
End Sub
|
144
|
|
- Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
|
|
148
|
+ Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 調料單_dgv.CellClick
|
145
|
149
|
If e.RowIndex = -1 Then : Else
|
146
|
|
- TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("調料單號").Value.ToString : Button3.Enabled = True : Button5.Enabled = True
|
147
|
|
- ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("供應商編號").Value : ComboBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("發件人").Value
|
148
|
|
- ComboBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("收件人").Value : DateTimePicker1.Value = DataGridView1.Rows(e.RowIndex).Cells("日期").Value
|
149
|
|
- TextBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("制表人").Value : ComboBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("客戶").Value
|
150
|
|
- ComboBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("SHOW年").Value : ComboBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("SHOW月").Value
|
|
150
|
+ ComboBox下拉表單資料載入()
|
|
151
|
+ TextBox1.Text = 調料單_dgv.Rows(e.RowIndex).Cells("調料單號").Value.ToString : Button3.Enabled = True : Button5.Enabled = True
|
|
152
|
+ 供應商編碼_cb.Text = 調料單_dgv.Rows(e.RowIndex).Cells("供應商編號").Value : ComboBox3.Text = 調料單_dgv.Rows(e.RowIndex).Cells("發件人").Value
|
|
153
|
+ ComboBox4.Text = 調料單_dgv.Rows(e.RowIndex).Cells("收件人").Value : DateTimePicker1.Value = 調料單_dgv.Rows(e.RowIndex).Cells("日期").Value
|
|
154
|
+ TextBox7.Text = 調料單_dgv.Rows(e.RowIndex).Cells("制表人").Value : ComboBox7.Text = 調料單_dgv.Rows(e.RowIndex).Cells("客戶").Value
|
|
155
|
+ ComboBox5.Text = 調料單_dgv.Rows(e.RowIndex).Cells("SHOW年").Value : ComboBox6.Text = 調料單_dgv.Rows(e.RowIndex).Cells("SHOW月").Value
|
151
|
156
|
Set_使用者清單()
|
152
|
157
|
End If
|
153
|
158
|
End Sub
|
|
@@ -167,23 +172,23 @@ Public Class 樣品物料調料單申請
|
167
|
172
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
168
|
173
|
If Label62.Visible = True Then : Label62.Visible = False : Else : Label62.Visible = True : End If
|
169
|
174
|
End Sub
|
170
|
|
- Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
|
171
|
|
- ComboBox2.SelectedIndex = ComboBox1.SelectedIndex
|
|
175
|
+ Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 供應商_cb.SelectedIndexChanged
|
|
176
|
+ 供應商編碼_cb.SelectedIndex = 供應商_cb.SelectedIndex
|
172
|
177
|
End Sub
|
173
|
|
- Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
|
174
|
|
- ComboBox1.SelectedIndex = ComboBox2.SelectedIndex
|
|
178
|
+ Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 供應商編碼_cb.SelectedIndexChanged
|
|
179
|
+ 供應商_cb.SelectedIndex = 供應商編碼_cb.SelectedIndex
|
175
|
180
|
conn.Close()
|
176
|
181
|
If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
177
|
|
- SQL1 = "SELECT 公司名, 公司電話1, 聯繫人1 FROM 供應商清單 WHERE (供應商編碼 LIKE '" & ComboBox2.Text & "') ORDER BY 廠商"
|
|
182
|
+ SQL1 = "SELECT 公司名, 公司電話1, 聯繫人1 FROM 供應商清單 WHERE (供應商編碼 LIKE '" & 供應商編碼_cb.Text & "') ORDER BY 廠商"
|
178
|
183
|
cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
|
179
|
184
|
If dr.Read() Then : TextBox2.Text = dr("公司名") : TextBox3.Text = dr("聯繫人1") : TextBox4.Text = dr("公司電話1") : End If
|
180
|
185
|
conn.Close()
|
181
|
186
|
End Sub
|
182
|
|
- Private Sub ComboBox18_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox18.SelectedIndexChanged
|
|
187
|
+ Private Sub ComboBox18_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles 廠商類別_cb.SelectedIndexChanged
|
183
|
188
|
ComboBox1下拉表單資料載入()
|
184
|
189
|
End Sub
|
185
|
190
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
186
|
|
- Timer1.Enabled = True : DataGridView1.Enabled = False
|
|
191
|
+ Timer1.Enabled = True : 調料單_dgv.Enabled = False
|
187
|
192
|
Button1.Enabled = False : Button2.Enabled = True : Button6.Enabled = True : Button15.Enabled = True
|
188
|
193
|
Set_日期格式轉換() : Dim NUM1 As Integer
|
189
|
194
|
For i As Integer = 1 To 999
|
|
@@ -230,7 +235,7 @@ Public Class 樣品物料調料單申請
|
230
|
235
|
Set_日期格式轉換()
|
231
|
236
|
If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
|
232
|
237
|
SQL1 = "UPDATE 樣品物料調料單抬頭 SET 日期 = N'" & DTP & "', 發件人 = N'" & ComboBox3.Text & "', 收件人 = N'" & ComboBox4.Text & "', 客戶 = N'" & ComboBox7.Text &
|
233
|
|
- "', 制表人 = N'" & gUserName & "', 供應商編號 = N'" & ComboBox2.Text & "', SHOW年 = N'" & ComboBox5.Text & "', SHOW月 = N'" & ComboBox6.Text &
|
|
238
|
+ "', 制表人 = N'" & gUserName & "', 供應商編號 = N'" & 供應商編碼_cb.Text & "', SHOW年 = N'" & ComboBox5.Text & "', SHOW月 = N'" & ComboBox6.Text &
|
234
|
239
|
"' WHERE (調料單號 LIKE N'" & TextBox1.Text & "')"
|
235
|
240
|
cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
|
236
|
241
|
End Sub
|
|
@@ -282,8 +287,8 @@ Public Class 樣品物料調料單申請
|
282
|
287
|
End If
|
283
|
288
|
End Sub
|
284
|
289
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
285
|
|
- DataGridView1.Enabled = True
|
286
|
|
- If ComboBox1.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox7.Text = "" Then
|
|
290
|
+ 調料單_dgv.Enabled = True
|
|
291
|
+ If 供應商_cb.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox7.Text = "" Then
|
287
|
292
|
MsgBox("所有的下拉清單都要選擇,請重新確定資料是否正確。")
|
288
|
293
|
Else
|
289
|
294
|
If TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
|
|
@@ -298,16 +303,16 @@ Public Class 樣品物料調料單申請
|
298
|
303
|
End Sub
|
299
|
304
|
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
300
|
305
|
Button3.Enabled = False : Button4.Enabled = True : Button6.Enabled = True : Button15.Enabled = True : Timer1.Enabled = True
|
301
|
|
- DataGridView1.Enabled = False
|
|
306
|
+ 調料單_dgv.Enabled = False
|
302
|
307
|
End Sub
|
303
|
308
|
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
|
304
|
|
- If ComboBox1.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox7.Text = "" Then
|
|
309
|
+ If 供應商_cb.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox7.Text = "" Then
|
305
|
310
|
MsgBox("所有的下拉清單都要選擇,請重新確定資料是否正確。")
|
306
|
311
|
Else
|
307
|
312
|
If TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
|
308
|
313
|
MsgBox("供應商資料內容有缺失,請先完善供應商資料。")
|
309
|
314
|
Else
|
310
|
|
- DataGridView1.Enabled = True
|
|
315
|
+ 調料單_dgv.Enabled = True
|
311
|
316
|
Timer1.Enabled = False : Label62.Visible = False
|
312
|
317
|
Button3.Enabled = True : Button4.Enabled = False : Button6.Enabled = False : Button15.Enabled = False
|
313
|
318
|
存檔1() : 存檔() : TextBox7.Text = gUserName
|