No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

人員薪資.vb 221KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000
  1. Option Explicit On
  2. Imports System.IO
  3. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  4. Imports Microsoft.Office.Interop.Excel.Constants
  5. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  6. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  7. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  8. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  9. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  10. Imports Microsoft.Office.Interop.Excel.XlWindowState
  11. Imports Microsoft.Office.Interop.Excel.XlPageOrientation
  12. Imports Microsoft.Office.Interop.Excel
  13. Imports PdfSharp.Pdf
  14. Imports PdfSharp.Pdf.IO
  15. Public Class 人員薪資
  16. Dim 對話框(17) As String
  17. Dim 間隔1, 時長, 總時, VBN, CBN, GN1, 之前選擇 As Integer
  18. Dim 時段(6), 計算(6), X1, AUTO時, AUTO舊1, AUTO舊2 As String
  19. Dim 本周周一 As Date
  20. Dim xlApp As Application
  21. Dim xlBook As Workbook
  22. Dim xlSheet As Worksheet
  23. Private Function IsVerticalScrollBarVisible(dgv As DataGridView) As Boolean
  24. Return dgv.FirstDisplayedScrollingRowIndex > 0 OrElse dgv.DisplayedRowCount(False) < dgv.Rows.Count
  25. End Function
  26. Private Sub 語言轉換讀取()
  27. If 系統語言 = "繁體中文" Then : 語言 = "CH" : ElseIf 系統語言 = "English" Then : 語言 = "EN" : ElseIf 系統語言 = "Indonesian" Then : 語言 = "IN" : End If
  28. 對話框(16) = 系統語言字典("H609-141-" & 語言) : 對話框(17) = 系統語言字典("H609-142-" & 語言) : 表頭(0) = 系統語言字典("H601-103-" & 語言)
  29. 表頭(1) = 系統語言字典("H602-104-" & 語言) : 表頭(2) = 系統語言字典("H609-107-" & 語言) : 表頭(3) = 系統語言字典("H609-108-" & 語言)
  30. 表頭(4) = 系統語言字典("H609-109-" & 語言) : 表頭(5) = 系統語言字典("H609-110-" & 語言) : 表頭(6) = 系統語言字典("H609-111-" & 語言)
  31. 表頭(7) = 系統語言字典("H609-112-" & 語言) : 表頭(8) = 系統語言字典("H609-113-" & 語言) : 表頭(9) = 系統語言字典("H609-114-" & 語言)
  32. 表頭(10) = 系統語言字典("H609-115-" & 語言) : 表頭(11) = 系統語言字典("H609-116-" & 語言) : 表頭(12) = 系統語言字典("H609-117-" & 語言)
  33. 表頭(13) = 系統語言字典("H609-118-" & 語言) : 表頭(14) = 系統語言字典("H609-119-" & 語言) : 表頭(15) = 系統語言字典("H609-120-" & 語言)
  34. 表頭(16) = 系統語言字典("H609-123-" & 語言) : 表頭(17) = 系統語言字典("H609-124-" & 語言) : 表頭(18) = 系統語言字典("H609-128-" & 語言)
  35. 表頭(19) = 系統語言字典("H601-108-" & 語言) : 表頭(20) = 系統語言字典("H609-129-" & 語言) : 表頭(21) = 系統語言字典("H609-125-" & 語言)
  36. 表頭(22) = 系統語言字典("H607-103-" & 語言) : 表頭(23) = 系統語言字典("H609-130-" & 語言) : 表頭(24) = 系統語言字典("H609-131-" & 語言)
  37. 表頭(25) = 系統語言字典("H609-132-" & 語言) : 表頭(26) = 系統語言字典("H611-105-" & 語言) : 表頭(27) = 系統語言字典("H611-106-" & 語言)
  38. 表頭(28) = 系統語言字典("H611-107-" & 語言) : 表頭(29) = 系統語言字典("H611-108-" & 語言) : 工人_ch.Text = 系統語言字典("G000-159-" & 語言)
  39. 對話框(0) = 系統語言字典("H611-100-" & 語言) : 對話框(1) = 系統語言字典("H611-101-" & 語言) : 對話框(2) = 系統語言字典("H611-102-" & 語言)
  40. 對話框(3) = 系統語言字典("H611-103-" & 語言) : 對話框(4) = 系統語言字典("H611-104-" & 語言) : 表頭(30) = 系統語言字典("H611-109-" & 語言)
  41. DA1_bt.Text = 系統語言字典("H611-111-" & 語言) : DA2_bt.Text = 系統語言字典("H611-112-" & 語言) : DA3_bt.Text = 系統語言字典("H611-113-" & 語言)
  42. 群組輸入_ch.Text = 系統語言字典("H611-114-" & 語言) : 群組選擇_ch.Text = 系統語言字典("H611-115-" & 語言) : 考勤表_bt.Text = 系統語言字典("H611-116-" & 語言)
  43. 薪資表_bt.Text = 系統語言字典("H611-117-" & 語言) : Label11.Text = 系統語言字典("H611-118-" & 語言) : Label1.Text = 系統語言字典("H611-119-" & 語言)
  44. Label7.Text = 系統語言字典("H609-124-" & 語言) : Label1.Text = 系統語言字典("H611-120-" & 語言)
  45. 表頭(64) = 系統語言字典("H611-122-" & 語言) : 表頭(31) = 系統語言字典("H611-123-" & 語言) : 表頭(32) = 系統語言字典("H611-124-" & 語言)
  46. 表頭(33) = 系統語言字典("H611-125-" & 語言) : 表頭(34) = 系統語言字典("H611-126-" & 語言) : 表頭(35) = 系統語言字典("H611-127-" & 語言)
  47. 表頭(36) = 系統語言字典("H611-128-" & 語言) : 表頭(37) = 系統語言字典("H611-129-" & 語言) : 表頭(38) = 系統語言字典("H611-130-" & 語言)
  48. 表頭(39) = 系統語言字典("H611-131-" & 語言) : 表頭(40) = 系統語言字典("H611-132-" & 語言) : 表頭(41) = 系統語言字典("H611-133-" & 語言)
  49. 表頭(42) = 系統語言字典("H611-134-" & 語言) : 表頭(43) = 系統語言字典("H611-135-" & 語言) : 表頭(44) = 系統語言字典("H611-136-" & 語言)
  50. 表頭(45) = 系統語言字典("H611-137-" & 語言) : 表頭(46) = 系統語言字典("H611-138-" & 語言) : 表頭(47) = 系統語言字典("H611-139-" & 語言)
  51. 表頭(48) = 系統語言字典("H611-140-" & 語言) : 表頭(49) = 系統語言字典("H611-141-" & 語言) : 表頭(50) = 系統語言字典("H611-142-" & 語言)
  52. 表頭(51) = 系統語言字典("H611-143-" & 語言) : 表頭(52) = 系統語言字典("H611-144-" & 語言) : 表頭(53) = 系統語言字典("H611-145-" & 語言)
  53. 表頭(54) = 系統語言字典("H611-146-" & 語言) : 表頭(55) = 系統語言字典("H611-147-" & 語言) : 表頭(56) = 系統語言字典("H611-148-" & 語言)
  54. 表頭(57) = 系統語言字典("H611-149-" & 語言) : 表頭(58) = 系統語言字典("H611-150-" & 語言) : 表頭(59) = 系統語言字典("H611-151-" & 語言)
  55. 表頭(60) = 系統語言字典("H611-152-" & 語言) : 表頭(61) = 系統語言字典("H611-153-" & 語言) : 表頭(62) = 系統語言字典("H611-154-" & 語言)
  56. 表頭(63) = 系統語言字典("H611-155-" & 語言)
  57. End Sub
  58. Private Sub Set_使用者清單()
  59. Set_總清單() : Set_虛擬表() : Dim ds1, ds2 As New DataSet
  60. 清單1_dgv.DataSource = Nothing : ds1.Clear()
  61. 清單1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  62. 清單1_dgv.ColumnHeadersHeight = 45 : 清單1_dgv.AllowUserToAddRows = False : 清單1_dgv.RowTemplate.Height = 35
  63. 合計_dgv.DataSource = Nothing : ds2.Clear()
  64. 合計_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  65. 合計_dgv.ColumnHeadersHeight = 45 : 合計_dgv.AllowUserToAddRows = False : 合計_dgv.RowTemplate.Height = 35
  66. 合計_dgv.ColumnHeadersVisible = False
  67. If 群組1_cb.Text = "HARIAN GROUP" Then
  68. SQL5 = ""
  69. SQL4 = "[HX-PGS-MSN].dbo.人員資料表.員工代碼"
  70. Else
  71. SQL5 = " AND [HX-PGS-MSN].dbo.人員資料表.部門名稱 NOT LIKE 'HARIAN GROUP'"
  72. SQL4 = "[HX-PGS-MSN].dbo.人員資料表.部門名稱,使用者權限管理表.姓名"
  73. End If
  74. PA25 = 地區_cb.SelectedIndex : SQL3 = "" : PA14 = 級別_cb.Text : PA19 = 群組_cb.Text
  75. SQL_人員薪資表1() : da.Fill(ds1) : 清單1_dgv.DataSource = ds1.Tables(0) : conn.Close()
  76. SQL_人員薪資表2() : da.Fill(ds2) : 合計_dgv.DataSource = ds2.Tables(0) : conn.Close() : PA25 = ""
  77. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  78. If 清單1_dgv.Rows(i).Cells(12).Value.ToString = "" Then : 清單1_dgv.Rows(i).Cells(12).Value = 0 : End If
  79. Next
  80. 清單1_dgv.Columns("Save.").FillWeight = 40 : 清單1_dgv.Columns(12).Visible = True : 清單1_dgv.Columns(50).Visible = False : 清單1_dgv.Columns(0).FillWeight = 120
  81. 清單1_dgv.Columns(4).FillWeight = 25
  82. 合計_dgv.Columns("Save.").FillWeight = 40 : 合計_dgv.Columns(12).Visible = True : 合計_dgv.Columns(50).Visible = False : 合計_dgv.Columns(0).FillWeight = 120
  83. 合計_dgv.Columns(4).FillWeight = 25
  84. For i As Integer = 2 To 14 : 清單1_dgv.Columns(i).Visible = False : Next : For i As Integer = 29 To 48 : 清單1_dgv.Columns(i).Visible = False : Next
  85. For i As Integer = 15 To 28 : 清單1_dgv.Columns(i).FillWeight = 60 : Next : For i As Integer = 29 To 34 : 清單1_dgv.Columns(i).FillWeight = 60 : Next
  86. For i As Integer = 35 To 48 : 清單1_dgv.Columns(i).FillWeight = 40 : Next : 清單1_dgv.Columns(12).Visible = True : 清單1_dgv.Columns(4).Visible = True
  87. For i As Integer = 1 To 50 : 清單1_dgv.Columns(i).ReadOnly = True : Next
  88. If 群組選擇_ch.Checked = True Then : 清單1_dgv.Columns(0).ReadOnly = True : Else : 清單1_dgv.Columns(0).ReadOnly = False : End If
  89. 清單1_dgv.Columns(12).ReadOnly = False
  90. For i As Integer = 2 To 14 : 合計_dgv.Columns(i).Visible = False : Next : For i As Integer = 29 To 48 : 合計_dgv.Columns(i).Visible = False : Next
  91. For i As Integer = 15 To 28 : 合計_dgv.Columns(i).FillWeight = 60 : Next : For i As Integer = 29 To 34 : 合計_dgv.Columns(i).FillWeight = 60 : Next
  92. For i As Integer = 35 To 48 : 合計_dgv.Columns(i).FillWeight = 40 : Next : 合計_dgv.Columns(12).Visible = True : 合計_dgv.Columns(4).Visible = True
  93. For i As Integer = 1 To 50 : 合計_dgv.Columns(i).ReadOnly = True : Next
  94. If 群組選擇_ch.Checked = True Then : 合計_dgv.Columns(0).ReadOnly = True : Else : 合計_dgv.Columns(0).ReadOnly = False : End If
  95. 合計_dgv.Columns(12).ReadOnly = False
  96. 清單1_dgv.Columns(12).DefaultCellStyle.Format = "#,##0" : 清單1_dgv.Columns(13).DefaultCellStyle.Format = "#,##0"
  97. For i As Integer = 4 To 11
  98. 清單1_dgv.Columns(i).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  99. 清單1_dgv.Columns(i).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  100. Next
  101. For i As Integer = 12 To 48
  102. 清單1_dgv.Columns(i).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  103. 清單1_dgv.Columns(i).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  104. Next
  105. If 深色風格 = False Then
  106. 清單1_dgv.Columns(15).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(16).DefaultCellStyle.ForeColor = Color.Red
  107. 清單1_dgv.Columns(17).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(18).DefaultCellStyle.ForeColor = Color.Blue
  108. 清單1_dgv.Columns(19).DefaultCellStyle.ForeColor = Color.Green : 清單1_dgv.Columns(20).DefaultCellStyle.ForeColor = Color.Green
  109. 清單1_dgv.Columns(21).DefaultCellStyle.ForeColor = Color.Coral : 清單1_dgv.Columns(22).DefaultCellStyle.ForeColor = Color.Coral
  110. 清單1_dgv.Columns(23).DefaultCellStyle.ForeColor = Color.Cyan : 清單1_dgv.Columns(24).DefaultCellStyle.ForeColor = Color.Cyan
  111. 清單1_dgv.Columns(25).DefaultCellStyle.ForeColor = Color.Salmon : 清單1_dgv.Columns(26).DefaultCellStyle.ForeColor = Color.Salmon
  112. 清單1_dgv.Columns(27).DefaultCellStyle.ForeColor = Color.SlateGray : 清單1_dgv.Columns(28).DefaultCellStyle.ForeColor = Color.SlateGray
  113. 清單1_dgv.Columns(29).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(30).DefaultCellStyle.ForeColor = Color.Red
  114. 清單1_dgv.Columns(31).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(32).DefaultCellStyle.ForeColor = Color.Blue
  115. 清單1_dgv.Columns(33).DefaultCellStyle.ForeColor = Color.Green : 清單1_dgv.Columns(34).DefaultCellStyle.ForeColor = Color.Green
  116. 清單1_dgv.Columns(35).DefaultCellStyle.ForeColor = Color.Coral : 清單1_dgv.Columns(36).DefaultCellStyle.ForeColor = Color.Coral
  117. 清單1_dgv.Columns(37).DefaultCellStyle.ForeColor = Color.Cyan : 清單1_dgv.Columns(38).DefaultCellStyle.ForeColor = Color.Cyan
  118. 清單1_dgv.Columns(39).DefaultCellStyle.ForeColor = Color.Salmon : 清單1_dgv.Columns(40).DefaultCellStyle.ForeColor = Color.Salmon
  119. 清單1_dgv.Columns(41).DefaultCellStyle.ForeColor = Color.SlateGray : 清單1_dgv.Columns(42).DefaultCellStyle.ForeColor = Color.SlateGray
  120. 清單1_dgv.Columns(43).DefaultCellStyle.ForeColor = Color.Red : 清單1_dgv.Columns(44).DefaultCellStyle.ForeColor = Color.Red
  121. 清單1_dgv.Columns(45).DefaultCellStyle.ForeColor = Color.Blue : 清單1_dgv.Columns(46).DefaultCellStyle.ForeColor = Color.Blue
  122. 清單1_dgv.Columns(47).DefaultCellStyle.ForeColor = Color.Green : 清單1_dgv.Columns(48).DefaultCellStyle.ForeColor = Color.Green
  123. Else
  124. 清單1_dgv.Columns(15).DefaultCellStyle.ForeColor = Color.LightPink : 清單1_dgv.Columns(16).DefaultCellStyle.ForeColor = Color.LightPink
  125. 清單1_dgv.Columns(17).DefaultCellStyle.ForeColor = Color.LightBlue : 清單1_dgv.Columns(18).DefaultCellStyle.ForeColor = Color.LightBlue
  126. 清單1_dgv.Columns(19).DefaultCellStyle.ForeColor = Color.LightGreen : 清單1_dgv.Columns(20).DefaultCellStyle.ForeColor = Color.LightGreen
  127. 清單1_dgv.Columns(21).DefaultCellStyle.ForeColor = Color.LightCoral : 清單1_dgv.Columns(22).DefaultCellStyle.ForeColor = Color.LightCoral
  128. 清單1_dgv.Columns(23).DefaultCellStyle.ForeColor = Color.LightCyan : 清單1_dgv.Columns(24).DefaultCellStyle.ForeColor = Color.LightCyan
  129. 清單1_dgv.Columns(25).DefaultCellStyle.ForeColor = Color.LightSalmon : 清單1_dgv.Columns(26).DefaultCellStyle.ForeColor = Color.LightSalmon
  130. 清單1_dgv.Columns(27).DefaultCellStyle.ForeColor = Color.LightSlateGray : 清單1_dgv.Columns(28).DefaultCellStyle.ForeColor = Color.LightSlateGray
  131. 清單1_dgv.Columns(29).DefaultCellStyle.ForeColor = Color.LightPink : 清單1_dgv.Columns(30).DefaultCellStyle.ForeColor = Color.LightPink
  132. 清單1_dgv.Columns(31).DefaultCellStyle.ForeColor = Color.LightBlue : 清單1_dgv.Columns(32).DefaultCellStyle.ForeColor = Color.LightBlue
  133. 清單1_dgv.Columns(33).DefaultCellStyle.ForeColor = Color.LightGreen : 清單1_dgv.Columns(34).DefaultCellStyle.ForeColor = Color.LightGreen
  134. 清單1_dgv.Columns(35).DefaultCellStyle.ForeColor = Color.LightCoral : 清單1_dgv.Columns(36).DefaultCellStyle.ForeColor = Color.LightCoral
  135. 清單1_dgv.Columns(37).DefaultCellStyle.ForeColor = Color.LightCyan : 清單1_dgv.Columns(38).DefaultCellStyle.ForeColor = Color.LightCyan
  136. 清單1_dgv.Columns(39).DefaultCellStyle.ForeColor = Color.LightSalmon : 清單1_dgv.Columns(40).DefaultCellStyle.ForeColor = Color.LightSalmon
  137. 清單1_dgv.Columns(41).DefaultCellStyle.ForeColor = Color.LightSlateGray : 清單1_dgv.Columns(42).DefaultCellStyle.ForeColor = Color.LightSlateGray
  138. 清單1_dgv.Columns(43).DefaultCellStyle.ForeColor = Color.LightPink : 清單1_dgv.Columns(44).DefaultCellStyle.ForeColor = Color.LightPink
  139. 清單1_dgv.Columns(45).DefaultCellStyle.ForeColor = Color.LightBlue : 清單1_dgv.Columns(46).DefaultCellStyle.ForeColor = Color.LightBlue
  140. 清單1_dgv.Columns(47).DefaultCellStyle.ForeColor = Color.LightGreen : 清單1_dgv.Columns(48).DefaultCellStyle.ForeColor = Color.LightGreen
  141. End If : 清單1_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  142. 合計_dgv.Columns(12).DefaultCellStyle.Format = "#,##0" : 合計_dgv.Columns(13).DefaultCellStyle.Format = "#,##0"
  143. For i As Integer = 4 To 11
  144. 合計_dgv.Columns(i).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  145. 合計_dgv.Columns(i).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  146. Next
  147. For i As Integer = 12 To 48
  148. 合計_dgv.Columns(i).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  149. 合計_dgv.Columns(i).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  150. Next
  151. If 深色風格 = False Then
  152. 合計_dgv.Columns(15).DefaultCellStyle.ForeColor = Color.Red : 合計_dgv.Columns(16).DefaultCellStyle.ForeColor = Color.Red
  153. 合計_dgv.Columns(17).DefaultCellStyle.ForeColor = Color.Blue : 合計_dgv.Columns(18).DefaultCellStyle.ForeColor = Color.Blue
  154. 合計_dgv.Columns(19).DefaultCellStyle.ForeColor = Color.Green : 合計_dgv.Columns(20).DefaultCellStyle.ForeColor = Color.Green
  155. 合計_dgv.Columns(21).DefaultCellStyle.ForeColor = Color.Coral : 合計_dgv.Columns(22).DefaultCellStyle.ForeColor = Color.Coral
  156. 合計_dgv.Columns(23).DefaultCellStyle.ForeColor = Color.Cyan : 合計_dgv.Columns(24).DefaultCellStyle.ForeColor = Color.Cyan
  157. 合計_dgv.Columns(25).DefaultCellStyle.ForeColor = Color.Salmon : 合計_dgv.Columns(26).DefaultCellStyle.ForeColor = Color.Salmon
  158. 合計_dgv.Columns(27).DefaultCellStyle.ForeColor = Color.SlateGray : 合計_dgv.Columns(28).DefaultCellStyle.ForeColor = Color.SlateGray
  159. 合計_dgv.Columns(29).DefaultCellStyle.ForeColor = Color.Red : 合計_dgv.Columns(30).DefaultCellStyle.ForeColor = Color.Red
  160. 合計_dgv.Columns(31).DefaultCellStyle.ForeColor = Color.Blue : 合計_dgv.Columns(32).DefaultCellStyle.ForeColor = Color.Blue
  161. 合計_dgv.Columns(33).DefaultCellStyle.ForeColor = Color.Green : 合計_dgv.Columns(34).DefaultCellStyle.ForeColor = Color.Green
  162. 合計_dgv.Columns(35).DefaultCellStyle.ForeColor = Color.Coral : 合計_dgv.Columns(36).DefaultCellStyle.ForeColor = Color.Coral
  163. 合計_dgv.Columns(37).DefaultCellStyle.ForeColor = Color.Cyan : 合計_dgv.Columns(38).DefaultCellStyle.ForeColor = Color.Cyan
  164. 合計_dgv.Columns(39).DefaultCellStyle.ForeColor = Color.Salmon : 合計_dgv.Columns(40).DefaultCellStyle.ForeColor = Color.Salmon
  165. 合計_dgv.Columns(41).DefaultCellStyle.ForeColor = Color.SlateGray : 合計_dgv.Columns(42).DefaultCellStyle.ForeColor = Color.SlateGray
  166. 合計_dgv.Columns(43).DefaultCellStyle.ForeColor = Color.Red : 合計_dgv.Columns(44).DefaultCellStyle.ForeColor = Color.Red
  167. 合計_dgv.Columns(45).DefaultCellStyle.ForeColor = Color.Blue : 合計_dgv.Columns(46).DefaultCellStyle.ForeColor = Color.Blue
  168. 合計_dgv.Columns(47).DefaultCellStyle.ForeColor = Color.Green : 合計_dgv.Columns(48).DefaultCellStyle.ForeColor = Color.Green
  169. Else
  170. 合計_dgv.Columns(15).DefaultCellStyle.ForeColor = Color.LightPink : 合計_dgv.Columns(16).DefaultCellStyle.ForeColor = Color.LightPink
  171. 合計_dgv.Columns(17).DefaultCellStyle.ForeColor = Color.LightBlue : 合計_dgv.Columns(18).DefaultCellStyle.ForeColor = Color.LightBlue
  172. 合計_dgv.Columns(19).DefaultCellStyle.ForeColor = Color.LightGreen : 合計_dgv.Columns(20).DefaultCellStyle.ForeColor = Color.LightGreen
  173. 合計_dgv.Columns(21).DefaultCellStyle.ForeColor = Color.LightCoral : 合計_dgv.Columns(22).DefaultCellStyle.ForeColor = Color.LightCoral
  174. 合計_dgv.Columns(23).DefaultCellStyle.ForeColor = Color.LightCyan : 合計_dgv.Columns(24).DefaultCellStyle.ForeColor = Color.LightCyan
  175. 合計_dgv.Columns(25).DefaultCellStyle.ForeColor = Color.LightSalmon : 合計_dgv.Columns(26).DefaultCellStyle.ForeColor = Color.LightSalmon
  176. 合計_dgv.Columns(27).DefaultCellStyle.ForeColor = Color.LightSlateGray : 合計_dgv.Columns(28).DefaultCellStyle.ForeColor = Color.LightSlateGray
  177. 合計_dgv.Columns(29).DefaultCellStyle.ForeColor = Color.LightPink : 合計_dgv.Columns(30).DefaultCellStyle.ForeColor = Color.LightPink
  178. 合計_dgv.Columns(31).DefaultCellStyle.ForeColor = Color.LightBlue : 合計_dgv.Columns(32).DefaultCellStyle.ForeColor = Color.LightBlue
  179. 合計_dgv.Columns(33).DefaultCellStyle.ForeColor = Color.LightGreen : 合計_dgv.Columns(34).DefaultCellStyle.ForeColor = Color.LightGreen
  180. 合計_dgv.Columns(35).DefaultCellStyle.ForeColor = Color.LightCoral : 合計_dgv.Columns(36).DefaultCellStyle.ForeColor = Color.LightCoral
  181. 合計_dgv.Columns(37).DefaultCellStyle.ForeColor = Color.LightCyan : 合計_dgv.Columns(38).DefaultCellStyle.ForeColor = Color.LightCyan
  182. 合計_dgv.Columns(39).DefaultCellStyle.ForeColor = Color.LightSalmon : 合計_dgv.Columns(40).DefaultCellStyle.ForeColor = Color.LightSalmon
  183. 合計_dgv.Columns(41).DefaultCellStyle.ForeColor = Color.LightSlateGray : 合計_dgv.Columns(42).DefaultCellStyle.ForeColor = Color.LightSlateGray
  184. 合計_dgv.Columns(43).DefaultCellStyle.ForeColor = Color.LightPink : 合計_dgv.Columns(44).DefaultCellStyle.ForeColor = Color.LightPink
  185. 合計_dgv.Columns(45).DefaultCellStyle.ForeColor = Color.LightBlue : 合計_dgv.Columns(46).DefaultCellStyle.ForeColor = Color.LightBlue
  186. 合計_dgv.Columns(47).DefaultCellStyle.ForeColor = Color.LightGreen : 合計_dgv.Columns(48).DefaultCellStyle.ForeColor = Color.LightGreen
  187. End If : 合計_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  188. Dim mycol1 As DataGridViewImageColumn = 清單1_dgv.Columns("Save.") : mycol1.ImageLayout = DataGridViewImageCellLayout.Zoom
  189. For I As Integer = 0 To 清單1_dgv.Rows.Count - 1
  190. 清單1_dgv.Rows(I).Cells("Save.").Value = My.Resources.SAVER
  191. Next
  192. '-------------------------合計DGV變形----------------------------------------------------------------------------------------------------------------------
  193. If IsVerticalScrollBarVisible(清單1_dgv) Then : 合計_dgv.Size = New Size(清單1_dgv.Size.Width - 17, 合計_dgv.Size.Height)
  194. Else : 合計_dgv.Size = New Size(清單1_dgv.Size.Width, 合計_dgv.Size.Height) : End If
  195. 合計_dgv.Rows(0).Cells(0).Value = "" : 合計_dgv.Rows(0).Cells(1).Value = "" : 合計_dgv.Rows(0).Cells(4).Value = "" : 合計_dgv.Rows(0).Cells(12).Value = "0"
  196. 合計_dgv.Rows(0).Cells(13).Value = "0" : 合計_dgv.Rows(0).Cells(15).Value = "" : 合計_dgv.Rows(0).Cells(16).Value = "" : 合計_dgv.Rows(0).Cells(17).Value = ""
  197. 合計_dgv.Rows(0).Cells(18).Value = "" : 合計_dgv.Rows(0).Cells(19).Value = "" : 合計_dgv.Rows(0).Cells(20).Value = "" : 合計_dgv.Rows(0).Cells(21).Value = ""
  198. 合計_dgv.Rows(0).Cells(22).Value = "" : 合計_dgv.Rows(0).Cells(23).Value = "" : 合計_dgv.Rows(0).Cells(24).Value = "" : 合計_dgv.Rows(0).Cells(25).Value = ""
  199. 合計_dgv.Rows(0).Cells(26).Value = "" : 合計_dgv.Rows(0).Cells(27).Value = "" : 合計_dgv.Rows(0).Cells(28).Value = "" : 合計_dgv.Rows(0).Cells(29).Value = "0"
  200. 合計_dgv.Rows(0).Cells(30).Value = "0" : 合計_dgv.Rows(0).Cells(31).Value = "" : 合計_dgv.Rows(0).Cells(32).Value = "" : 合計_dgv.Rows(0).Cells(33).Value = "0"
  201. 合計_dgv.Rows(0).Cells(34).Value = "0" : 合計_dgv.Rows(0).Cells(35).Value = "0" : 合計_dgv.Rows(0).Cells(36).Value = "0" : 合計_dgv.Rows(0).Cells(37).Value = "0"
  202. 合計_dgv.Rows(0).Cells(38).Value = "0" : 合計_dgv.Rows(0).Cells(39).Value = "0" : 合計_dgv.Rows(0).Cells(40).Value = "0" : 合計_dgv.Rows(0).Cells(41).Value = "0"
  203. 合計_dgv.Rows(0).Cells(42).Value = "0" : 合計_dgv.Rows(0).Cells(43).Value = "0" : 合計_dgv.Rows(0).Cells(44).Value = "0" : 合計_dgv.Rows(0).Cells(45).Value = "0"
  204. 合計_dgv.Rows(0).Cells(46).Value = "0" : 合計_dgv.Rows(0).Cells(47).Value = "0" : 合計_dgv.Rows(0).Cells(48).Value = "0"
  205. 合計_dgv.Rows(0).Cells("Save.").Value = My.Resources.NULL1
  206. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  207. '-------------------------實際考勤--------------------------------------------------------------------------------------------------------------------
  208. If 清單1_dgv.Rows(i).Cells(0).Value.ToString <> "" Then : 清單1_dgv.Rows(i).Cells(0).Value = 清單1_dgv.Rows(i).Cells(0).Value.ToString.ToUpper : End If
  209. If 清單1_dgv.Rows(i).Cells(1).Value.ToString <> "" Then : 清單1_dgv.Rows(i).Cells(1).Value = 清單1_dgv.Rows(i).Cells(1).Value.ToString.ToUpper : End If
  210. '-------------------------清空資料取得預設值--------------------------------------------------------------------------------------------------------------------
  211. For FF As Integer = 15 To 48 : 清單1_dgv.Rows(i).Cells(FF).Value = "" : Next
  212. '-------------------------計算週考勤表--------------------------------------------------------------------------------------------------------------------
  213. For II As Integer = 0 To 總清單_dgv.Rows.Count - 1
  214. If 清單1_dgv.Rows(i).Cells("ID卡號").Value.ToString = 總清單_dgv.Rows(II).Cells("ID卡號").Value.ToString Then
  215. '-------------------------計算星期一--------------------------------------------------------------------------------------------------------------------
  216. If 月份2_cb.Text = Strings.Mid(星1_bt.Text, 6, 2) Then
  217. If 總清單_dgv.Rows(II).Cells(表頭(3)).Value.ToString = 星1_bt.Text Then
  218. If 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  219. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString = "" And
  220. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  221. 清單1_dgv.Rows(i).Cells(15).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  222. 清單1_dgv.Rows(i).Cells(16).Value = 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString
  223. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  224. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  225. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  226. 清單1_dgv.Rows(i).Cells(15).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  227. 清單1_dgv.Rows(i).Cells(16).Value = 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString
  228. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  229. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  230. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString <> "" Then
  231. 清單1_dgv.Rows(i).Cells(15).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  232. 清單1_dgv.Rows(i).Cells(16).Value = 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString
  233. End If
  234. End If
  235. End If
  236. '-------------------------計算星期二--------------------------------------------------------------------------------------------------------------------
  237. If 月份2_cb.Text = Strings.Mid(星2_bt.Text, 6, 2) Then
  238. If 總清單_dgv.Rows(II).Cells(表頭(3)).Value.ToString = 星2_bt.Text Then
  239. If 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  240. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString = "" And
  241. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  242. 清單1_dgv.Rows(i).Cells(17).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  243. 清單1_dgv.Rows(i).Cells(18).Value = 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString
  244. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  245. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  246. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  247. 清單1_dgv.Rows(i).Cells(17).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  248. 清單1_dgv.Rows(i).Cells(18).Value = 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString
  249. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  250. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  251. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString <> "" Then
  252. 清單1_dgv.Rows(i).Cells(17).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  253. 清單1_dgv.Rows(i).Cells(18).Value = 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString
  254. End If
  255. End If
  256. End If
  257. '-------------------------計算星期三--------------------------------------------------------------------------------------------------------------------
  258. If 月份2_cb.Text = Strings.Mid(星3_bt.Text, 6, 2) Then
  259. If 總清單_dgv.Rows(II).Cells(表頭(3)).Value.ToString = 星3_bt.Text Then
  260. If 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  261. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString = "" And
  262. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  263. 清單1_dgv.Rows(i).Cells(19).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  264. 清單1_dgv.Rows(i).Cells(20).Value = 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString
  265. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  266. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  267. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  268. 清單1_dgv.Rows(i).Cells(19).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  269. 清單1_dgv.Rows(i).Cells(20).Value = 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString
  270. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  271. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  272. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString <> "" Then
  273. 清單1_dgv.Rows(i).Cells(19).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  274. 清單1_dgv.Rows(i).Cells(20).Value = 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString
  275. End If
  276. End If
  277. End If
  278. '-------------------------計算星期四--------------------------------------------------------------------------------------------------------------------
  279. If 月份2_cb.Text = Strings.Mid(星4_bt.Text, 6, 2) Then
  280. If 總清單_dgv.Rows(II).Cells(表頭(3)).Value.ToString = 星4_bt.Text Then
  281. If 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  282. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString = "" And
  283. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  284. 清單1_dgv.Rows(i).Cells(21).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  285. 清單1_dgv.Rows(i).Cells(22).Value = 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString
  286. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  287. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  288. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  289. 清單1_dgv.Rows(i).Cells(21).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  290. 清單1_dgv.Rows(i).Cells(22).Value = 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString
  291. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  292. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  293. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString <> "" Then
  294. 清單1_dgv.Rows(i).Cells(21).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  295. 清單1_dgv.Rows(i).Cells(22).Value = 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString
  296. End If
  297. End If
  298. End If
  299. '-------------------------計算星期五--------------------------------------------------------------------------------------------------------------------
  300. If 月份2_cb.Text = Strings.Mid(星5_bt.Text, 6, 2) Then
  301. If 總清單_dgv.Rows(II).Cells(表頭(3)).Value.ToString = 星5_bt.Text Then
  302. If 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  303. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString = "" And
  304. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  305. 清單1_dgv.Rows(i).Cells(23).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  306. 清單1_dgv.Rows(i).Cells(24).Value = 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString
  307. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  308. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  309. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  310. 清單1_dgv.Rows(i).Cells(23).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  311. 清單1_dgv.Rows(i).Cells(24).Value = 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString
  312. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  313. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  314. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString <> "" Then
  315. 清單1_dgv.Rows(i).Cells(23).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  316. 清單1_dgv.Rows(i).Cells(24).Value = 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString
  317. End If
  318. End If
  319. End If
  320. '-------------------------計算星期六--------------------------------------------------------------------------------------------------------------------
  321. If 月份2_cb.Text = Strings.Mid(星6_bt.Text, 6, 2) Then
  322. If 總清單_dgv.Rows(II).Cells(表頭(3)).Value.ToString = 星6_bt.Text Then
  323. If 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  324. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString = "" And
  325. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  326. 清單1_dgv.Rows(i).Cells(25).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  327. 清單1_dgv.Rows(i).Cells(26).Value = 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString
  328. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  329. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  330. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  331. 清單1_dgv.Rows(i).Cells(25).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  332. 清單1_dgv.Rows(i).Cells(26).Value = 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString
  333. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  334. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  335. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString <> "" Then
  336. 清單1_dgv.Rows(i).Cells(25).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  337. 清單1_dgv.Rows(i).Cells(26).Value = 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString
  338. End If
  339. End If
  340. End If
  341. '-------------------------計算星期日--------------------------------------------------------------------------------------------------------------------
  342. If 月份2_cb.Text = Strings.Mid(星7_bt.Text, 6, 2) Then
  343. If 總清單_dgv.Rows(II).Cells(表頭(3)).Value.ToString = 星7_bt.Text Then
  344. If 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  345. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString = "" And
  346. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  347. 清單1_dgv.Rows(i).Cells(27).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  348. 清單1_dgv.Rows(i).Cells(28).Value = 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString
  349. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  350. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  351. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString = "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString = "" Then
  352. 清單1_dgv.Rows(i).Cells(27).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  353. 清單1_dgv.Rows(i).Cells(28).Value = 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString
  354. ElseIf 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(5)).Value.ToString <> "" And
  355. 總清單_dgv.Rows(II).Cells(表頭(6)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(7)).Value.ToString <> "" And
  356. 總清單_dgv.Rows(II).Cells(表頭(8)).Value.ToString <> "" And 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString <> "" Then
  357. 清單1_dgv.Rows(i).Cells(27).Value = 總清單_dgv.Rows(II).Cells(表頭(4)).Value.ToString
  358. 清單1_dgv.Rows(i).Cells(28).Value = 總清單_dgv.Rows(II).Cells(表頭(9)).Value.ToString
  359. End If
  360. End If
  361. End If
  362. End If
  363. Next
  364. '-------------------------虛擬考勤--------------------------------------------------------------------------------------------------------------------
  365. For ii As Integer = 0 To 虛擬表_dgv.Rows.Count - 1
  366. If 清單1_dgv.Rows(i).Cells(50).Value.ToString = 虛擬表_dgv.Rows(ii).Cells(0).Value.ToString Then
  367. If 月份2_cb.Text = Strings.Mid(星1_bt.Text, 6, 2) Then
  368. 清單1_dgv.Rows(i).Cells(15).Value = 虛擬表_dgv.Rows(ii).Cells(1).Value.ToString : 清單1_dgv.Rows(i).Cells(16).Value = 虛擬表_dgv.Rows(ii).Cells(2).Value.ToString
  369. End If
  370. If 月份2_cb.Text = Strings.Mid(星2_bt.Text, 6, 2) Then
  371. 清單1_dgv.Rows(i).Cells(17).Value = 虛擬表_dgv.Rows(ii).Cells(3).Value.ToString : 清單1_dgv.Rows(i).Cells(18).Value = 虛擬表_dgv.Rows(ii).Cells(4).Value.ToString
  372. End If
  373. If 月份2_cb.Text = Strings.Mid(星3_bt.Text, 6, 2) Then
  374. 清單1_dgv.Rows(i).Cells(19).Value = 虛擬表_dgv.Rows(ii).Cells(5).Value.ToString : 清單1_dgv.Rows(i).Cells(20).Value = 虛擬表_dgv.Rows(ii).Cells(6).Value.ToString
  375. End If
  376. If 月份2_cb.Text = Strings.Mid(星4_bt.Text, 6, 2) Then
  377. 清單1_dgv.Rows(i).Cells(21).Value = 虛擬表_dgv.Rows(ii).Cells(7).Value.ToString : 清單1_dgv.Rows(i).Cells(22).Value = 虛擬表_dgv.Rows(ii).Cells(8).Value.ToString
  378. End If
  379. If 月份2_cb.Text = Strings.Mid(星5_bt.Text, 6, 2) Then
  380. 清單1_dgv.Rows(i).Cells(23).Value = 虛擬表_dgv.Rows(ii).Cells(9).Value.ToString : 清單1_dgv.Rows(i).Cells(24).Value = 虛擬表_dgv.Rows(ii).Cells(10).Value.ToString
  381. End If
  382. If 月份2_cb.Text = Strings.Mid(星6_bt.Text, 6, 2) Then
  383. 清單1_dgv.Rows(i).Cells(25).Value = 虛擬表_dgv.Rows(ii).Cells(11).Value.ToString : 清單1_dgv.Rows(i).Cells(26).Value = 虛擬表_dgv.Rows(ii).Cells(12).Value.ToString
  384. End If
  385. If 月份2_cb.Text = Strings.Mid(星7_bt.Text, 6, 2) Then
  386. 清單1_dgv.Rows(i).Cells(27).Value = 虛擬表_dgv.Rows(ii).Cells(13).Value.ToString : 清單1_dgv.Rows(i).Cells(28).Value = 虛擬表_dgv.Rows(ii).Cells(14).Value.ToString
  387. End If
  388. End If
  389. Next
  390. Next : AUTO時段() : 表頭變形1()
  391. If 群組1_cb.Text = "HARIAN GROUP" Or 群組1_cb.Text = "" Then
  392. PA25 = 年份2_cb.Text : PA26 = 月份2_cb.Text : PA27 = Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd")
  393. If 群組1_cb.Text = "HARIAN GROUP" Then : PA30 = "1" : Else : PA30 = "0" : End If
  394. PA28 = 合計_dgv.Rows(0).Cells(4).Value.ToString : PA29 = 合計_dgv.Rows(0).Cells(13).Value.ToString
  395. SQL_工人薪資彙總報表_查詢()
  396. If dr.Read Then : SQL_工人薪資彙總報表_修改() : Else : SQL_工人薪資彙總報表_新增() : End If
  397. End If : PA25 = "" : PA26 = "" : PA27 = "" : PA28 = "" : PA29 = "" : PA30 = ""
  398. End Sub
  399. Private Sub 表頭變形1()
  400. Dim NNS, 位置(50), X軸1 As Integer
  401. For Each column As DataGridViewColumn In 清單1_dgv.Columns
  402. If column.Index >= 0 Then
  403. Dim currentWidth As Integer = column.Width
  404. 位置(NNS) = currentWidth
  405. End If
  406. If NNS = 15 Or NNS = 16 Or NNS = 17 Or NNS = 18 Or NNS = 19 Or NNS = 20 Or NNS = 21 Or NNS = 22 Or NNS = 23 Or NNS = 24 Or NNS = 25 Or NNS = 26 Or NNS = 27 Or NNS = 28 Or
  407. NNS = 35 Or NNS = 36 Or NNS = 37 Or NNS = 38 Or NNS = 39 Or NNS = 40 Or NNS = 41 Or NNS = 42 Or NNS = 43 Or NNS = 44 Or NNS = 45 Or NNS = 46 Or NNS = 47 Or NNS = 48 Then
  408. column.HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter
  409. End If : NNS += 1
  410. Next
  411. X軸1 = 清單1_dgv.Location.X + 位置(0) + 位置(1) + 位置(4) + 位置(12) + 7
  412. 星1_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星1_bt.Size = New Size(位置(15) + 位置(16) - 2, 星1_bt.Size.Height)
  413. X軸1 = X軸1 + 位置(15) + 位置(16) : 星2_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星2_bt.Size = New Size(位置(15) + 位置(16) - 2, 星1_bt.Size.Height)
  414. X軸1 = X軸1 + 位置(17) + 位置(18) : 星3_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星3_bt.Size = New Size(位置(15) + 位置(16) - 2, 星1_bt.Size.Height)
  415. X軸1 = X軸1 + 位置(19) + 位置(20) : 星4_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星4_bt.Size = New Size(位置(15) + 位置(16) - 2, 星1_bt.Size.Height)
  416. X軸1 = X軸1 + 位置(21) + 位置(22) : 星5_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星5_bt.Size = New Size(位置(15) + 位置(16) - 2, 星1_bt.Size.Height)
  417. X軸1 = X軸1 + 位置(23) + 位置(24) : 星6_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星6_bt.Size = New Size(位置(15) + 位置(16) - 2, 星1_bt.Size.Height)
  418. X軸1 = X軸1 + 位置(25) + 位置(26) : 星7_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星7_bt.Size = New Size(位置(15) + 位置(16) - 2, 星1_bt.Size.Height)
  419. End Sub
  420. Private Sub 表頭變形2()
  421. Dim NNS, 位置(50), X軸1 As Integer
  422. For Each column As DataGridViewColumn In 清單1_dgv.Columns
  423. If column.Index >= 0 Then
  424. Dim currentWidth As Integer = column.Width
  425. 位置(NNS) = currentWidth
  426. End If
  427. If NNS = 15 Or NNS = 16 Or NNS = 17 Or NNS = 18 Or NNS = 19 Or NNS = 20 Or NNS = 21 Or NNS = 22 Or NNS = 23 Or NNS = 24 Or NNS = 25 Or NNS = 26 Or NNS = 27 Or NNS = 28 Or
  428. NNS = 35 Or NNS = 36 Or NNS = 37 Or NNS = 38 Or NNS = 39 Or NNS = 40 Or NNS = 41 Or NNS = 42 Or NNS = 43 Or NNS = 44 Or NNS = 45 Or NNS = 46 Or NNS = 47 Or NNS = 48 Then
  429. column.HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter
  430. End If : NNS += 1
  431. Next
  432. X軸1 = 清單1_dgv.Location.X + 位置(0) + 位置(1) + 位置(4) + 位置(13) + 位置(29) + 位置(30) + 位置(31) + 位置(32) + 位置(33) + 位置(34) + 7
  433. 星1_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星1_bt.Size = New Size(位置(35) + 位置(36) - 2, 星1_bt.Size.Height)
  434. X軸1 = X軸1 + 位置(35) + 位置(36) : 星2_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星2_bt.Size = New Size(位置(35) + 位置(36) - 2, 星1_bt.Size.Height)
  435. X軸1 = X軸1 + 位置(37) + 位置(38) : 星3_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星3_bt.Size = New Size(位置(35) + 位置(36) - 2, 星1_bt.Size.Height)
  436. X軸1 = X軸1 + 位置(39) + 位置(40) : 星4_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星4_bt.Size = New Size(位置(35) + 位置(36) - 2, 星1_bt.Size.Height)
  437. X軸1 = X軸1 + 位置(41) + 位置(42) : 星5_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星5_bt.Size = New Size(位置(35) + 位置(36) - 2, 星1_bt.Size.Height)
  438. X軸1 = X軸1 + 位置(43) + 位置(44) : 星6_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星6_bt.Size = New Size(位置(35) + 位置(36) - 2, 星1_bt.Size.Height)
  439. X軸1 = X軸1 + 位置(45) + 位置(46) : 星7_bt.Location = New System.Drawing.Point(X軸1, 星1_bt.Location.Y) : 星7_bt.Size = New Size(位置(35) + 位置(36) - 2, 星1_bt.Size.Height)
  440. End Sub
  441. Private Sub Set_虛擬表()
  442. Dim ds1 As New DataSet
  443. 虛擬表_dgv.DataSource = Nothing : ds1.Clear()
  444. 虛擬表_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  445. 虛擬表_dgv.ColumnHeadersHeight = 25 : 虛擬表_dgv.AllowUserToAddRows = False : 虛擬表_dgv.RowTemplate.Height = 25
  446. PA25 = 星1_bt.Text : SQL_考勤虛擬表() : PA25 = ""
  447. da.Fill(ds1) : 虛擬表_dgv.DataSource = ds1.Tables(0) : conn.Close()
  448. End Sub
  449. Private Sub Set_總清單()
  450. Dim ds1 As New DataSet
  451. 總清單_dgv.DataSource = Nothing : ds1.Clear()
  452. 總清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  453. 總清單_dgv.ColumnHeadersHeight = 25 : 總清單_dgv.AllowUserToAddRows = False : 總清單_dgv.RowTemplate.Height = 25
  454. PA2 = 年份2_cb.Text : PA3 = 月份2_cb.Text : PA25 = 地區_cb.SelectedIndex : SQL_考勤總明細() : PA25 = ""
  455. da.Fill(ds1) : 總清單_dgv.DataSource = ds1.Tables(0) : conn.Close()
  456. 總清單_dgv.Columns(表頭(17)).FillWeight = 70 : 總清單_dgv.Columns(表頭(18)).FillWeight = 70
  457. 總清單_dgv.Columns("第一").Visible = False : 總清單_dgv.Columns("第二").Visible = False : 總清單_dgv.Columns("第三").Visible = False
  458. 總清單_dgv.Columns("第四").Visible = False : 總清單_dgv.Columns("第五").Visible = False : 總清單_dgv.Columns("第六").Visible = False
  459. For I As Integer = 4 To 9 : 總清單_dgv.Columns(表頭(I)).Visible = False : Next : 總時 = 0
  460. For i As Integer = 0 To 總清單_dgv.Rows.Count - 1
  461. '-------------基本資料準備------------------------------------
  462. If 工人_ch.Checked = True Then : 總清單_dgv.Rows(i).Cells(表頭(17)).Value = True
  463. Else : If IsDBNull(總清單_dgv.Rows(i).Cells(表頭(17)).Value) Then : 總清單_dgv.Rows(i).Cells(表頭(17)).Value = False : End If : End If
  464. If IsDBNull(總清單_dgv.Rows(i).Cells(表頭(18)).Value) Then : 總清單_dgv.Rows(i).Cells(表頭(18)).Value = False : End If
  465. If 總清單_dgv.Rows(i).Cells("MGB").Value.ToString = "星期一" Then : 總清單_dgv.Rows(i).Cells(表頭(2)).Value = 對話框(0)
  466. ElseIf 總清單_dgv.Rows(i).Cells("MGB").Value.ToString = "星期二" Then : 總清單_dgv.Rows(i).Cells(表頭(2)).Value = 對話框(1)
  467. ElseIf 總清單_dgv.Rows(i).Cells("MGB").Value.ToString = "星期三" Then : 總清單_dgv.Rows(i).Cells(表頭(2)).Value = 對話框(2)
  468. ElseIf 總清單_dgv.Rows(i).Cells("MGB").Value.ToString = "星期四" Then : 總清單_dgv.Rows(i).Cells(表頭(2)).Value = 對話框(3)
  469. ElseIf 總清單_dgv.Rows(i).Cells("MGB").Value.ToString = "星期五" Then : 總清單_dgv.Rows(i).Cells(表頭(2)).Value = 對話框(4)
  470. ElseIf 總清單_dgv.Rows(i).Cells("MGB").Value.ToString = "星期六" Then : 總清單_dgv.Rows(i).Cells(表頭(2)).Value = 對話框(5)
  471. ElseIf 總清單_dgv.Rows(i).Cells("MGB").Value.ToString = "星期日" Then : 總清單_dgv.Rows(i).Cells(表頭(2)).Value = 對話框(6)
  472. End If
  473. Dim DFG(6) As String : Dim CV As Integer = 1 : For V As Integer = 0 To 6 : DFG(V) = "" : Next
  474. If 總清單_dgv.Rows(i).Cells("第一").Value.ToString <> "" Then : DFG(CV) = 總清單_dgv.Rows(i).Cells("第一").Value.ToString : CV += 1 : End If
  475. If 總清單_dgv.Rows(i).Cells("第二").Value.ToString <> "" Then : DFG(CV) = 總清單_dgv.Rows(i).Cells("第二").Value.ToString : CV += 1 : End If
  476. If 總清單_dgv.Rows(i).Cells("第三").Value.ToString <> "" Then : DFG(CV) = 總清單_dgv.Rows(i).Cells("第三").Value.ToString : CV += 1 : End If
  477. If 總清單_dgv.Rows(i).Cells("第四").Value.ToString <> "" Then : DFG(CV) = 總清單_dgv.Rows(i).Cells("第四").Value.ToString : CV += 1 : End If
  478. If 總清單_dgv.Rows(i).Cells("第五").Value.ToString <> "" Then : DFG(CV) = 總清單_dgv.Rows(i).Cells("第五").Value.ToString : CV += 1 : End If
  479. If 總清單_dgv.Rows(i).Cells("第六").Value.ToString <> "" Then : DFG(CV) = 總清單_dgv.Rows(i).Cells("第六").Value.ToString : CV += 1 : End If
  480. 時段(1) = DFG(1) : 時段(2) = DFG(2)
  481. 時段(3) = DFG(3) : 時段(4) = DFG(4)
  482. 時段(5) = DFG(5) : 時段(6) = DFG(6)
  483. For II As Integer = 4 To 16 : 總清單_dgv.Rows(i).Cells(表頭(II)).Value = "" : Next
  484. '-------------時間推移計算------------------------------------
  485. If 時段(1) = "" And 時段(2) = "" And 時段(3) = "" And 時段(4) = "" And 時段(5) = "" And 時段(6) = "" Then
  486. ElseIf 時段(1) <> "" And 時段(2) = "" And 時段(3) = "" And 時段(4) = "" And 時段(5) = "" And 時段(6) = "" Then
  487. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  488. ElseIf 時段(1) <> "" And 時段(2) <> "" And 時段(3) = "" And 時段(4) = "" And 時段(5) = "" And 時段(6) = "" Then
  489. X1 = 時段(1) : Set_時段定點() : 計算(0) = X1 : X1 = 時段(2) : Set_時段定點() : 計算(1) = X1 : 時間比對()
  490. If 間隔1 >= 665 Then
  491. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  492. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(15)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(9)).Value = 時段(2)
  493. 'X1 = 時段(1) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = X1 : 時段(2) = X1
  494. 'X1 = 時段(2) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = X1 : 時段(3) = X1
  495. 'X1 = 時段(3) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = X1 : 時段(4) = X1
  496. 'X1 = 時段(4) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = X1
  497. 總清單_dgv.Rows(i).Cells(表頭(11)).Value = "12:00:00" : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = "12:00:00"
  498. 總清單_dgv.Rows(i).Cells(表頭(12)).Value = "13:00:00" : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = "13:00:00"
  499. 總清單_dgv.Rows(i).Cells(表頭(13)).Value = "17:00:00" : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = "17:00:00"
  500. 總清單_dgv.Rows(i).Cells(表頭(14)).Value = "18:00:00" : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = "18:00:00"
  501. ElseIf 間隔1 >= 325 And 間隔1 < 665 Then
  502. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  503. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(2)
  504. 'X1 = 時段(1) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = X1 : 時段(2) = X1
  505. 'X1 = 時段(2) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = X1 : 時段(3) = X1
  506. 總清單_dgv.Rows(i).Cells(表頭(11)).Value = "12:00:00" : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = "12:00:00"
  507. 總清單_dgv.Rows(i).Cells(表頭(12)).Value = "13:00:00" : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = "13:00:00"
  508. ElseIf 間隔1 < 325 Then
  509. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  510. X1 = 時段(1) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  511. End If
  512. ElseIf 時段(1) <> "" And 時段(2) <> "" And 時段(3) <> "" And 時段(4) = "" And 時段(5) = "" And 時段(6) = "" Then
  513. X1 = 時段(1) : Set_時段定點() : 計算(0) = X1 : X1 = 時段(3) : Set_時段定點() : 計算(1) = X1 : 時間比對()
  514. If 間隔1 >= 665 Then '---------大於十小時
  515. X1 = 時段(1) : Set_時段定點() : 計算(0) = X1 : X1 = 時段(2) : Set_時段定點() : 計算(1) = X1 : 時間比對()
  516. If 間隔1 <= 325 Then
  517. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  518. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  519. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(15)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(9)).Value = 時段(3)
  520. 'X1 = 時段(2) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = X1 : 時段(3) = X1
  521. 'X1 = 時段(3) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = X1 : 時段(4) = X1
  522. 'X1 = 時段(4) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = X1
  523. 總清單_dgv.Rows(i).Cells(表頭(12)).Value = "13:00:00" : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = "13:00:00"
  524. 總清單_dgv.Rows(i).Cells(表頭(13)).Value = "17:00:00" : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = "17:00:00"
  525. 總清單_dgv.Rows(i).Cells(表頭(14)).Value = "18:00:00" : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = "18:00:00"
  526. ElseIf 間隔1 > 325 Then
  527. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  528. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(15)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(9)).Value = 時段(3)
  529. 'X1 = 時段(1) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = X1 : 時段(2) = X1
  530. 'X1 = 時段(2) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = X1 : 時段(3) = X1
  531. 'X1 = 時段(3) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = X1 : 時段(4) = X1
  532. 'X1 = 時段(4) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = X1
  533. 總清單_dgv.Rows(i).Cells(表頭(11)).Value = "12:00:00" : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = "12:00:00"
  534. 總清單_dgv.Rows(i).Cells(表頭(12)).Value = "13:00:00" : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = "13:00:00"
  535. 總清單_dgv.Rows(i).Cells(表頭(13)).Value = "17:00:00" : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = "17:00:00"
  536. 總清單_dgv.Rows(i).Cells(表頭(14)).Value = "18:00:00" : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = "18:00:00"
  537. End If
  538. ElseIf 間隔1 > 325 And 間隔1 < 625 Then
  539. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  540. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(3)
  541. 'X1 = 時段(1) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = X1 : 時段(2) = X1
  542. 'X1 = 時段(2) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = X1 : 時段(3) = X1
  543. 總清單_dgv.Rows(i).Cells(表頭(11)).Value = "12:00:00" : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = "12:00:00"
  544. 總清單_dgv.Rows(i).Cells(表頭(12)).Value = "13:00:00" : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = "13:00:00"
  545. ElseIf 間隔1 >= 325 Then
  546. X1 = 時段(2) : Set_時段定點() : 計算(0) = X1 : X1 = 時段(3) : Set_時段定點() : 計算(1) = X1 : 時間比對()
  547. If 間隔1 >= 90 Then
  548. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  549. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  550. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(3)
  551. X1 = 時段(2) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = X1
  552. Else
  553. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  554. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  555. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1
  556. End If
  557. Else
  558. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  559. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  560. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1
  561. End If
  562. ElseIf 時段(1) <> "" And 時段(2) <> "" And 時段(3) <> "" And 時段(4) <> "" And 時段(5) = "" And 時段(6) = "" Then
  563. X1 = 時段(1) : Set_時段定點() : 計算(0) = X1 : X1 = 時段(4) : Set_時段定點() : 計算(1) = X1 : 時間比對()
  564. If 間隔1 >= 665 Then
  565. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  566. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  567. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = 時段(3)
  568. X1 = 時段(4) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(15)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(9)).Value = 時段(4)
  569. 'X1 = 時段(3) : Set_時段定點_加四小時() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = X1 : 時段(4) = X1
  570. 'X1 = 時段(4) : Set_時段定點_加一小時() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = X1
  571. 總清單_dgv.Rows(i).Cells(表頭(13)).Value = "17:00:00" : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = "17:00:00"
  572. 總清單_dgv.Rows(i).Cells(表頭(14)).Value = "18:00:00" : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = "18:00:00"
  573. Else
  574. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  575. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  576. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = 時段(3)
  577. X1 = 時段(4) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(4)
  578. End If
  579. ElseIf 時段(1) <> "" And 時段(2) <> "" And 時段(3) <> "" And 時段(4) <> "" And 時段(5) <> "" And 時段(6) = "" Then
  580. X1 = 時段(1) : Set_時段定點() : 計算(0) = X1 : X1 = 時段(5) : Set_時段定點() : 計算(1) = X1 : 時間比對()
  581. If 間隔1 >= 665 Then
  582. X1 = 時段(4) : Set_時段定點() : 計算(0) = X1 : X1 = 時段(5) : Set_時段定點() : 計算(1) = X1 : 時間比對()
  583. If 間隔1 >= 90 Then
  584. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  585. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  586. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = 時段(3)
  587. X1 = 時段(4) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(4)
  588. X1 = 時段(5) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(15)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(9)).Value = 時段(6)
  589. X1 = 時段(5) : Set_時段定點_減一小時() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = X1
  590. Else
  591. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  592. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  593. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = 時段(3)
  594. X1 = 時段(4) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(4)
  595. X1 = 時段(5) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = 時段(5)
  596. End If
  597. Else
  598. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  599. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  600. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = 時段(3)
  601. X1 = 時段(4) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(4)
  602. X1 = 時段(5) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = 時段(5)
  603. End If
  604. ElseIf 時段(1) <> "" And 時段(2) <> "" And 時段(3) <> "" And 時段(4) <> "" And 時段(5) <> "" And 時段(6) <> "" Then
  605. X1 = 時段(1) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(10)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(4)).Value = 時段(1)
  606. X1 = 時段(2) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(11)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(5)).Value = 時段(2)
  607. X1 = 時段(3) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(12)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(6)).Value = 時段(3)
  608. X1 = 時段(4) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(13)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(7)).Value = 時段(4)
  609. X1 = 時段(5) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(14)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(8)).Value = 時段(5)
  610. X1 = 時段(6) : Set_時段定點() : 總清單_dgv.Rows(i).Cells(表頭(15)).Value = X1 : 總清單_dgv.Rows(i).Cells(表頭(9)).Value = 時段(6)
  611. End If
  612. '-------------時間彙總計算------------------------------------
  613. 時長 = 0
  614. If 總清單_dgv.Rows(i).Cells(表頭(10)).Value.ToString <> "" And 總清單_dgv.Rows(i).Cells(表頭(11)).Value.ToString <> "" And
  615. 總清單_dgv.Rows(i).Cells(表頭(12)).Value.ToString = "" And 總清單_dgv.Rows(i).Cells(表頭(13)).Value.ToString = "" And
  616. 總清單_dgv.Rows(i).Cells(表頭(14)).Value.ToString = "" And 總清單_dgv.Rows(i).Cells(表頭(15)).Value.ToString = "" Then
  617. 計算(0) = 總清單_dgv.Rows(i).Cells(表頭(10)).Value.ToString : 計算(1) = 總清單_dgv.Rows(i).Cells(表頭(11)).Value.ToString : 時間比對() : 時長 += (間隔1 / 60)
  618. If 時長 <= 8 Then : 總清單_dgv.Rows(i).Cells(表頭(16)).Value = "0" & 時長 & " H 00 M" : End If
  619. ElseIf 總清單_dgv.Rows(i).Cells(表頭(10)).Value.ToString <> "" And 總清單_dgv.Rows(i).Cells(表頭(11)).Value.ToString <> "" And
  620. 總清單_dgv.Rows(i).Cells(表頭(12)).Value.ToString <> "" And 總清單_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" And
  621. 總清單_dgv.Rows(i).Cells(表頭(14)).Value.ToString = "" And 總清單_dgv.Rows(i).Cells(表頭(15)).Value.ToString = "" Then
  622. 計算(0) = 總清單_dgv.Rows(i).Cells(表頭(10)).Value.ToString : 計算(1) = 總清單_dgv.Rows(i).Cells(表頭(11)).Value.ToString : 時間比對() : 時長 += (間隔1 / 60)
  623. 計算(0) = 總清單_dgv.Rows(i).Cells(表頭(12)).Value.ToString : 計算(1) = 總清單_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 時間比對() : 時長 += (間隔1 / 60)
  624. If 時長 <= 8 Then : 總清單_dgv.Rows(i).Cells(表頭(16)).Value = "0" & 時長 & " H 00 M" : Else
  625. If 總清單_dgv.Rows(i).Cells(表頭(17)).Value = False Then
  626. 總清單_dgv.Rows(i).Cells(表頭(16)).Value = "08 H 00 M"
  627. Else
  628. If 時長 < 10 Then : 總清單_dgv.Rows(i).Cells(表頭(16)).Value = "0" & 時長 & " H 00 M"
  629. Else : 總清單_dgv.Rows(i).Cells(表頭(16)).Value = 時長 & " H 00 M" : End If
  630. End If
  631. End If
  632. ElseIf 總清單_dgv.Rows(i).Cells(表頭(10)).Value.ToString <> "" And 總清單_dgv.Rows(i).Cells(表頭(11)).Value.ToString <> "" And
  633. 總清單_dgv.Rows(i).Cells(表頭(12)).Value.ToString <> "" And 總清單_dgv.Rows(i).Cells(表頭(13)).Value.ToString <> "" And
  634. 總清單_dgv.Rows(i).Cells(表頭(14)).Value.ToString <> "" And 總清單_dgv.Rows(i).Cells(表頭(15)).Value.ToString <> "" Then
  635. 計算(0) = 總清單_dgv.Rows(i).Cells(表頭(10)).Value.ToString : 計算(1) = 總清單_dgv.Rows(i).Cells(表頭(11)).Value.ToString : 時間比對() : 時長 += (間隔1 / 60)
  636. 計算(0) = 總清單_dgv.Rows(i).Cells(表頭(12)).Value.ToString : 計算(1) = 總清單_dgv.Rows(i).Cells(表頭(13)).Value.ToString : 時間比對() : 時長 += (間隔1 / 60)
  637. 計算(0) = 總清單_dgv.Rows(i).Cells(表頭(14)).Value.ToString : 計算(1) = 總清單_dgv.Rows(i).Cells(表頭(15)).Value.ToString : 時間比對() : 時長 += (間隔1 / 60)
  638. If 時長 <= 8 Then : 總清單_dgv.Rows(i).Cells(表頭(16)).Value = "0" & 時長 & " H 00 M" : Else
  639. If 總清單_dgv.Rows(i).Cells(表頭(17)).Value = False Then
  640. 總清單_dgv.Rows(i).Cells(表頭(16)).Value = "08 H 00 M"
  641. Else
  642. If 時長 < 10 Then : 總清單_dgv.Rows(i).Cells(表頭(16)).Value = "0" & 時長 & " H 00 M"
  643. Else : 總清單_dgv.Rows(i).Cells(表頭(16)).Value = 時長 & " H 00 M" : End If
  644. End If
  645. End If
  646. End If
  647. Next : For I As Integer = 10 To 15 : 總清單_dgv.Columns(I).Visible = True : Next
  648. End Sub
  649. Private Sub Set_時段定點()
  650. Dim 時 As String = Strings.Left(X1, 2) : Dim 分 As String = Strings.Mid(X1, 4, 2)
  651. If (時 = "23" And CInt(分) >= 30) Or (時 = "00" And CInt(分) < 0) Then : X1 = "23:59:59" : ElseIf (時 = "00" And CInt(分) >= 30) Or (時 = "01" And CInt(分) < 30) Then : X1 = "01:00:00"
  652. ElseIf (時 = "01" And CInt(分) >= 30) Or (時 = "02" And CInt(分) < 30) Then : X1 = "02:00:00" : ElseIf (時 = "02" And CInt(分) >= 30) Or (時 = "03" And CInt(分) < 30) Then : X1 = "03:00:00"
  653. ElseIf (時 = "03" And CInt(分) >= 30) Or (時 = "04" And CInt(分) < 30) Then : X1 = "04:00:00" : ElseIf (時 = "04" And CInt(分) >= 30) Or (時 = "05" And CInt(分) < 30) Then : X1 = "05:00:00"
  654. ElseIf (時 = "05" And CInt(分) >= 30) Or (時 = "06" And CInt(分) < 30) Then : X1 = "06:00:00" : ElseIf (時 = "06" And CInt(分) >= 30) Or (時 = "07" And CInt(分) < 30) Then : X1 = "07:00:00"
  655. ElseIf (時 = "07" And CInt(分) >= 30) Or (時 = "08" And CInt(分) < 30) Then : X1 = "08:00:00" : ElseIf (時 = "08" And CInt(分) >= 30) Or (時 = "09" And CInt(分) < 30) Then : X1 = "09:00:00"
  656. ElseIf (時 = "09" And CInt(分) >= 30) Or (時 = "10" And CInt(分) < 30) Then : X1 = "10:00:00" : ElseIf (時 = "10" And CInt(分) >= 30) Or (時 = "11" And CInt(分) < 30) Then : X1 = "11:00:00"
  657. ElseIf (時 = "11" And CInt(分) >= 30) Or (時 = "12" And CInt(分) < 30) Then : X1 = "12:00:00" : ElseIf (時 = "12" And CInt(分) >= 30) Or (時 = "13" And CInt(分) < 30) Then : X1 = "13:00:00"
  658. ElseIf (時 = "13" And CInt(分) >= 30) Or (時 = "14" And CInt(分) < 30) Then : X1 = "14:00:00" : ElseIf (時 = "14" And CInt(分) >= 30) Or (時 = "15" And CInt(分) < 30) Then : X1 = "15:00:00"
  659. ElseIf (時 = "15" And CInt(分) >= 30) Or (時 = "16" And CInt(分) < 30) Then : X1 = "16:00:00" : ElseIf (時 = "16" And CInt(分) >= 30) Or (時 = "17" And CInt(分) < 30) Then : X1 = "17:00:00"
  660. ElseIf (時 = "17" And CInt(分) >= 30) Or (時 = "18" And CInt(分) < 30) Then : X1 = "18:00:00" : ElseIf (時 = "18" And CInt(分) >= 30) Or (時 = "19" And CInt(分) < 30) Then : X1 = "19:00:00"
  661. ElseIf (時 = "19" And CInt(分) >= 30) Or (時 = "20" And CInt(分) < 30) Then : X1 = "20:00:00" : ElseIf (時 = "20" And CInt(分) >= 30) Or (時 = "21" And CInt(分) < 30) Then : X1 = "21:00:00"
  662. ElseIf (時 = "21" And CInt(分) >= 30) Or (時 = "22" And CInt(分) < 30) Then : X1 = "22:00:00" : ElseIf (時 = "22" And CInt(分) >= 30) Or (時 = "23" And CInt(分) < 30) Then : X1 = "23:00:00"
  663. End If
  664. End Sub
  665. Private Sub Set_時段定點_減一小時()
  666. Dim 時 As String = Strings.Left(X1, 2) : Dim 分 As String = Strings.Mid(X1, 4, 2)
  667. If (時 = "23" And CInt(分) >= 30) Or (時 = "00" And CInt(分) < 30) Then : X1 = "23:00:00" : ElseIf (時 = "00" And CInt(分) >= 30) Or (時 = "01" And CInt(分) < 30) Then : X1 = "00:00:00"
  668. ElseIf (時 = "01" And CInt(分) >= 30) Or (時 = "02" And CInt(分) < 30) Then : X1 = "01:00:00" : ElseIf (時 = "02" And CInt(分) >= 30) Or (時 = "03" And CInt(分) < 30) Then : X1 = "02:00:00"
  669. ElseIf (時 = "03" And CInt(分) >= 30) Or (時 = "04" And CInt(分) < 30) Then : X1 = "03:00:00" : ElseIf (時 = "04" And CInt(分) >= 30) Or (時 = "05" And CInt(分) < 30) Then : X1 = "04:00:00"
  670. ElseIf (時 = "05" And CInt(分) >= 30) Or (時 = "06" And CInt(分) < 30) Then : X1 = "05:00:00" : ElseIf (時 = "06" And CInt(分) >= 30) Or (時 = "07" And CInt(分) < 30) Then : X1 = "06:00:00"
  671. ElseIf (時 = "07" And CInt(分) >= 30) Or (時 = "08" And CInt(分) < 30) Then : X1 = "07:00:00" : ElseIf (時 = "08" And CInt(分) >= 30) Or (時 = "09" And CInt(分) < 30) Then : X1 = "08:00:00"
  672. ElseIf (時 = "09" And CInt(分) >= 30) Or (時 = "10" And CInt(分) < 30) Then : X1 = "09:00:00" : ElseIf (時 = "10" And CInt(分) >= 30) Or (時 = "11" And CInt(分) < 30) Then : X1 = "10:00:00"
  673. ElseIf (時 = "11" And CInt(分) >= 30) Or (時 = "12" And CInt(分) < 30) Then : X1 = "11:00:00" : ElseIf (時 = "12" And CInt(分) >= 30) Or (時 = "13" And CInt(分) < 30) Then : X1 = "12:00:00"
  674. ElseIf (時 = "13" And CInt(分) >= 30) Or (時 = "14" And CInt(分) < 30) Then : X1 = "13:00:00" : ElseIf (時 = "14" And CInt(分) >= 30) Or (時 = "15" And CInt(分) < 30) Then : X1 = "14:00:00"
  675. ElseIf (時 = "15" And CInt(分) >= 30) Or (時 = "16" And CInt(分) < 30) Then : X1 = "15:00:00" : ElseIf (時 = "16" And CInt(分) >= 30) Or (時 = "17" And CInt(分) < 30) Then : X1 = "16:00:00"
  676. ElseIf (時 = "17" And CInt(分) >= 30) Or (時 = "18" And CInt(分) < 30) Then : X1 = "17:00:00" : ElseIf (時 = "18" And CInt(分) >= 30) Or (時 = "19" And CInt(分) < 30) Then : X1 = "18:00:00"
  677. ElseIf (時 = "19" And CInt(分) >= 30) Or (時 = "20" And CInt(分) < 30) Then : X1 = "19:00:00" : ElseIf (時 = "20" And CInt(分) >= 30) Or (時 = "21" And CInt(分) < 30) Then : X1 = "20:00:00"
  678. ElseIf (時 = "21" And CInt(分) >= 30) Or (時 = "22" And CInt(分) < 30) Then : X1 = "21:00:00" : ElseIf (時 = "22" And CInt(分) >= 30) Or (時 = "23" And CInt(分) < 30) Then : X1 = "22:00:00"
  679. End If
  680. End Sub
  681. Private Sub Set_時段定點_加一小時()
  682. Dim 時 As String = Strings.Left(X1, 2) : Dim 分 As String = Strings.Mid(X1, 4, 2)
  683. If (時 = "23" And CInt(分) >= 30) Or (時 = "00" And CInt(分) < 30) Then : X1 = "01:00:00" : ElseIf (時 = "00" And CInt(分) >= 30) Or (時 = "01" And CInt(分) < 30) Then : X1 = "02:00:00"
  684. ElseIf (時 = "01" And CInt(分) >= 30) Or (時 = "02" And CInt(分) < 30) Then : X1 = "03:00:00" : ElseIf (時 = "02" And CInt(分) >= 30) Or (時 = "03" And CInt(分) < 30) Then : X1 = "04:00:00"
  685. ElseIf (時 = "03" And CInt(分) >= 30) Or (時 = "04" And CInt(分) < 30) Then : X1 = "05:00:00" : ElseIf (時 = "04" And CInt(分) >= 30) Or (時 = "05" And CInt(分) < 30) Then : X1 = "06:00:00"
  686. ElseIf (時 = "05" And CInt(分) >= 30) Or (時 = "06" And CInt(分) < 30) Then : X1 = "07:00:00" : ElseIf (時 = "06" And CInt(分) >= 30) Or (時 = "07" And CInt(分) < 30) Then : X1 = "08:00:00"
  687. ElseIf (時 = "07" And CInt(分) >= 30) Or (時 = "08" And CInt(分) < 30) Then : X1 = "09:00:00" : ElseIf (時 = "08" And CInt(分) >= 30) Or (時 = "09" And CInt(分) < 30) Then : X1 = "10:00:00"
  688. ElseIf (時 = "09" And CInt(分) >= 30) Or (時 = "10" And CInt(分) < 30) Then : X1 = "11:00:00" : ElseIf (時 = "10" And CInt(分) >= 30) Or (時 = "11" And CInt(分) < 30) Then : X1 = "12:00:00"
  689. ElseIf (時 = "11" And CInt(分) >= 30) Or (時 = "12" And CInt(分) < 30) Then : X1 = "13:00:00" : ElseIf (時 = "12" And CInt(分) >= 30) Or (時 = "13" And CInt(分) < 30) Then : X1 = "14:00:00"
  690. ElseIf (時 = "13" And CInt(分) >= 30) Or (時 = "14" And CInt(分) < 30) Then : X1 = "15:00:00" : ElseIf (時 = "14" And CInt(分) >= 30) Or (時 = "15" And CInt(分) < 30) Then : X1 = "16:00:00"
  691. ElseIf (時 = "15" And CInt(分) >= 30) Or (時 = "16" And CInt(分) < 30) Then : X1 = "17:00:00" : ElseIf (時 = "16" And CInt(分) >= 30) Or (時 = "17" And CInt(分) < 30) Then : X1 = "18:00:00"
  692. ElseIf (時 = "17" And CInt(分) >= 30) Or (時 = "18" And CInt(分) < 30) Then : X1 = "19:00:00" : ElseIf (時 = "18" And CInt(分) >= 30) Or (時 = "19" And CInt(分) < 30) Then : X1 = "20:00:00"
  693. ElseIf (時 = "19" And CInt(分) >= 30) Or (時 = "20" And CInt(分) < 30) Then : X1 = "21:00:00" : ElseIf (時 = "20" And CInt(分) >= 30) Or (時 = "21" And CInt(分) < 30) Then : X1 = "22:00:00"
  694. ElseIf (時 = "21" And CInt(分) >= 30) Or (時 = "22" And CInt(分) < 30) Then : X1 = "23:00:00" : ElseIf (時 = "22" And CInt(分) >= 30) Or (時 = "23" And CInt(分) < 30) Then : X1 = "24:00:00"
  695. End If
  696. End Sub
  697. Private Sub Set_時段定點_加四小時()
  698. Dim 時 As String = Strings.Left(X1, 2) : Dim 分 As String = Strings.Mid(X1, 4, 2)
  699. If (時 = "23" And CInt(分) >= 30) Or (時 = "00" And CInt(分) < 30) Then : X1 = "04:00:00" : ElseIf (時 = "00" And CInt(分) >= 30) Or (時 = "01" And CInt(分) < 30) Then : X1 = "05:00:00"
  700. ElseIf (時 = "01" And CInt(分) >= 30) Or (時 = "02" And CInt(分) < 30) Then : X1 = "06:00:00" : ElseIf (時 = "02" And CInt(分) >= 30) Or (時 = "03" And CInt(分) < 30) Then : X1 = "07:00:00"
  701. ElseIf (時 = "03" And CInt(分) >= 30) Or (時 = "04" And CInt(分) < 30) Then : X1 = "08:00:00" : ElseIf (時 = "04" And CInt(分) >= 30) Or (時 = "05" And CInt(分) < 30) Then : X1 = "09:00:00"
  702. ElseIf (時 = "05" And CInt(分) >= 30) Or (時 = "06" And CInt(分) < 30) Then : X1 = "10:00:00" : ElseIf (時 = "06" And CInt(分) >= 30) Or (時 = "07" And CInt(分) < 30) Then : X1 = "11:00:00"
  703. ElseIf (時 = "07" And CInt(分) >= 30) Or (時 = "08" And CInt(分) < 30) Then : X1 = "12:00:00" : ElseIf (時 = "08" And CInt(分) >= 30) Or (時 = "09" And CInt(分) < 30) Then : X1 = "13:00:00"
  704. ElseIf (時 = "09" And CInt(分) >= 30) Or (時 = "10" And CInt(分) < 30) Then : X1 = "14:00:00" : ElseIf (時 = "10" And CInt(分) >= 30) Or (時 = "11" And CInt(分) < 30) Then : X1 = "15:00:00"
  705. ElseIf (時 = "11" And CInt(分) >= 30) Or (時 = "12" And CInt(分) < 30) Then : X1 = "16:00:00" : ElseIf (時 = "12" And CInt(分) >= 30) Or (時 = "13" And CInt(分) < 30) Then : X1 = "17:00:00"
  706. ElseIf (時 = "13" And CInt(分) >= 30) Or (時 = "14" And CInt(分) < 30) Then : X1 = "18:00:00" : ElseIf (時 = "14" And CInt(分) >= 30) Or (時 = "15" And CInt(分) < 30) Then : X1 = "19:00:00"
  707. ElseIf (時 = "15" And CInt(分) >= 30) Or (時 = "16" And CInt(分) < 30) Then : X1 = "20:00:00" : ElseIf (時 = "16" And CInt(分) >= 30) Or (時 = "17" And CInt(分) < 30) Then : X1 = "21:00:00"
  708. ElseIf (時 = "17" And CInt(分) >= 30) Or (時 = "18" And CInt(分) < 30) Then : X1 = "22:00:00" : ElseIf (時 = "18" And CInt(分) >= 30) Or (時 = "19" And CInt(分) < 30) Then : X1 = "23:00:00"
  709. ElseIf (時 = "19" And CInt(分) >= 30) Or (時 = "20" And CInt(分) < 30) Then : X1 = "00:00:00" : ElseIf (時 = "20" And CInt(分) >= 30) Or (時 = "21" And CInt(分) < 30) Then : X1 = "01:00:00"
  710. ElseIf (時 = "21" And CInt(分) >= 30) Or (時 = "22" And CInt(分) < 30) Then : X1 = "02:00:00" : ElseIf (時 = "22" And CInt(分) >= 30) Or (時 = "23" And CInt(分) < 30) Then : X1 = "03:00:00"
  711. End If
  712. End Sub
  713. Private Sub 時間比對()
  714. Dim dateA As Date = Date.ParseExact("[" & 計算(0) & "]", "[HH:mm:ss]", Nothing)
  715. Dim dateB As Date = Date.ParseExact("[" & 計算(1) & "]", "[HH:mm:ss]", Nothing)
  716. Dim hoursDiff As Integer = DateDiff(DateInterval.Minute, dateA, dateB)
  717. 間隔1 = Math.Abs(hoursDiff)
  718. End Sub
  719. Private Sub 級別清單()
  720. SQL_考勤級別讀取() : 級別_cb.Items.Clear() : 級別_cb.Items.Add("")
  721. While (dr.Read()) : 級別_cb.Items.Add(dr("級別")) : End While : conn.Close()
  722. End Sub
  723. Private Sub 地區清單()
  724. 地區_cb.Items.Clear() : 地區_cb.Items.Add("") : 地區_cb.Items.Add(對話框(16)) : 地區_cb.Items.Add(對話框(17))
  725. End Sub
  726. Private Sub 年分清單()
  727. SQL_年分清單() : 年份2_cb.Items.Clear()
  728. While (dr.Read()) : 年份2_cb.Items.Add(dr("日期")) : End While : conn.Close()
  729. End Sub
  730. Private Sub 群組清單()
  731. SQL_人員薪資表_群組() : 群組_cb.Items.Clear() : 群組1_cb.Items.Clear() : 群組_cb.Items.Add("") : 群組1_cb.Items.Add("")
  732. While (dr.Read()) : 群組_cb.Items.Add(dr("部門名稱")) : 群組1_cb.Items.Add(dr("部門名稱")) : End While : conn.Close()
  733. End Sub
  734. Private Sub 星期設定()
  735. 星1_bt.Text = Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd") : 星2_bt.Text = Strings.Format(開始日期_dtp.Value.AddDays(1), "yyyy/MM/dd")
  736. 星3_bt.Text = Strings.Format(開始日期_dtp.Value.AddDays(2), "yyyy/MM/dd") : 星4_bt.Text = Strings.Format(開始日期_dtp.Value.AddDays(3), "yyyy/MM/dd")
  737. 星5_bt.Text = Strings.Format(開始日期_dtp.Value.AddDays(4), "yyyy/MM/dd") : 星6_bt.Text = Strings.Format(開始日期_dtp.Value.AddDays(5), "yyyy/MM/dd")
  738. 星7_bt.Text = Strings.Format(開始日期_dtp.Value.AddDays(6), "yyyy/MM/dd")
  739. End Sub
  740. Private Sub 人員薪資_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  741. HX_PGS_ERP_SYS.WindowState = 2 : Me.MdiParent = HX_PGS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  742. HX_PGS_ERP_SYS.MaximizeBox = False : HX_PGS_ERP_SYS.MinimizeBox = False : 之前選擇 = -1
  743. 風格() : H(611) = True : 介面 = "H611" : 語言轉換讀取() : 首次開啟 = True : 顯示說明(999, True)
  744. 結束日期_dtp.Value = Today() : 開始日期_dtp.Value = 結束日期_dtp.Value
  745. Dim oldDate As Date : Dim oldWeekDay As Integer : oldDate = 結束日期_dtp.Value : oldWeekDay = Weekday(oldDate)
  746. If oldWeekDay = 7 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(1)
  747. ElseIf oldWeekDay = 6 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(2)
  748. ElseIf oldWeekDay = 5 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(3)
  749. ElseIf oldWeekDay = 4 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(4)
  750. ElseIf oldWeekDay = 3 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(5)
  751. ElseIf oldWeekDay = 2 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(6)
  752. End If : 開始日期_dtp.Value = 結束日期_dtp.Value.AddDays(-6) : 結束日期_dtp.Value = 開始日期_dtp.Value.AddDays(+6)
  753. 本周周一 = 開始日期_dtp.Value : 星期設定()
  754. If 登入人級別 = "00" Then
  755. 縮放2_bt.Visible = True
  756. Else
  757. 縮放2_bt.Visible = False
  758. End If
  759. 工人 = True : 在職 = True : 總清單_dgv.Visible = False : 視窗3_pl.Visible = False : 總清單_dgv.SendToBack() : Panel2.SendToBack()
  760. End Sub
  761. Private Sub 人員薪資_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  762. 年分清單() : 年份2_cb.Text = Year(Today) : 月份2_cb.SelectedIndex = Month(Today) - 1
  763. 群組清單() : If 群組_cb.Items.Count > 1 Then : 群組_cb.SelectedIndex = 0 : End If
  764. 級別清單() : 地區清單() : Set_使用者清單() : 首次開啟 = False
  765. End Sub
  766. Private Sub 人員薪資_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
  767. MyMod.清單字體大小調整()
  768. 清單1_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", HX_PGS_ERP_SYS.字體_NUD.Value)
  769. End Sub
  770. Private Sub 系統說明_bt_Click(sender As Object, e As EventArgs) Handles 系統說明_bt.Click
  771. 介面 = "H611" : WEB說明頁面.Show()
  772. End Sub
  773. Private Sub 語轉扭_bt_Click(sender As Object, e As EventArgs) Handles 語轉扭_bt.Click
  774. H(611) = True : 介面 = "H611" : 語言轉換讀取() : 首次開啟 = False
  775. End Sub
  776. Private Sub 人員薪資_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
  777. HX_PGS_ERP_SYS.MaximizeBox = True : HX_PGS_ERP_SYS.MinimizeBox = True : H(611) = False : MyMod.虛擬桌面開啟()
  778. End Sub
  779. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  780. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  781. End Sub
  782. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  783. timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
  784. End Sub
  785. Private Sub 清單1_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 清單1_dgv.MouseUp
  786. 'If 清單1_dgv.SelectedCells.Count = 1 Then : MsgBox(清單1_dgv.SelectedCells(0).ColumnIndex & " " & 清單1_dgv.SelectedCells(0).RowIndex) : End If
  787. If 清單1_dgv.SelectedCells.Count > 0 Then
  788. If 之前選擇 = -1 Then : Else
  789. If 深色風格 = False Then : 清單1_dgv.Rows(之前選擇).DefaultCellStyle.BackColor = Color.White
  790. Else : 清單1_dgv.Rows(之前選擇).DefaultCellStyle.BackColor = Color.Black : End If
  791. End If
  792. If 深色風格 = False Then
  793. 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).DefaultCellStyle.BackColor = Color.LightGreen : 之前選擇 = 清單1_dgv.SelectedCells(0).RowIndex
  794. Else
  795. 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).DefaultCellStyle.BackColor = Color.Green : 之前選擇 = 清單1_dgv.SelectedCells(0).RowIndex
  796. End If
  797. If 清單1_dgv.SelectedCells(0).ColumnIndex = 0 Then
  798. If 群組選擇_ch.Checked = True Then
  799. 群組_cb.Text = 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(0).Value.ToString
  800. CB選擇清單(群組_cb, 群組_cb.Text)
  801. 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(0).Value = 群組_cb.Text
  802. End If
  803. ElseIf 清單1_dgv.SelectedCells(0).ColumnIndex = 11 Then
  804. Dim 原來的 As String = 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(11).Value.ToString
  805. For I As Integer = 0 To 3000 : PPBB(I) = "" : Next
  806. For I As Integer = 0 To 4 : PPBB(I) = 對話框(I) : NN1 = I : Next
  807. 下拉清單_2.ShowDialog()
  808. If PPAA = "" Then : 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(11).Value = 原來的
  809. Else : 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(11).Value = PPAA : End If
  810. ElseIf 清單1_dgv.SelectedCells(0).ColumnIndex = 49 Then
  811. PA30 = 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(0).Value
  812. PA31 = 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(0).Value
  813. PA32 = 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(12).Value
  814. PA33 = 清單1_dgv.Rows(清單1_dgv.SelectedCells(0).RowIndex).Cells(50).Value
  815. SQL_人員薪資表_修改() : 群組清單() : MGB(系統語言字典("H509-126-" & 語言), 1)
  816. End If
  817. End If
  818. End Sub
  819. Private Sub 清單1_dgv_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles 清單1_dgv.CellEnter
  820. Dim TSSL As Long
  821. For XC As Integer = 0 To 清單1_dgv.Rows.Count - 1
  822. If IsDBNull(清單1_dgv.Rows(XC).Cells(12).Value) Then : Else
  823. If 清單1_dgv.Rows(XC).Cells(12).Value.ToString <> "" Then
  824. 清單1_dgv.Rows(XC).Cells(31).Value = Strings.Format(清單1_dgv.Rows(XC).Cells(12).Value / 8, "#,##0")
  825. 清單1_dgv.Rows(XC).Cells(32).Value = Strings.Format(清單1_dgv.Rows(XC).Cells(12).Value / 6, "#,##0")
  826. 清單1_dgv.Rows(XC).Cells(29).Value = Strings.Format((清單1_dgv.Rows(XC).Cells(12).Value / 8) * CLng(清單1_dgv.Rows(XC).Cells(33).Value.ToString), "#,##0")
  827. 清單1_dgv.Rows(XC).Cells(30).Value = Strings.Format((清單1_dgv.Rows(XC).Cells(12).Value / 6) * CLng(清單1_dgv.Rows(XC).Cells(34).Value.ToString), "#,##0")
  828. 清單1_dgv.Rows(XC).Cells(13).Value = CLng(清單1_dgv.Rows(XC).Cells(29).Value.ToString) + CLng(清單1_dgv.Rows(XC).Cells(30).Value.ToString)
  829. TSSL += CLng(清單1_dgv.Rows(XC).Cells(13).Value.ToString)
  830. HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(TSSL, "#,##0")
  831. End If
  832. End If
  833. 清單1_dgv.Rows(XC).Cells(表頭(30)).Value = 清單1_dgv.Rows(XC).Cells(表頭(25)).Value
  834. If 清單1_dgv.Rows(XC).Cells(0).Value.ToString <> "" Then : 清單1_dgv.Rows(XC).Cells(0).Value = 清單1_dgv.Rows(XC).Cells(0).Value.ToString.ToUpper : End If
  835. If 清單1_dgv.Rows(XC).Cells(1).Value.ToString <> "" Then : 清單1_dgv.Rows(XC).Cells(1).Value = 清單1_dgv.Rows(XC).Cells(1).Value.ToString.ToUpper : End If
  836. Next
  837. End Sub
  838. Private Sub DA1_bt_Click(sender As Object, e As EventArgs) Handles DA1_bt.Click
  839. 結束日期_dtp.Value = 開始日期_dtp.Value.AddDays(-1) : 開始日期_dtp.Value = 開始日期_dtp.Value.AddDays(-7)
  840. 日期判斷() : 星期設定() : Set_使用者清單()
  841. End Sub
  842. Private Sub DA2_bt_Click(sender As Object, e As EventArgs) Handles DA2_bt.Click
  843. 結束日期_dtp.Value = Today() : 開始日期_dtp.Value = 結束日期_dtp.Value
  844. Dim oldDate As Date : Dim oldWeekDay As Integer : oldDate = 結束日期_dtp.Value : oldWeekDay = Weekday(oldDate)
  845. If oldWeekDay = 7 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(1) : ElseIf oldWeekDay = 6 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(2)
  846. ElseIf oldWeekDay = 5 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(3) : ElseIf oldWeekDay = 4 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(4)
  847. ElseIf oldWeekDay = 3 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(5) : ElseIf oldWeekDay = 2 Then : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(6)
  848. End If : 開始日期_dtp.Value = 結束日期_dtp.Value.AddDays(-6) : 結束日期_dtp.Value = 開始日期_dtp.Value.AddDays(+6)
  849. 日期判斷() : 星期設定() : Set_使用者清單()
  850. End Sub
  851. Private Sub DA3_bt_Click(sender As Object, e As EventArgs) Handles DA3_bt.Click
  852. 結束日期_dtp.Value = 開始日期_dtp.Value.AddDays(+13) : 開始日期_dtp.Value = 開始日期_dtp.Value.AddDays(+7)
  853. 日期判斷() : 星期設定() : Set_使用者清單()
  854. End Sub
  855. Private Sub 重新讀取_bt_Click(sender As Object, e As EventArgs) Handles 重新讀取_bt.Click
  856. 日期判斷() : 星期設定() : Set_使用者清單()
  857. End Sub
  858. Private Sub 日期判斷()
  859. If Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 4) <> Strings.Left(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 4) Then
  860. PA17 = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 4) : PA18 = Strings.Left(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 4)
  861. 選擇考勤月份.ShowDialog() : 年份2_cb.Text = PA19
  862. Else
  863. If Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 4) <> 年份2_cb.Text Then : 年份2_cb.Text = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 4) : End If
  864. End If
  865. If Strings.Mid(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 6, 2) <> Strings.Mid(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 6, 2) Then
  866. PA17 = Strings.Mid(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 6, 2) : PA18 = Strings.Mid(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 6, 2)
  867. 選擇考勤月份.ShowDialog() : 月份2_cb.Text = PA19
  868. Else
  869. If Strings.Mid(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 6, 2) <> 月份2_cb.Text Then : 月份2_cb.Text = Strings.Mid(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 6, 2) : End If
  870. End If
  871. End Sub
  872. Private Sub 群組輸入_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 群組輸入_ch.Click
  873. 群組輸入_ch.Checked = True : 群組選擇_ch.Checked = False : 清單1_dgv.Columns(0).ReadOnly = False
  874. End Sub
  875. Private Sub 群組選擇_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 群組選擇_ch.Click
  876. 群組輸入_ch.Checked = False : 群組選擇_ch.Checked = True : 清單1_dgv.Columns(0).ReadOnly = True
  877. End Sub
  878. Private Sub 設定_bt_Click(sender As Object, e As EventArgs) Handles 設定_bt.Click
  879. 'If 清單1_dgv.Columns(11).Visible = False Then : 清單1_dgv.Columns(11).Visible = True : Else : 清單1_dgv.Columns(11).Visible = False : End If
  880. Dim XC As Integer = Me.Size.Width : Dim YC As Integer = Me.Size.Height : Dim XD As Integer = 視窗3_pl.Width : Dim YD As Integer = 視窗3_pl.Height : 首次開啟 = False
  881. If 視窗3_pl.Visible = False Then
  882. If 群組1_cb.Text <> "HARIAN GROUP" Then : MGB(系統語言字典("H611-110-" & 語言), 1) : Else
  883. 視窗3_pl.Location = New System.Drawing.Point((XC - XD) / 2, (YC - YD) / 2) : 視窗3_pl.Visible = True : 視窗3_pl.BringToFront()
  884. 極限設定()
  885. End If
  886. Else : 視窗3_pl.Visible = False : End If
  887. End Sub
  888. Private Sub 加班_nud_ValueChanged(sender As Object, e As EventArgs) Handles 加班_nud.ValueChanged
  889. 極限設定()
  890. End Sub
  891. Private Sub 沖帳金額_nud_ValueChanged(sender As Object, e As EventArgs) Handles 沖帳金額_nud.ValueChanged
  892. 休假比例_nud.Value = (沖帳金額_nud.Value / 總數_nud.Value * 100)
  893. 休假天數_nud.Value = 可沖天數_nud.Value - (沖帳金額_nud.Value / 平均每天_nud.Value)
  894. End Sub
  895. Private Sub 極限設定()
  896. If 首次開啟 = False Then
  897. Dim 總次數 As Integer = 0 : 總數_nud.Value = 0
  898. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  899. If 清單1_dgv.Rows(i).Cells(12).Value.ToString <> "" Then
  900. 總數_nud.Value += (清單1_dgv.Rows(i).Cells(12).Value + ((清單1_dgv.Rows(i).Cells(12).Value / 6) * 加班_nud.Value)) * 7 : 總次數 += 7
  901. End If
  902. Next : 可沖天數_nud.Value = 總次數 : 平均每天_nud.Value = 總數_nud.Value / 可沖天數_nud.Value
  903. 沖帳金額_nud.Maximum = 總數_nud.Value : 沖帳金額_nud.Minimum = 可沖天數_nud.Value : 沖帳金額_nud.Value = 平均每天_nud.Value * 7
  904. 休假比例_nud.Value = 100 - (沖帳金額_nud.Value / 總數_nud.Value * 100)
  905. 休假天數_nud.Value = 可沖天數_nud.Value - (沖帳金額_nud.Value / 平均每天_nud.Value)
  906. End If
  907. End Sub
  908. Private Sub 縮放2_bt_Click(sender As Object, e As EventArgs) Handles 縮放2_bt.Click
  909. If 總清單_dgv.Visible = False Then : 總清單_dgv.Visible = True : 總清單_dgv.BringToFront() : Else : 總清單_dgv.Visible = False : 總清單_dgv.SendToBack() : End If
  910. End Sub
  911. Private Sub 考勤表_bt_Click(sender As Object, e As EventArgs) Handles 考勤表_bt.Click
  912. 合計_dgv.Columns(12).Visible = True : For i As Integer = 15 To 28 : 合計_dgv.Columns(i).Visible = True : Next
  913. 合計_dgv.Columns(13).Visible = False : For i As Integer = 29 To 48 : 合計_dgv.Columns(i).Visible = False : Next
  914. 清單1_dgv.Columns(12).Visible = True : For i As Integer = 15 To 28 : 清單1_dgv.Columns(i).Visible = True : Next
  915. 清單1_dgv.Columns(13).Visible = False : For i As Integer = 29 To 48 : 清單1_dgv.Columns(i).Visible = False : Next : 表頭變形1()
  916. End Sub
  917. Private Sub 薪資表_bt_Click(sender As Object, e As EventArgs) Handles 薪資表_bt.Click
  918. 合計_dgv.Columns(12).Visible = False : For i As Integer = 15 To 28 : 合計_dgv.Columns(i).Visible = False : Next
  919. 合計_dgv.Columns(13).Visible = True : For i As Integer = 29 To 48 : 合計_dgv.Columns(i).Visible = True : Next
  920. 清單1_dgv.Columns(12).Visible = False : For i As Integer = 15 To 28 : 清單1_dgv.Columns(i).Visible = False : Next
  921. 清單1_dgv.Columns(13).Visible = True : For i As Integer = 29 To 48 : 清單1_dgv.Columns(i).Visible = True : Next : 表頭變形2()
  922. End Sub
  923. Private Sub 級別_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 級別_cb.SelectedIndexChanged
  924. Set_使用者清單()
  925. End Sub
  926. Private Sub 地區_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 地區_cb.SelectedIndexChanged
  927. Set_使用者清單()
  928. End Sub
  929. Private Sub 群組_cb_Click(sender As Object, e As EventArgs) Handles 群組_cb.Click
  930. CB選擇清單_可選空白(群組_cb) : Set_使用者清單()
  931. End Sub
  932. Private Sub 群組1_cb_Click(sender As Object, e As EventArgs) Handles 群組1_cb.Click
  933. CB選擇清單_可選空白(群組1_cb) : 群組_cb.Text = 群組1_cb.Text : Set_使用者清單()
  934. End Sub
  935. Private Sub 年份2_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 年份2_cb.SelectedIndexChanged
  936. If 首次開啟 = False Then : Set_使用者清單() : End If
  937. End Sub
  938. Private Sub 年份2_cb_Click(sender As Object, e As EventArgs) Handles 年份2_cb.Click
  939. CB選擇清單(年份2_cb, 年份2_cb.Text) : Set_使用者清單()
  940. End Sub
  941. Private Sub 月份2_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 月份2_cb.SelectedIndexChanged
  942. If 首次開啟 = False Then : Set_使用者清單() : End If
  943. End Sub
  944. Private Sub 月份2_cb_Click(sender As Object, e As EventArgs) Handles 月份2_cb.Click
  945. CB選擇清單(月份2_cb, 月份2_cb.Text) : Set_使用者清單()
  946. End Sub
  947. Private Sub 工人_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 工人_ch.Click
  948. If 工人_ch.Checked = True Then : 工人 = True : Else : 工人 = False : End If : Set_使用者清單()
  949. End Sub
  950. Private Sub CanceL3_bt_Click(sender As Object, e As EventArgs) Handles CanceL3_bt.Click
  951. If 視窗3_pl.Visible = False Then : 視窗3_pl.Visible = True : 視窗3_pl.BringToFront() : Else : 視窗3_pl.Visible = False : End If
  952. End Sub
  953. Private Sub 存檔_bt_Click(sender As Object, e As EventArgs) Handles 存檔_bt.Click
  954. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  955. PA30 = 清單1_dgv.Rows(i).Cells(0).Value.ToString : PA31 = 清單1_dgv.Rows(i).Cells(0).Value.ToString
  956. PA32 = 清單1_dgv.Rows(i).Cells(12).Value.ToString : PA33 = 清單1_dgv.Rows(i).Cells(50).Value.ToString
  957. SQL_人員薪資表_修改()
  958. Next : 群組清單() : MGB(系統語言字典("H509-126-" & 語言), 1)
  959. End Sub
  960. Private Sub 考勤調整_bt_Click(sender As Object, e As EventArgs) Handles 考勤調整_bt.Click
  961. Dim random1 As New Random() : Dim random2 As New Random() : Dim random3 As New Random() : Dim random4 As New Random() : Dim random5 As New Random()
  962. Dim random6 As New Random() : Dim random7 As New Random() : Dim hours As Integer
  963. If 群組1_cb.Text <> "HARIAN GROUP" Then : MGB(系統語言字典("H611-110-" & 語言), 1) : Else : 清除_bt.PerformClick()
  964. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  965. If 休假比例_nud.Value > 0 And 休假比例_nud.Value < 20 Then
  966. Dim 計數 As Integer
  967. Randomize() : hours = random1.Next(1, 100) : If hours < 休假比例_nud.Value + 45 Then
  968. If 清單1_dgv.Rows(i).Cells(15).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(15).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  969. If 清單1_dgv.Rows(i).Cells(16).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(16).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  970. End If
  971. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 10 Then : Exit For : End If
  972. Randomize() : hours = random2.Next(1, 100) : If hours < 休假比例_nud.Value + 45 Then
  973. If 清單1_dgv.Rows(i).Cells(17).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(17).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  974. If 清單1_dgv.Rows(i).Cells(18).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(18).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  975. End If
  976. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 10 Then : Exit For : End If
  977. Randomize() : hours = random3.Next(1, 100) : If hours < 休假比例_nud.Value + 45 Then
  978. If 清單1_dgv.Rows(i).Cells(19).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(19).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  979. If 清單1_dgv.Rows(i).Cells(20).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(20).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  980. End If
  981. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 10 Then : Exit For : End If
  982. Randomize() : hours = random4.Next(1, 100) : If hours < 休假比例_nud.Value + 45 Then
  983. If 清單1_dgv.Rows(i).Cells(21).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(21).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  984. If 清單1_dgv.Rows(i).Cells(22).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(22).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  985. End If
  986. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 10 Then : Exit For : End If
  987. Randomize() : hours = random5.Next(1, 100) : If hours < 休假比例_nud.Value + 45 Then
  988. If 清單1_dgv.Rows(i).Cells(23).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(23).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  989. If 清單1_dgv.Rows(i).Cells(24).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(24).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  990. End If
  991. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 10 Then : Exit For : End If
  992. Randomize() : hours = random6.Next(1, 100) : If hours < 休假比例_nud.Value + 45 Then
  993. If 清單1_dgv.Rows(i).Cells(25).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(25).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  994. If 清單1_dgv.Rows(i).Cells(26).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(26).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  995. End If
  996. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 10 Then : Exit For : End If
  997. ElseIf 休假比例_nud.Value >= 20 And 休假比例_nud.Value < 40 Then
  998. Dim 計數 As Integer
  999. Randomize() : hours = random1.Next(1, 100) : If hours < 休假比例_nud.Value + 25 Then
  1000. If 清單1_dgv.Rows(i).Cells(15).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(15).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1001. If 清單1_dgv.Rows(i).Cells(16).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(16).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1002. End If
  1003. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 7 Then : Exit For : End If
  1004. Randomize() : hours = random2.Next(1, 100) : If hours < 休假比例_nud.Value + 25 Then
  1005. If 清單1_dgv.Rows(i).Cells(17).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(17).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1006. If 清單1_dgv.Rows(i).Cells(18).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(18).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1007. End If
  1008. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 7 Then : Exit For : End If
  1009. Randomize() : hours = random3.Next(1, 100) : If hours < 休假比例_nud.Value + 25 Then
  1010. If 清單1_dgv.Rows(i).Cells(19).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(19).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1011. If 清單1_dgv.Rows(i).Cells(20).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(20).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1012. End If
  1013. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 7 Then : Exit For : End If
  1014. Randomize() : hours = random4.Next(1, 100) : If hours < 休假比例_nud.Value + 25 Then
  1015. If 清單1_dgv.Rows(i).Cells(21).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(21).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1016. If 清單1_dgv.Rows(i).Cells(22).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(22).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1017. End If
  1018. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 7 Then : Exit For : End If
  1019. Randomize() : hours = random5.Next(1, 100) : If hours < 休假比例_nud.Value + 25 Then
  1020. If 清單1_dgv.Rows(i).Cells(23).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(23).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1021. If 清單1_dgv.Rows(i).Cells(24).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(24).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1022. End If
  1023. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 7 Then : Exit For : End If
  1024. Randomize() : hours = random6.Next(1, 100) : If hours < 休假比例_nud.Value + 25 Then
  1025. If 清單1_dgv.Rows(i).Cells(25).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(25).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1026. If 清單1_dgv.Rows(i).Cells(26).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(26).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1027. End If
  1028. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 7 Then : Exit For : End If
  1029. ElseIf 休假比例_nud.Value >= 40 And 休假比例_nud.Value < 60 Then
  1030. Dim 計數 As Integer
  1031. Randomize() : hours = random1.Next(1, 100) : If hours < 休假比例_nud.Value + 15 Then
  1032. If 清單1_dgv.Rows(i).Cells(15).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(15).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1033. If 清單1_dgv.Rows(i).Cells(16).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(16).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1034. End If
  1035. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 5 Then : Exit For : End If
  1036. Randomize() : hours = random2.Next(1, 100) : If hours < 休假比例_nud.Value + 15 Then
  1037. If 清單1_dgv.Rows(i).Cells(17).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(17).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1038. If 清單1_dgv.Rows(i).Cells(18).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(18).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1039. End If
  1040. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 5 Then : Exit For : End If
  1041. Randomize() : hours = random3.Next(1, 100) : If hours < 休假比例_nud.Value + 15 Then
  1042. If 清單1_dgv.Rows(i).Cells(19).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(19).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1043. If 清單1_dgv.Rows(i).Cells(20).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(20).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1044. End If
  1045. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 5 Then : Exit For : End If
  1046. Randomize() : hours = random4.Next(1, 100) : If hours < 休假比例_nud.Value + 15 Then
  1047. If 清單1_dgv.Rows(i).Cells(21).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(21).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1048. If 清單1_dgv.Rows(i).Cells(22).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(22).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1049. End If
  1050. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 5 Then : Exit For : End If
  1051. Randomize() : hours = random5.Next(1, 100) : If hours < 休假比例_nud.Value + 15 Then
  1052. If 清單1_dgv.Rows(i).Cells(23).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(23).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1053. If 清單1_dgv.Rows(i).Cells(24).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(24).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1054. End If
  1055. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 5 Then : Exit For : End If
  1056. Randomize() : hours = random6.Next(1, 100) : If hours < 休假比例_nud.Value + 15 Then
  1057. If 清單1_dgv.Rows(i).Cells(25).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(25).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1058. If 清單1_dgv.Rows(i).Cells(26).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(26).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1059. End If
  1060. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 5 Then : Exit For : End If
  1061. ElseIf 休假比例_nud.Value >= 60 And 休假比例_nud.Value < 80 Then
  1062. Dim 計數 As Integer
  1063. Randomize() : hours = random1.Next(1, 100) : If hours < 休假比例_nud.Value + 10 Then
  1064. If 清單1_dgv.Rows(i).Cells(15).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(15).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1065. If 清單1_dgv.Rows(i).Cells(16).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(16).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1066. End If
  1067. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 3 Then : Exit For : End If
  1068. Randomize() : hours = random2.Next(1, 100) : If hours < 休假比例_nud.Value + 10 Then
  1069. If 清單1_dgv.Rows(i).Cells(17).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(17).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1070. If 清單1_dgv.Rows(i).Cells(18).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(18).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1071. End If
  1072. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 3 Then : Exit For : End If
  1073. Randomize() : hours = random3.Next(1, 100) : If hours < 休假比例_nud.Value + 10 Then
  1074. If 清單1_dgv.Rows(i).Cells(19).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(19).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1075. If 清單1_dgv.Rows(i).Cells(20).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(20).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1076. End If
  1077. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 3 Then : Exit For : End If
  1078. Randomize() : hours = random4.Next(1, 100) : If hours < 休假比例_nud.Value + 10 Then
  1079. If 清單1_dgv.Rows(i).Cells(21).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(21).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1080. If 清單1_dgv.Rows(i).Cells(22).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(22).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1081. End If
  1082. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 3 Then : Exit For : End If
  1083. Randomize() : hours = random5.Next(1, 100) : If hours < 休假比例_nud.Value + 10 Then
  1084. If 清單1_dgv.Rows(i).Cells(23).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(23).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1085. If 清單1_dgv.Rows(i).Cells(24).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(24).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1086. End If
  1087. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 3 Then : Exit For : End If
  1088. Randomize() : hours = random6.Next(1, 100) : If hours < 休假比例_nud.Value + 10 Then
  1089. If 清單1_dgv.Rows(i).Cells(25).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(25).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1090. If 清單1_dgv.Rows(i).Cells(26).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(26).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1091. End If
  1092. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 3 Then : Exit For : End If
  1093. Randomize() : hours = random7.Next(1, 100) : If hours < 休假比例_nud.Value - 48 Then
  1094. If 清單1_dgv.Rows(i).Cells(27).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(27).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1095. If 清單1_dgv.Rows(i).Cells(28).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(28).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1096. End If
  1097. If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 3 Then : Exit For : End If
  1098. ElseIf 休假比例_nud.Value >= 80 And 休假比例_nud.Value < 100 Then
  1099. Dim 計數 As Integer
  1100. Randomize() : hours = random1.Next(1, 100) : If hours < 休假比例_nud.Value + 5 Then
  1101. If 清單1_dgv.Rows(i).Cells(15).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(15).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1102. If 清單1_dgv.Rows(i).Cells(16).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(16).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1103. End If : If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 1 Then : Exit For : End If
  1104. Randomize() : hours = random2.Next(1, 100) : If hours < 休假比例_nud.Value + 5 Then
  1105. If 清單1_dgv.Rows(i).Cells(17).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(17).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1106. If 清單1_dgv.Rows(i).Cells(18).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(18).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1107. End If : If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 1 Then : Exit For : End If
  1108. Randomize() : hours = random3.Next(1, 100) : If hours < 休假比例_nud.Value + 5 Then
  1109. If 清單1_dgv.Rows(i).Cells(19).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(19).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1110. If 清單1_dgv.Rows(i).Cells(20).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(20).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1111. End If : If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 1 Then : Exit For : End If
  1112. Randomize() : hours = random4.Next(1, 100) : If hours < 休假比例_nud.Value + 5 Then
  1113. If 清單1_dgv.Rows(i).Cells(21).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(21).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1114. If 清單1_dgv.Rows(i).Cells(22).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(22).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1115. End If : If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 1 Then : Exit For : End If
  1116. Randomize() : hours = random5.Next(1, 100) : If hours < 休假比例_nud.Value + 5 Then
  1117. If 清單1_dgv.Rows(i).Cells(23).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(23).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1118. If 清單1_dgv.Rows(i).Cells(24).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(24).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1119. End If : If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 1 Then : Exit For : End If
  1120. Randomize() : hours = random6.Next(1, 100) : If hours < 休假比例_nud.Value + 5 Then
  1121. If 清單1_dgv.Rows(i).Cells(25).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(25).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1122. If 清單1_dgv.Rows(i).Cells(26).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(26).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1123. End If : If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 1 Then : Exit For : End If
  1124. Randomize() : hours = random7.Next(1, 100) : If hours < 休假比例_nud.Value - 30 Then
  1125. If 清單1_dgv.Rows(i).Cells(27).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(27).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1126. If 清單1_dgv.Rows(i).Cells(28).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(28).Value = AUTO時 : AUTO舊2 = AUTO時 : End If : 計數 += 1
  1127. End If : If 計數 > 可沖天數_nud.Value - 休假天數_nud.Value + 1 Then : Exit For : End If
  1128. ElseIf 休假比例_nud.Value = 100 Then
  1129. If 清單1_dgv.Rows(i).Cells(15).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(15).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1130. If 清單1_dgv.Rows(i).Cells(16).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(16).Value = AUTO時 : AUTO舊2 = AUTO時 : End If
  1131. If 清單1_dgv.Rows(i).Cells(17).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(17).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1132. If 清單1_dgv.Rows(i).Cells(18).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(18).Value = AUTO時 : AUTO舊2 = AUTO時 : End If
  1133. If 清單1_dgv.Rows(i).Cells(19).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(19).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1134. If 清單1_dgv.Rows(i).Cells(20).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(20).Value = AUTO時 : AUTO舊2 = AUTO時 : End If
  1135. If 清單1_dgv.Rows(i).Cells(21).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(21).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1136. If 清單1_dgv.Rows(i).Cells(22).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(22).Value = AUTO時 : AUTO舊2 = AUTO時 : End If
  1137. If 清單1_dgv.Rows(i).Cells(23).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(23).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1138. If 清單1_dgv.Rows(i).Cells(24).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(24).Value = AUTO時 : AUTO舊2 = AUTO時 : End If
  1139. If 清單1_dgv.Rows(i).Cells(25).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(25).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1140. If 清單1_dgv.Rows(i).Cells(26).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(26).Value = AUTO時 : AUTO舊2 = AUTO時 : End If
  1141. If 清單1_dgv.Rows(i).Cells(27).Value = "" Then : AUTO時段1() : 清單1_dgv.Rows(i).Cells(27).Value = AUTO時 : AUTO舊1 = AUTO時 : End If
  1142. If 清單1_dgv.Rows(i).Cells(28).Value = "" Then : AUTO時段2() : 清單1_dgv.Rows(i).Cells(28).Value = AUTO時 : AUTO舊2 = AUTO時 : End If
  1143. End If
  1144. Next : AUTO時段()
  1145. End If
  1146. End Sub
  1147. Private Sub AUTO時段()
  1148. Dim TSSL As Integer : Dim 加總1, 加總2, 加總3, 加總4, 加總5, 加總6, 加總7 As Long
  1149. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1150. '-------------------------計算星期一--------------------------------------------------------------------------------------------------------------------
  1151. If 清單1_dgv.Rows(i).Cells(15).Value.ToString <> "" And 清單1_dgv.Rows(i).Cells(16).Value.ToString <> "" Then
  1152. X1 = 清單1_dgv.Rows(i).Cells(15).Value.ToString : Set_時段定點() : 計算(0) = X1 : X1 = 清單1_dgv.Rows(i).Cells(16).Value.ToString : Set_時段定點() : 計算(1) = X1 : 時間比對()
  1153. If 間隔1 >= 240 And 間隔1 < 660 Then : 間隔1 -= 60 : ElseIf 間隔1 >= 660 Then : 間隔1 -= -120 : End If
  1154. Dim 加班1 As Integer = 0 : Dim 時間 As Integer = 間隔1 / 60 : If 時間 <= 8 Then : Else : 加班1 = 時間 - 8 : 時間 = 8 : End If
  1155. 清單1_dgv.Rows(i).Cells(35).Value = 時間 : 清單1_dgv.Rows(i).Cells(36).Value = 加班1
  1156. Else : 清單1_dgv.Rows(i).Cells(35).Value = "" : 清單1_dgv.Rows(i).Cells(36).Value = "" : End If
  1157. '-------------------------計算星期二--------------------------------------------------------------------------------------------------------------------
  1158. If 清單1_dgv.Rows(i).Cells(17).Value.ToString <> "" And 清單1_dgv.Rows(i).Cells(18).Value.ToString <> "" Then
  1159. X1 = 清單1_dgv.Rows(i).Cells(17).Value.ToString : Set_時段定點() : 計算(0) = X1 : X1 = 清單1_dgv.Rows(i).Cells(18).Value.ToString : Set_時段定點() : 計算(1) = X1 : 時間比對()
  1160. If 間隔1 >= 240 And 間隔1 < 660 Then : 間隔1 -= 60 : ElseIf 間隔1 >= 660 Then : 間隔1 -= 120 : End If
  1161. Dim 加班1 As Integer = 0 : Dim 時間 As Integer = 間隔1 / 60 : If 時間 <= 8 Then : Else : 加班1 = 時間 - 8 : 時間 = 8 : End If
  1162. 清單1_dgv.Rows(i).Cells(37).Value = 時間 : 清單1_dgv.Rows(i).Cells(38).Value = 加班1
  1163. Else : 清單1_dgv.Rows(i).Cells(37).Value = "" : 清單1_dgv.Rows(i).Cells(38).Value = "" : End If
  1164. '-------------------------計算星期三--------------------------------------------------------------------------------------------------------------------
  1165. If 清單1_dgv.Rows(i).Cells(19).Value.ToString <> "" And 清單1_dgv.Rows(i).Cells(20).Value.ToString <> "" Then
  1166. X1 = 清單1_dgv.Rows(i).Cells(19).Value.ToString : Set_時段定點() : 計算(0) = X1 : X1 = 清單1_dgv.Rows(i).Cells(20).Value.ToString : Set_時段定點() : 計算(1) = X1 : 時間比對()
  1167. If 間隔1 >= 240 And 間隔1 < 660 Then : 間隔1 -= 60 : ElseIf 間隔1 >= 660 Then : 間隔1 -= 120 : End If
  1168. Dim 加班1 As Integer = 0 : Dim 時間 As Integer = 間隔1 / 60 : If 時間 <= 8 Then : Else : 加班1 = 時間 - 8 : 時間 = 8 : End If
  1169. 清單1_dgv.Rows(i).Cells(39).Value = 時間 : 清單1_dgv.Rows(i).Cells(40).Value = 加班1
  1170. Else : 清單1_dgv.Rows(i).Cells(39).Value = "" : 清單1_dgv.Rows(i).Cells(40).Value = "" : End If
  1171. '-------------------------計算星期四--------------------------------------------------------------------------------------------------------------------
  1172. If 清單1_dgv.Rows(i).Cells(21).Value.ToString <> "" And 清單1_dgv.Rows(i).Cells(22).Value.ToString <> "" Then
  1173. X1 = 清單1_dgv.Rows(i).Cells(21).Value.ToString : Set_時段定點() : 計算(0) = X1 : X1 = 清單1_dgv.Rows(i).Cells(22).Value.ToString : Set_時段定點() : 計算(1) = X1 : 時間比對()
  1174. If 間隔1 >= 240 And 間隔1 < 660 Then : 間隔1 -= 60 : ElseIf 間隔1 >= 660 Then : 間隔1 -= 120 : End If
  1175. Dim 加班1 As Integer = 0 : Dim 時間 As Integer = 間隔1 / 60 : If 時間 <= 8 Then : Else : 加班1 = 時間 - 8 : 時間 = 8 : End If
  1176. 清單1_dgv.Rows(i).Cells(41).Value = 時間 : 清單1_dgv.Rows(i).Cells(42).Value = 加班1
  1177. Else : 清單1_dgv.Rows(i).Cells(41).Value = "" : 清單1_dgv.Rows(i).Cells(42).Value = "" : End If
  1178. '-------------------------計算星期五--------------------------------------------------------------------------------------------------------------------
  1179. If 清單1_dgv.Rows(i).Cells(23).Value.ToString <> "" And 清單1_dgv.Rows(i).Cells(24).Value.ToString <> "" Then
  1180. X1 = 清單1_dgv.Rows(i).Cells(23).Value.ToString : Set_時段定點() : 計算(0) = X1 : X1 = 清單1_dgv.Rows(i).Cells(24).Value.ToString : Set_時段定點() : 計算(1) = X1 : 時間比對()
  1181. If 間隔1 >= 240 And 間隔1 < 660 Then : 間隔1 -= 60 : ElseIf 間隔1 >= 660 Then : 間隔1 -= 120 : End If
  1182. Dim 加班1 As Integer = 0 : Dim 時間 As Integer = 間隔1 / 60 : If 時間 <= 8 Then : Else : 加班1 = 時間 - 8 : 時間 = 8 : End If
  1183. 清單1_dgv.Rows(i).Cells(43).Value = 時間 : 清單1_dgv.Rows(i).Cells(44).Value = 加班1
  1184. Else : 清單1_dgv.Rows(i).Cells(43).Value = "" : 清單1_dgv.Rows(i).Cells(44).Value = "" : End If
  1185. '-------------------------計算星期六--------------------------------------------------------------------------------------------------------------------
  1186. If 清單1_dgv.Rows(i).Cells(25).Value.ToString <> "" And 清單1_dgv.Rows(i).Cells(26).Value.ToString <> "" Then
  1187. X1 = 清單1_dgv.Rows(i).Cells(25).Value.ToString : Set_時段定點() : 計算(0) = X1 : X1 = 清單1_dgv.Rows(i).Cells(26).Value.ToString : Set_時段定點() : 計算(1) = X1 : 時間比對()
  1188. If 間隔1 >= 240 And 間隔1 < 660 Then : 間隔1 -= 60 : ElseIf 間隔1 >= 660 Then : 間隔1 -= 120 : End If
  1189. Dim 加班1 As Integer = 0 : Dim 時間 As Integer = 間隔1 / 60 : If 時間 <= 8 Then : Else : 加班1 = 時間 - 8 : 時間 = 8 : End If
  1190. 清單1_dgv.Rows(i).Cells(45).Value = 時間 : 清單1_dgv.Rows(i).Cells(46).Value = 加班1
  1191. Else : 清單1_dgv.Rows(i).Cells(45).Value = "" : 清單1_dgv.Rows(i).Cells(46).Value = "" : End If
  1192. '-------------------------計算星期日--------------------------------------------------------------------------------------------------------------------
  1193. If 清單1_dgv.Rows(i).Cells(27).Value.ToString <> "" And 清單1_dgv.Rows(i).Cells(28).Value.ToString <> "" Then
  1194. X1 = 清單1_dgv.Rows(i).Cells(27).Value.ToString : Set_時段定點() : 計算(0) = X1 : X1 = 清單1_dgv.Rows(i).Cells(28).Value.ToString : Set_時段定點() : 計算(1) = X1 : 時間比對()
  1195. If 間隔1 >= 240 And 間隔1 < 660 Then : 間隔1 -= 60 : ElseIf 間隔1 >= 660 Then : 間隔1 -= 120 : End If
  1196. Dim 加班1 As Integer = 0 : Dim 時間 As Integer = 間隔1 / 60 : If 時間 <= 8 Then : Else : 加班1 = 時間 - 8 : 時間 = 8 : End If
  1197. 清單1_dgv.Rows(i).Cells(47).Value = 時間 : 清單1_dgv.Rows(i).Cells(48).Value = 加班1
  1198. Else : 清單1_dgv.Rows(i).Cells(47).Value = "" : 清單1_dgv.Rows(i).Cells(48).Value = "" : End If
  1199. Dim 正常(6), 加班(6) As Integer
  1200. If 清單1_dgv.Rows(i).Cells(35).Value <> "" Then : 正常(0) = 清單1_dgv.Rows(i).Cells(35).Value.ToString : Else : 正常(0) = 0 : End If
  1201. If 清單1_dgv.Rows(i).Cells(37).Value <> "" Then : 正常(1) = 清單1_dgv.Rows(i).Cells(37).Value.ToString : Else : 正常(1) = 0 : End If
  1202. If 清單1_dgv.Rows(i).Cells(39).Value <> "" Then : 正常(2) = 清單1_dgv.Rows(i).Cells(39).Value.ToString : Else : 正常(2) = 0 : End If
  1203. If 清單1_dgv.Rows(i).Cells(41).Value <> "" Then : 正常(3) = 清單1_dgv.Rows(i).Cells(41).Value.ToString : Else : 正常(3) = 0 : End If
  1204. If 清單1_dgv.Rows(i).Cells(43).Value <> "" Then : 正常(4) = 清單1_dgv.Rows(i).Cells(43).Value.ToString : Else : 正常(4) = 0 : End If
  1205. If 清單1_dgv.Rows(i).Cells(45).Value <> "" Then : 正常(5) = 清單1_dgv.Rows(i).Cells(45).Value.ToString : Else : 正常(5) = 0 : End If
  1206. If 清單1_dgv.Rows(i).Cells(47).Value <> "" Then : 正常(6) = 清單1_dgv.Rows(i).Cells(47).Value.ToString : Else : 正常(6) = 0 : End If
  1207. If 清單1_dgv.Rows(i).Cells(36).Value <> "" Then : 加班(0) = 清單1_dgv.Rows(i).Cells(36).Value.ToString : Else : 加班(0) = 0 : End If
  1208. If 清單1_dgv.Rows(i).Cells(38).Value <> "" Then : 加班(1) = 清單1_dgv.Rows(i).Cells(38).Value.ToString : Else : 加班(1) = 0 : End If
  1209. If 清單1_dgv.Rows(i).Cells(40).Value <> "" Then : 加班(2) = 清單1_dgv.Rows(i).Cells(40).Value.ToString : Else : 加班(2) = 0 : End If
  1210. If 清單1_dgv.Rows(i).Cells(42).Value <> "" Then : 加班(3) = 清單1_dgv.Rows(i).Cells(42).Value.ToString : Else : 加班(3) = 0 : End If
  1211. If 清單1_dgv.Rows(i).Cells(44).Value <> "" Then : 加班(4) = 清單1_dgv.Rows(i).Cells(44).Value.ToString : Else : 加班(4) = 0 : End If
  1212. If 清單1_dgv.Rows(i).Cells(46).Value <> "" Then : 加班(5) = 清單1_dgv.Rows(i).Cells(46).Value.ToString : Else : 加班(5) = 0 : End If
  1213. If 清單1_dgv.Rows(i).Cells(48).Value <> "" Then : 加班(6) = 清單1_dgv.Rows(i).Cells(48).Value.ToString : Else : 加班(6) = 0 : End If
  1214. 清單1_dgv.Rows(i).Cells(33).Value = 正常(0) + 正常(1) + 正常(2) + 正常(3) + 正常(4) + 正常(5) + 正常(6)
  1215. 清單1_dgv.Rows(i).Cells(34).Value = 加班(0) + 加班(1) + 加班(2) + 加班(3) + 加班(4) + 加班(5) + 加班(6)
  1216. '-------------------------計算工資單價--------------------------------------------------------------------------------------------------------------------
  1217. If IsDBNull(清單1_dgv.Rows(i).Cells(12).Value) Then : Else
  1218. If 清單1_dgv.Rows(i).Cells(12).Value.ToString <> "" Then
  1219. 清單1_dgv.Rows(i).Cells(31).Value = Strings.Format(清單1_dgv.Rows(i).Cells(12).Value / 8, "#,##0")
  1220. 清單1_dgv.Rows(i).Cells(32).Value = Strings.Format(清單1_dgv.Rows(i).Cells(12).Value / 6, "#,##0")
  1221. 清單1_dgv.Rows(i).Cells(29).Value = Strings.Format((清單1_dgv.Rows(i).Cells(12).Value / 8) * CLng(清單1_dgv.Rows(i).Cells(33).Value.ToString), "#,##0")
  1222. 清單1_dgv.Rows(i).Cells(30).Value = Strings.Format((清單1_dgv.Rows(i).Cells(12).Value / 6) * CLng(清單1_dgv.Rows(i).Cells(34).Value.ToString), "#,##0")
  1223. 清單1_dgv.Rows(i).Cells(13).Value = CLng(清單1_dgv.Rows(i).Cells(29).Value.ToString) + CLng(清單1_dgv.Rows(i).Cells(30).Value.ToString)
  1224. TSSL += CLng(清單1_dgv.Rows(i).Cells(13).Value.ToString)
  1225. HX_PGS_ERP_SYS.合計_TSSL.Text = "Total : " & Strings.Format(TSSL, "#,##0")
  1226. End If
  1227. End If
  1228. '-------------------------計算工資單價--------------------------------------------------------------------------------------------------------------------
  1229. 清單1_dgv.Rows(i).Cells(4).Value = i + 1 : 合計_dgv.Rows(0).Cells(4).Value = i + 1 : 合計_dgv.Rows(0).Cells(13).Value += CLng(清單1_dgv.Rows(i).Cells(13).Value.ToString)
  1230. 合計_dgv.Rows(0).Cells(29).Value += CLng(清單1_dgv.Rows(i).Cells(29).Value.ToString) : 合計_dgv.Rows(0).Cells(30).Value += CLng(清單1_dgv.Rows(i).Cells(30).Value.ToString)
  1231. If 清單1_dgv.Rows(i).Cells(33).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(33).Value += CLng(清單1_dgv.Rows(i).Cells(33).Value.ToString) : End If
  1232. If 清單1_dgv.Rows(i).Cells(34).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(34).Value += CLng(清單1_dgv.Rows(i).Cells(34).Value.ToString) : End If
  1233. If 清單1_dgv.Rows(i).Cells(35).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(35).Value += CLng(清單1_dgv.Rows(i).Cells(35).Value.ToString) : End If
  1234. If 清單1_dgv.Rows(i).Cells(36).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(36).Value += CLng(清單1_dgv.Rows(i).Cells(36).Value.ToString) : End If
  1235. If 清單1_dgv.Rows(i).Cells(37).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(37).Value += CLng(清單1_dgv.Rows(i).Cells(37).Value.ToString) : End If
  1236. If 清單1_dgv.Rows(i).Cells(38).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(38).Value += CLng(清單1_dgv.Rows(i).Cells(38).Value.ToString) : End If
  1237. If 清單1_dgv.Rows(i).Cells(39).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(39).Value += CLng(清單1_dgv.Rows(i).Cells(39).Value.ToString) : End If
  1238. If 清單1_dgv.Rows(i).Cells(40).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(40).Value += CLng(清單1_dgv.Rows(i).Cells(40).Value.ToString) : End If
  1239. If 清單1_dgv.Rows(i).Cells(41).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(41).Value += CLng(清單1_dgv.Rows(i).Cells(41).Value.ToString) : End If
  1240. If 清單1_dgv.Rows(i).Cells(42).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(42).Value += CLng(清單1_dgv.Rows(i).Cells(42).Value.ToString) : End If
  1241. If 清單1_dgv.Rows(i).Cells(43).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(43).Value += CLng(清單1_dgv.Rows(i).Cells(43).Value.ToString) : End If
  1242. If 清單1_dgv.Rows(i).Cells(44).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(44).Value += CLng(清單1_dgv.Rows(i).Cells(44).Value.ToString) : End If
  1243. If 清單1_dgv.Rows(i).Cells(45).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(45).Value += CLng(清單1_dgv.Rows(i).Cells(45).Value.ToString) : End If
  1244. If 清單1_dgv.Rows(i).Cells(46).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(46).Value += CLng(清單1_dgv.Rows(i).Cells(46).Value.ToString) : End If
  1245. If 清單1_dgv.Rows(i).Cells(47).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(47).Value += CLng(清單1_dgv.Rows(i).Cells(47).Value.ToString) : End If
  1246. If 清單1_dgv.Rows(i).Cells(48).Value.ToString <> "" Then : 合計_dgv.Rows(0).Cells(48).Value += CLng(清單1_dgv.Rows(i).Cells(48).Value.ToString) : End If
  1247. If 清單1_dgv.Rows(i).Cells(15).Value.ToString = "" Then : Else : 加總1 += 1 : End If
  1248. If 清單1_dgv.Rows(i).Cells(17).Value.ToString = "" Then : Else : 加總2 += 1 : End If
  1249. If 清單1_dgv.Rows(i).Cells(19).Value.ToString = "" Then : Else : 加總3 += 1 : End If
  1250. If 清單1_dgv.Rows(i).Cells(21).Value.ToString = "" Then : Else : 加總4 += 1 : End If
  1251. If 清單1_dgv.Rows(i).Cells(23).Value.ToString = "" Then : Else : 加總5 += 1 : End If
  1252. If 清單1_dgv.Rows(i).Cells(25).Value.ToString = "" Then : Else : 加總6 += 1 : End If
  1253. If 清單1_dgv.Rows(i).Cells(27).Value.ToString = "" Then : Else : 加總7 += 1 : End If
  1254. Next
  1255. 合計_dgv.Rows(0).Cells(15).Value = 加總1 : 合計_dgv.Rows(0).Cells(17).Value = 加總2 : 合計_dgv.Rows(0).Cells(19).Value = 加總3 : 合計_dgv.Rows(0).Cells(21).Value = 加總4
  1256. 合計_dgv.Rows(0).Cells(23).Value = 加總5 : 合計_dgv.Rows(0).Cells(25).Value = 加總6 : 合計_dgv.Rows(0).Cells(27).Value = 加總7
  1257. 合計_dgv.Rows(0).Cells(29).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(29).Value), "#,##0")
  1258. 合計_dgv.Rows(0).Cells(30).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(30).Value), "#,##0")
  1259. 合計_dgv.Rows(0).Cells(33).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(33).Value), "#,##0")
  1260. 合計_dgv.Rows(0).Cells(34).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(34).Value), "#,##0")
  1261. 合計_dgv.Rows(0).Cells(35).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(35).Value), "#,##0")
  1262. 合計_dgv.Rows(0).Cells(36).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(36).Value), "#,##0")
  1263. 合計_dgv.Rows(0).Cells(37).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(37).Value), "#,##0")
  1264. 合計_dgv.Rows(0).Cells(38).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(38).Value), "#,##0")
  1265. 合計_dgv.Rows(0).Cells(39).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(39).Value), "#,##0")
  1266. 合計_dgv.Rows(0).Cells(40).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(40).Value), "#,##0")
  1267. 合計_dgv.Rows(0).Cells(41).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(41).Value), "#,##0")
  1268. 合計_dgv.Rows(0).Cells(42).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(42).Value), "#,##0")
  1269. 合計_dgv.Rows(0).Cells(43).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(43).Value), "#,##0")
  1270. 合計_dgv.Rows(0).Cells(44).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(44).Value), "#,##0")
  1271. 合計_dgv.Rows(0).Cells(45).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(45).Value), "#,##0")
  1272. 合計_dgv.Rows(0).Cells(46).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(46).Value), "#,##0")
  1273. 合計_dgv.Rows(0).Cells(47).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(47).Value), "#,##0")
  1274. 合計_dgv.Rows(0).Cells(48).Value = Strings.Format(CLng(合計_dgv.Rows(0).Cells(48).Value), "#,##0")
  1275. End Sub
  1276. Private Sub AUTO時段1()
  1277. Dim random As New Random()
  1278. For i As Integer = 1 To 1000
  1279. Randomize() : Dim hours As Integer = random.Next(6, 7) : Dim minutes As Integer
  1280. If hours = 6 Then : Randomize() : minutes = random.Next(45, 59) : Else : Randomize() : minutes = random.Next(0, 3) : End If
  1281. Randomize() : Dim seconds As Integer = random.Next(0, 60) : AUTO時 = $"{hours:00}:{minutes:00}:{seconds:00}"
  1282. If AUTO舊1 <> AUTO時 Then : Exit For : End If
  1283. Next
  1284. End Sub
  1285. Private Sub AUTO時段2()
  1286. Dim random As New Random()
  1287. For i As Integer = 1 To 1000
  1288. Dim hours As Integer
  1289. If 加班_nud.Value = 1 Then : Randomize() : hours = random.Next(16, 17)
  1290. ElseIf 加班_nud.Value = 2 Then : Randomize() : hours = random.Next(18, 19)
  1291. ElseIf 加班_nud.Value = 3 Then : Randomize() : hours = random.Next(19, 20) : End If
  1292. Dim minutes As Integer
  1293. If 加班_nud.Value = 1 Then : If hours = 16 Then : Randomize() : minutes = random.Next(55, 59) : Else : Randomize() : minutes = random.Next(0, 15) : End If
  1294. ElseIf 加班_nud.Value = 2 Then : If hours = 18 Then : Randomize() : minutes = random.Next(55, 59) : Else : Randomize() : minutes = random.Next(0, 15) : End If
  1295. ElseIf 加班_nud.Value = 3 Then : If hours = 19 Then : Randomize() : minutes = random.Next(55, 59) : Else : Randomize() : minutes = random.Next(0, 15) : End If : End If
  1296. Randomize() : Dim seconds As Integer = random.Next(0, 60) : AUTO時 = $"{hours:00}:{minutes:00}:{seconds:00}"
  1297. If AUTO舊2 <> AUTO時 Then : Exit For : End If
  1298. Next
  1299. End Sub
  1300. Private Sub 清除_bt_Click(sender As Object, e As EventArgs) Handles 清除_bt.Click
  1301. If 群組1_cb.Text <> "HARIAN GROUP" Then : MGB(系統語言字典("H611-110-" & 語言), 1) : Else
  1302. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1303. 清單1_dgv.Rows(i).Cells(15).Value = "" : 清單1_dgv.Rows(i).Cells(16).Value = "" : 清單1_dgv.Rows(i).Cells(17).Value = "" : 清單1_dgv.Rows(i).Cells(18).Value = ""
  1304. 清單1_dgv.Rows(i).Cells(19).Value = "" : 清單1_dgv.Rows(i).Cells(20).Value = "" : 清單1_dgv.Rows(i).Cells(21).Value = "" : 清單1_dgv.Rows(i).Cells(22).Value = ""
  1305. 清單1_dgv.Rows(i).Cells(23).Value = "" : 清單1_dgv.Rows(i).Cells(24).Value = "" : 清單1_dgv.Rows(i).Cells(25).Value = "" : 清單1_dgv.Rows(i).Cells(26).Value = ""
  1306. 清單1_dgv.Rows(i).Cells(27).Value = "" : 清單1_dgv.Rows(i).Cells(28).Value = ""
  1307. Next : AUTO時段()
  1308. End If
  1309. End Sub
  1310. Private Sub 虛擬存檔_bt_Click(sender As Object, e As EventArgs) Handles 虛擬存檔_bt.Click
  1311. If 群組1_cb.Text <> "HARIAN GROUP" Then : MGB(系統語言字典("H611-110-" & 語言), 1) : Else
  1312. Dim 可以存檔 As Boolean = False
  1313. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1314. If 清單1_dgv.Rows(i).Cells(15).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(20).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(25).Value.ToString = "" And
  1315. 清單1_dgv.Rows(i).Cells(16).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(21).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(26).Value.ToString = "" And
  1316. 清單1_dgv.Rows(i).Cells(17).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(22).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(27).Value.ToString = "" And
  1317. 清單1_dgv.Rows(i).Cells(18).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(23).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(28).Value.ToString = "" And
  1318. 清單1_dgv.Rows(i).Cells(19).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(24).Value.ToString = "" Then : Else : 可以存檔 = True : End If
  1319. Next
  1320. If 可以存檔 = True Then
  1321. Dim AAS As String : PA45 = 星1_bt.Text : SQL_虛擬考勤明細表刪除()
  1322. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1323. If 清單1_dgv.Rows(i).Cells(15).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(20).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(25).Value.ToString = "" And
  1324. 清單1_dgv.Rows(i).Cells(16).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(21).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(26).Value.ToString = "" And
  1325. 清單1_dgv.Rows(i).Cells(17).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(22).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(27).Value.ToString = "" And
  1326. 清單1_dgv.Rows(i).Cells(18).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(23).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(28).Value.ToString = "" And
  1327. 清單1_dgv.Rows(i).Cells(19).Value.ToString = "" And 清單1_dgv.Rows(i).Cells(24).Value.ToString = "" Then : Else
  1328. AAS = "(N'" & 清單1_dgv.Rows(i).Cells(50).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(15).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(16).Value.ToString & "',
  1329. N'" & 清單1_dgv.Rows(i).Cells(17).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(18).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(19).Value.ToString & "',
  1330. N'" & 清單1_dgv.Rows(i).Cells(20).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(21).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(22).Value.ToString & "',
  1331. N'" & 清單1_dgv.Rows(i).Cells(23).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(24).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(25).Value.ToString & "',
  1332. N'" & 清單1_dgv.Rows(i).Cells(26).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(27).Value.ToString & "', N'" & 清單1_dgv.Rows(i).Cells(28).Value.ToString & "',
  1333. N'" & 星1_bt.Text & "')"
  1334. End If : If i = 0 Then : SQL2 = AAS : Else : SQL2 = SQL2 & "," & AAS : End If
  1335. Next
  1336. SQL_虛擬考勤明細表新增() : Set_使用者清單() : MGB(系統語言字典("H509-126-" & 語言), 1)
  1337. Else : MGB(系統語言字典("H611-121-" & 語言), 1) : End If
  1338. End If
  1339. End Sub
  1340. Private Sub 列印_bt_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  1341. PA17 = "EXCEL" : PA18 = "PDF" : 選擇考勤月份.ShowDialog()
  1342. Dim FVG As String
  1343. xlApp = CType(CreateObject("Excel.Application"), Application)
  1344. xlBook = xlApp.Workbooks.Add
  1345. xlApp.DisplayAlerts = True
  1346. xlApp.Visible = True
  1347. xlApp.Application.WindowState = xlMaximized
  1348. GN1 = 0
  1349. ''----------------------------------------------------------------------------------------------------------------------
  1350. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select
  1351. If 群組1_cb.Text = "" Then : FVG = "ALL GROUP 伙食費" : Else : FVG = 群組1_cb.Text & "伙食費" : End If
  1352. xlApp.Sheets(1).Name = FVG : xlBook.Activate() : xlSheet.Activate()
  1353. xlSheet.Cells(1, 1) = "點工伙食費表(吃飯錢) UANG MAKAN BURUH HARIAN " & FVG
  1354. xlSheet.Cells(2, 1) = "STT" : xlSheet.Cells(2, 2) = "員工編號" & vbCrLf & "ID_No" : xlSheet.Cells(2, 3) = "姓名" & vbCrLf & "Name" : xlSheet.Cells(2, 4) = "TOTAL UANG MAKAN"
  1355. xlSheet.Cells(2, 5) = "TOTAL MASUK KERJA" : xlSheet.Cells(2, 6) = "UANG MAKAN / HARI"
  1356. xlSheet.Cells(2, 7) = 星1_bt.Text : xlSheet.Cells(3, 7) = "上班" : xlSheet.Cells(2, 8) = 星2_bt.Text : xlSheet.Cells(3, 8) = "上班"
  1357. xlSheet.Cells(2, 9) = 星3_bt.Text : xlSheet.Cells(3, 9) = "上班" : xlSheet.Cells(2, 10) = 星4_bt.Text : xlSheet.Cells(3, 10) = "上班"
  1358. xlSheet.Cells(2, 11) = 星5_bt.Text : xlSheet.Cells(3, 11) = "上班" : xlSheet.Cells(2, 12) = 星6_bt.Text : xlSheet.Cells(3, 12) = "上班"
  1359. xlSheet.Cells(2, 13) = 星7_bt.Text : xlSheet.Cells(3, 13) = "上班" : xlSheet.Cells(2, 14) = "備註"
  1360. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1361. xlSheet.Cells(4 + i, 1) = i + 1 : xlSheet.Cells(4 + i, 2) = 清單1_dgv.Rows(i).Cells("ID卡號").Value.ToString
  1362. xlSheet.Cells(4 + i, 3) = 清單1_dgv.Rows(i).Cells(表頭(0)).Value.ToString : xlSheet.Cells(4 + i, 6) = "5000"
  1363. xlSheet.Cells(4 + i, 5) = "= SUM(G" & 4 + i & ": M" & 4 + i & ")" : xlSheet.Cells(4 + i, 4) = "=F" & 4 + i & "*E" & 4 + i & ""
  1364. If 清單1_dgv.Rows(i).Cells(表頭(64)).Value.ToString <> "" Then : xlSheet.Cells(4 + i, 7) = "1" : End If
  1365. If 清單1_dgv.Rows(i).Cells(表頭(32)).Value.ToString <> "" Then : xlSheet.Cells(4 + i, 8) = "1" : End If
  1366. If 清單1_dgv.Rows(i).Cells(表頭(34)).Value.ToString <> "" Then : xlSheet.Cells(4 + i, 9) = "1" : End If
  1367. If 清單1_dgv.Rows(i).Cells(表頭(36)).Value.ToString <> "" Then : xlSheet.Cells(4 + i, 10) = "1" : End If
  1368. If 清單1_dgv.Rows(i).Cells(表頭(38)).Value.ToString <> "" Then : xlSheet.Cells(4 + i, 11) = "1" : End If
  1369. If 清單1_dgv.Rows(i).Cells(表頭(40)).Value.ToString <> "" Then : xlSheet.Cells(4 + i, 12) = "1" : End If
  1370. If 清單1_dgv.Rows(i).Cells(表頭(42)).Value.ToString <> "" Then : xlSheet.Cells(4 + i, 13) = "1" : End If : GN1 += 1
  1371. Next : xlSheet.Cells(4 + GN1 + 1, 3) = "TOTAL : " : xlSheet.Cells(4 + GN1 + 1, 4) = "=SUM(D4:D" & 4 + GN1 & ")" : BB(xlApp, xlSheet)
  1372. '----------------------------------------------------------------------------------------------------------------------
  1373. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select
  1374. If 群組1_cb.Text = "" Then : FVG = "ALL GROUP 薪資表" : Else : FVG = 群組1_cb.Text & "薪資表" : End If
  1375. xlApp.Sheets(1).Name = FVG : xlBook.Activate() : xlSheet.Activate()
  1376. xlSheet.Cells(1, 1) = "點 工 薪 資 表 TABEL GAJI " & FVG
  1377. xlSheet.Cells(2, 1) = "STT" : xlSheet.Cells(2, 2) = "員工編號" & vbCrLf & "ID_No" : xlSheet.Cells(2, 3) = "姓名" & vbCrLf & "Name" : xlSheet.Cells(2, 4) = "總計" & vbCrLf & "A=B+C"
  1378. xlSheet.Cells(2, 5) = "工資金額" : xlSheet.Cells(3, 5) = "正常" & vbCrLf & "B=D*F" : xlSheet.Cells(3, 6) = "加班" & vbCrLf & "C=E*G"
  1379. xlSheet.Cells(2, 7) = "工資單價" : xlSheet.Cells(3, 7) = "正常/H" & vbCrLf & "D" : xlSheet.Cells(3, 8) = "加班/H" & vbCrLf & "E"
  1380. xlSheet.Cells(2, 9) = "合計" : xlSheet.Cells(3, 9) = "正常/H" & vbCrLf & "F" : xlSheet.Cells(3, 10) = "加班/H" & vbCrLf & "G"
  1381. xlSheet.Cells(2, 11) = 星1_bt.Text : xlSheet.Cells(3, 11) = "正常/H" : xlSheet.Cells(3, 12) = "加班/H"
  1382. xlSheet.Cells(2, 13) = 星2_bt.Text : xlSheet.Cells(3, 13) = "正常/H" : xlSheet.Cells(3, 14) = "加班/H"
  1383. xlSheet.Cells(2, 15) = 星3_bt.Text : xlSheet.Cells(3, 15) = "正常/H" : xlSheet.Cells(3, 16) = "加班/H"
  1384. xlSheet.Cells(2, 17) = 星4_bt.Text : xlSheet.Cells(3, 17) = "正常/H" : xlSheet.Cells(3, 18) = "加班/H"
  1385. xlSheet.Cells(2, 19) = 星5_bt.Text : xlSheet.Cells(3, 19) = "正常/H" : xlSheet.Cells(3, 20) = "加班/H"
  1386. xlSheet.Cells(2, 21) = 星6_bt.Text : xlSheet.Cells(3, 21) = "正常/H" : xlSheet.Cells(3, 22) = "加班/H"
  1387. xlSheet.Cells(2, 23) = 星7_bt.Text : xlSheet.Cells(3, 23) = "正常/H" : xlSheet.Cells(3, 24) = "加班/H"
  1388. xlSheet.Cells(2, 25) = "備註"
  1389. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1390. xlSheet.Cells(4 + i, 1) = i + 1 : xlSheet.Cells(4 + i, 2) = 清單1_dgv.Rows(i).Cells("ID卡號").Value.ToString
  1391. xlSheet.Cells(4 + i, 3) = 清單1_dgv.Rows(i).Cells(表頭(0)).Value.ToString : xlSheet.Cells(4 + i, 4) = 清單1_dgv.Rows(i).Cells(表頭(28)).Value.ToString
  1392. xlSheet.Cells(4 + i, 5) = 清單1_dgv.Rows(i).Cells(表頭(58)).Value.ToString : xlSheet.Cells(4 + i, 6) = 清單1_dgv.Rows(i).Cells(表頭(59)).Value.ToString
  1393. xlSheet.Cells(4 + i, 7) = 清單1_dgv.Rows(i).Cells(表頭(60)).Value.ToString : xlSheet.Cells(4 + i, 8) = 清單1_dgv.Rows(i).Cells(表頭(61)).Value.ToString
  1394. xlSheet.Cells(4 + i, 9) = 清單1_dgv.Rows(i).Cells(表頭(62)).Value.ToString : xlSheet.Cells(4 + i, 10) = 清單1_dgv.Rows(i).Cells(表頭(63)).Value.ToString
  1395. xlSheet.Cells(4 + i, 11) = 清單1_dgv.Rows(i).Cells(表頭(44)).Value.ToString : xlSheet.Cells(4 + i, 12) = 清單1_dgv.Rows(i).Cells(表頭(45)).Value.ToString
  1396. xlSheet.Cells(4 + i, 13) = 清單1_dgv.Rows(i).Cells(表頭(46)).Value.ToString : xlSheet.Cells(4 + i, 14) = 清單1_dgv.Rows(i).Cells(表頭(47)).Value.ToString
  1397. xlSheet.Cells(4 + i, 15) = 清單1_dgv.Rows(i).Cells(表頭(48)).Value.ToString : xlSheet.Cells(4 + i, 16) = 清單1_dgv.Rows(i).Cells(表頭(49)).Value.ToString
  1398. xlSheet.Cells(4 + i, 17) = 清單1_dgv.Rows(i).Cells(表頭(50)).Value.ToString : xlSheet.Cells(4 + i, 18) = 清單1_dgv.Rows(i).Cells(表頭(51)).Value.ToString
  1399. xlSheet.Cells(4 + i, 19) = 清單1_dgv.Rows(i).Cells(表頭(52)).Value.ToString : xlSheet.Cells(4 + i, 20) = 清單1_dgv.Rows(i).Cells(表頭(53)).Value.ToString
  1400. xlSheet.Cells(4 + i, 21) = 清單1_dgv.Rows(i).Cells(表頭(54)).Value.ToString : xlSheet.Cells(4 + i, 22) = 清單1_dgv.Rows(i).Cells(表頭(55)).Value.ToString
  1401. xlSheet.Cells(4 + i, 23) = 清單1_dgv.Rows(i).Cells(表頭(56)).Value.ToString : xlSheet.Cells(4 + i, 24) = 清單1_dgv.Rows(i).Cells(表頭(57)).Value.ToString
  1402. Next
  1403. xlSheet.Cells(4 + GN1 + 1, 3) = "TOTAL : " : xlSheet.Cells(4 + GN1 + 1, 4) = "=SUM(D4:D" & 4 + GN1 & ")"
  1404. xlSheet.Cells(4 + GN1 + 1, 5) = "=SUM(E4:E" & 4 + GN1 & ")" : xlSheet.Cells(4 + GN1 + 1, 6) = "=SUM(F4:F" & 4 + GN1 & ")" : CC(xlApp, xlSheet)
  1405. '----------------------------------------------------------------------------------------------------------------------
  1406. xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select
  1407. If 群組1_cb.Text = "" Then : FVG = "ALL GROUP 考勤表" : Else : FVG = 群組1_cb.Text & "考勤表" : End If
  1408. xlApp.Sheets(1).Name = FVG : xlBook.Activate() : xlSheet.Activate()
  1409. xlSheet.Cells(1, 1) = "點 工 薪 資 表 GAJI BURUH HARIAN " & FVG
  1410. xlSheet.Cells(2, 1) = "STT" : xlSheet.Cells(2, 2) = "員工編號" & vbCrLf & "ID_No" : xlSheet.Cells(2, 3) = "姓名" & vbCrLf & "Name" : xlSheet.Cells(2, 4) = "基本薪資" & vbCrLf & "天/RP"
  1411. xlSheet.Cells(2, 5) = 星1_bt.Text : xlSheet.Cells(3, 5) = "上班" : xlSheet.Cells(3, 6) = "下班"
  1412. xlSheet.Cells(2, 7) = 星2_bt.Text : xlSheet.Cells(3, 7) = "上班" : xlSheet.Cells(3, 8) = "下班"
  1413. xlSheet.Cells(2, 9) = 星3_bt.Text : xlSheet.Cells(3, 9) = "上班" : xlSheet.Cells(3, 10) = "下班"
  1414. xlSheet.Cells(2, 11) = 星4_bt.Text : xlSheet.Cells(3, 11) = "上班" : xlSheet.Cells(3, 12) = "下班"
  1415. xlSheet.Cells(2, 13) = 星5_bt.Text : xlSheet.Cells(3, 13) = "上班" : xlSheet.Cells(3, 14) = "下班"
  1416. xlSheet.Cells(2, 15) = 星6_bt.Text : xlSheet.Cells(3, 15) = "上班" : xlSheet.Cells(3, 16) = "下班"
  1417. xlSheet.Cells(2, 17) = 星7_bt.Text : xlSheet.Cells(3, 17) = "上班" : xlSheet.Cells(3, 18) = "下班"
  1418. xlSheet.Cells(2, 19) = "備註"
  1419. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1420. xlSheet.Cells(4 + i, 1) = i + 1 : xlSheet.Cells(4 + i, 2) = 清單1_dgv.Rows(i).Cells("ID卡號").Value.ToString
  1421. xlSheet.Cells(4 + i, 3) = 清單1_dgv.Rows(i).Cells(表頭(0)).Value.ToString : xlSheet.Cells(4 + i, 4) = 清單1_dgv.Rows(i).Cells(表頭(27)).Value.ToString
  1422. xlSheet.Cells(4 + i, 5) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(64)).Value.ToString, 5) : xlSheet.Cells(4 + i, 6) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(31)).Value.ToString, 5)
  1423. xlSheet.Cells(4 + i, 7) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(32)).Value.ToString, 5) : xlSheet.Cells(4 + i, 8) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(33)).Value.ToString, 5)
  1424. xlSheet.Cells(4 + i, 9) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(34)).Value.ToString, 5) : xlSheet.Cells(4 + i, 10) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(35)).Value.ToString, 5)
  1425. xlSheet.Cells(4 + i, 11) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(36)).Value.ToString, 5) : xlSheet.Cells(4 + i, 12) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(37)).Value.ToString, 5)
  1426. xlSheet.Cells(4 + i, 13) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(38)).Value.ToString, 5) : xlSheet.Cells(4 + i, 14) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(39)).Value.ToString, 5)
  1427. xlSheet.Cells(4 + i, 15) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(40)).Value.ToString, 5) : xlSheet.Cells(4 + i, 16) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(41)).Value.ToString, 5)
  1428. xlSheet.Cells(4 + i, 17) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(42)).Value.ToString, 5) : xlSheet.Cells(4 + i, 18) = Strings.Left(清單1_dgv.Rows(i).Cells(表頭(43)).Value.ToString, 5)
  1429. Next : AA(xlApp, xlSheet)
  1430. xlApp.Sheets(4).Delete : xlSheet.PageSetup.PrintArea = ""
  1431. xlApp.Cells.Select()
  1432. xlApp.Application.WindowState = xlMinimized
  1433. If PA19 = "PDF" Then
  1434. '-------------轉換成PDF---------------------------------------------------------------------
  1435. Dim SERT As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
  1436. xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, SERT & "\" & FVG & "_X1.pdf", XlFixedFormatQuality.xlQualityStandard, True)
  1437. xlBook.Sheets(2).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, SERT & "\" & FVG & "_X2.pdf", XlFixedFormatQuality.xlQualityStandard, True)
  1438. xlBook.Sheets(3).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, SERT & "\" & FVG & "_X3.pdf", XlFixedFormatQuality.xlQualityStandard, True)
  1439. Dim pdf1 As String = SERT & "\" & FVG & "_X1.pdf"
  1440. Dim pdf2 As String = SERT & "\" & FVG & "_X2.pdf"
  1441. Dim pdf3 As String = SERT & "\" & FVG & "_X3.pdf"
  1442. Dim outputPDF As String = SERT & "\" & FVG & ".pdf"
  1443. Dim mergedDocument As New PdfDocument() ' 创建一个新的PDF文档对象
  1444. Dim document1 As PdfDocument = PdfReader.Open(pdf1, PdfDocumentOpenMode.Import) ' 打开第一个PDF文件
  1445. For Each page As PdfPage In document1.Pages : mergedDocument.AddPage(page) : Next ' 将第一个PDF文件的页面逐一添加到合并文档
  1446. Dim document2 As PdfDocument = PdfReader.Open(pdf2, PdfDocumentOpenMode.Import) ' 打开第二个PDF文件
  1447. For Each page As PdfPage In document2.Pages : mergedDocument.AddPage(page) : Next ' 将第二个PDF文件的页面逐一添加到合并文档
  1448. Dim document3 As PdfDocument = PdfReader.Open(pdf3, PdfDocumentOpenMode.Import) ' 打开第三个PDF文件
  1449. For Each page As PdfPage In document3.Pages : mergedDocument.AddPage(page) : Next ' 将第三个PDF文件的页面逐一添加到合并文档
  1450. mergedDocument.Save(outputPDF) ' 保存合并后的PDF文件
  1451. document1.Close() : document2.Close() : document3.Close() ' 关闭文档对象
  1452. File.Delete(SERT & "\" & FVG & "_X1.pdf")
  1453. File.Delete(SERT & "\" & FVG & "_X2.pdf")
  1454. File.Delete(SERT & "\" & FVG & "_X3.pdf") ' 删除文件1和文件2
  1455. '-------------關閉EXCEL---------------------------------------------------------------------
  1456. xlSheet.PageSetup.PrintArea = "" : xlApp.Cells.Select()
  1457. xlApp.Application.WindowState = xlMinimized
  1458. xlBook.Close(False)
  1459. Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
  1460. Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
  1461. Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
  1462. xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect()
  1463. '-------------開啟PDF---------------------------------------------------------------------
  1464. Dim pdfFilePath As String = SERT & "\" & FVG & ".pdf"
  1465. If IsChromeInstalled() Then
  1466. Try
  1467. Dim chromeProcess As New Process()
  1468. chromeProcess.StartInfo.FileName = "chrome"
  1469. chromeProcess.StartInfo.Arguments = """" & pdfFilePath & """"
  1470. chromeProcess.Start()
  1471. Catch ex As Exception
  1472. End Try
  1473. Else
  1474. Try
  1475. System.Diagnostics.Process.Start("""" & pdfFilePath & """")
  1476. Catch ex As Exception
  1477. End Try
  1478. End If
  1479. End If
  1480. MGB(系統語言字典("H508-121-" & 語言), 1) : PA17 = "" : PA18 = "" : PA19 = ""
  1481. End Sub
  1482. ' 檢查系統是否已安裝 Google Chrome
  1483. Private Function IsChromeInstalled() As Boolean
  1484. Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
  1485. If key IsNot Nothing Then
  1486. For Each subkeyName As String In key.GetSubKeyNames()
  1487. Dim subkey As Microsoft.Win32.RegistryKey = key.OpenSubKey(subkeyName)
  1488. Dim displayName As Object = subkey.GetValue("DisplayName")
  1489. If displayName IsNot Nothing AndAlso displayName.ToString().Contains("Google Chrome") Then
  1490. Return True
  1491. End If
  1492. Next
  1493. End If
  1494. Return False
  1495. End Function
  1496. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  1497. Return CType(xlBook.Worksheets.Add, Worksheet)
  1498. End Function
  1499. Private Sub AA(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Worksheet)
  1500. xlSheet.Cells.Select()
  1501. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1502. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1503. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1504. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  1505. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 4 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 10
  1506. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 22 : xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 10
  1507. xlSheet.Columns("D:D").Select : myExcel.Selection.NumberFormatLocal = "#,##0" : xlSheet.Columns("E:R").Select : myExcel.Selection.ColumnWidth = 6
  1508. xlSheet.Range("A2:S3").Select()
  1509. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1510. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1511. xlSheet.Range("C4:R" & GN1 + 4).Select()
  1512. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1513. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1514. xlSheet.Range("A4:B" & GN1 + 4).Select()
  1515. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 9 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1516. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1517. xlSheet.Range("A1:S1").Select()
  1518. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1519. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1520. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 49407 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
  1521. xlSheet.Range("A2:A3").Select()
  1522. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1523. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1524. xlSheet.Range("B2:B3").Select()
  1525. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1526. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1527. xlSheet.Range("C2:C3").Select()
  1528. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1529. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1530. xlSheet.Range("D2:D3").Select()
  1531. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1532. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1533. xlSheet.Range("E2:F2").Select()
  1534. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1535. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1536. xlSheet.Range("G2:H2").Select()
  1537. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1538. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1539. xlSheet.Range("I2:J2").Select()
  1540. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1541. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1542. xlSheet.Range("K2:L2").Select()
  1543. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1544. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1545. xlSheet.Range("M2:N2").Select()
  1546. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1547. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1548. xlSheet.Range("O2:P2").Select()
  1549. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1550. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1551. xlSheet.Range("Q2:R2").Select()
  1552. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1553. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1554. xlSheet.Range("S2:S3").Select()
  1555. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1556. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1557. xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 30 : xlSheet.Rows("2:3").Select : myExcel.Selection.RowHeight = 20
  1558. xlSheet.Rows("4:" & GN1 + 4).Select : myExcel.Selection.RowHeight = 25
  1559. xlSheet.Range("A1:S3").Select()
  1560. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1561. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1562. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1563. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1564. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1565. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1566. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1567. xlSheet.Range("A4:S" & GN1 + 4).Select()
  1568. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1569. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1570. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1571. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1572. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1573. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1574. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1575. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1576. If 清單1_dgv.Rows(i).Cells(表頭(64)).Value.ToString = "" Then : xlSheet.Range("E" & 4 + i).Select()
  1577. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1578. If 清單1_dgv.Rows(i).Cells(表頭(31)).Value.ToString = "" Then : xlSheet.Range("F" & 4 + i).Select()
  1579. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1580. If 清單1_dgv.Rows(i).Cells(表頭(32)).Value.ToString = "" Then : xlSheet.Range("G" & 4 + i).Select()
  1581. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1582. If 清單1_dgv.Rows(i).Cells(表頭(33)).Value.ToString = "" Then : xlSheet.Range("H" & 4 + i).Select()
  1583. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1584. If 清單1_dgv.Rows(i).Cells(表頭(34)).Value.ToString = "" Then : xlSheet.Range("I" & 4 + i).Select()
  1585. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1586. If 清單1_dgv.Rows(i).Cells(表頭(35)).Value.ToString = "" Then : xlSheet.Range("J" & 4 + i).Select()
  1587. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1588. If 清單1_dgv.Rows(i).Cells(表頭(36)).Value.ToString = "" Then : xlSheet.Range("K" & 4 + i).Select()
  1589. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1590. If 清單1_dgv.Rows(i).Cells(表頭(37)).Value.ToString = "" Then : xlSheet.Range("L" & 4 + i).Select()
  1591. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1592. If 清單1_dgv.Rows(i).Cells(表頭(38)).Value.ToString = "" Then : xlSheet.Range("M" & 4 + i).Select()
  1593. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1594. If 清單1_dgv.Rows(i).Cells(表頭(39)).Value.ToString = "" Then : xlSheet.Range("N" & 4 + i).Select()
  1595. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1596. If 清單1_dgv.Rows(i).Cells(表頭(40)).Value.ToString = "" Then : xlSheet.Range("O" & 4 + i).Select()
  1597. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1598. If 清單1_dgv.Rows(i).Cells(表頭(41)).Value.ToString = "" Then : xlSheet.Range("P" & 4 + i).Select()
  1599. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1600. If 清單1_dgv.Rows(i).Cells(表頭(42)).Value.ToString = "" Then : xlSheet.Range("Q" & 4 + i).Select()
  1601. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1602. If 清單1_dgv.Rows(i).Cells(表頭(43)).Value.ToString = "" Then : xlSheet.Range("R" & 4 + i).Select()
  1603. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1604. Next
  1605. xlSheet.Range("B2:D3").Select()
  1606. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1607. .ShrinkToFit = False : .ReadingOrder = xlContext : End With
  1608. xlSheet.Range("C4:C" & GN1 + 4).Select()
  1609. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1610. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  1611. myExcel.ActiveWindow.DisplayGridlines = False
  1612. myExcel.Application.PrintCommunication = False
  1613. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$3" : .PrintTitleColumns = "" : End With
  1614. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  1615. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  1616. .LeftMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .RightMargin = myExcel.Application.InchesToPoints(0.196850393700787)
  1617. .TopMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .BottomMargin = myExcel.Application.InchesToPoints(0.393700787401575)
  1618. .HeaderMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .FooterMargin = myExcel.Application.InchesToPoints(0.196850393700787)
  1619. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Orientation = xlLandscape
  1620. .Draft = False : .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False
  1621. .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  1622. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = ""
  1623. .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = ""
  1624. .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  1625. End With
  1626. myExcel.Application.PrintCommunication = True
  1627. myExcel.Application.PrintCommunication = False : With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$5" : .PrintTitleColumns = "" : End With
  1628. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  1629. With myExcel.ActiveSheet.PageSetup : .LeftHeader = ""
  1630. .CenterHeader = "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "" & Chr(10) & "&G"
  1631. .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  1632. .LeftMargin = myExcel.Application.InchesToPoints(0.236220472440945) : .RightMargin = myExcel.Application.InchesToPoints(0.236220472440945)
  1633. .TopMargin = myExcel.Application.InchesToPoints(0.748031496062992) : .BottomMargin = myExcel.Application.InchesToPoints(0.748031496062992)
  1634. .HeaderMargin = myExcel.Application.InchesToPoints(0.31496062992126) : .FooterMargin = myExcel.Application.InchesToPoints(0.31496062992126)
  1635. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Draft = False
  1636. .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False : .OddAndEvenPagesHeaderFooter = False
  1637. .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  1638. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  1639. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  1640. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  1641. End With : myExcel.Application.PrintCommunication = True
  1642. End Sub
  1643. Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Worksheet)
  1644. xlSheet.Cells.Select()
  1645. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1646. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1647. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 4 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 14
  1648. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 25 : xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 13
  1649. xlSheet.Columns("E:F").Select : myExcel.Selection.ColumnWidth = 8 : xlSheet.Columns("G:M").Select : myExcel.Selection.ColumnWidth = 9
  1650. xlSheet.Rows("2:3").Select : myExcel.Selection.RowHeight = 25 : xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 30
  1651. xlSheet.Columns("D:F").Select : myExcel.Selection.NumberFormatLocal = "#,##0"
  1652. xlSheet.Rows("4:" & GN1 + 5).Select : myExcel.Selection.RowHeight = 25
  1653. xlSheet.Range("A2:A3").Select()
  1654. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1655. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1656. xlSheet.Range("B2:B3").Select()
  1657. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1658. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1659. xlSheet.Range("C2:C3").Select()
  1660. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1661. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1662. xlSheet.Range("D2:D3").Select()
  1663. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1664. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With : myExcel.Selection.Merge
  1665. xlSheet.Range("E2:E3").Select()
  1666. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1667. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With : myExcel.Selection.Merge
  1668. xlSheet.Range("F2:F3").Select()
  1669. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1670. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = True : End With : myExcel.Selection.Merge
  1671. xlSheet.Range("G3:M3").Select()
  1672. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1673. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  1674. xlSheet.Range("N2:N3").Select()
  1675. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1676. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1677. xlSheet.Range("A1:N1").Select()
  1678. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1679. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1680. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 49407 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
  1681. xlSheet.Range("A1:N3").Select()
  1682. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1683. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1684. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1685. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1686. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1687. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1688. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1689. xlSheet.Range("A4:N" & GN1 + 5).Select()
  1690. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1691. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1692. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1693. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1694. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1695. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1696. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1697. xlSheet.Range("C" & GN1 + 5).Select()
  1698. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1699. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  1700. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1701. If 清單1_dgv.Rows(i).Cells(表頭(64)).Value.ToString = "" Then : xlSheet.Range("G" & 4 + i).Select()
  1702. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1703. If 清單1_dgv.Rows(i).Cells(表頭(32)).Value.ToString = "" Then : xlSheet.Range("H" & 4 + i).Select()
  1704. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1705. If 清單1_dgv.Rows(i).Cells(表頭(34)).Value.ToString = "" Then : xlSheet.Range("I" & 4 + i).Select()
  1706. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1707. If 清單1_dgv.Rows(i).Cells(表頭(36)).Value.ToString = "" Then : xlSheet.Range("J" & 4 + i).Select()
  1708. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1709. If 清單1_dgv.Rows(i).Cells(表頭(38)).Value.ToString = "" Then : xlSheet.Range("K" & 4 + i).Select()
  1710. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1711. If 清單1_dgv.Rows(i).Cells(表頭(40)).Value.ToString = "" Then : xlSheet.Range("L" & 4 + i).Select()
  1712. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1713. If 清單1_dgv.Rows(i).Cells(表頭(42)).Value.ToString = "" Then : xlSheet.Range("M" & 4 + i).Select()
  1714. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1715. Next
  1716. xlSheet.Range("A2:N3").Select()
  1717. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1718. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1719. myExcel.ActiveWindow.DisplayGridlines = False
  1720. myExcel.Application.PrintCommunication = False
  1721. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$3" : .PrintTitleColumns = "" : End With
  1722. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  1723. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  1724. .LeftMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .RightMargin = myExcel.Application.InchesToPoints(0.196850393700787)
  1725. .TopMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .BottomMargin = myExcel.Application.InchesToPoints(0.393700787401575)
  1726. .HeaderMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .FooterMargin = myExcel.Application.InchesToPoints(0.196850393700787)
  1727. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Orientation = xlLandscape
  1728. .Draft = False : .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False
  1729. .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  1730. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = ""
  1731. .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = ""
  1732. .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  1733. End With
  1734. myExcel.Application.PrintCommunication = True
  1735. End Sub
  1736. Private Sub CC(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Worksheet)
  1737. xlSheet.Cells.Select()
  1738. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1739. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1740. xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 4 : xlSheet.Columns("B:B").Select : myExcel.Selection.ColumnWidth = 10
  1741. xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 22 : xlSheet.Columns("D:E").Select : myExcel.Selection.ColumnWidth = 11
  1742. xlSheet.Columns("F:F").Select : myExcel.Selection.ColumnWidth = 8 : xlSheet.Columns("G:H").Select : myExcel.Selection.ColumnWidth = 8
  1743. xlSheet.Columns("I:X").Select : myExcel.Selection.ColumnWidth = 5 : xlSheet.Columns("I:J").Select : myExcel.Selection.ColumnWidth = 7
  1744. xlSheet.Columns("K:X").Select : myExcel.Selection.ColumnWidth = 4 : xlSheet.Rows("1:1").Select : myExcel.Selection.RowHeight = 30
  1745. xlSheet.Rows("2:2").Select : myExcel.Selection.RowHeight = 15 : xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 35
  1746. xlSheet.Rows("4:" & GN1 + 5).Select : myExcel.Selection.RowHeight = 25 : xlSheet.Columns("D:F").Select : myExcel.Selection.NumberFormatLocal = "#,##0"
  1747. xlSheet.Range("C4:Y" & GN1 + 5).Select()
  1748. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1749. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1750. xlSheet.Range("A4:B" & GN1 + 5).Select()
  1751. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 9 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1752. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1753. xlSheet.Range("K3:X3").Select()
  1754. With myExcel.Selection : .HorizontalAlignment = xlGeneral : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1755. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  1756. xlSheet.Range("I4:X" & GN1 + 5).Select()
  1757. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1758. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  1759. xlSheet.Range("A2:A3").Select()
  1760. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1761. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1762. xlSheet.Range("B2:B3").Select()
  1763. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1764. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1765. xlSheet.Range("C2:C3").Select()
  1766. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1767. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1768. xlSheet.Range("D2:D3").Select()
  1769. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1770. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1771. xlSheet.Range("E2:F2").Select()
  1772. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1773. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1774. xlSheet.Range("G2:H2").Select()
  1775. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1776. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1777. xlSheet.Range("I2:J2").Select()
  1778. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1779. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1780. xlSheet.Range("K2:L2").Select()
  1781. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1782. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1783. xlSheet.Range("M2:N2").Select()
  1784. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1785. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1786. xlSheet.Range("O2:P2").Select()
  1787. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1788. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1789. xlSheet.Range("Q2:R2").Select()
  1790. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1791. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1792. xlSheet.Range("S2:T2").Select()
  1793. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1794. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1795. xlSheet.Range("U2:V2").Select()
  1796. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1797. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1798. xlSheet.Range("W2:X2").Select()
  1799. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1800. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1801. xlSheet.Range("Y2:Y3").Select()
  1802. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1803. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1804. xlSheet.Range("A2:Y3").Select()
  1805. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 10 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1806. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1807. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  1808. .ReadingOrder = xlContext : End With
  1809. xlSheet.Range("K2:X2").Select()
  1810. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 8 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  1811. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  1812. xlSheet.Range("A1:Y1").Select()
  1813. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  1814. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
  1815. With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 49407 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
  1816. xlSheet.Range("A1:Y3").Select()
  1817. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1818. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1819. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1820. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1821. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1822. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1823. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1824. xlSheet.Range("A4:Y" & GN1 + 5).Select()
  1825. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  1826. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1827. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1828. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1829. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1830. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1831. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  1832. For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
  1833. If 清單1_dgv.Rows(i).Cells(表頭(64)).Value.ToString = "" Then : xlSheet.Range("K" & 4 + i).Select()
  1834. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1835. If 清單1_dgv.Rows(i).Cells(表頭(31)).Value.ToString = "" Then : xlSheet.Range("L" & 4 + i).Select()
  1836. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1837. If 清單1_dgv.Rows(i).Cells(表頭(32)).Value.ToString = "" Then : xlSheet.Range("M" & 4 + i).Select()
  1838. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1839. If 清單1_dgv.Rows(i).Cells(表頭(33)).Value.ToString = "" Then : xlSheet.Range("N" & 4 + i).Select()
  1840. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1841. If 清單1_dgv.Rows(i).Cells(表頭(34)).Value.ToString = "" Then : xlSheet.Range("O" & 4 + i).Select()
  1842. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1843. If 清單1_dgv.Rows(i).Cells(表頭(35)).Value.ToString = "" Then : xlSheet.Range("P" & 4 + i).Select()
  1844. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1845. If 清單1_dgv.Rows(i).Cells(表頭(36)).Value.ToString = "" Then : xlSheet.Range("Q" & 4 + i).Select()
  1846. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1847. If 清單1_dgv.Rows(i).Cells(表頭(37)).Value.ToString = "" Then : xlSheet.Range("R" & 4 + i).Select()
  1848. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1849. If 清單1_dgv.Rows(i).Cells(表頭(38)).Value.ToString = "" Then : xlSheet.Range("S" & 4 + i).Select()
  1850. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1851. If 清單1_dgv.Rows(i).Cells(表頭(39)).Value.ToString = "" Then : xlSheet.Range("T" & 4 + i).Select()
  1852. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1853. If 清單1_dgv.Rows(i).Cells(表頭(40)).Value.ToString = "" Then : xlSheet.Range("U" & 4 + i).Select()
  1854. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1855. If 清單1_dgv.Rows(i).Cells(表頭(41)).Value.ToString = "" Then : xlSheet.Range("V" & 4 + i).Select()
  1856. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1857. If 清單1_dgv.Rows(i).Cells(表頭(42)).Value.ToString = "" Then : xlSheet.Range("W" & 4 + i).Select()
  1858. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1859. If 清單1_dgv.Rows(i).Cells(表頭(43)).Value.ToString = "" Then : xlSheet.Range("X" & 4 + i).Select()
  1860. With myExcel.Selection.Borders(xlDiagonalUp) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With : End If
  1861. Next
  1862. myExcel.ActiveWindow.DisplayGridlines = False
  1863. myExcel.Application.PrintCommunication = False
  1864. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "$1:$3" : .PrintTitleColumns = "" : End With
  1865. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  1866. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "第 &P 頁,共 &N 頁" : .RightFooter = ""
  1867. .LeftMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .RightMargin = myExcel.Application.InchesToPoints(0.196850393700787)
  1868. .TopMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .BottomMargin = myExcel.Application.InchesToPoints(0.393700787401575)
  1869. .HeaderMargin = myExcel.Application.InchesToPoints(0.196850393700787) : .FooterMargin = myExcel.Application.InchesToPoints(0.196850393700787)
  1870. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Orientation = xlLandscape
  1871. .Draft = False : .FirstPageNumber = xlAutomatic : .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = False
  1872. .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False : .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  1873. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = ""
  1874. .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = ""
  1875. .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  1876. End With
  1877. myExcel.Application.PrintCommunication = True
  1878. End Sub
  1879. '----------------------自創視窗滑鼠拖曳功能---------------------------------------------------------------------------------------------------------
  1880. Dim OldX, OldY As Long : Dim drag As Boolean
  1881. Private Sub 視窗3_pl_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 視窗3_pl.MouseDown
  1882. If e.Button = MouseButtons.Left Then : OldX = e.X : OldY = e.Y : drag = True : End If
  1883. End Sub
  1884. Private Sub 視窗3_pl_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 視窗3_pl.MouseMove
  1885. If drag Then : 視窗3_pl.Left = 視窗3_pl.Left + e.X - OldX : 視窗3_pl.Top = 視窗3_pl.Top + e.Y - OldY : End If
  1886. End Sub
  1887. Private Sub 視窗3_pl_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 視窗3_pl.MouseUp
  1888. drag = False
  1889. End Sub
  1890. Private Sub Label11_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label11.MouseDown
  1891. If e.Button = MouseButtons.Left Then : OldX = e.X : OldY = e.Y : drag = True : End If
  1892. End Sub
  1893. Private Sub Label11_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label11.MouseMove
  1894. If drag Then : 視窗3_pl.Left = 視窗3_pl.Left + e.X - OldX : 視窗3_pl.Top = 視窗3_pl.Top + e.Y - OldY : End If
  1895. End Sub
  1896. Private Sub Label11_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label11.MouseUp
  1897. drag = False
  1898. End Sub
  1899. Private Sub 風格()
  1900. If 深色風格 = False Then
  1901. Me.BackColor = SystemColors.Control : 視窗3_pl.BackColor = Color.White : Panel4.BackColor = SystemColors.Control
  1902. '----------------黑-------------------------------------------
  1903. Label5.ForeColor = Color.Black : Label4.ForeColor = Color.Black : 工人_ch.ForeColor = Color.Black : Label2.ForeColor = Color.Black
  1904. 群組輸入_ch.ForeColor = Color.Black : 群組選擇_ch.ForeColor = Color.Black : Label1.ForeColor = Color.Black : Label3.ForeColor = Color.Black
  1905. Label6.ForeColor = Color.Black : Label7.ForeColor = Color.Black : Label8.ForeColor = Color.Black : Label9.ForeColor = Color.Black
  1906. Label10.ForeColor = Color.Black : Label11.ForeColor = Color.Black
  1907. 存檔_bt.BackColor = Color.White : 系統說明_bt.BackColor = Color.White : 列印_bt.BackColor = Color.White : 設定_bt.BackColor = Color.White
  1908. 考勤調整_bt.BackColor = Color.White : 清除_bt.BackColor = Color.White : 虛擬存檔_bt.BackColor = Color.White : 重新讀取_bt.BackColor = Color.White
  1909. DA1_bt.BackColor = Color.White : DA1_bt.ForeColor = Color.Black : DA2_bt.BackColor = Color.White : DA2_bt.ForeColor = Color.Black
  1910. DA3_bt.BackColor = Color.White : DA3_bt.ForeColor = Color.Black : 考勤表_bt.BackColor = Color.White : 考勤表_bt.ForeColor = Color.Black
  1911. 薪資表_bt.BackColor = Color.White : 薪資表_bt.ForeColor = Color.Black : 月份2_cb.BackColor = Color.White : 月份2_cb.ForeColor = Color.Black
  1912. 年份2_cb.BackColor = Color.White : 年份2_cb.ForeColor = Color.Black : 群組_cb.BackColor = Color.White : 群組_cb.ForeColor = Color.Black
  1913. 群組1_cb.BackColor = Color.White : 群組1_cb.ForeColor = Color.Black : 總數_nud.BackColor = Color.White : 總數_nud.ForeColor = Color.Black
  1914. 平均每天_nud.BackColor = Color.White : 平均每天_nud.ForeColor = Color.Black : 可沖天數_nud.BackColor = Color.White : 可沖天數_nud.ForeColor = Color.Black
  1915. 加班_nud.BackColor = Color.White : 加班_nud.ForeColor = Color.Black : 沖帳金額_nud.BackColor = Color.White : 沖帳金額_nud.ForeColor = Color.Black
  1916. 休假比例_nud.BackColor = Color.White : 休假比例_nud.ForeColor = Color.Black : 休假天數_nud.BackColor = Color.White : 休假天數_nud.ForeColor = Color.Black
  1917. 星1_bt.BackColor = Color.White : 星1_bt.ForeColor = Color.Black : 星2_bt.BackColor = Color.White : 星2_bt.ForeColor = Color.Black
  1918. 星3_bt.BackColor = Color.White : 星3_bt.ForeColor = Color.Black : 星4_bt.BackColor = Color.White : 星4_bt.ForeColor = Color.Black
  1919. 星5_bt.BackColor = Color.White : 星5_bt.ForeColor = Color.Black : 星6_bt.BackColor = Color.White : 星6_bt.ForeColor = Color.Black
  1920. 星7_bt.BackColor = Color.White : 星7_bt.ForeColor = Color.Black
  1921. 清單1_dgv.EnableHeadersVisualStyles = True : 清單1_dgv.BackgroundColor = Color.White : 清單1_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
  1922. 清單1_dgv.DefaultCellStyle.BackColor = Color.White : 清單1_dgv.DefaultCellStyle.ForeColor = Color.Black
  1923. 總清單_dgv.EnableHeadersVisualStyles = True : 總清單_dgv.BackgroundColor = Color.White : 總清單_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
  1924. 總清單_dgv.DefaultCellStyle.BackColor = Color.White : 總清單_dgv.DefaultCellStyle.ForeColor = Color.Black
  1925. 合計_dgv.EnableHeadersVisualStyles = True : 合計_dgv.BackgroundColor = Color.White : 合計_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black
  1926. 合計_dgv.DefaultCellStyle.BackColor = Color.White : 合計_dgv.DefaultCellStyle.ForeColor = Color.Black
  1927. Else
  1928. Me.BackColor = Color.Black : 視窗3_pl.BackColor = Color.DimGray : Panel4.BackColor = Color.Black
  1929. '----------------黑-------------------------------------------
  1930. Label5.ForeColor = Color.White : Label4.ForeColor = Color.White : 工人_ch.ForeColor = Color.White : Label2.ForeColor = Color.White
  1931. 群組輸入_ch.ForeColor = Color.White : 群組選擇_ch.ForeColor = Color.White : Label1.ForeColor = Color.White : Label3.ForeColor = Color.White
  1932. Label6.ForeColor = Color.White : Label7.ForeColor = Color.White : Label8.ForeColor = Color.White : Label9.ForeColor = Color.White
  1933. Label10.ForeColor = Color.White : Label11.ForeColor = Color.White
  1934. 存檔_bt.BackColor = Color.DimGray : 系統說明_bt.BackColor = Color.DimGray : 列印_bt.BackColor = Color.DimGray : 設定_bt.BackColor = Color.DimGray
  1935. 考勤調整_bt.BackColor = Color.DimGray : 清除_bt.BackColor = Color.DimGray : 虛擬存檔_bt.BackColor = Color.DimGray : 重新讀取_bt.BackColor = Color.DimGray
  1936. DA1_bt.BackColor = Color.DimGray : DA1_bt.ForeColor = Color.White : DA2_bt.BackColor = Color.DimGray : DA2_bt.ForeColor = Color.White
  1937. DA3_bt.BackColor = Color.DimGray : DA3_bt.ForeColor = Color.White : 考勤表_bt.BackColor = Color.DimGray : 考勤表_bt.ForeColor = Color.White
  1938. 薪資表_bt.BackColor = Color.DimGray : 薪資表_bt.ForeColor = Color.White : 月份2_cb.BackColor = Color.DimGray : 月份2_cb.ForeColor = Color.White
  1939. 年份2_cb.BackColor = Color.DimGray : 年份2_cb.ForeColor = Color.White : 群組_cb.BackColor = Color.DimGray : 群組_cb.ForeColor = Color.White
  1940. 群組1_cb.BackColor = Color.DimGray : 群組1_cb.ForeColor = Color.White : 總數_nud.BackColor = Color.DimGray : 總數_nud.ForeColor = Color.White
  1941. 平均每天_nud.BackColor = Color.DimGray : 平均每天_nud.ForeColor = Color.White : 可沖天數_nud.BackColor = Color.DimGray : 可沖天數_nud.ForeColor = Color.White
  1942. 加班_nud.BackColor = Color.DimGray : 加班_nud.ForeColor = Color.White : 沖帳金額_nud.BackColor = Color.DimGray : 沖帳金額_nud.ForeColor = Color.White
  1943. 休假比例_nud.BackColor = Color.DimGray : 休假比例_nud.ForeColor = Color.White : 休假天數_nud.BackColor = Color.DimGray : 休假天數_nud.ForeColor = Color.White
  1944. 星1_bt.BackColor = Color.Black : 星1_bt.ForeColor = Color.White : 星2_bt.BackColor = Color.Black : 星2_bt.ForeColor = Color.White
  1945. 星3_bt.BackColor = Color.Black : 星3_bt.ForeColor = Color.White : 星4_bt.BackColor = Color.Black : 星4_bt.ForeColor = Color.White
  1946. 星5_bt.BackColor = Color.Black : 星5_bt.ForeColor = Color.White : 星6_bt.BackColor = Color.Black : 星6_bt.ForeColor = Color.White
  1947. 星7_bt.BackColor = Color.Black : 星7_bt.ForeColor = Color.White
  1948. 清單1_dgv.EnableHeadersVisualStyles = False : 清單1_dgv.BackgroundColor = Color.DimGray : 清單1_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
  1949. 清單1_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 清單1_dgv.DefaultCellStyle.BackColor = Color.Black : 清單1_dgv.DefaultCellStyle.ForeColor = Color.White
  1950. 總清單_dgv.EnableHeadersVisualStyles = False : 總清單_dgv.BackgroundColor = Color.DimGray : 總清單_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
  1951. 總清單_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 總清單_dgv.DefaultCellStyle.BackColor = Color.Black : 總清單_dgv.DefaultCellStyle.ForeColor = Color.White
  1952. 合計_dgv.EnableHeadersVisualStyles = False : 合計_dgv.BackgroundColor = Color.DimGray : 合計_dgv.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
  1953. 合計_dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.Black : 合計_dgv.DefaultCellStyle.BackColor = Color.Black : 合計_dgv.DefaultCellStyle.ForeColor = Color.White
  1954. End If
  1955. End Sub
  1956. End Class