Option Strict Off Imports System.IO 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 ds8 As New DataSet : Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet Dim N1, N2 As Integer : Dim 新項次 As String : Dim NUM1 As Integer : Private ReadOnly 對話框(7) As String : Dim 物料規格 As String 'ReadOnly QRCODE As DotNetBarcode = New DotNetBarcode Private Sub Set_清單() Dim ds As New DataSet : 明細_dgv.DataSource = Nothing : ds.Clear() 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 明細_dgv.ColumnHeadersHeight = 25 明細_dgv.AllowUserToAddRows = False If 小間距1_ch.Checked = False And 中間距1_ch.Checked = False And 大間距1_ch.Checked = True Then : 明細_dgv.RowTemplate.Height = 75 ElseIf 小間距1_ch.Checked = False And 中間距1_ch.Checked = True And 大間距1_ch.Checked = False Then : 明細_dgv.RowTemplate.Height = 45 ElseIf 小間距1_ch.Checked = True And 中間距1_ch.Checked = False And 大間距1_ch.Checked = False Then : 明細_dgv.RowTemplate.Height = 25 : End If SQL_建築物料採購單一覽表_明細() da.Fill(ds) : 明細_dgv.DataSource = ds.Tables(0) : conn.Close() 明細_dgv.Columns(0).Visible = False : 明細_dgv.Columns(1).FillWeight = 80 : 明細_dgv.Columns(2).FillWeight = 80 : 明細_dgv.Columns(3).FillWeight = 250 明細_dgv.Columns(4).FillWeight = 245 : 明細_dgv.Columns(5).FillWeight = 80 : 明細_dgv.Columns(6).FillWeight = 80 : 明細_dgv.Columns(7).FillWeight = 80 明細_dgv.Columns(8).FillWeight = 80 : 明細_dgv.Columns(9).Visible = False : 明細_dgv.Columns(10).Visible = False : 明細_dgv.Columns(11).Visible = False 明細_dgv.Columns(12).Visible = False : 明細_dgv.Columns(13).Visible = False : 明細_dgv.Columns(14).Visible = False : 明細_dgv.Columns(15).Visible = False 明細_dgv.Columns(16).Visible = False : 明細_dgv.Columns(17).Visible = False : 明細_dgv.Columns(18).Visible = False : 明細_dgv.Columns(19).Visible = False 明細_dgv.Columns(20).Visible = False : 明細_dgv.Columns(21).Visible = False : 明細_dgv.Columns(22).Visible = False : 明細_dgv.Columns(23).Visible = False 明細_dgv.Columns(24).Visible = False : 明細_dgv.Columns(25).FillWeight = 80 明細_dgv.Columns(6).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(7).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" 明細_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter 明細_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter 明細_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 明細_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter If 低網速模式 = False Then 明細_dgv.Columns("Image").FillWeight = 80 : 明細_dgv.Columns("Image").Visible = True Dim mycol As DataGridViewImageColumn = 明細_dgv.Columns("Image") mycol.ImageLayout = DataGridViewImageCellLayout.Zoom Else If 明細_dgv.Columns.Count = 27 Then 明細_dgv.Columns("Image").Visible = False End If End If 新項次 = "00" For i As Integer = 0 To 明細_dgv.Rows.Count - 1 NUM1 = Double.Parse(新項次) + 1 If NUM1 < 10 Then : 新項次 = "0" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 End If 明細_dgv.Rows(i).Cells(表頭(2)).Value = 新項次 '-------------------------規格合併呈現---------------------------------------------------------------------------------------------------------------------------------------- If i = 0 Then PA3 = 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value SQL_規格庫抬頭讀取() If dr.Read() Then AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8") End If conn.Close() Else If 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value.ToString <> 明細_dgv.Rows(i - 1).Cells("規格庫抬頭指定").Value.ToString Then AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = "" ' 不同的抬頭入資料前,先清除 PA3 = 明細_dgv.Rows(i).Cells("規格庫抬頭指定").Value SQL_規格庫抬頭讀取() If dr.Read() Then AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8") End If conn.Close() End If End If Dim ZA1, ZA2, ZA3, ZA4, ZA5, ZA6, ZA7, ZA8 As String : 物料規格 = "" If 詳細資料2_ch.Checked = True Then If 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" Then ZA1 = AAA1 & "=" & 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 物料規格 = ZA1 : End If If 明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : ZA2 = AAA2 & "=" & 明細_dgv.Rows(i).Cells("A2").Value If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If If 明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : ZA3 = AAA3 & "=" & 明細_dgv.Rows(i).Cells("A3").Value If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If If 明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : ZA4 = AAA4 & "=" & 明細_dgv.Rows(i).Cells("A4").Value If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If If 明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : ZA5 = AAA5 & "=" & 明細_dgv.Rows(i).Cells("A5").Value If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If If 明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : ZA6 = AAA6 & "=" & 明細_dgv.Rows(i).Cells("A6").Value If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If If 明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : ZA7 = AAA7 & "=" & 明細_dgv.Rows(i).Cells("A7").Value If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If If 明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : ZA8 = AAA8 & "=" & 明細_dgv.Rows(i).Cells("A8").Value If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If Else If 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" Then : ZA1 = 明細_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 物料規格 = ZA1 : End If If 明細_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then ZA2 = 明細_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If If 明細_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then ZA3 = 明細_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If If 明細_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then ZA4 = 明細_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If If 明細_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then ZA5 = 明細_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If If 明細_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then ZA6 = 明細_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If If 明細_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then ZA7 = 明細_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If If 明細_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then ZA8 = 明細_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If End If 明細_dgv.Rows(i).Cells(表頭(13)).Value = 物料規格 Next i 總金額計算() : Set_清單_1() End Sub Private Sub Set_清單_1() Dim ds5 As New DataSet : 明細1_dgv.DataSource = Nothing : ds5.Clear() 明細1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 明細1_dgv.ColumnHeadersHeight = 40 明細1_dgv.AllowUserToAddRows = False 明細1_dgv.RowTemplate.Height = 35 SQL_建築物料採購單一覽表_明細() da.Fill(ds5) : 明細1_dgv.DataSource = ds5.Tables(0) : conn.Close() If 低網速模式 = False Then 明細1_dgv.Columns("Image").FillWeight = 80 : 明細1_dgv.Columns("Image").Visible = True Dim mycol As DataGridViewImageColumn = 明細1_dgv.Columns("Image") mycol.ImageLayout = DataGridViewImageCellLayout.Zoom Else If 明細1_dgv.Columns.Count = 27 Then 明細1_dgv.Columns("Image").Visible = False End If End If 新項次 = "00" For i As Integer = 0 To 明細1_dgv.Rows.Count - 1 NUM1 = Double.Parse(新項次) + 1 If NUM1 < 10 Then : 新項次 = "0" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 End If 明細1_dgv.Rows(i).Cells(表頭(2)).Value = 新項次 '------------------------------------------------------------------------------------------------------------------------- If i = 0 Then AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = "" PA3 = 明細1_dgv.Rows(i).Cells("規格庫抬頭指定").Value : PA20 = 系統語言_cb.Text SQL_規格庫抬頭讀取_列印用() If dr.Read() Then AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8") End If conn.Close() Else If 明細1_dgv.Rows(i).Cells("規格庫抬頭指定").Value.ToString <> 明細1_dgv.Rows(i - 1).Cells("規格庫抬頭指定").Value.ToString Then AAA1 = "" : AAA2 = "" : AAA3 = "" : AAA4 = "" : AAA5 = "" : AAA6 = "" : AAA7 = "" : AAA8 = "" PA3 = 明細1_dgv.Rows(i).Cells("規格庫抬頭指定").Value : PA20 = 系統語言_cb.Text SQL_規格庫抬頭讀取_列印用() If dr.Read() Then AAA1 = dr("A1") : AAA2 = dr("A2") : AAA3 = dr("A3") : AAA4 = dr("A4") : AAA5 = dr("A5") : AAA6 = dr("A6") : AAA7 = dr("A7") : AAA8 = dr("A8") End If conn.Close() End If End If Dim ZA1, ZA2, ZA3, ZA4, ZA5, ZA6, ZA7, ZA8 As String : 物料規格 = "" If 詳細資料2_ch.Checked = True Then If 明細1_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" Then ZA1 = AAA1 & "=" & 明細1_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 物料規格 = ZA1 : End If If 明細1_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then : ZA2 = AAA2 & "=" & 明細1_dgv.Rows(i).Cells("A2").Value If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If If 明細1_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then : ZA3 = AAA3 & "=" & 明細1_dgv.Rows(i).Cells("A3").Value If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If If 明細1_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then : ZA4 = AAA4 & "=" & 明細1_dgv.Rows(i).Cells("A4").Value If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If If 明細1_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then : ZA5 = AAA5 & "=" & 明細1_dgv.Rows(i).Cells("A5").Value If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If If 明細1_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then : ZA6 = AAA6 & "=" & 明細1_dgv.Rows(i).Cells("A6").Value If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If If 明細1_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then : ZA7 = AAA7 & "=" & 明細1_dgv.Rows(i).Cells("A7").Value If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If If 明細1_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then : ZA8 = AAA8 & "=" & 明細1_dgv.Rows(i).Cells("A8").Value If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If Else If 明細1_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" Then : ZA1 = 明細1_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 物料規格 = ZA1 : End If If 明細1_dgv.Rows(i).Cells("A2").Value.ToString <> "" Then ZA2 = 明細1_dgv.Rows(i).Cells("A2").Value : If 物料規格 = "" Then : 物料規格 = ZA2 : Else : 物料規格 = 物料規格 + "、" + ZA2 : End If : End If If 明細1_dgv.Rows(i).Cells("A3").Value.ToString <> "" Then ZA3 = 明細1_dgv.Rows(i).Cells("A3").Value : If 物料規格 = "" Then : 物料規格 = ZA3 : Else : 物料規格 = 物料規格 + "、" + ZA3 : End If : End If If 明細1_dgv.Rows(i).Cells("A4").Value.ToString <> "" Then ZA4 = 明細1_dgv.Rows(i).Cells("A4").Value : If 物料規格 = "" Then : 物料規格 = ZA4 : Else : 物料規格 = 物料規格 + "、" + ZA4 : End If : End If If 明細1_dgv.Rows(i).Cells("A5").Value.ToString <> "" Then ZA5 = 明細1_dgv.Rows(i).Cells("A5").Value : If 物料規格 = "" Then : 物料規格 = ZA5 : Else : 物料規格 = 物料規格 + "、" + ZA5 : End If : End If If 明細1_dgv.Rows(i).Cells("A6").Value.ToString <> "" Then ZA6 = 明細1_dgv.Rows(i).Cells("A6").Value : If 物料規格 = "" Then : 物料規格 = ZA6 : Else : 物料規格 = 物料規格 + "、" + ZA6 : End If : End If If 明細1_dgv.Rows(i).Cells("A7").Value.ToString <> "" Then ZA7 = 明細1_dgv.Rows(i).Cells("A7").Value : If 物料規格 = "" Then : 物料規格 = ZA7 : Else : 物料規格 = 物料規格 + "、" + ZA7 : End If : End If If 明細1_dgv.Rows(i).Cells("A8").Value.ToString <> "" Then ZA8 = 明細1_dgv.Rows(i).Cells("A8").Value : If 物料規格 = "" Then : 物料規格 = ZA8 : Else : 物料規格 = 物料規格 + "、" + ZA8 : End If : End If End If 明細1_dgv.Rows(i).Cells(表頭(13)).Value = 物料規格 Next i End Sub Private Sub Set_清單1() Dim ds1 As New DataSet : 已核准_dgv.DataSource = Nothing : ds1.Clear() 已核准_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 已核准_dgv.ColumnHeadersHeight = 40 : 已核准_dgv.RowTemplate.Height = 30 已核准_dgv.AllowUserToAddRows = False If 全部資料_cb.Checked = True Then : SQL_建築物料採購單一覽表_已核准() : Else : SQL_建築物料採購單一覽表_已核准1() : End If da.Fill(ds1) : 已核准_dgv.DataSource = ds1.Tables(0) : conn.Close() 已核准_dgv.Columns(表頭(0)).FillWeight = 40 : 已核准_dgv.Columns(表頭(1)).FillWeight = 40 : 已核准_dgv.Columns(25).FillWeight = 40 已核准_dgv.Columns(21).FillWeight = 180 : 已核准_dgv.Columns(26).FillWeight = 40 : 已核准_dgv.Columns(27).FillWeight = 40 已核准_dgv.Columns(22).DefaultCellStyle.Format = "#,##0" : 已核准_dgv.Columns(23).DefaultCellStyle.Format = "#,##0" 已核准_dgv.Columns(24).DefaultCellStyle.Format = "#,##0" 已核准_dgv.Columns(22).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 已核准_dgv.Columns(23).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 已核准_dgv.Columns(24).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 已核准_dgv.EditMode = DataGridViewEditMode.EditOnEnter Dim mycol1 As DataGridViewImageColumn = 已核准_dgv.Columns("Select All") : mycol1.ImageLayout = DataGridViewImageCellLayout.Zoom Dim mycol2 As DataGridViewImageColumn = 已核准_dgv.Columns("To DK") : mycol2.ImageLayout = DataGridViewImageCellLayout.Zoom Dim mycol3 As DataGridViewImageColumn = 已核准_dgv.Columns("Save") : mycol3.ImageLayout = DataGridViewImageCellLayout.Zoom For i As Integer = 0 To 已核准_dgv.Rows.Count - 1 Dim 折扣, 稅金 As Long : 折扣 = 0 : 稅金 = 0 已核准_dgv.Rows(i).Cells("Select All").Value = My.Resources.add_1 : 已核准_dgv.Rows(i).Cells("To DK").Value = My.Resources.Money2 已核准_dgv.Rows(i).Cells("Save").Value = My.Resources.SAVER : 已核准_dgv.Rows(i).Cells(表頭(8)).Value = 0 If 已核准_dgv.Rows(i).Cells("DISC").Value <> 0 Then : 折扣 = 已核准_dgv.Rows(i).Cells(表頭(7)).Value / 100 * 已核准_dgv.Rows(i).Cells("DISC").Value : End If If 已核准_dgv.Rows(i).Cells("PPN").Value <> 0 Then : 稅金 = 已核准_dgv.Rows(i).Cells(表頭(7)).Value / 100 * 已核准_dgv.Rows(i).Cells("PPN").Value : End If 已核准_dgv.Rows(i).Cells(表頭(7)).Value += (稅金 - 折扣) Next 已核准_dgv.Columns(0).FillWeight = 125 For i As Integer = 1 To 20 : 已核准_dgv.Columns(i).Visible = False : Next If 已核准_dgv.Size.Width = 255 Then For i As Integer = 21 To 27 : 已核准_dgv.Columns(i).Visible = False : Next Else For i As Integer = 21 To 27 : 已核准_dgv.Columns(i).Visible = True : Next End If 已核准_dgv.Columns(0).ReadOnly = True : 已核准_dgv.Columns(21).ReadOnly = True : 已核准_dgv.Columns(23).ReadOnly = True : 已核准_dgv.Columns(24).ReadOnly = True 已核准_dgv.Columns(25).ReadOnly = True : 已核准_dgv.Columns(26).ReadOnly = True : 已核准_dgv.Columns(27).ReadOnly = True : 已核准_dgv.Columns(28).ReadOnly = True 已核准_dgv.Columns(29).ReadOnly = True End Sub Private Sub 打開清單() If 已核准_dgv.Size.Width = 255 Then 已核准_dgv.Size = New Size(915, 已核准_dgv.Size.Height) For i As Integer = 21 To 27 : 已核准_dgv.Columns(i).Visible = True : Next Else 已核准_dgv.Size = New Size(255, 已核准_dgv.Size.Height) For i As Integer = 21 To 27 : 已核准_dgv.Columns(i).Visible = False : Next End If End Sub Private Sub Set_清單2() Dim ds2 As New DataSet : 已作廢_dgv.DataSource = Nothing : ds2.Clear() 已作廢_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 已作廢_dgv.ColumnHeadersHeight = 25 已作廢_dgv.AllowUserToAddRows = False SQL_建築物料採購單一覽表_已作廢() da.Fill(ds2) : 已作廢_dgv.DataSource = ds2.Tables(0) : conn.Close() 已作廢_dgv.Columns(0).FillWeight = 125 : 已作廢_dgv.Columns(1).Visible = False : 已作廢_dgv.Columns(2).Visible = False : 已作廢_dgv.Columns(3).Visible = False 已作廢_dgv.Columns(4).Visible = False : 已作廢_dgv.Columns(5).Visible = False : 已作廢_dgv.Columns(6).Visible = False : 已作廢_dgv.Columns(7).Visible = False 已作廢_dgv.Columns(8).Visible = False : 已作廢_dgv.Columns(9).Visible = False : 已作廢_dgv.Columns(10).Visible = False : 已作廢_dgv.Columns(11).Visible = False 已作廢_dgv.Columns(12).Visible = False : 已作廢_dgv.Columns(13).Visible = False : 已作廢_dgv.Columns(14).Visible = False : 已作廢_dgv.Columns(15).Visible = False 已作廢_dgv.Columns(16).Visible = False End Sub Private Sub ComboBox2下拉表單資料載入() SQL_供應商資料表_公司名_下拉用() : 廠商_cb.Items.Clear() : While (dr.Read()) : 廠商_cb.Items.Add(dr("公司名")) : End While : conn.Close() End Sub Private Sub 總金額計算() Dim FFGG As Integer = 0 總金額_tb.Text = "0" For i As Integer = 0 To 明細_dgv.Rows.Count - 1 明細_dgv.Rows(i).Cells(表頭(27)).Value = 明細_dgv.Rows(i).Cells(表頭(26)).Value * 明細_dgv.Rows(i).Cells(表頭(15)).Value FFGG = Val(FFGG) + 明細_dgv.Rows(i).Cells(表頭(27)).Value Next i 折扣金額_tb.Text = Val(折扣比_tb.Text) * FFGG / 100 If 稅金計算_ch.Checked = True Then If 折扣比_tb.Text = "0" Then 稅金金額_tb.Text = FFGG * Val(稅金比_tb.Text) / 100 Else 稅金金額_tb.Text = (FFGG - 折扣金額_tb.Text) * Val(稅金比_tb.Text) / 100 End If Else 稅金金額_tb.Text = "0" End If 總金額_tb.Text = FFGG - Val(折扣金額_tb.Text) + Val(稅金金額_tb.Text) 折扣金額_tb.Text = Strings.Format(Val(折扣金額_tb.Text), "#,##0") : 稅金金額_tb.Text = Strings.Format(Val(稅金金額_tb.Text), "#,##0") 總金額_tb.Text = Strings.Format(Val(總金額_tb.Text), "#,##0") End Sub Private Sub 語言轉換讀取() If 系統語言 = "繁體中文" Then : 語言 = "CH" : ElseIf 系統語言 = "English" Then : 語言 = "EN" : ElseIf 系統語言 = "Indonesian" Then : 語言 = "IN" : End If 一級簽核_lb.Text = 系統語言字典("H208-100-" & 語言) : 二級簽核_lb.Text = 系統語言字典("H208-101-" & 語言) : 已作廢_lb.Text = 系統語言字典("H208-102-" & 語言) 已核准_lb.Text = 系統語言字典("H208-103-" & 語言) : 表頭(19) = 系統語言字典("H208-104-" & 語言) : 表頭(134) = 系統語言字典("H208-105-" & 語言) 表頭(27) = 系統語言字典("H208-106-" & 語言) : 表頭(12) = 系統語言字典("H208-107-" & 語言) : 表頭(13) = 系統語言字典("H208-108-" & 語言) 表頭(14) = 系統語言字典("H208-109-" & 語言) : 表頭(16) = 系統語言字典("H208-110-" & 語言) : 表頭(18) = 系統語言字典("H208-111-" & 語言) 表頭(26) = 系統語言字典("H208-112-" & 語言) : 表頭(2) = 系統語言字典("H208-113-" & 語言) : 表頭(15) = 系統語言字典("H208-114-" & 語言) 圖片編碼_lb.Text = 系統語言字典("H208-115-" & 語言) : 對話框(0) = 系統語言字典("H208-116-" & 語言) : 選擇公司_lb.Text = 系統語言字典("H208-117-" & 語言) 總金額_lb.Text = 系統語言字典("H208-118-" & 語言) : 驗證碼_lb.Text = 系統語言字典("H208-119-" & 語言) : 重新整理_tsm.Text = 系統語言字典("H208-120-" & 語言) Me.Text = 系統語言字典("H001-169-" & 語言) : 表頭(0) = 系統語言字典("H206-145-" & 語言) : 表頭(1) = 系統語言字典("H206-146-" & 語言) 對話框(1) = 系統語言字典("H208-121-" & 語言) : 對話框(2) = 系統語言字典("H208-122-" & 語言) : 對話框(3) = 系統語言字典("H208-123-" & 語言) 對話框(4) = 系統語言字典("H314-117-" & 語言) : 對話框(5) = 系統語言字典("H314-118-" & 語言) : 對話框(6) = 系統語言字典("H314-119-" & 語言) 對話框(7) = 系統語言字典("H314-122-" & 語言) : 表頭(8) = 系統語言字典("H314-120-" & 語言) : 表頭(9) = 系統語言字典("H314-121-" & 語言) 表頭(6) = 系統語言字典("H299-109-" & 語言) : 表頭(7) = 系統語言字典("H304-103-" & 語言) End Sub Private Sub 採購單歷史檔案_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.MdiParent = HX_PGS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True 風格() : H(208) = True : 介面 = "H208" : 語言轉換讀取() : 顯示說明(999, False) : Panel1.SendToBack() 核對員_tb.Visible = False : 核對日期_tb.Visible = False : 詢價員_tb.Visible = False : 尋價日期_tb.Visible = False 驗證碼1_tb.Visible = False : 供應商編碼_tb.Visible = False : 系統語言_cb.Text = "Indonesian" SQL_採購單控制表轉財務金額_歸零() : ComboBox2下拉表單資料載入() : Set_清單1() : Set_清單2() MyMod.清單字體大小調整() 已核准_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value) 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value) End Sub Private Sub 採購單歷史檔案_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged MyMod.清單字體大小調整() 已核准_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value) 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value) End Sub Private Sub 採購單詢價_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed H(208) = False : MyMod.虛擬桌面開啟() End Sub Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click 介面 = "H208" : 語言轉換讀取() Set_清單1() : Set_清單2() : Set_清單() End Sub Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True End Sub Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True End Sub Dim 已超出 As Boolean Private Sub 已核准_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 已核准_dgv.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) If e.RowIndex = 已核准_dgv.Rows.Count - 1 Then : Exit Sub : Else If 已核准_dgv(21, e.RowIndex).Value.ToString <> 已核准_dgv(21, e.RowIndex + 1).Value.ToString Then Dim startX As Integer = IIf(已核准_dgv.RowHeadersVisible, 已核准_dgv.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1 Dim endX As Integer = startX + 已核准_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 已核准_dgv.HorizontalScrollingOffset e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub End If End If End Sub Private Sub 已核准_dgv_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles 已核准_dgv.CellEndEdit If 已核准_dgv.Rows(e.RowIndex).Cells(22).Value > 已核准_dgv.Rows(e.RowIndex).Cells(24).Value - 已核准_dgv.Rows(e.RowIndex).Cells(23).Value Then 已核准_dgv.Rows(e.RowIndex).Cells(22).Value = 已核准_dgv.Rows(e.RowIndex).Cells(24).Value - 已核准_dgv.Rows(e.RowIndex).Cells(23).Value End If End Sub Private Sub 已核准_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 已核准_dgv.MouseUp If 已核准_dgv.SelectedCells.Count > 0 Then If 已核准_dgv.SelectedCells(0).ColumnIndex = 25 Then 已核准_dgv.Rows(已核准_dgv.SelectedCells(0).RowIndex).Cells(22).Value = 已核准_dgv.Rows(已核准_dgv.SelectedCells(0).RowIndex).Cells(24).Value - 已核准_dgv.Rows(已核准_dgv.SelectedCells(0).RowIndex).Cells(23).Value ElseIf 已核准_dgv.SelectedCells(0).ColumnIndex = 26 Then 轉財務單.PerformClick() ElseIf 已核准_dgv.SelectedCells(0).ColumnIndex = 27 Then If 財物支付單申請_傳票.申請金額_nud.Value <> 0 Then : PA21 = "" : PA22 = "" : PA23 = "" : PA24 = "" : PA25 = "" : PA26 = "" If 財物支付單申請_傳票.支付對象_tb.Text = "" Then : PA21 = 對話框(4) : PA22 = " " & 財物支付單申請_傳票.Label18.Text & " " : PA26 = " " & 對話框(5) & " " : End If If 財物支付單申請_傳票.營行帳號_tb.Text = "" Then : PA21 = 對話框(4) : PA23 = " " & 財物支付單申請_傳票.Label15.Text & " " : PA26 = " " & 對話框(5) & " " : End If If 財物支付單申請_傳票.支付銀行_tb.Text = "" Then : PA21 = 對話框(4) : PA24 = " " & 財物支付單申請_傳票.Label17.Text & " " : PA26 = " " & 對話框(5) & " " : End If If 財物支付單申請_傳票.銀行支行_tb.Text = "" Then : PA21 = 對話框(4) : PA25 = " " & 財物支付單申請_傳票.Label16.Text & " " : PA26 = " " & 對話框(5) & " " : End If MGB(對話框(7) & vbCrLf & PA21 & PA22 & PA23 & PA24 & PA25 & PA26, 2) : 首次開啟 = False If 訊息回應 = "YES" Then 財物支付單申請_傳票.開立收支單1_bt.PerformClick() Dim XS As Integer = 0 : Dim SRTG As String = "" Dim currentTime As DateTime = DateTime.Now For i As Integer = 0 To 已核准_dgv.Rows.Count - 1 If 已核准_dgv.Rows(i).Cells(22).Value <> 0 Then If XS < 9 Then : SRTG = "HP" & currentTime.ToString("yyyyMMddHHmmss") & "00" & XS + 1 ElseIf XS < 99 Then : SRTG = "HP" & currentTime.ToString("yyyyMMddHHmmss") & "0" & XS + 1 ElseIf XS < 999 Then : SRTG = "HP" & currentTime.ToString("yyyyMMddHHmmss") & XS + 1 : End If If XS = 0 Then SQL2 = "('" & 財物支付單申請_傳票.單號_tb.Text & "', '" & 已核准_dgv.Rows(i).Cells(0).Value.ToString & "', '" & 已核准_dgv.Rows(i).Cells(22).Value.ToString & "', '" & SRTG & "')" Else SQL2 &= ", ('" & 財物支付單申請_傳票.單號_tb.Text & "', '" & 已核准_dgv.Rows(i).Cells(0).Value.ToString & "', '" & 已核准_dgv.Rows(i).Cells(22).Value.ToString & "', '" & SRTG & "')" End If PA42 = 已核准_dgv.Rows(i).Cells(22).Value + 已核准_dgv.Rows(i).Cells(23).Value : PA43 = 已核准_dgv.Rows(i).Cells(0).Value.ToString : PA44 = "1" SQL_採購轉財務金額修改_修改() : XS += 1 End If Next : SQL_財務採購關聯表_新增() : Set_清單1() : MGB(對話框(6), 1) : 首次開啟 = False End If : PA21 = "" : PA22 = "" : PA23 = "" : PA24 = "" : PA25 = "" : PA26 = "" End If End If End If End Sub Private Sub 明細_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 明細_dgv.MouseUp 'If 明細_dgv.SelectedCells.Count = 1 Then : 通知訊息 = 明細_dgv.SelectedCells(0).ColumnIndex & " " & 明細_dgv.SelectedCells(0).RowIndex) : End If If 明細_dgv.SelectedCells.Count = 1 Then : 已超出 = False : End If If 明細_dgv.SelectedCells.Count > 0 Then If 明細_dgv.SelectedCells(0).ColumnIndex = 8 Then If 已超出 = False Then Dim x As Double = 0 For i As Integer = 0 To 明細_dgv.SelectedCells.Count - 1 Dim 變數 As String = "" : Dim 取變數 As String 取變數 = 明細_dgv.Rows(明細_dgv.SelectedCells.Item(i).RowIndex).Cells(明細_dgv.SelectedCells.Item(i).ColumnIndex).Value For ii As Integer = 1 To Len(取變數) If ii = 1 Then : 變數 = Strings.Left(取變數, ii) : Else : If Strings.Mid(取變數, ii, 1) <> "," Then : 變數 &= Strings.Mid(取變數, ii, 1) : End If : End If Next : x += Val(變數) Next i : HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(x, "#,##0") Else : HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(0, "#,##0") End If Else : 已超出 = True : HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(0, "#,##0") End If End If End Sub Private Sub 明細_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 明細_dgv.CellEnter 總金額_tb.Text = "0" For i As Integer = 0 To 明細_dgv.Rows.Count - 1 明細_dgv.Rows(i).Cells(表頭(27)).Value = 明細_dgv.Rows(i).Cells(表頭(26)).Value * 明細_dgv.Rows(i).Cells(表頭(15)).Value 總金額_tb.Text = Val(總金額_tb.Text) + 明細_dgv.Rows(i).Cells(表頭(27)).Value Next i 總金額_tb.Text = Strings.Format(Val(總金額_tb.Text), "#,##0") End Sub Private Sub 明細_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 明細_dgv.CellClick If e.RowIndex = -1 Then : Else PA1 = 明細_dgv.Rows(e.RowIndex).Cells("群組碼").Value : PA2 = 明細_dgv.Rows(e.RowIndex).Cells("料號原則").Value SQL_物料圖庫_圖檔讀取() While dr.Read() = True Dim unused As Byte() = New Byte(-1) {} Dim bytes As Byte() = DirectCast(dr.Item("圖檔"), Byte()) Dim oStream As New MemoryStream(bytes) 物料圖檔_pb.Image = Bitmap.FromStream(oStream) End While conn.Close() : 物料圖檔_pb.SizeMode = 4 End If End Sub Private Sub 已核准_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 已核准_dgv.CellClick If e.RowIndex = -1 Then : Else 採購單號_tb.Text = 已核准_dgv(0, e.RowIndex).Value.ToString : 折扣比_tb.Text = 已核准_dgv(13, e.RowIndex).Value.ToString : 稅金計算_ch.Checked = 已核准_dgv(14, e.RowIndex).Value 稅金比_tb.Text = 已核准_dgv(15, e.RowIndex).Value.ToString : 核對員_tb.Text = 已核准_dgv(4, e.RowIndex).Value.ToString : 核對日期_tb.Text = 已核准_dgv(5, e.RowIndex).Value.ToString 詢價員_tb.Text = 已核准_dgv(6, e.RowIndex).Value.ToString : 尋價日期_tb.Text = 已核准_dgv(7, e.RowIndex).Value.ToString : 驗證碼1_tb.Text = 已核准_dgv(11, e.RowIndex).Value.ToString 審核日期1_tb.Text = 已核准_dgv("一級核准核准日期", e.RowIndex).Value.ToString : 審核日期2_tb.Text = 已核准_dgv("核准日期", e.RowIndex).Value.ToString 採購人員_tb.Text = 已核准_dgv("採購員", e.RowIndex).Value.ToString : 採購日期_tb.Text = 已核准_dgv("採購日期", e.RowIndex).Value.ToString 手動號碼_tb.Text = 已核准_dgv("手動號碼", e.RowIndex).Value.ToString If Strings.Left(採購單號_tb.Text, 3) = "HXI" Then : 選擇公司_cb.Text = "PT HONG XHE INDUSTRIAL" ElseIf Strings.Left(採購單號_tb.Text, 3) = "PGS" Then : 選擇公司_cb.Text = "PT PUNCAK GEMILANG SEMESTA" : End If 供應商編碼_tb.Text = 已核准_dgv(1, e.RowIndex).Value.ToString : conn.Close() PA1 = 供應商編碼_tb.Text : SQL_建築物料採購單生成_供應商資料一() If dr.Read() Then : 廠商_cb.Text = dr("公司名") : conn.Close() : End If : conn.Close() 驗證碼_tb.Text = 已核准_dgv(11, e.RowIndex).Value.ToString : 圖片編碼_tb.Text = 已核准_dgv(10, e.RowIndex).Value.ToString 使用地點_tb.Text = 已核准_dgv(3, e.RowIndex).Value.ToString : 需求日期_dtp.Value = 已核准_dgv(2, e.RowIndex).Value PA1 = 已核准_dgv("一級核准簽名檔編號", e.RowIndex).Value.ToString : SQL_主管簽名檔管理_圖片流水號() 簽名檔1_pb.Image = Nothing While dr.Read() = True Dim unused As Byte() = New Byte(-1) {} Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte()) Dim oStream As New MemoryStream(bytes) 簽名檔1_pb.Image = Bitmap.FromStream(oStream) End While conn.Close() : 簽名檔1_pb.SizeMode = 4 Set_清單() QRCode2_rb.Value = 驗證碼1_tb.Text : QRCode1_rb.Value = 驗證碼1_tb.Text QRCode_pb.Image = QRCode1_rb.ExportToImage() End If End Sub Private Sub 已作廢_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 已作廢_dgv.CellClick If e.RowIndex = -1 Then : Else 採購單號_tb.Text = 已作廢_dgv(0, e.RowIndex).Value.ToString : 折扣比_tb.Text = 已作廢_dgv(13, e.RowIndex).Value.ToString : 稅金計算_ch.Checked = 已作廢_dgv(14, e.RowIndex).Value 稅金比_tb.Text = 已作廢_dgv(15, e.RowIndex).Value.ToString : 核對員_tb.Text = 已作廢_dgv(4, e.RowIndex).Value.ToString : 核對日期_tb.Text = 已作廢_dgv(5, e.RowIndex).Value.ToString 詢價員_tb.Text = 已作廢_dgv(6, e.RowIndex).Value.ToString : 尋價日期_tb.Text = 已作廢_dgv(7, e.RowIndex).Value.ToString If Strings.Left(採購單號_tb.Text, 3) = "HXI" Then : 選擇公司_cb.Text = "PT HONG XHE INDUSTRIAL" ElseIf Strings.Left(採購單號_tb.Text, 3) = "PGS" Then : 選擇公司_cb.Text = "PT PUNCAK GEMILANG SEMESTA" : End If 簽名檔1_pb.Image = Nothing 供應商編碼_tb.Text = 已作廢_dgv(1, e.RowIndex).Value.ToString : conn.Close() PA = 供應商編碼_tb.Text : SQL_建築物料採購單生成_供應商資料一() If dr.Read() Then : 廠商_cb.Text = dr("公司名") : conn.Close() : End If : conn.Close() 驗證碼_tb.Text = 已作廢_dgv(11, e.RowIndex).Value.ToString : 圖片編碼_tb.Text = 已作廢_dgv(10, e.RowIndex).Value.ToString 使用地點_tb.Text = 已作廢_dgv(3, e.RowIndex).Value.ToString : 需求日期_dtp.Value = 已作廢_dgv(2, e.RowIndex).Value Set_清單() End If End Sub Private Sub 廠商_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 廠商_cb.SelectedIndexChanged PA1 = 廠商_cb.Text : SQL_建築物料採購單生成_供應商資料二() If dr.Read() Then 供應商編碼_tb.Text = dr("供應商編碼") : 地址_tb.Text = dr("公司地址") : 電話_tb.Text = dr("公司電話1") : 郵件_tb.Text = dr("聯繫人1郵箱") : 傳真_tb.Text = dr("公司傳真1") End If conn.Close() End Sub Private Sub 圖片編碼_tb_TextChanged(sender As Object, e As EventArgs) Handles 圖片編碼_tb.TextChanged PA1 = 圖片編碼_tb.Text : SQL_主管簽名檔管理_圖片流水號() 簽名檔2_pb.Image = Nothing While dr.Read() = True Dim unused As Byte() = New Byte(-1) {} Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte()) Dim oStream As New MemoryStream(bytes) 簽名檔2_pb.Image = Bitmap.FromStream(oStream) End While conn.Close() : 簽名檔2_pb.SizeMode = 4 End Sub Private Sub 小間距1_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 小間距1_ch.Click 小間距1_ch.Checked = True : 中間距1_ch.Checked = False : 大間距1_ch.Checked = False : Set_清單() End Sub Private Sub 中間距1_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 中間距1_ch.Click 小間距1_ch.Checked = False : 中間距1_ch.Checked = True : 大間距1_ch.Checked = False : Set_清單() End Sub Private Sub 大間距1_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 大間距1_ch.Click 小間距1_ch.Checked = False : 中間距1_ch.Checked = False : 大間距1_ch.Checked = True : Set_清單() End Sub Private Sub 物料圖檔_pb_Click(sender As Object, e As EventArgs) Handles 物料圖檔_pb.Click If IsNothing(物料圖檔_pb.Image) = False Then : 圖片傳遞 = 物料圖檔_pb.Image : 圖片放大視窗.ShowDialog() : End If End Sub Private Sub 詳細資料2_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 詳細資料2_ch.Click If 詳細資料2_ch.Checked = True Then : 詳細資料2_ch.Checked = True : Else : 詳細資料2_ch.Checked = False : End If : Set_清單() End Sub Private Sub 選擇公司_cb_Click(sender As Object, e As EventArgs) Handles 選擇公司_cb.Click CB選擇清單(選擇公司_cb, 選擇公司_cb.Text) End Sub Private Sub 廠商_cb_Click(sender As Object, e As EventArgs) Handles 廠商_cb.Click CB選擇清單(廠商_cb, 廠商_cb.Text) End Sub Private Sub 系統語言_cb_Click(sender As Object, e As EventArgs) Handles 系統語言_cb.Click CB選擇清單(系統語言_cb, 系統語言_cb.Text) End Sub Private Sub 打開清單_bt_Click(sender As Object, e As EventArgs) Handles 打開清單_bt.Click 打開清單() End Sub Private Sub 轉財務單_Click(sender As Object, e As EventArgs) Handles 轉財務單.Click PA25 = 0 : PA26 = 對話框(2) & " " & 廠商_cb.Text & " " & 對話框(3) : 財物支付單申請_傳票.內容_tb.Text = "" Dim XA As Integer = 0 : Dim 可以轉 As Boolean = False For i As Integer = 0 To 已核准_dgv.Rows.Count - 1 If 已核准_dgv.Rows(i).Cells(22).Value <> 0 Then : PA25 = CLng(PA25) + 已核准_dgv.Rows(i).Cells(22).Value : 可以轉 = True If XA = 0 Then : PA26 &= 已核准_dgv.Rows(i).Cells(0).Value : Else : PA26 &= "、" & 已核准_dgv.Rows(i).Cells(0).Value : End If : XA += 1 End If Next If 可以轉 = True Then If 財物支付單申請_傳票.Visible = True Then : Else : 跨部門開啟 = False : 財物支付單申請_傳票.Show() : End If If CLng(PA25) < 100000000000000 Then 財物支付單申請_傳票.申請金額_nud.Value = PA25 : 財物支付單申請_傳票.內容_tb.Text = PA26 : 財物支付單申請_傳票.編號1_cb.Text = "B-02" 財物支付單申請_傳票.編號2_cb.Text = "B-02-01" : 財物支付單申請_傳票.編號3_cb.Text = "B-02-01-02" PA48 = "採購" Else : MGB(對話框(1), 1) : 首次開啟 = False : End If End If : PA25 = "" : PA26 = "" : 財物支付單申請_傳票.BringToFront() End Sub Private Sub 全部資料_cb_Click(sender As Object, e As EventArgs) Handles 全部資料_cb.Click Set_清單1() End Sub Private Sub 確認列印_bt_Click_1(sender As Object, e As EventArgs) Handles 確認列印_bt.Click If 採購人員_tb.Text = "" Then SQL_物料採購單_首次列印() : 採購人員_tb.Text = gUserName : 採購日期_tb.Text = Today() End If Dim ds6 As New DataSet : 請購資料_dgv.DataSource = Nothing : ds6.Clear() 請購資料_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 請購資料_dgv.ColumnHeadersHeight = 25 : 請購資料_dgv.AllowUserToAddRows = False PA38 = 採購單號_tb.Text : SQL_採購資料() : da.Fill(ds6) : 請購資料_dgv.DataSource = ds6.Tables(0) : conn.Close() 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 N1 = 0 : N2 = 0 'xlSheet.Cells(2, 1) = 選擇公司_cb.Text xlSheet.Cells(3, 1) = "PURCHASE ORDER" xlSheet.Cells(5, 1) = "ORDER TO : " & 廠商_cb.Text : xlSheet.Cells(6, 1) = "ALAMAT : " & 地址_tb.Text : xlSheet.Cells(7, 1) = "Telp : " & 電話_tb.Text xlSheet.Cells(8, 1) = "Fax : " & 傳真_tb.Text : xlSheet.Cells(9, 1) = "Email : " & 郵件_tb.Text xlSheet.Cells(10, 1) = "No." : xlSheet.Cells(10, 2) = "Nama produk" : xlSheet.Cells(10, 3) = "Spesifikasi" : xlSheet.Cells(10, 4) = "Komentar" : xlSheet.Cells(10, 5) = "SATUAN" xlSheet.Cells(10, 6) = "QTY" : xlSheet.Cells(10, 7) = "UNIT PRICE" : xlSheet.Cells(10, 8) = "TOTAL PRICE" xlSheet.Cells(5, 5) = "PO NOMOR 1 : " : xlSheet.Cells(5, 7) = 手動號碼_tb.Text xlSheet.Cells(7, 5) = "PO NOMOR 2 : " : xlSheet.Cells(7, 7) = 採購單號_tb.Text xlSheet.Cells(8, 5) = "TGL/BLN/THN : " : xlSheet.Cells(8, 7) = 需求日期_dtp.Value xlSheet.Cells(9, 5) = "TEMPAT PEMAKAIAN : " : xlSheet.Cells(9, 7) = 使用地點_tb.Text Dim GGHH As Integer = 0 For i As Integer = 0 To 明細1_dgv.Rows.Count - 1 xlSheet.Cells(i + 11, 1) = 明細1_dgv.Rows(i).Cells(表頭(2)).Value : xlSheet.Cells(i + 11, 2) = 明細1_dgv.Rows(i).Cells(表頭(12)).Value xlSheet.Cells(i + 11, 3) = 明細1_dgv.Rows(i).Cells(表頭(13)).Value : xlSheet.Cells(i + 11, 4) = 明細1_dgv.Rows(i).Cells(表頭(14)).Value xlSheet.Cells(i + 11, 5) = 明細1_dgv.Rows(i).Cells(表頭(16)).Value : xlSheet.Cells(i + 11, 6) = 明細1_dgv.Rows(i).Cells(表頭(15)).Value xlSheet.Cells(i + 11, 7) = 明細1_dgv.Rows(i).Cells(表頭(26)).Value : xlSheet.Cells(i + 11, 8) = 明細1_dgv.Rows(i).Cells(表頭(27)).Value GGHH += 明細1_dgv.Rows(i).Cells(表頭(27)).Value N1 = i + 11 Next i xlSheet.Cells(N1 + 2, 7) = "TOTAL :" : xlSheet.Cells(N1 + 2, 8) = GGHH xlSheet.Cells(N1 + 3, 7) = "DISC " & 折扣比_tb.Text & "% :" : xlSheet.Cells(N1 + 3, 8) = 折扣金額_tb.Text xlSheet.Cells(N1 + 4, 7) = "PPN " & 稅金比_tb.Text & "% :" : xlSheet.Cells(N1 + 4, 8) = 稅金金額_tb.Text xlSheet.Cells(N1 + 5, 7) = "GRAND TOTAL :" : xlSheet.Cells(N1 + 5, 8) = 總金額_tb.Text xlSheet.Cells(N1 + 6, 1) = "Bagian Pembelian Barang" : xlSheet.Cells(N1 + 8, 1) = 採購人員_tb.Text : xlSheet.Cells(N1 + 9, 1) = 採購日期_tb.Text xlSheet.Cells(N1 + 6, 3) = "Direktur Utama" : xlSheet.Cells(N1 + 9, 3) = 審核日期2_tb.Text xlSheet.Cells(N1 + 6, 4) = "Bagian Pemeriksa" : xlSheet.Cells(N1 + 9, 4) = 審核日期1_tb.Text xlSheet.Cells(N1 + 6, 6) = "Bagian Pengisian Harga" : xlSheet.Cells(N1 + 8, 6) = 詢價員_tb.Text : xlSheet.Cells(N1 + 9, 6) = 尋價日期_tb.Text xlSheet.Cells(N1 + 6, 8) = "Asisten Proyek" : xlSheet.Cells(N1 + 8, 8) = 核對員_tb.Text : xlSheet.Cells(N1 + 9, 8) = 核對日期_tb.Text For i As Integer = 0 To 請購資料_dgv.Rows.Count - 1 xlSheet.Cells(i + N1 + 12, 1) = 請購資料_dgv.Rows(i).Cells(0).Value If 系統語言 = "繁體中文" Then xlSheet.Cells(i + N1 + 12, 3) = 請購資料_dgv.Rows(i).Cells(2).Value Else xlSheet.Cells(i + N1 + 12, 3) = 請購資料_dgv.Rows(i).Cells(1).Value End If xlSheet.Cells(i + N1 + 12, 8) = 請購資料_dgv.Rows(i).Cells(3).Value : N2 += 1 Next : AA(xlApp, xlSheet) : DD(xlApp, xlSheet) : EE(xlApp, xlSheet) : CC(xlApp, xlSheet) : FF(xlApp, xlSheet) If Strings.Left(採購單號_tb.Text, 2) = "HX" Then : GG(xlApp, xlSheet) : Else : HH(xlApp, xlSheet) : End If '-------------轉換成PDF--------------------------------------------------------------------- Dim SERT As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, SERT & "\" & 採購單號_tb.Text & "_PO(採購單).pdf", XlFixedFormatQuality.xlQualityStandard, True) '-------------關閉EXCEL--------------------------------------------------------------------- xlSheet.PageSetup.PrintArea = "" : xlApp.Cells.Select() xlApp.Application.WindowState = xlMinimized xlBook.Close(False) Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet) Runtime.InteropServices.Marshal.ReleaseComObject(xlBook) Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect() MGB(對話框(0), 1) : 首次開啟 = False 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 = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 6 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 24 xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 35 : xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 20 xlSheet.Columns("E:E").Select : myExcel.Selection.ColumnWidth = 10 : xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 15 xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 15 : xlSheet.Columns("H:H").Select : myExcel.Selection.ColumnWidth = 30 xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 90 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 5 xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("4:4").Select : myExcel.Selection.RowHeight = 5 xlSheet.Rows("5:9").Select : myExcel.Selection.RowHeight = 20 : xlSheet.Rows("10:10").Select : myExcel.Selection.RowHeight = 20 xlSheet.Rows("11:" & N1).Select : myExcel.Selection.RowHeight = 65 : xlSheet.Rows(N1 + 1 & ":" & N1 + 1).Select : myExcel.Selection.RowHeight = 5 xlSheet.Rows(N1 + 2 & ":" & N1 + 5).Select : myExcel.Selection.RowHeight = 17 : xlSheet.Rows(N1 + 6 & ":" & N1 + 6).Select : myExcel.Selection.RowHeight = 35 xlSheet.Rows(N1 + 7 & ":" & N1 + 9).Select : myExcel.Selection.RowHeight = 35 xlSheet.Range("A2:H2").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.Font : .Name = "微軟正黑體" : .Size = 26 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With xlSheet.Range("A3:H3").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.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.Range("A10:H" & 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 + 2 & ":H" & N1 + 2).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("A" & N1 + 3 & ":H" & N1 + 3).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("A" & N1 + 4 & ":H" & N1 + 4).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("A" & N1 + 5 & ":H" & N1 + 5).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("A" & N1 + 6 & ":B" & N1 + 6).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 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("C" & N1 + 6 & ":C" & N1 + 6).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 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("D" & N1 + 6 & ":E" & N1 + 6).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 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("F" & N1 + 6 & ":G" & N1 + 6).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 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("H" & N1 + 6).Select() With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With 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("A" & N1 + 7 & ":B" & N1 + 9).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("C" & N1 + 7 & ":C" & N1 + 9).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("D" & N1 + 7 & ":E" & N1 + 9).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("F" & N1 + 7 & ":G" & N1 + 9).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 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("H" & N1 + 7 & ":H" & N1 + 9).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 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("A10:A" & N1).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("B11:D" & N1).Select() With myExcel.Selection .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False .ReadingOrder = xlContext : .MergeCells = False : End With xlSheet.Range("E11:F" & N1).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("G11:H" & N1).Select() : myExcel.Selection.NumberFormatLocal = "#,##0" xlSheet.Range("H" & N1 + 2).Select() : myExcel.Selection.NumberFormatLocal = "#,##0" xlSheet.Range("H" & N1 + 2 & ":H" & N1 + 5).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 With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With myExcel.ActiveWindow.DisplayGridlines = False xlSheet.Range("A3:H3").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 = xlThin : End With myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("G7:G9").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("A10:H" & 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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : 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 + 2 & ":H" & N1 + 5).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With xlSheet.Range("A" & N1 + 6 & ":B" & N1 + 9).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone xlSheet.Range("C" & N1 + 6 & ":C" & N1 + 9).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone xlSheet.Range("D" & N1 + 6 & ":E" & N1 + 9).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone xlSheet.Range("F" & N1 + 6 & ":G" & N1 + 9).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone xlSheet.Range("H" & N1 + 6 & ":H" & N1 + 9).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone xlSheet.Rows("5:9").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.Rows("11:" & N1).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.Range("A10:H10").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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xlSheet.Range("A11:H" & 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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With xlSheet.Range("B11:D" & 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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With xlSheet.Range("F11:F" & 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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With xlSheet.Range("H11:H" & 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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With xlSheet.Range("A" & N1 + 2 & ":H" & N1 + 5).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With xlSheet.Range("H" & N1 + 2 & ":H" & N1 + 5).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 = xlMedium : End With With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlHairline : End With xlSheet.Range("G" & N1 + 2 & ":G" & N1 + 5).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("F" & N1 + 8 & ":G" & N1 + 8).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("F" & N1 + 9 & ":G" & N1 + 9).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("A" & N1 + 8 & ":B" & N1 + 8).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("A" & N1 + 9 & ":B" & N1 + 9).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("C" & N1 + 9).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("A" & N1 + 11 & ":H" & N1 + N2 + 11).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 myExcel.Application.PrintCommunication = False With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$10" : .PrintTitleColumns = "" : End With myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = "" .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945) .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992) .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126) .PrintHeadings = False : .PrintGridlines = False : .PrintQuality = 600 : .CenterHorizontally = False : .CenterVertically = False : .Draft = False .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True : .EvenPage.LeftHeader.Text = "" .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = "" .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = "" .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = "" End With : myExcel.Application.PrintCommunication = True End Sub Private Sub CC(ByVal myExcel As Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet) Clipboard.SetDataObject(簽名檔2_pb.Image) xlSheet.Range("C" & N1 + 8).Select() myExcel.ActiveSheet.Pictures.Paste.Select myExcel.Selection.ShapeRange.Height = 50 myExcel.Selection.ShapeRange.IncrementLeft(10) myExcel.Selection.ShapeRange.IncrementTop(-23) End Sub Private Sub DD(ByVal myExcel As Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet) Clipboard.SetDataObject(QRCode_pb.Image) xlSheet.Range("H5").Select() myExcel.ActiveSheet.Pictures.Paste.Select myExcel.Selection.ShapeRange.Height = 90 myExcel.Selection.ShapeRange.IncrementLeft(70) myExcel.Selection.ShapeRange.IncrementTop(1) End Sub Private Sub EE(ByVal myExcel As Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet) Clipboard.SetDataObject(簽名檔1_pb.Image) xlSheet.Range("D" & N1 + 8).Select() myExcel.ActiveSheet.Pictures.Paste.Select myExcel.Selection.ShapeRange.Height = 50 myExcel.Selection.ShapeRange.IncrementLeft(10) myExcel.Selection.ShapeRange.IncrementTop(-23) End Sub Private Sub GG(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Worksheet) Clipboard.SetDataObject(財物支付單申請_傳票.PictureBox1.Image) xlSheet.Range("A1").Select() myExcel.ActiveSheet.Pictures.Paste.Select myExcel.Selection.ShapeRange.Height = 93 myExcel.Selection.ShapeRange.IncrementLeft(50) myExcel.Selection.ShapeRange.IncrementTop(0) End Sub Private Sub HH(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Worksheet) Clipboard.SetDataObject(財物支付單申請_傳票.PictureBox2.Image) xlSheet.Range("A1").Select() myExcel.ActiveSheet.Pictures.Paste.Select myExcel.Selection.ShapeRange.Height = 93 myExcel.Selection.ShapeRange.IncrementLeft(50) myExcel.Selection.ShapeRange.IncrementTop(0) End Sub Private Sub FF(ByVal myExcel As Application, ByVal xlSheet As Worksheet) myExcel.Application.PrintCommunication = False With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$11" : .PrintTitleColumns = "" : End With myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = "" .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945) .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992) .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126) .PrintHeadings = False : .PrintGridlines = False : .PrintQuality = 600 : .CenterHorizontally = False : .CenterVertically = False : .Draft = False .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True : .EvenPage.LeftHeader.Text = "" .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = "" .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = "" .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = "" End With : myExcel.Application.PrintCommunication = True End Sub '-----------------------------滑鼠右鍵-------------------------------------------------------------------------------------------------------------------------------------- Private Sub 重新整理SegarkanToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新整理_tsm.Click Set_清單1() : Set_清單2() End Sub Private Sub 風格() If 深色風格 = False Then Me.BackColor = SystemColors.Control 選擇公司_lb.ForeColor = Color.Blue 已核准_lb.ForeColor = Color.Black : 一級簽核_lb.ForeColor = Color.Black : 二級簽核_lb.ForeColor = Color.Black : Label1.ForeColor = Color.Black Label2.ForeColor = Color.Black : Label3.ForeColor = Color.Black : Label6.ForeColor = Color.Black : Label12.ForeColor = Color.Black Label11.ForeColor = Color.Black : Label8.ForeColor = Color.Black : Label5.ForeColor = Color.Black : Label7.ForeColor = Color.Black 總金額_lb.ForeColor = Color.Black : 詳細資料2_ch.ForeColor = Color.Black : 小間距1_ch.ForeColor = Color.Black : 中間距1_ch.ForeColor = Color.Black 大間距1_ch.ForeColor = Color.Black : 稅金計算_ch.ForeColor = Color.Black : Label9.ForeColor = Color.Black 語轉扭_bt.BackColor = Color.White : 語轉扭_bt.ForeColor = Color.Black 地址_tb.BackColor = Color.White : 地址_tb.ForeColor = Color.Black : 電話_tb.BackColor = Color.White : 電話_tb.ForeColor = Color.Black 採購單號_tb.BackColor = Color.White : 採購單號_tb.ForeColor = Color.Black : 折扣比_tb.BackColor = Color.White : 折扣比_tb.ForeColor = Color.Black 折扣金額_tb.BackColor = Color.White : 折扣金額_tb.ForeColor = Color.Black : 傳真_tb.BackColor = Color.White : 傳真_tb.ForeColor = Color.Black 稅金比_tb.BackColor = Color.White : 稅金比_tb.ForeColor = Color.Black : 稅金金額_tb.BackColor = Color.White : 稅金金額_tb.ForeColor = Color.Black 郵件_tb.BackColor = Color.White : 郵件_tb.ForeColor = Color.Black : 使用地點_tb.BackColor = Color.White : 使用地點_tb.ForeColor = Color.Black 總金額_tb.BackColor = Color.White : 總金額_tb.ForeColor = Color.Black 選擇公司_cb.BackColor = Color.White : 選擇公司_cb.ForeColor = Color.Black : 廠商_cb.BackColor = Color.White : 廠商_cb.ForeColor = Color.Black 系統語言_cb.BackColor = Color.White : 系統語言_cb.ForeColor = Color.Black : 手動號碼_tb.BackColor = Color.White : 手動號碼_tb.ForeColor = Color.Black 確認列印_bt.BackColor = Color.White 已核准_dgv.EnableHeadersVisualStyles = True : 已核准_dgv.BackgroundColor = Color.White : 已核准_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black 已核准_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightPink 已核准_dgv.DefaultCellStyle.BackColor = Color.White : 已核准_dgv.DefaultCellStyle.ForeColor = Color.Black 明細_dgv.EnableHeadersVisualStyles = True : 明細_dgv.BackgroundColor = Color.White : 明細_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black 明細_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue 明細_dgv.DefaultCellStyle.BackColor = Color.White : 明細_dgv.DefaultCellStyle.ForeColor = Color.Black Else Me.BackColor = Color.Black 選擇公司_lb.ForeColor = Color.LightBlue 已核准_lb.ForeColor = Color.White : 一級簽核_lb.ForeColor = Color.White : 二級簽核_lb.ForeColor = Color.White : Label1.ForeColor = Color.White Label2.ForeColor = Color.White : Label3.ForeColor = Color.White : Label6.ForeColor = Color.White : Label12.ForeColor = Color.White Label11.ForeColor = Color.White : Label8.ForeColor = Color.White : Label5.ForeColor = Color.White : Label7.ForeColor = Color.White 總金額_lb.ForeColor = Color.White : 詳細資料2_ch.ForeColor = Color.White : 小間距1_ch.ForeColor = Color.White : 中間距1_ch.ForeColor = Color.White 大間距1_ch.ForeColor = Color.White : 稅金計算_ch.ForeColor = Color.White : Label9.ForeColor = Color.White 語轉扭_bt.BackColor = Color.DimGray : 語轉扭_bt.ForeColor = Color.White 地址_tb.BackColor = Color.DimGray : 地址_tb.ForeColor = Color.White : 電話_tb.BackColor = Color.DimGray : 電話_tb.ForeColor = Color.White 採購單號_tb.BackColor = Color.DimGray : 採購單號_tb.ForeColor = Color.White : 折扣比_tb.BackColor = Color.DimGray : 折扣比_tb.ForeColor = Color.White 折扣金額_tb.BackColor = Color.DimGray : 折扣金額_tb.ForeColor = Color.White : 傳真_tb.BackColor = Color.DimGray : 傳真_tb.ForeColor = Color.White 稅金比_tb.BackColor = Color.DimGray : 稅金比_tb.ForeColor = Color.White : 稅金金額_tb.BackColor = Color.DimGray : 稅金金額_tb.ForeColor = Color.White 郵件_tb.BackColor = Color.DimGray : 郵件_tb.ForeColor = Color.White : 使用地點_tb.BackColor = Color.DimGray : 使用地點_tb.ForeColor = Color.White 總金額_tb.BackColor = Color.DimGray : 總金額_tb.ForeColor = Color.White 選擇公司_cb.BackColor = Color.DimGray : 選擇公司_cb.ForeColor = Color.White : 廠商_cb.BackColor = Color.DimGray : 廠商_cb.ForeColor = Color.White 系統語言_cb.BackColor = Color.DimGray : 系統語言_cb.ForeColor = Color.White : 手動號碼_tb.BackColor = Color.DimGray : 手動號碼_tb.ForeColor = Color.White 確認列印_bt.BackColor = Color.DimGray 已核准_dgv.EnableHeadersVisualStyles = False : 已核准_dgv.BackgroundColor = Color.DimGray : 已核准_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White 已核准_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 已核准_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.DimGray 已核准_dgv.DefaultCellStyle.BackColor = Color.Black : 已核准_dgv.DefaultCellStyle.ForeColor = Color.White 明細_dgv.EnableHeadersVisualStyles = False : 明細_dgv.BackgroundColor = Color.DimGray : 明細_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White 明細_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 明細_dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.DimGray 明細_dgv.DefaultCellStyle.BackColor = Color.Black : 明細_dgv.DefaultCellStyle.ForeColor = Color.White End If End Sub End Class