Option Strict Off Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle Imports Microsoft.Office.Interop.Excel.Constants Imports Microsoft.Office.Interop.Excel.XlBordersIndex Imports Microsoft.Office.Interop.Excel.XlLineStyle Imports Microsoft.Office.Interop.Excel.XlBorderWeight Imports Microsoft.Office.Interop.Excel.XlThemeFont Imports Microsoft.Office.Interop.Excel.XlThemeColor Imports Microsoft.Office.Interop.Excel.XlWindowState Imports Microsoft.Office.Interop.Excel Public Class 採購單申請 ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet : ReadOnly ds2 As New DataSet Dim EDR As Integer = 0 : Dim ESTR As String : Dim N1 As Integer Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet Private Sub Set_物料清單() DataGridView1.DataSource = Nothing : ds.Clear() : DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing : DataGridView1.ColumnHeadersHeight = 25 DataGridView1.AllowUserToAddRows = False : DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText : DataGridView1.MultiSelect = True SQL_採購單申請_物料清單() da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() DataGridView1.Columns(0).FillWeight = 10 : DataGridView1.Columns(1).Visible = False : DataGridView1.Columns(2).FillWeight = 20 : DataGridView1.Columns(3).FillWeight = 5 DataGridView1.Columns(4).Visible = False : DataGridView1.Columns(5).Visible = False : DataGridView1.Columns(6).Visible = False : DataGridView1.Columns(7).Visible = False DataGridView1.Columns(8).Visible = False : DataGridView1.Columns(9).Visible = False : DataGridView1.Columns(10).Visible = False DataGridView1.Columns(3).DefaultCellStyle.Format = "#,##0" : DataGridView1.Columns(4).DefaultCellStyle.Format = "#,##0" DataGridView1.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(3).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView1.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView1.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView1.Columns(1).ReadOnly = True : DataGridView1.Columns(2).ReadOnly = True : DataGridView1.Columns(3).ReadOnly = True : DataGridView1.Columns(4).ReadOnly = True DataGridView1.Columns(5).ReadOnly = True : DataGridView1.Columns(6).ReadOnly = True : DataGridView1.Columns(7).ReadOnly = True : DataGridView1.Columns(8).ReadOnly = True DataGridView1.Columns(9).ReadOnly = True : DataGridView1.Columns(10).ReadOnly = True : DataGridView1.Columns(0).ReadOnly = True End Sub Private Sub Set_採購清單() DataGridView2.DataSource = Nothing : ds1.Clear() : DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing : DataGridView2.ColumnHeadersHeight = 25 DataGridView2.AllowUserToAddRows = False : DataGridView2.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText : DataGridView2.MultiSelect = True SQL_採購單申請_單號彙總() da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close() DataGridView2.Columns(0).FillWeight = 135 : DataGridView2.Columns(1).FillWeight = 90 : DataGridView2.Columns(2).Visible = False : DataGridView2.Columns(3).FillWeight = 100 DataGridView2.Columns(4).FillWeight = 90 End Sub Private Sub Set_單據明細() DataGridView3.DataSource = Nothing : ds2.Clear() : DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing : DataGridView3.ColumnHeadersHeight = 25 DataGridView3.AllowUserToAddRows = False : DataGridView3.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText : DataGridView3.MultiSelect = True SQL_採購單申請明細() da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close() TextBox15.Text = "0" For i As Integer = 0 To DataGridView3.Rows.Count - 1 DataGridView3(1, i).Value = i + 1 : TextBox15.Text = Val(TextBox15.Text) + DataGridView3.Rows(i).Cells("進貨成本_台幣").Value DataGridView3.Rows(i).Cells("選擇").Value = False Next TextBox15.Text = Strings.Format(Val(TextBox15.Text), "#,#00") DataGridView3.Columns(6).DefaultCellStyle.Format = "#,##0" : DataGridView3.Columns(7).DefaultCellStyle.Format = "#,##0.00" DataGridView3.Columns(8).DefaultCellStyle.Format = "#,##0.0000" : DataGridView3.Columns(9).DefaultCellStyle.Format = "#,##0" : DataGridView3.Columns(10).DefaultCellStyle.Format = "#,##0" DataGridView3.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(2).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : DataGridView3.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter DataGridView3.Columns(0).Visible = False : DataGridView3.Columns(1).FillWeight = 50 : DataGridView3.Columns(2).FillWeight = 80 : DataGridView3.Columns(3).FillWeight = 200 DataGridView3.Columns(4).Visible = False : DataGridView3.Columns(5).Visible = False : DataGridView3.Columns(6).FillWeight = 50 : DataGridView3.Columns(7).FillWeight = 50 DataGridView3.Columns(8).FillWeight = 50 : DataGridView3.Columns(9).FillWeight = 50 : DataGridView3.Columns(10).FillWeight = 65 : DataGridView3.Columns(11).FillWeight = 100 DataGridView3.Columns(12).FillWeight = 80 : DataGridView3.Columns(13).Visible = False : DataGridView3.Columns(14).Visible = False : DataGridView3.Columns(15).Visible = False DataGridView3.Columns(16).Visible = False : DataGridView3.Columns(17).FillWeight = 50 DataGridView3.EditMode = DataGridViewEditMode.EditOnEnter DataGridView3.Columns(1).ReadOnly = True : DataGridView3.Columns(2).ReadOnly = True : DataGridView3.Columns(3).ReadOnly = True : DataGridView3.Columns(4).ReadOnly = True DataGridView3.Columns(5).ReadOnly = True : DataGridView3.Columns(8).ReadOnly = True : DataGridView3.Columns(9).ReadOnly = True : DataGridView3.Columns(10).ReadOnly = True DataGridView3.Columns(12).ReadOnly = True End Sub Private Sub ComboBox1下拉表單資料載入() SQL_物料頁碼清單() ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("頁碼")) : End While : conn.Close() End Sub Private Sub ComboBox2下拉表單資料載入() SQL_供應商資料表下拉清單() ComboBox2.Items.Clear() : ComboBox3.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("簡稱")) : ComboBox3.Items.Add(dr("編號")) : End While : conn.Close() End Sub Private Sub 採購單申請_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.MdiParent = MAOJI_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True TextBox9.Enabled = False : TextBox7.Enabled = False : TextBox14.Enabled = False : RadioButton1.Checked = True : ComboBox3.Visible = False ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入() : Set_採購清單() : Set_物料清單() End Sub Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick If e.RowIndex = -1 Then : Else TextBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("料號").Value.ToString NumericUpDown2.Value = DataGridView1.Rows(e.RowIndex).Cells("成本").Value.ToString End If End Sub Private Sub DataGridView2_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick If e.RowIndex = -1 Then : Else TextBox9.Text = DataGridView2.Rows(e.RowIndex).Cells("單據編號").Value.ToString : ComboBox3.Text = DataGridView2.Rows(e.RowIndex).Cells("供應商編號").Value.ToString DateTimePicker1.Value = DataGridView2.Rows(e.RowIndex).Cells("採購下單").Value.ToString : DateTimePicker2.Value = DataGridView2.Rows(e.RowIndex).Cells("交期").Value.ToString Set_單據明細() End If End Sub Private Sub DataGridView3_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView3.CellClick If e.RowIndex = -1 Then : Else TextBox14.Text = DataGridView3.Rows(e.RowIndex).Cells("資料流水號").Value.ToString For i As Integer = 0 To DataGridView3.Rows.Count - 1 : DataGridView3.Rows(i).Cells("選擇").Value = False : Next DataGridView3.Rows(e.RowIndex).Cells("選擇").Value = True End If End Sub Private Sub DataGridView3_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView3.CellEnter TextBox15.Text = "0" For i As Integer = 0 To DataGridView3.Rows.Count - 1 DataGridView3.Rows(i).Cells("台幣單價").Value = DataGridView3.Rows(i).Cells("單價").Value * DataGridView3.Rows(i).Cells("匯率").Value DataGridView3.Rows(i).Cells("進貨成本_台幣").Value = DataGridView3.Rows(i).Cells("單價").Value * DataGridView3.Rows(i).Cells("匯率").Value * DataGridView3.Rows(i).Cells("數量").Value DataGridView3(1, i).Value = i + 1 TextBox15.Text = Val(TextBox15.Text) + DataGridView3.Rows(i).Cells("進貨成本_台幣").Value Next i TextBox15.Text = Strings.Format(Val(TextBox15.Text), "#,#00") End Sub Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.TextChanged Set_物料清單() End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged Set_物料清單() End Sub Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged PA = TextBox5.Text SQL_供應商資料表關鍵字查詢() ComboBox2.Items.Clear() : ComboBox3.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("簡稱")) : ComboBox3.Items.Add(dr("編號")) : End While : conn.Close() : PA = "" End Sub Private Sub 供應商資料() SQL_採購單申請_供應商資料表讀取() If (dr.Read()) Then TextBox2.Text = dr("名稱") : TextBox6.Text = dr("公司電話1") : TextBox3.Text = dr("公司電話2") : TextBox8.Text = dr("傳真1") : TextBox11.Text = dr("郵遞區號1") TextBox10.Text = dr("地址1") : TextBox13.Text = dr("郵遞區號2") : TextBox12.Text = dr("地址2") : TextBox26.Text = dr("統一編號") : TextBox4.Text = dr("付款方式") End If : conn.Close() End Sub Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged ComboBox3.SelectedIndex = ComboBox2.SelectedIndex : 供應商資料() End Sub Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged ComboBox2.SelectedIndex = ComboBox3.SelectedIndex : 供應商資料() End Sub Private Sub Set_日期格式轉換() DTP = Strings.Format(DateTimePicker1.Value, "yyyy/MM/dd") : DTP1 = Strings.Format(DateTimePicker1.Value, "yyyyMMdd") : DTP2 = Strings.Format(DateTimePicker2.Value, "yyyy/MM/dd") End Sub Private Sub Set_自動生成流水號() SQL_倉儲明細表流水號最後一筆() If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("資料流水號").ToString, 8)) : Else : EDR = 0 : End If : conn.Close() : EDR += 1 If EDR < 10 Then : ESTR = "WD" & "0000000" & EDR ElseIf EDR > 9 And EDR < 100 Then : ESTR = "WD" & "000000" & EDR ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "WD" & "00000" & EDR ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "WD" & "0000" & EDR ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "WD" & "000" & EDR ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "WD" & "00" & EDR ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "WD" & "0" & EDR ElseIf EDR > 9999999 Then : ESTR = "WD" & EDR End If End Sub Private Sub Set_新增明細() PA1 = TextBox7.Text : SQL_物料資料庫成本查詢() If dr.Read() Then If dr("成本") = 0 Then : NU1 = NumericUpDown2.Value : PA1 = TextBox7.Text : SQL_物料資料庫成本修改() : conn.Close() : Else : conn.Close() : End If End If PA1 = ESTR : PA2 = TextBox9.Text : PA3 = ComboBox3.Text : PA4 = TextBox7.Text : NU1 = NumericUpDown2.Value : NU2 = NumericUpDown3.Value NU3 = NumericUpDown1.Value : NU4 = 0 : PA5 = "採購入庫" : PA6 = DTP : PA7 = "" : NU5 = 0 : PA8 = "" : PA9 = DTP2 SQL_倉儲明細表新增() : conn.Close() MsgBox("資料新增完畢 。") : Set_單據明細() : Set_物料清單() End Sub Private Sub 存檔1() Dim SSDD As Integer = 0 For i As Integer = 0 To DataGridView3.Rows.Count - 1 資料數 = DataGridView3.Rows.Count : MyModule1.進度條() PA1 = DataGridView3.Rows(i).Cells("資料流水號").Value : SQL_倉儲明細表_入庫日期讀取() If dr.Read() Then If dr("入庫日期").ToString = "" Then NU1 = DataGridView3.Rows(i).Cells("單價").Value : NU2 = DataGridView3.Rows(i).Cells("數量").Value PA1 = DataGridView3.Rows(i).Cells("備註").Value : PA2 = DTP2 : PA3 = DataGridView3.Rows(i).Cells("資料流水號").Value SQL_採購單申請_倉儲明細表修改_入庫() : conn.Close() Else conn.Close() : SSDD += 1 End If End If Next : MAOJI_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 : If SSDD = 0 Then : Else : MsgBox("共有 " & SSDD & "筆資料已入庫,沒有變更。") : End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If TextBox7.Text = "" Then : MsgBox("料號沒有選擇") : Else If ComboBox3.Text = "" Then : MsgBox("供應商沒有選擇") : Else If NumericUpDown3.Value = 0 Then : MsgBox("採購金額沒有填寫") : Else If NumericUpDown2.Value = 0 Then : MsgBox("匯率不可為零") : Else If NumericUpDown1.Value = 0 Then : MsgBox("數量不可為零") : Else If TextBox9.Text = "" Then '----------------------自动生成單據編號------------------------------------------------------------------------- If CheckBox1.Checked = True Then : Else : DateTimePicker1.Value = Today() : End If Dim NUM1 As Integer : Set_日期格式轉換() For i As Integer = 1 To 999 NUM1 = 0 + i If NUM1 < 10 Then : TextBox9.Text = "WD-" & DTP1 & "-00" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox9.Text = "WD-" & DTP1 & "-0" & NUM1 ElseIf NUM1 > 99 Then : TextBox9.Text = "WD-" & DTP1 & "-" & NUM1 : End If : PA1 = TextBox9.Text SQL_倉儲明細表生成單據編號() If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close() Next Set_自動生成流水號() : TextBox14.Text = ESTR : conn.Close() : 存檔1() : Set_新增明細() : Set_採購清單() Else Set_日期格式轉換() : Set_自動生成流水號() : TextBox14.Text = ESTR : conn.Close() : 存檔1() : Set_新增明細() End If End If End If End If End If End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click For i As Integer = 0 To DataGridView3.Rows.Count - 1 資料數 = DataGridView3.Rows.Count : MyModule1.進度條() NU1 = NumericUpDown3.Value : PA1 = DataGridView3.Rows(i).Cells("資料流水號").Value : SQL_採購單申請_倉儲明細表匯率修改() : conn.Close() Next : MAOJI_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 : Set_單據明細() : MsgBox("資料修改,存檔完畢 。") End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Set_日期格式轉換() : 存檔1() : Set_單據明細() : Set_採購清單() : MsgBox("資料修改,存檔完畢 。") End Sub Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.Click RadioButton1.Checked = True : RadioButton2.Checked = False : Set_採購清單() : Button1.Enabled = True : Button2.Enabled = True : Button3.Enabled = True 新增物料到採購單ToolStripMenuItem.Enabled = True : 刪除採購單中選中的物料ToolStripMenuItem.Enabled = True : 修改匯率ToolStripMenuItem.Enabled = True 修改存檔ToolStripMenuItem.Enabled = True End Sub Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.Click If CC(35) = False Then RadioButton1.Checked = False : RadioButton2.Checked = True : Set_採購清單() : Button1.Enabled = False : Button2.Enabled = False : Button3.Enabled = False 新增物料到採購單ToolStripMenuItem.Enabled = False : 刪除採購單中選中的物料ToolStripMenuItem.Enabled = False : 修改匯率ToolStripMenuItem.Enabled = False 修改存檔ToolStripMenuItem.Enabled = False Else RadioButton1.Checked = False : RadioButton2.Checked = True : Set_採購清單() : Button1.Enabled = True : Button2.Enabled = True : Button3.Enabled = True 新增物料到採購單ToolStripMenuItem.Enabled = True : 刪除採購單中選中的物料ToolStripMenuItem.Enabled = True : 修改匯率ToolStripMenuItem.Enabled = True 修改存檔ToolStripMenuItem.Enabled = True End If End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click '----------------------自动生成單據編號------------------------------------------------------------------------- Dim NUM1 As Integer : Set_日期格式轉換() For i As Integer = 1 To 999 NUM1 = 0 + i If NUM1 < 10 Then : TextBox9.Text = "WD-" & DTP1 & "-00" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox9.Text = "WD-" & DTP1 & "-0" & NUM1 ElseIf NUM1 > 99 Then : TextBox9.Text = "WD-" & DTP1 & "-" & NUM1 : End If : PA1 = TextBox9.Text SQL_倉儲明細表生成單據編號() If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close() Next For i As Integer = 0 To DataGridView3.Rows.Count - 1 資料數 = DataGridView3.Rows.Count : MyModule1.進度條() PA1 = DataGridView3.Rows(i).Cells("料號").Value SQL_物料資料庫成本查詢() If dr.Read() Then If dr("成本") = 0 Then : NU1 = DataGridView3.Rows(i).Cells("單價").Value : PA1 = DataGridView3.Rows(i).Cells("料號").Value SQL_物料資料庫成本修改() : conn.Close() Else : conn.Close() : End If End If Set_自動生成流水號() : TextBox14.Text = ESTR PA1 = ESTR : PA2 = TextBox9.Text : PA3 = DataGridView3.Rows(i).Cells("供應商編號").Value : PA4 = DataGridView3.Rows(i).Cells("料號").Value : NU1 = DataGridView3.Rows(i).Cells("單價").Value NU2 = DataGridView3.Rows(i).Cells("匯率").Value : NU3 = DataGridView3.Rows(i).Cells("數量").Value : NU4 = 0 : PA5 = "採購入庫" : PA6 = DTP : PA7 = "" : NU5 = 0 : PA8 = "" : PA9 = DTP2 SQL_倉儲明細表新增() : conn.Close() Next : MAOJI_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 : MsgBox("單據複製完畢 。") : Set_物料清單() End Sub Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click If TextBox9.Text = "" Then : MsgBox("沒有選擇要列印的單號 。") : Else : 列印用SQL = TextBox9.Text : PA = "採購訂貨單" : 列印_產品標籤介面.ShowDialog() : End If End Sub '-----------------------------列印成EXCEL------------------------------------------------------------------------------------------------------------------------------------------ Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click xlApp = CType(CreateObject("Excel.Application"), Application) xlBook = xlApp.Workbooks.Add xlApp.DisplayAlerts = True xlBook.Activate() xlSheet = NewMethod(xlBook) xlSheet.Activate() xlApp.Visible = True xlApp.Application.WindowState = xlMaximized xlSheet.Cells(1, 1) = MAOJI_ERP_SYS.ComboBox2.Text : xlSheet.Cells(2, 1) = 公司地址 : xlSheet.Cells(3, 1) = "採購訂單" : xlSheet.Cells(4, 1) = "採購編號 : " : xlSheet.Cells(4, 3) = TextBox9.Text xlSheet.Cells(5, 1) = "採購日期 : " : xlSheet.Cells(5, 3) = DateTimePicker1.Value : xlSheet.Cells(5, 6) = "付款方式 : " : xlSheet.Cells(5, 7) = TextBox4.Text : xlSheet.Cells(5, 9) = "需求交期 : " xlSheet.Cells(5, 10) = DateTimePicker2.Value : xlSheet.Cells(4, 9) = "統一編號 : " : xlSheet.Cells(4, 10) = 公司統編 : xlSheet.Cells(7, 1) = "TO : " : xlSheet.Cells(8, 1) = "郵號1 : " xlSheet.Cells(9, 1) = "郵號1 : " : xlSheet.Cells(7, 2) = TextBox2.Text : xlSheet.Cells(8, 2) = TextBox11.Text : xlSheet.Cells(9, 2) = TextBox13.Text : xlSheet.Cells(8, 3) = "地址1 : " xlSheet.Cells(9, 3) = "地址2 : " : xlSheet.Cells(8, 4) = TextBox10.Text : xlSheet.Cells(9, 4) = TextBox12.Text : xlSheet.Cells(7, 9) = "公司電話1 : " : xlSheet.Cells(8, 9) = "公司電話2 : " xlSheet.Cells(9, 9) = "傳真 : " : xlSheet.Cells(7, 10) = TextBox6.Text : xlSheet.Cells(8, 10) = TextBox3.Text : xlSheet.Cells(9, 10) = TextBox8.Text : xlSheet.Cells(11, 1) = "項次" xlSheet.Cells(11, 2) = "料號" : xlSheet.Cells(11, 4) = "品名" : xlSheet.Cells(11, 6) = "數量" : xlSheet.Cells(11, 7) = "單價" : xlSheet.Cells(11, 8) = "匯率" : xlSheet.Cells(11, 9) = "採購金額" xlSheet.Cells(11, 10) = "備註" For i As Integer = 0 To DataGridView3.Rows.Count - 1 xlSheet.Cells(i + 12, 1) = DataGridView3.Rows(i).Cells("項次").Value xlSheet.Cells(i + 12, 2) = DataGridView3.Rows(i).Cells("料號").Value xlSheet.Cells(i + 12, 4) = DataGridView3.Rows(i).Cells("品名").Value xlSheet.Cells(i + 12, 6) = DataGridView3.Rows(i).Cells("數量").Value xlSheet.Cells(i + 12, 7) = DataGridView3.Rows(i).Cells("單價").Value xlSheet.Cells(i + 12, 8) = DataGridView3.Rows(i).Cells("匯率").Value xlSheet.Cells(i + 12, 9) = "=F" & i + 12 & "*G" & i + 12 & "*H" & i + 12 xlSheet.Cells(i + 12, 10) = DataGridView3.Rows(i).Cells("備註").Value N1 = i + 12 Next xlSheet.Cells(N1 + 1, 5) = "TOTAL : " : xlSheet.Cells(N1 + 1, 6) = "=SUM(F12:F" & N1 & ")" : xlSheet.Cells(N1 + 1, 9) = "=SUM(I12:I" & N1 & ")" : xlSheet.Cells(N1 + 2, 1) = "核准 : " xlSheet.Cells(N1 + 2, 9) = "製表人 : " : xlSheet.Cells(N1 + 2, 10) = gUserName AA(xlApp, xlSheet) xlSheet.PageSetup.PrintArea = "" xlApp.Cells.Select() xlSheet.Range("B1").Select() xlApp.Application.WindowState = xlMinimized xlSheet.Cells.Select() xlApp.ActiveSheet.Protect(DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="0911274990") xlApp.ActiveSheet.EnableSelection = 1 MsgBox("列印完成。") End Sub Private Shared Function NewMethod(xlBook As Workbook) As Worksheet Return CType(xlBook.Worksheets.Add, Worksheet) End Function Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet) xlSheet.Cells.Select() With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With xlSheet.Columns("A:C").Select : myExcel.Selection.ColumnWidth = 6 xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 10 xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 20 xlSheet.Columns("F:G").Select : myExcel.Selection.ColumnWidth = 10 xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 8 xlSheet.Columns("I:I").Select : myExcel.Selection.ColumnWidth = 12 xlSheet.Columns("J:J").Select : myExcel.Selection.ColumnWidth = 30 xlSheet.Rows("1:1").Select With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 28 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With xlSheet.Rows("2:2").Select With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With xlSheet.Rows("3:3").Select With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With xlSheet.Range("A1:J1").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge xlSheet.Range("A2:J2").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge xlSheet.Range("A3:J3").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A4:B4").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("A5:B5").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("C4:D4").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("C5:D5").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With xlSheet.Range("J4").Select() With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("J5").Select() With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("A7:A9").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("I4:I9").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("B8").Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("C8:C9").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Rows("4:9").Select : myExcel.Selection.RowHeight = 18 xlSheet.Rows("6:6").Select : myExcel.Selection.RowHeight = 5 xlSheet.Rows("10:10").Select : myExcel.Selection.RowHeight = 5 xlSheet.Rows("11:11").Select : myExcel.Selection.RowHeight = 25 xlSheet.Rows("12:" & N1 + 1).Select : myExcel.Selection.RowHeight = 18 xlSheet.Rows(N1 + 2 & ":" & N1 + 2).Select : myExcel.Selection.RowHeight = 30 xlSheet.Range("A4:B5").Select() With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With xlSheet.Range("F5").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With xlSheet.Range("I4:I5").Select() With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With xlSheet.Range("A5:J5").Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A7:A9").Select() With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With xlSheet.Range("C8:C9").Select() With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With xlSheet.Range("I7:I9").Select() With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314 : .PatternTintAndShade = 0 : End With xlSheet.Range("A9:J9").Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A11:J" & N1).Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With xlSheet.Range("A" & N1 + 1 & ":J" & N1 + 1).Select() myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A11:A" & N1).Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With For i As Integer = 11 To N1 xlSheet.Range("B" & i & ":C" & i).Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge xlSheet.Range("D" & i & ":E" & i).Select() With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge Next xlSheet.Range("F11:F" & N1 + 1).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-" xlSheet.Range("F11").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("G11:G" & N1).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0.0_-;-* #,##0.0_-;_-* ""-""??_-;_-@_-" xlSheet.Range("G11").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("H11:H" & N1).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0.000_-;-* #,##0.000_-;_-* ""-""??_-;_-@_-" xlSheet.Range("H11").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("I11:I" & N1 + 1).Select() : myExcel.Selection.Style = "Comma" : myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-" xlSheet.Range("I11").Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("E" & N1 + 1).Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("A" & N1 + 2).Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("I" & N1 + 2).Select() With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With myExcel.ActiveWindow.DisplayGridlines = False End Sub '-----------------------------滑鼠右鍵------------------------------------------------------------------------------------------------------------------------------------------ Private Sub 重新整理ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理ToolStripMenuItem.Click Set_採購清單() : Set_物料清單() : ComboBox2下拉表單資料載入() End Sub Private Sub 開立新的採購單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 開立新的採購單ToolStripMenuItem.Click If CheckBox1.Checked = True Then : Else : DateTimePicker1.Value = Today() : End If TextBox9.Text = "" : TextBox15.Text = "0" : DateTimePicker1.Value = Today() : TextBox14.Text = "" TextBox2.Text = "" : TextBox6.Text = "" : TextBox3.Text = "" : TextBox8.Text = "" : TextBox11.Text = "" TextBox10.Text = "" : TextBox13.Text = "" : TextBox12.Text = "" : TextBox26.Text = "" : TextBox4.Text = "" ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入() : Set_採購清單() : Set_物料清單() DataGridView3.DataSource = Nothing : ds2.Clear() : Me.RadioButton1.PerformClick() End Sub Private Sub 刪除採購單中選中的物料ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 刪除採購單中選中的物料ToolStripMenuItem.Click PA1 = TextBox14.Text : SQL_倉儲明細表_入庫日期讀取() If dr("入庫日期") = "" Then : conn.Close() If TextBox14.Text = "" Then : MsgBox("沒有選擇要刪除了料號 。") Else Dim aa1 As MsgBoxResult = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel) If aa1 = MsgBoxResult.Ok Then PA1 = TextBox14.Text : SQL_倉儲明細表刪除() : conn.Close() : TextBox14.Text = "" : Set_單據明細() End If End If Else conn.Close() : MsgBox("已入庫的資料不可刪除 。") End If End Sub Private Sub 新增物料到採購單ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 新增物料到採購單ToolStripMenuItem.Click Me.Button1.PerformClick() End Sub Private Sub 修改匯率ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 修改匯率ToolStripMenuItem.Click Me.Button2.PerformClick() : MsgBox("資料修改,存檔完畢 。") End Sub Private Sub 修改存檔ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 修改存檔ToolStripMenuItem.Click Me.Button3.PerformClick() : MsgBox("資料修改,存檔完畢 。") End Sub Private Sub 列印成EXCELToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 列印成EXCELToolStripMenuItem.Click Me.Button5.PerformClick() End Sub Private Sub 列印產品標籤ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 列印產品標籤ToolStripMenuItem.Click Me.Button6.PerformClick() End Sub End Class