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 : ReadOnly ds6 As New DataSet Dim 物料規格 As String : ReadOnly 對話框(22) As String : Dim 新項次 As String : Dim NUM1 As Integer : Dim N1 As Integer : Dim yy As Boolean Private Sub Set_單價() Dim ds6 As New DataSet : 價錢_dgv.DataSource = Nothing : ds6.Clear() 價錢_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 價錢_dgv.ColumnHeadersHeight = 25 價錢_dgv.AllowUserToAddRows = False If 日期_rb.Checked = False And 單價_rb.Checked = True Then SQL_加權平均() ElseIf 日期_rb.Checked = True And 單價_rb.Checked = False Then SQL_最近日期() End If da.Fill(ds6) : 價錢_dgv.DataSource = ds6.Tables(0) : conn.Close() End Sub Private Sub Set_請購單清單() Dim ds As New DataSet : 請購_dgv.DataSource = Nothing : ds.Clear() 請購_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 請購_dgv.ColumnHeadersHeight = 40 請購_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 PA1 = 倉庫編號_tb.Text SQL_採購單詢價_請購單清單() da.Fill(ds) : 請購_dgv.DataSource = ds.Tables(0) : conn.Close() 請購_dgv.Columns(0).FillWeight = 40 : 請購_dgv.Columns(1).FillWeight = 70 : 請購_dgv.Columns(2).FillWeight = 50 請購_dgv.Columns(3).FillWeight = 170 : 請購_dgv.Columns(4).FillWeight = 170 請購_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).FillWeight = 70 請購_dgv.Columns(13).FillWeight = 45 : 請購_dgv.Columns(14).Visible = False : 請購_dgv.Columns(15).FillWeight = 70 : 請購_dgv.Columns(16).Visible = False 請購_dgv.Columns(17).FillWeight = 45 : 請購_dgv.Columns(18).Visible = False : 請購_dgv.Columns(19).Visible = False : 請購_dgv.Columns(20).Visible = False 請購_dgv.Columns(21).Visible = False : 請購_dgv.Columns(22).FillWeight = 70 : 請購_dgv.Columns(23).FillWeight = 70 : 請購_dgv.Columns(24).FillWeight = 55 請購_dgv.Columns(25).Visible = False : 請購_dgv.Columns(26).Visible = False : 請購_dgv.Columns(27).FillWeight = 40 If 低網速模式 = False Then 請購_dgv.Columns(28).FillWeight = 45 : 請購_dgv.Columns(28).Visible = True Dim mycol As DataGridViewImageColumn = 請購_dgv.Columns("Image") mycol.ImageLayout = DataGridViewImageCellLayout.Zoom Else If 請購_dgv.Columns.Count = 29 Then 請購_dgv.Columns(28).Visible = False End If End If 請購_dgv.Columns(表頭(15)).DefaultCellStyle.Format = "#,##0" 請購_dgv.Columns(表頭(15)).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(表頭(15)).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(0).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(12).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(12).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(13).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(13).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(15).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(15).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(17).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(17).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(18).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(18).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(20).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(20).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(22).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(22).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(23).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(23).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(24).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 請購_dgv.Columns(24).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 請購_dgv.Columns(0).ReadOnly = True : 請購_dgv.Columns(1).ReadOnly = True : 請購_dgv.Columns(3).ReadOnly = True : 請購_dgv.Columns(4).ReadOnly = True 請購_dgv.Columns(12).ReadOnly = True : 請購_dgv.Columns(13).ReadOnly = True : 請購_dgv.Columns(15).ReadOnly = True : 請購_dgv.Columns(17).ReadOnly = True 請購_dgv.Columns(18).ReadOnly = True : 請購_dgv.Columns(20).ReadOnly = True : 請購_dgv.Columns(22).ReadOnly = True : 請購_dgv.Columns(23).ReadOnly = True 請購_dgv.Columns(24).ReadOnly = True For i As Integer = 0 To 請購_dgv.Rows.Count - 1 '-------------------------規格合併呈現---------------------------------------------------------------------------------------------------------------------------------------- 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 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 = 物料規格 : 請購_dgv.Rows(i).Cells(0).Value = i + 1 : 請購_dgv.Rows(i).Cells(27).Value = False Next For i As Integer = 0 To 請購_dgv.Rows.Count - 1 If IsDBNull(請購_dgv.Rows(i).Cells("" & (表頭(44)) & "").Value) Then : 請購_dgv.Rows(i).Cells("" & (表頭(44)) & "").Value = False : End If Next For i As Integer = 0 To 請購_dgv.Rows.Count - 1 If IsDBNull(請購_dgv.Rows(i).Cells("" & (表頭(134)) & "").Value) Then : 請購_dgv.Rows(i).Cells("" & (表頭(134)) & "").Value = " " : End If Next For i As Integer = 0 To 請購_dgv.Rows.Count - 1 If 請購_dgv("" & (表頭(44)) & "", i).Value = True Then : 請購_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen Else : 請購_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White : End If Next End Sub Private Sub Set_清單2() Dim ds2 As New DataSet : 採購單_dgv.DataSource = Nothing : ds2.Clear() 採購單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 採購單_dgv.ColumnHeadersHeight = 40 採購單_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 End Sub Private Sub Set_採購單清單() Dim ds3 As New DataSet : 明細_dgv.DataSource = Nothing : ds3.Clear() 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 明細_dgv.ColumnHeadersHeight = 40 明細_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 PA2 = 採購單號_tb.Text : SQL_採購單詢價_明細() da.Fill(ds3) : 明細_dgv.DataSource = ds3.Tables(0) : conn.Close() 明細_dgv.Columns(0).Visible = False : 明細_dgv.Columns(1).FillWeight = 60 : 明細_dgv.Columns(2).FillWeight = 90 : 明細_dgv.Columns(3).FillWeight = 250 : 明細_dgv.Columns(4).FillWeight = 250 明細_dgv.Columns(5).FillWeight = 150 : 明細_dgv.Columns(6).FillWeight = 60 : 明細_dgv.Columns(7).FillWeight = 80 : 明細_dgv.Columns(8).FillWeight = 80 明細_dgv.Columns(9).FillWeight = 80 : 明細_dgv.Columns(10).Visible = False : 明細_dgv.Columns(11).Visible = False : 明細_dgv.Columns(12).Visible = False 明細_dgv.Columns(13).Visible = False : 明細_dgv.Columns(14).FillWeight = 80 : 明細_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 = 65 : 明細_dgv.Columns(26).FillWeight = 65 : 明細_dgv.Columns(27).FillWeight = 90 : 明細_dgv.Columns(表頭(88)).Visible = False 明細_dgv.Columns("OUP").FillWeight = 80 明細_dgv.Columns(5).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(7).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(8).DefaultCellStyle.Format = "#,##0" 明細_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter 明細_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns("OUP").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter 明細_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 明細_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns("OUP").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter 明細_dgv.EditMode = DataGridViewEditMode.EditOnEnter : 明細_dgv.Columns(6).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(9).DefaultCellStyle.Format = "#,##0.00" 明細_dgv.Columns(1).ReadOnly = True : 明細_dgv.Columns(2).ReadOnly = True : 明細_dgv.Columns(3).ReadOnly = True 明細_dgv.Columns(表頭(16)).ReadOnly = True : 明細_dgv.Columns(表頭(27)).ReadOnly = True : 明細_dgv.Columns("OUP").ReadOnly = True If 低網速模式 = False Then 明細_dgv.Columns(28).FillWeight = 80 : 明細_dgv.Columns(28).Visible = True Dim mycol As DataGridViewImageColumn = 明細_dgv.Columns("Image") mycol.ImageLayout = DataGridViewImageCellLayout.Zoom Else If 明細_dgv.Columns.Count = 29 Then 明細_dgv.Columns(28).Visible = False End If End If 新項次 = "00" For i As Integer = 0 To 明細_dgv.Rows.Count - 1 明細_dgv.Rows(i).Cells("Cancel order").Value = False 明細_dgv.Columns("OUP").DefaultCellStyle.Format = "#,0" NUM1 = Double.Parse(新項次) + 1 If NUM1 < 10 Then : 新項次 = "0" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : 新項次 = NUM1 End If 明細_dgv.Rows(i).Cells("" & 表頭(11) & "").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 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 = 物料規格 '--------------取得歷史單價------------------------------------------------------------------------------------------ PA = 明細_dgv.Rows(i).Cells("料號").Value Set_單價() If 價錢_dgv.Rows.Count = 0 Then 明細_dgv.Rows(i).Cells("OUP").Value = 0 Else 明細_dgv.Rows(i).Cells("OUP").Value = 價錢_dgv.Rows(0).Cells("單價").Value End If Next i Set_採購單清單1() For i As Integer = 0 To 明細_dgv.Rows.Count - 1 If 明細_dgv("" & (表頭(44)) & "", i).Value = True Then 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen Else 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White End If Next i 價格() End Sub Private Sub Set_採購單清單1() Dim ds1 As New DataSet : 明細1_dgv.DataSource = Nothing : ds1.Clear() 明細1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 明細1_dgv.ColumnHeadersHeight = 40 明細1_dgv.AllowUserToAddRows = False 明細1_dgv.RowTemplate.Height = 25 PA2 = 採購單號_tb.Text : SQL_採購單詢價_明細() da.Fill(ds1) : 明細1_dgv.DataSource = ds1.Tables(0) : conn.Close() If 低網速模式 = False Then 明細1_dgv.Columns(25).FillWeight = 80 : 明細1_dgv.Columns(25).Visible = True Dim mycol As DataGridViewImageColumn = 明細1_dgv.Columns("Image") mycol.ImageLayout = DataGridViewImageCellLayout.Zoom Else If 明細1_dgv.Columns.Count = 26 Then 明細1_dgv.Columns(25).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("" & 表頭(11) & "").Value = 新項次 '-------------------------規格合併呈現---------------------------------------------------------------------------------------------------------------------------------------- If i = 0 Then 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 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 If 明細1_dgv.Rows(i).Cells("規格庫編號").Value = "SQLB03" 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 ElseIf 明細1_dgv.Rows(i).Cells("規格庫編號").Value = "SQLB04" 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 ElseIf 明細1_dgv.Rows(i).Cells("規格庫編號").Value = "SQLB05" 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 ElseIf 明細1_dgv.Rows(i).Cells("規格庫編號").Value = "SQLB06" 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 ElseIf 明細1_dgv.Rows(i).Cells("規格庫編號").Value = "SQLB07" 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 ElseIf 明細1_dgv.Rows(i).Cells("規格庫編號").Value = "SQLB08" 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 End If 明細1_dgv.Rows(i).Cells("" & 表頭(13) & "").Value = 物料規格 Next i End Sub Private Sub 金額計算() 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 If 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value = "0" Then 明細_dgv.Rows(i).Cells("" & 表頭(44) & "").Value = False Else 明細_dgv.Rows(i).Cells("" & 表頭(44) & "").Value = True End If Next i End Sub Private Sub Set_料號比價() Dim ds1 As New DataSet 料號_dgv.DataSource = Nothing : ds1.Clear() 料號_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 料號_dgv.ColumnHeadersHeight = 25 料號_dgv.AllowUserToAddRows = False PA = 料號1_tb.Text : SQL_料號比對價格() da.Fill(ds1) : 料號_dgv.DataSource = ds1.Tables(0) : conn.Close() 料號_dgv.Columns(3).DefaultCellStyle.Format = "#,##0.00" 料號_dgv.Columns(3).FillWeight = 50 End Sub Private Sub Set_語言() 語言_dgv.DataSource = Nothing : ds8.Clear() 語言_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 語言_dgv.ColumnHeadersHeight = 25 語言_dgv.AllowUserToAddRows = False SQL_系統語言導入() da.Fill(ds8) : 語言_dgv.DataSource = ds8.Tables(0) : conn.Close() End Sub Private Sub 語言轉換讀取() Set_語言() : conn.Close() For i As Integer = 0 To 語言_dgv.Rows.Count - 1 If 語言_dgv("控件", i).Value.ToString = "採購單詢價" Then : Me.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "指定倉庫_lb" Then : 指定倉庫_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "倉庫級別_lb" Then : 倉庫級別_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "倉庫編號_lb" Then : 倉庫編號_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "全部取消_bt" Then : 全部取消_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "全部選擇_bt" Then : 全部選擇_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "依據入庫單號全部選擇_bt" Then : 依據入庫單號全部選擇_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "刪除請購單上點選資料_bt" Then : 刪除請購單上點選資料_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "生成採購單_bt" Then : 生成採購單_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "列印成詢價單_bt" Then : 列印成詢價單_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "未受理請購單_bt" Then : 未受理請購單_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "詢價中的採購單_bt" Then : 詢價中的採購單_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "選擇公司_lb" Then : 選擇公司_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "選擇_lb" Then : 選擇_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "項次_lb" Then : 項次_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "刪除_bt" Then : 刪除_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "存檔_bt" Then : 存檔_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_項次" Then : 表頭(11) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_品名" Then : 表頭(12) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_規格" Then : 表頭(13) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_備註" Then : 表頭(14) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_數量" Then : 表頭(15) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_單位" Then : 表頭(16) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_用途" Then : 表頭(17) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_單號" Then : 表頭(18) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_請購單號" Then : 表頭(88) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_申請人" Then : 表頭(19) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_核准人" Then : 表頭(21) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_單價" Then : 表頭(26) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_金額" Then : 表頭(27) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_需求日期" Then : 表頭(30) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_選擇" Then : 表頭(44) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_群組碼" Then : 表頭(62) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_料號" Then : 表頭(77) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框1" Then : 對話框(0) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框2" Then : 對話框(1) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框3" Then : 對話框(2) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框4" Then : 對話框(3) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框5" Then : 對話框(4) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框6" Then : 對話框(5) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框7" Then : 對話框(6) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框8" Then : 對話框(7) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "文字_lb" Then : 文字_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "文字2_lb" Then : 文字2_lb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框9" Then : 對話框(8) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框10" Then : 對話框(9) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框11" Then : 對話框(10) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框12" Then : 對話框(11) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框13" Then : 對話框(12) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框14" Then : 對話框(13) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框15" Then : 對話框(14) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框16" Then : 對話框(15) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框17" Then : 對話框(16) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框18" Then : 對話框(17) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "退回請購單_bt" Then : 退回請購單_bt.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "單價_rb" Then : 單價_rb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "日期_rb" Then : 日期_rb.Text = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框19" Then : 對話框(18) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框20" Then : 對話框(19) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框21" Then : 對話框(20) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框22" Then : 對話框(21) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "請購明細_dgv_合約號" Then : 表頭(134) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_合約號" Then : 表頭(134) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "清單_dgv_採購單號" Then : 表頭(24) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "對話框23" Then : 對話框(22) = 語言_dgv("內容", i).Value.ToString : End If If 語言_dgv("控件", i).Value.ToString = "料號_bt" Then : 料號_bt.Text = 語言_dgv("內容", i).Value.ToString : End If Next End Sub Private Sub 價格() Dim 差異, 比對 As Double For i As Integer = 0 To 明細_dgv.Rows.Count - 1 If 明細_dgv.Rows(i).Cells("OUP").Value = 0 And 明細_dgv.Rows(i).Cells(表頭(26)).Value = 0 Then ElseIf 明細_dgv.Rows(i).Cells(表頭(26)).Value = 0 And 明細_dgv.Rows(i).Cells("OUP").Value <> 0 Then 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.Lavender ElseIf 明細_dgv.Rows(i).Cells("OUP").Value <> 0 And 明細_dgv.Rows(i).Cells(表頭(26)).Value <> 0 Then 差異 = 明細_dgv.Rows(i).Cells(表頭(26)).Value - 明細_dgv.Rows(i).Cells("OUP").Value 比對 = 差異 / 明細_dgv.Rows(i).Cells(表頭(26)).Value * 100 If 比對 > 0 Then : 比對 *= 1 : ElseIf 比對 < 0 Then : 比對 *= -1 : End If If 比對 < 比例1 Then ElseIf 比對 > 比例1 And 比對 < 比例2 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen ElseIf 比對 > 比例2 And 比對 < 比例3 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue ElseIf 比對 >= 比例3 Then : 明細_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink : End If End If Next End Sub Private Sub 指定倉庫_cb_下拉表單資料載入() SQL_倉名_下拉清單() : 指定倉庫_cb.Items.Clear() While (dr.Read()) : 指定倉庫_cb.Items.Add(dr("倉名")) : End While : conn.Close() 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(204) = True : 介面 = "H204" : 語言轉換讀取() SQL_清單欄位查詢() If Acdr.Read() Then : 小間距1_ch.Checked = Acdr("L_1_1") : 中間距1_ch.Checked = Acdr("L_2_1") : 大間距1_ch.Checked = Acdr("L_3_1") : End If : Access1.Close() 未受理請購單_bt.Enabled = False : 生成採購單_bt.Enabled = False : 列印成詢價單_bt.Enabled = False : 文字2_lb.Visible = False 採購單_dgv.Visible = False : 明細_dgv.Visible = False : 刪除請購單上點選資料_bt.Enabled = False : 存檔_bt.Enabled = False : 刪除_bt.Enabled = False 需求日期_dtp.Format = DateTimePickerFormat.Custom : 需求日期_dtp.CustomFormat = " " : 系統語言_cb.Text = "Indonesian" : 退回請購單_bt.Enabled = False 單價_rb.Checked = True If 文字_lb.Visible = True Then : 文字2_lb.Visible = False : End If 料號_bt.Visible = False : 料號_dgv.Visible = False : 料號1_tb.Visible = False : Panel1.SendToBack() Label1.Text = 對話框(18) & 比例1 & 對話框(19) & 比例2 & 對話框(20) & 比例2 & 對話框(19) & 比例3 & 對話框(21) & 比例3 指定倉庫_cb_下拉表單資料載入() : yy = True : Set_請購單清單() : Set_清單2() : Set_採購單清單() : yy = False : Set_單價() 採購單詢價_Size() End Sub Private Sub 採購單詢價_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged 採購單詢價_Size() End Sub Private Sub 採購單詢價_Size() MyModule1.清單字體大小調整() 採購單_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) 請購_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(204) = False : MyModule1.虛擬桌面開啟() End Sub Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click 介面 = "H204" : 語言轉換讀取() Set_清單2() : Set_單價() : Set_請購單清單() : Set_採購單清單() : Set_料號比價() Label1.Text = 對話框(18) & 比例1 & 對話框(19) & 比例2 & 對話框(20) & 比例2 & 對話框(19) & 比例3 & 對話框(21) & 比例3 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_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 明細_dgv.MouseUp 'If 明細_dgv.SelectedCells.Count = 1 Then : MsgBox(明細_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_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles 明細_dgv.CellEnter 金額計算() : 價格() End Sub Private Sub 明細_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 明細_dgv.RowPostPaint 價格() End Sub Private Sub 明細_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 明細_dgv.CellClick If e.RowIndex = -1 Then : Else 採購單號_tb.Text = 明細_dgv("採購單號", e.RowIndex).Value.ToString : 項次_tb.Text = 明細_dgv("項次", e.RowIndex).Value.ToString 請購單號1_tb.Text = 明細_dgv(表頭(88), e.RowIndex).Value.ToString : 料號_tb.Text = 明細_dgv("料號", e.RowIndex).Value.ToString 料號1_tb.Text = 明細_dgv("料號", e.RowIndex).Value.ToString 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 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("詢價員", e.RowIndex).Value.ToString : 尋價日期_tb.Text = 採購單_dgv("尋價日期", e.RowIndex).Value.ToString 需求日期_dtp.Value = 採購單_dgv(2, e.RowIndex).Value : 指定倉庫_cb.Text = 採購單_dgv("使用地點", e.RowIndex).Value.ToString Set_採購單清單() End If 生成採購單_bt.Enabled = False End Sub Private Sub 讀取最小需求日期() For i As Integer = 0 To 請購_dgv.Rows.Count - 1 If 請購_dgv.Rows(i).Cells(27).Value = True Then If 請購_dgv.Rows(i).Cells(表頭(30)).Value <> "" Then If 需求日期_dtp.Text = "" Or 需求日期_dtp.Text = " " Then 需求日期_dtp.Format = DateTimePickerFormat.Short 需求日期_dtp.Value = 請購_dgv.Rows(i).Cells(表頭(30)).Value ElseIf 需求日期_dtp.Text <> "" Then If 需求日期_dtp.Value = 請購_dgv.Rows(i).Cells(表頭(30)).Value Then ElseIf 需求日期_dtp.Value > 請購_dgv.Rows(i).Cells(表頭(30)).Value Then 需求日期_dtp.Value = 請購_dgv.Rows(i).Cells(表頭(30)).Value End If End If End If End If Next End Sub Private Sub 請購_dgv_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 請購_dgv.CellClick If e.RowIndex = -1 Then : Else 請購單號_tb.Text = 請購_dgv.Rows(e.RowIndex).Cells(1).Value.ToString PA1 = 請購_dgv.Rows(e.RowIndex).Cells(表頭(62)).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 If 倉庫編號_tb.Text = "" Then MsgBox(對話框(2)) Else 讀取最小需求日期() If 請購_dgv("" & (表頭(44)) & "", e.RowIndex).Value = True Then 請購_dgv("" & (表頭(44)) & "", e.RowIndex).Value = False Else 請購_dgv("" & (表頭(44)) & "", e.RowIndex).Value = True End If If 請購_dgv("" & (表頭(44)) & "", e.RowIndex).Value = True Then 請購_dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.LightGreen Else 請購_dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.White End If PA = 請購_dgv("" & (表頭(77)) & "", e.RowIndex).Value SQL_物料規格表_查詢() '---查詢物規格表中是否有這個料號 If dr.Read() Then Else Dim aa1 As MsgBoxResult = MsgBox(對話框(8) & vbCrLf & 對話框(9) & vbCrLf & 對話框(10), MsgBoxStyle.OkCancel) If aa1 = MsgBoxResult.Ok Then MsgBox(對話框(11)) Else SQL_請購單明細表_刪除一筆資料() '---刪除請購單上選中的資料 請購_dgv("" & (表頭(44)) & "", e.RowIndex).Value = False 請購_dgv.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.White MsgBox(對話框(12)) Set_請購單清單() End If End If End If End If 生成採購單_bt.Enabled = True End Sub Private Sub 請購_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 請購_dgv.RowPostPaint Dim linePen As New Pen(Color.Blue, 2) For i As Integer = 0 To 請購_dgv.Rows.Count - 1 If 請購_dgv("" & (表頭(44)) & "", i).Value = True Then 請購_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen Else 請購_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White End If Next If e.RowIndex = 請購_dgv.Rows.Count - 1 Then : Exit Sub : Else If 請購_dgv(1, e.RowIndex).Value.ToString <> 請購_dgv(1, 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 物料圖_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 指定倉庫_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 指定倉庫_cb.SelectedIndexChanged PA6 = 指定倉庫_cb.Text : SQL_指定倉儲_資料讀取() If dr.Read() Then : 倉庫級別_tb.Text = dr("倉級") : 倉庫編號_tb.Text = dr("倉名編號") : End If : conn.Close() Set_請購單清單() If 倉庫編號_tb.Text = "" Or 選擇公司_cb.Text = "" Then 生成採購單_bt.Enabled = False Else 生成採購單_bt.Enabled = True End If End Sub Private Sub 選擇公司_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 選擇公司_cb.SelectedIndexChanged If 倉庫編號_tb.Text = "" Or 選擇公司_cb.Text = "" Then 生成採購單_bt.Enabled = False Else 生成採購單_bt.Enabled = True End If End Sub Private Sub 需求日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 需求日期_dtp.MouseDown 需求日期_dtp.Format = DateTimePickerFormat.Short 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 : MyModule1.間距設定存檔_1() : Set_請購單清單() : 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 : MyModule1.間距設定存檔_2() : Set_請購單清單() : 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 : MyModule1.間距設定存檔_3() : Set_請購單清單() : Set_採購單清單() End Sub Private Sub 全部選擇_bt_Click(sender As Object, e As EventArgs) Handles 全部選擇_bt.Click If 倉庫編號_tb.Text = "" Then MsgBox(對話框(2)) Else For i As Integer = 0 To 請購_dgv.Rows.Count - 1 : 請購_dgv.Rows(i).Cells(表頭(44)).Value = True : Next i 讀取最小需求日期() End If End Sub Private Sub 全部取消_bt_Click(sender As Object, e As EventArgs) Handles 全部取消_bt.Click If 倉庫編號_tb.Text = "" Then MsgBox(對話框(2)) Else For i As Integer = 0 To 請購_dgv.Rows.Count - 1 : 請購_dgv.Rows(i).Cells(表頭(44)).Value = False : Next i 讀取最小需求日期() End If End Sub Private Sub 依據入庫單號全部選擇_bt_Click(sender As Object, e As EventArgs) Handles 依據入庫單號全部選擇_bt.Click If 倉庫編號_tb.Text = "" Then MsgBox(對話框(2)) Else For i As Integer = 0 To 請購_dgv.Rows.Count - 1 If 請購單號_tb.Text = 請購_dgv.Rows(i).Cells(1).Value.ToString Then 請購_dgv.Rows(i).Cells(表頭(44)).Value = True End If Next i 讀取最小需求日期() End If End Sub Private Sub 未受理請購單_bt_Click(sender As Object, e As EventArgs) Handles 未受理請購單_bt.Click 未受理請購單_bt.Enabled = False : 詢價中的採購單_bt.Enabled = True 採購單_dgv.Visible = False : 明細_dgv.Visible = False : 請購_dgv.Visible = True : 文字_lb.Visible = True : 文字2_lb.Visible = False 刪除請購單上點選資料_bt.Enabled = False : 存檔_bt.Enabled = False : 刪除_bt.Enabled = False : 列印成詢價單_bt.Enabled = False 退回請購單_bt.Enabled = False : 料號_bt.Visible = False : 料號_dgv.Visible = False : 料號1_tb.Visible = False End Sub Private Sub 未指定廠商採購單_bt_Click(sender As Object, e As EventArgs) Handles 詢價中的採購單_bt.Click 未受理請購單_bt.Enabled = True : 詢價中的採購單_bt.Enabled = False 採購單_dgv.Visible = True : 明細_dgv.Visible = True : 請購_dgv.Visible = False : 文字2_lb.Visible = True : 文字_lb.Visible = False : 全部取消_bt.Enabled = False 刪除請購單上點選資料_bt.Enabled = True : 存檔_bt.Enabled = True : 刪除_bt.Enabled = True : 列印成詢價單_bt.Enabled = True : 全部選擇_bt.Enabled = False 退回請購單_bt.Enabled = True : 生成採購單_bt.Enabled = False : 料號_bt.Visible = True : 料號1_tb.Visible = True End Sub Private Sub Set_日期格式轉換() DTP = Strings.Format(Today(), "yyyy/MM/dd") : DTP1 = Strings.Format(Today(), "yyyyMMdd") : DTP2 = Strings.Format(需求日期_dtp.Value, "yyyy/MM/dd") End Sub Private Sub 確定新增() Set_日期格式轉換() PA1 = 採購單號_tb.Text : PA2 = "" : PA3 = 指定倉庫_cb.Text : PA4 = "" : PA5 = "" : PA6 = "" : PA7 = "0" : BL1 = 0 : PA8 = "5" SQL_採購單控制表_新增() : conn.Close() For i As Integer = 0 To 請購_dgv.Rows.Count - 1 資料數 = 請購_dgv.Rows.Count : MyModule1.進度條() If 請購_dgv.Rows(i).Cells(表頭(44)).Value = True Then PA9 = 請購_dgv.Rows(i).Cells(表頭(44)).Value : PA2 = 請購_dgv.Rows(i).Cells(表頭(88)).Value : PA3 = 請購_dgv.Rows(i).Cells("項次").Value PA4 = 請購_dgv.Rows(i).Cells(表頭(12)).Value : PA5 = 請購_dgv.Rows(i).Cells(表頭(13)).Value : PA6 = 請購_dgv.Rows(i).Cells(表頭(14)).Value NU1 = 請購_dgv.Rows(i).Cells(表頭(15)).Value : PA8 = 請購_dgv.Rows(i).Cells(表頭(16)).Value : PA10 = "0" '--單價還未帶出 PA11 = 請購_dgv.Rows(i).Cells(表頭(62)).Value : PA12 = 請購_dgv.Rows(i).Cells("群組原則").Value : PA13 = 請購_dgv.Rows(i).Cells(表頭(77)).Value PA14 = 請購_dgv.Rows(i).Cells(表頭(134)).Value : PA15 = 請購_dgv.Rows(i).Cells(表頭(19)).Value SQL_請購單明細表_轉採修改() : SQL_採購單明細表_新增() : conn.Close() End If Next : HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 MsgBox(對話框(1)) End Sub Private Sub 確定退回() Set_日期格式轉換() If 採購單號_tb.Text = "" Or 料號_tb.Text = "" Then MsgBox(對話框(4)) Else Dim FF As Integer For i As Integer = 0 To 明細_dgv.Rows.Count - 1 If 明細_dgv.Rows(i).Cells("Cancel order").Value = True Then FF += 1 End If Next If 明細_dgv.Rows.Count = FF Then PA1 = 採購單號_tb.Text SQL_採購單控制表_刪除() : conn.Close() For i As Integer = 0 To 明細_dgv.Rows.Count - 1 If 明細_dgv.Rows(i).Cells("Cancel order").Value = True Then PA2 = 明細_dgv.Rows(i).Cells(表頭(88)).Value : PA3 = 明細_dgv.Rows(i).Cells("項次").Value SQL_請購單明細表_退採修改() : SQL_採購單明細表_刪除() : conn.Close() End If Next HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 Set_請購單清單() : Set_採購單清單() : Set_清單2() : MsgBox(對話框(14)) ElseIf 明細_dgv.Rows.Count > FF Then PA1 = 採購單號_tb.Text For i As Integer = 0 To 明細_dgv.Rows.Count - 1 If 明細_dgv.Rows(i).Cells("Cancel order").Value = True Then PA2 = 明細_dgv.Rows(i).Cells(表頭(88)).Value : PA3 = 明細_dgv.Rows(i).Cells("項次").Value SQL_請購單明細表_退採修改() : SQL_採購單明細表_刪除() : conn.Close() End If Next HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 Set_請購單清單() : Set_採購單清單() : Set_清單2() : MsgBox(對話框(15)) End If End If End Sub Private Sub 退回請購單_bt_Click(sender As Object, e As EventArgs) Handles 退回請購單_bt.Click Dim FF As Boolean For i As Integer = 0 To 明細_dgv.Rows.Count - 1 FF = 明細_dgv.Rows(i).Cells("Cancel order").Value If FF = True Then Exit For End If Next If FF = True Then 確定退回() : Set_採購單清單() : Set_清單2() : Set_請購單清單() Else MsgBox(對話框(16)) End If End Sub Private Sub 新增採購單_() If 選擇公司_cb.Text = "PT HONG XHE INDUSTRIAL" Then Set_日期格式轉換() : Dim NUM1 As Integer For i As Integer = 1 To 999 NUM1 = 0 + i If NUM1 < 10 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-00" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-0" & NUM1 ElseIf NUM1 > 99 Then : 採購單號_tb.Text = "HXI-C-" & DTP1 & "-" & NUM1 End If PA1 = 採購單號_tb.Text SQL_採購單控制表_單號最後一筆() : If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close() Next 確定新增() ElseIf 選擇公司_cb.Text = "PT PUNCAK GEMILANG SEMESTA" Then Set_日期格式轉換() : Dim NUM1 As Integer For i As Integer = 1 To 999 NUM1 = 0 + i If NUM1 < 10 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-00" & NUM1 ElseIf NUM1 > 9 And NUM1 < 100 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-0" & NUM1 ElseIf NUM1 > 99 Then : 採購單號_tb.Text = "PGS-C-" & DTP1 & "-" & NUM1 End If PA1 = 採購單號_tb.Text SQL_採購單控制表_單號最後一筆() : If dr.Read() Then : Else : i = 999 : conn.Close() : End If : conn.Close() Next 確定新增() End If 指定倉庫_cb_下拉表單資料載入() : Set_清單2() : Set_請購單清單() End Sub Private Sub 生成採購單_bt_Click(sender As Object, e As EventArgs) Handles 生成採購單_bt.Click Dim 判斷有選 As Boolean = False For i As Integer = 0 To 請購_dgv.Rows.Count - 1 If 請購_dgv.Rows(i).Cells(表頭(44)).Value = True Then 判斷有選 = True : Exit For End If Next If 判斷有選 = True Then If 採購單號_tb.Text <> "" Then Dim aa1 As MsgBoxResult = MsgBox(對話框(17), MsgBoxStyle.OkCancel) If aa1 = MsgBoxResult.Ok Then Set_日期格式轉換() PA1 = 採購單號_tb.Text For i As Integer = 0 To 請購_dgv.Rows.Count - 1 資料數 = 請購_dgv.Rows.Count : MyModule1.進度條() If 請購_dgv.Rows(i).Cells(表頭(44)).Value = True Then PA9 = 請購_dgv.Rows(i).Cells(表頭(44)).Value : PA2 = 請購_dgv.Rows(i).Cells(表頭(88)).Value : PA3 = 請購_dgv.Rows(i).Cells("項次").Value PA4 = 請購_dgv.Rows(i).Cells(表頭(12)).Value : PA5 = 請購_dgv.Rows(i).Cells(表頭(13)).Value : PA6 = 請購_dgv.Rows(i).Cells(表頭(14)).Value NU1 = 請購_dgv.Rows(i).Cells(表頭(15)).Value : PA8 = 請購_dgv.Rows(i).Cells(表頭(16)).Value : PA10 = "0" '--單價還未帶出 PA11 = 請購_dgv.Rows(i).Cells(表頭(62)).Value : PA12 = 請購_dgv.Rows(i).Cells("群組原則").Value : PA13 = 請購_dgv.Rows(i).Cells(表頭(77)).Value PA14 = 請購_dgv.Rows(i).Cells(表頭(134)).Value : PA15 = 請購_dgv.Rows(i).Cells(表頭(19)).Value SQL_請購單明細表_轉採修改() : SQL_採購單明細表_新增() : conn.Close() End If Next : HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 MsgBox(對話框(1)) 指定倉庫_cb_下拉表單資料載入() : Set_清單2() : Set_請購單清單() Else 新增採購單_() End If Else 新增採購單_() End If Else MsgBox(對話框(0)) End If End Sub Private Sub 刪除請購單上點選資料_bt_Click(sender As Object, e As EventArgs) Handles 刪除請購單上點選資料_bt.Click If 請購單號1_tb.Text = "" Then MsgBox(對話框(3)) Else If 項次_tb.Text = "" Then MsgBox(對話框(4)) Else Dim aa1 As MsgBoxResult aa1 = MsgBox(對話框(5), MsgBoxStyle.OkCancel) If aa1 = MsgBoxResult.Ok Then If 明細_dgv.Rows.Count <= 1 Then 刪除() Else PA2 = 請購單號1_tb.Text : PA3 = 項次_tb.Text : PA9 = "0" : PA1 = 料號_tb.Text : PA = 採購單號_tb.Text SQL_請購單明細表_轉採修改() : SQL_採購單詢價_採購明細刪除() : conn.Close() Set_請購單清單() : Set_清單2() : Set_採購單清單() End If End If End If End If End Sub Private Sub 存檔() Set_日期格式轉換() PA5 = 採購單號_tb.Text For i As Integer = 0 To 明細_dgv.Rows.Count - 1 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條() PA6 = 明細_dgv.Rows(i).Cells("" & 表頭(14) & "").Value : PA7 = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value PA8 = 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value : PA9 = 明細_dgv.Rows(i).Cells("" & 表頭(16) & "").Value PA10 = 明細_dgv.Rows(i).Cells("項次").Value : PA4 = 明細_dgv.Rows(i).Cells("" & 表頭(88) & "").Value SQL_採購單明細表_修改() : conn.Close() Next Set_採購單清單() : MsgBox(對話框(6)) : HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 End Sub Private Sub 存檔_bt_Click(sender As Object, e As EventArgs) Handles 存檔_bt.Click 存檔() End Sub Private Sub 刪除_bt_Click(sender As Object, e As EventArgs) Handles 刪除_bt.Click Dim aa1 As MsgBoxResult = MsgBox(對話框(5), MsgBoxStyle.OkCancel) If aa1 = MsgBoxResult.Ok Then : 刪除() : End If End Sub Private Sub 刪除() For i As Integer = 0 To 明細_dgv.Rows.Count - 1 資料數 = 明細_dgv.Rows.Count : MyModule1.進度條() PA2 = 明細_dgv.Rows(i).Cells("" & 表頭(88) & "").Value : PA3 = 明細_dgv.Rows(i).Cells("項次").Value : PA9 = "0" SQL_請購單明細表_轉採修改() : conn.Close() Next : HX_PGS_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0 PA = 採購單號_tb.Text SQL_採購單詢價_控制刪除() : SQL_採購單詢價_明細刪除() : conn.Close() Set_請購單清單() : Set_清單2() : Set_採購單清單() End Sub Private Sub 單價_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 單價_rb.Click Set_單價() End Sub Private Sub 日期_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 日期_rb.Click Set_單價() End Sub Private Sub 料號_bt_Click(sender As Object, e As EventArgs) Handles 料號_bt.Click Set_料號比價() If 料號1_tb.Text = "" Then : MsgBox(對話框(22)) : Else : If 料號_dgv.Visible = True Then : 料號_dgv.Visible = False : Else : 料號_dgv.Visible = True : End If : 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_請購單清單() : Set_採購單清單() End Sub Private Sub 列印成詢價單_bt_Click(sender As Object, e As EventArgs) Handles 列印成詢價單_bt.Click Dim zz As Integer For i As Integer = 0 To 明細_dgv.Rows.Count - 1 '明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value = "0.0" 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value = 明細_dgv.Rows(i).Cells("" & 表頭(26) & "").Value * 明細_dgv.Rows(i).Cells("" & 表頭(15) & "").Value zz = Val(zz) + 明細_dgv.Rows(i).Cells("" & 表頭(27) & "").Value Next i If zz > 0 Then 存檔() If 採購單號_tb.Text = "" Then MsgBox(對話框(2)) Else 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(2, 1) = 選擇公司_cb.Text : xlSheet.Cells(3, 1) = "MINTA PESANAN HARGA" xlSheet.Cells(5, 1) = "ORDER TO : " : xlSheet.Cells(6, 1) = "ALAMAT : " : xlSheet.Cells(7, 1) = "Telp : " xlSheet.Cells(8, 1) = "Fax : " : xlSheet.Cells(9, 1) = "Email : " 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(7, 5) = "PO NOMOR : " : 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 : " 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("" & 表頭(11) & "").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 % :" : xlSheet.Cells(N1 + 3, 8) = "" xlSheet.Cells(N1 + 4, 7) = "PPN % :" : xlSheet.Cells(N1 + 4, 8) = "" xlSheet.Cells(N1 + 5, 7) = "GRAND TOTAL :" : xlSheet.Cells(N1 + 5, 8) = "" xlSheet.Cells(N1 + 6, 1) = "Bagian Pembelian Barang" xlSheet.Cells(N1 + 6, 3) = "Direktur Utama" xlSheet.Cells(N1 + 6, 4) = "Bagian Pemeriksa" 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) = "" : xlSheet.Cells(N1 + 9, 8) = "" 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(對話框(7)) End If Else MsgBox(對話框(13)) End If 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 = 30 : 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 = 5 : xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 35 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 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 = "" : .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 : .CenterHorizontally = True : .CenterVertically = False : .Draft = False : .FirstPageNumber = xlAutomatic .BlackAndWhite = False : .Zoom = 60 : .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 End Class