Public Class 拆帳制考勤文件導入 Dim xlApp As Microsoft.Office.Interop.Excel.Application Dim xlBook As Microsoft.Office.Interop.Excel.Workbook Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet Dim file_name, 文件判斷 As String Private Sub 拆帳制考勤文件導入_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub 拆帳制考勤文件導入_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown SQL_營運成本收支單對帳表_查詢最後一筆年份清單() : 年份_cb.Items.Clear() : 年份_cb.Items.Add("") : While (dr.Read()) : 年份_cb.Items.Add(dr("年份")) : End While : conn.Close() End Sub Private Sub 選路徑1_bt_Click(sender As Object, e As EventArgs) Handles 選路徑1_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑1_tb.Text = 開啟檔案.FileName '----------服務紀錄總表----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑1_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(2, 1).value : 文件判斷 &= xlSheet.Cells(3, 1).value : 文件判斷 &= xlSheet.Cells(3, 2).value : 文件判斷 &= xlSheet.Cells(3, 3).value 文件判斷 &= xlSheet.Cells(3, 4).value : 文件判斷 &= xlSheet.Cells(3, 5).value : 文件判斷 &= xlSheet.Cells(3, 6).value : 文件判斷 &= xlSheet.Cells(3, 7).value If 文件判斷 = "服務紀錄編號案號服務項目代碼服務項目類別身分證字號姓名服務日期" Then : Else : MsgBox("服務紀錄總表 檔案不吻合!!") : 路徑1_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑2_bt_Click(sender As Object, e As EventArgs) Handles 選路徑2_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑2_tb.Text = 開啟檔案.FileName '----------拆 帳 明 細 表----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑2_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(2, 1).value : 文件判斷 &= xlSheet.Cells(3, 1).value : 文件判斷 &= xlSheet.Cells(3, 2).value : 文件判斷 &= xlSheet.Cells(3, 3).value 文件判斷 &= xlSheet.Cells(3, 4).value : 文件判斷 &= xlSheet.Cells(3, 5).value : 文件判斷 &= xlSheet.Cells(3, 6).value : 文件判斷 &= xlSheet.Cells(3, 7).value If 文件判斷 = "員工基本資料序號姓名身分證字號主責督導副督導總服務金額公司拆帳金額" Then : Else : MsgBox("拆帳明細表 檔案不吻合!!") : 路徑2_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑3_bt_Click(sender As Object, e As EventArgs) Handles 選路徑3_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑3_tb.Text = 開啟檔案.FileName '----------薪資報表明細----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑3_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(3, 1).value : 文件判斷 &= xlSheet.Cells(3, 2).value : 文件判斷 &= xlSheet.Cells(3, 3).value : 文件判斷 &= xlSheet.Cells(3, 4).value 文件判斷 &= xlSheet.Cells(3, 5).value : 文件判斷 &= xlSheet.Cells(3, 6).value : 文件判斷 &= xlSheet.Cells(3, 7).value : 文件判斷 &= xlSheet.Cells(3, 8).value If 文件判斷 = "序員工編號分類姓名主責督導B碼時薪G碼/S碼時薪轉場費計算 (排班時間)" Or 文件判斷 = "序員工編號分類姓名主責督導B碼時薪G碼/S碼時薪轉場費計算 (交通時間: Google Map)" Then Else : MsgBox("薪資報表明細 檔案不吻合!!") : 路徑3_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑4_bt_Click(sender As Object, e As EventArgs) Handles 選路徑4_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑4_tb.Text = 開啟檔案.FileName '----------每 日 明 細----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑4_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(3, 1).value : 文件判斷 &= xlSheet.Cells(3, 2).value : 文件判斷 &= xlSheet.Cells(3, 3).value : 文件判斷 &= xlSheet.Cells(3, 4).value 文件判斷 &= xlSheet.Cells(3, 5).value : 文件判斷 &= xlSheet.Cells(3, 6).value : 文件判斷 &= xlSheet.Cells(3, 7).value : 文件判斷 &= xlSheet.Cells(3, 8).value If 文件判斷 = "序員工編號分類姓名主責督導B碼時薪G碼/S碼時薪日期" Then : Else : MsgBox("每日明細 檔案不吻合!!") : 路徑4_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑5_bt_Click(sender As Object, e As EventArgs) Handles 選路徑5_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑5_tb.Text = 開啟檔案.FileName '----------個 案 總 表----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑5_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(3, 1).value : 文件判斷 &= xlSheet.Cells(3, 2).value : 文件判斷 &= xlSheet.Cells(3, 3).value : 文件判斷 &= xlSheet.Cells(3, 4).value 文件判斷 &= xlSheet.Cells(3, 5).value : 文件判斷 &= xlSheet.Cells(3, 6).value : 文件判斷 &= xlSheet.Cells(3, 7).value : 文件判斷 &= xlSheet.Cells(3, 8).value If 文件判斷 = "編號目前狀態個案來源案號衛福案號分類姓名性別" Then : Else : MsgBox("個案總表 檔案不吻合!!") : 路徑5_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑6_bt_Click(sender As Object, e As EventArgs) Handles 選路徑6_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑6_tb.Text = 開啟檔案.FileName '----------長照A碼清冊----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑6_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(4, 1).value : 文件判斷 &= xlSheet.Cells(4, 2).value : 文件判斷 &= xlSheet.Cells(4, 3).value : 文件判斷 &= xlSheet.Cells(4, 4).value 文件判斷 &= xlSheet.Cells(4, 5).value : 文件判斷 &= xlSheet.Cells(4, 6).value : 文件判斷 &= xlSheet.Cells(4, 7).value : 文件判斷 &= xlSheet.Cells(4, 8).value If 文件判斷 = "序號服務代碼採用計畫CMS等級服務項目類別身分證號個案姓名給付價格" Then 'For i As Integer = 5 To 99999 ' If IsNothing(xlSheet.Cells(i, 17).value) = True Then : Exit For : ElseIf xlSheet.Cells(i, 17).value.ToString.Contains("、") Then ' MsgBox("長照A碼清冊 內部檢測到有服務人員資料沒有拆開,請新確認檔案內容!!") : 路徑6_tb.Text = "" : Exit For ' End If 'Next Else : MsgBox("長照A碼清冊 檔案不吻合!!") : 路徑6_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑7_bt_Click(sender As Object, e As EventArgs) Handles 選路徑7_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑7_tb.Text = 開啟檔案.FileName '----------長照A碼清冊----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑7_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(4, 1).value : 文件判斷 &= xlSheet.Cells(4, 2).value : 文件判斷 &= xlSheet.Cells(4, 3).value : 文件判斷 &= xlSheet.Cells(4, 4).value 文件判斷 &= xlSheet.Cells(4, 5).value : 文件判斷 &= xlSheet.Cells(4, 6).value : 文件判斷 &= xlSheet.Cells(4, 7).value : 文件判斷 &= xlSheet.Cells(4, 8).value If 文件判斷 = "序號服務代碼採用計畫CMS等級服務項目類別身分證號個案姓名給付價格" Then For i As Integer = 5 To 99999 If IsNothing(xlSheet.Cells(i, 17).value) = True Then : Exit For : ElseIf xlSheet.Cells(i, 17).value.ToString.Contains("、") Then MsgBox("長照A碼清冊 內部檢測到有服務人員資料沒有拆開,請新確認檔案內容!!") : 路徑7_tb.Text = "" : Exit For End If Next Else : MsgBox("長照A碼清冊 檔案不吻合!!") : 路徑7_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑8_bt_Click(sender As Object, e As EventArgs) Handles 選路徑8_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑8_tb.Text = 開啟檔案.FileName '----------長照BA碼清冊(長照)----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑8_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(5, 1).value : 文件判斷 &= xlSheet.Cells(5, 2).value : 文件判斷 &= xlSheet.Cells(5, 3).value : 文件判斷 &= xlSheet.Cells(5, 4).value 文件判斷 &= xlSheet.Cells(5, 6).value : 文件判斷 &= xlSheet.Cells(5, 8).value : 文件判斷 &= xlSheet.Cells(5, 11).value : 文件判斷 &= xlSheet.Cells(5, 12).value 文件判斷 &= xlSheet.Cells(5, 15).value If 文件判斷 = "序號身分證號個案姓名採用計畫福利身分別服務日期次數申報費用補助比率" Then For i As Integer = 6 To 99999 If IsNothing(xlSheet.Cells(i, 23).value) = True Then : Exit For : ElseIf xlSheet.Cells(i, 23).value.ToString.Contains("、") Then MsgBox("長照BA碼清冊 內部檢測到有服務人員資料沒有拆開,請新確認檔案內容!!") : 路徑8_tb.Text = "" : Exit For End If Next Else : MsgBox("長照BA碼清冊 檔案不吻合!!") : 路徑8_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑9_bt_Click(sender As Object, e As EventArgs) Handles 選路徑9_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑9_tb.Text = 開啟檔案.FileName '----------短 照 A 碼 清 冊(長照)----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑9_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(4, 1).value : 文件判斷 &= xlSheet.Cells(4, 2).value : 文件判斷 &= xlSheet.Cells(4, 3).value : 文件判斷 &= xlSheet.Cells(4, 4).value 文件判斷 &= xlSheet.Cells(4, 5).value : 文件判斷 &= xlSheet.Cells(4, 6).value : 文件判斷 &= xlSheet.Cells(4, 7).value : 文件判斷 &= xlSheet.Cells(4, 8).value If 文件判斷 = "序號服務代碼採用計畫CMS等級服務項目類別身分證號個案姓名給付價格" Then For i As Integer = 5 To 99999 If IsNothing(xlSheet.Cells(i, 17).value) = True Then : Exit For : ElseIf xlSheet.Cells(i, 17).value.ToString.Contains("、") Then MsgBox("短照A碼清冊 內部檢測到有服務人員資料沒有拆開,請新確認檔案內容!!") : 路徑9_tb.Text = "" : Exit For End If Next Else : MsgBox("短照A碼清冊 檔案不吻合!!") : 路徑9_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 選路徑10_bt_Click(sender As Object, e As EventArgs) Handles 選路徑10_bt.Click If 開啟檔案.ShowDialog <> Windows.Forms.DialogResult.Cancel Then : 路徑10_tb.Text = 開啟檔案.FileName '----------短 照 SC 碼 清 冊(長照)----------------------------------------------------------------------------------------------------------------------------------------------- file_name = 路徑10_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() 文件判斷 = xlSheet.Cells(5, 1).value : 文件判斷 &= xlSheet.Cells(5, 2).value : 文件判斷 &= xlSheet.Cells(5, 3).value : 文件判斷 &= xlSheet.Cells(5, 4).value 文件判斷 &= xlSheet.Cells(5, 6).value : 文件判斷 &= xlSheet.Cells(5, 8).value : 文件判斷 &= xlSheet.Cells(5, 11).value : 文件判斷 &= xlSheet.Cells(5, 12).value 文件判斷 &= xlSheet.Cells(5, 15).value If 文件判斷 = "序號身分證號個案姓名採用計畫福利身分別服務日期次數申報費用補助比率" Then For i As Integer = 6 To 99999 If IsNothing(xlSheet.Cells(i, 23).value) = True Then : Exit For : ElseIf xlSheet.Cells(i, 23).value.ToString.Contains("、") Then MsgBox("短照SC碼清冊 內部檢測到有服務人員資料沒有拆開,請新確認檔案內容!!") : 路徑10_tb.Text = "" : Exit For End If Next Else : MsgBox("短照SC碼清冊 檔案不吻合!!") : 路徑10_tb.Text = "" : End If xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If End Sub Private Sub 導入_bt_Click(sender As Object, e As EventArgs) Handles 導入_bt.Click If 年份_cb.Text <> "" And 月份_cb.Text <> "" Then 資料數 = 10000 : Dim 文件判斷, 不吻合訊息 As String : 不吻合訊息 = "" '----------服務紀錄總表----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑1_tb.Text <> "" Then file_name = 路徑1_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() SQL2 = "" ConnOpen() : SQL1 = "DELETE 人事拆帳制服務紀錄_仁寶 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%'" : CmdSet_For_dr() For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 5, 1).value & "',N'" & xlSheet.Cells(I + 5, 2).value & "', N'" & xlSheet.Cells(I + 5, 3).value & "',N'" & xlSheet.Cells(I + 5, 4).value & "',N'" & xlSheet.Cells(I + 5, 5).value & "', N'" & xlSheet.Cells(I + 5, 6).value & "',N'" & xlSheet.Cells(I + 5, 7).value & "',N'" & xlSheet.Cells(I + 5, 8).value & "', N'" & xlSheet.Cells(I + 5, 9).value & "',N'" & xlSheet.Cells(I + 5, 10).value & "',N'" & xlSheet.Cells(I + 5, 11).value & "', N'" & xlSheet.Cells(I + 5, 12).value & "',N'" & xlSheet.Cells(I + 5, 13).value & "',N'" & xlSheet.Cells(I + 5, 14).value & "', N'" & xlSheet.Cells(I + 5, 15).value & "',N'" & xlSheet.Cells(I + 5, 16).value & "',N'" & xlSheet.Cells(I + 5, 17).value & "', N'" & xlSheet.Cells(I + 5, 18).value & "',N'" & xlSheet.Cells(I + 5, 19).value & "',N'" & xlSheet.Cells(I + 5, 20).value & "', N'" & xlSheet.Cells(I + 5, 21).value & "',N'" & xlSheet.Cells(I + 5, 26).value & "',N'" & xlSheet.Cells(I + 5, 27).value & "', N'" & xlSheet.Cells(I + 5, 34).value & "')," If (I <> 0 And I Mod 100 = 0) Or IsNothing(xlSheet.Cells(I + 5, 1).value) = True Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制服務紀錄_仁寶 (流水號, 編號, 案號, 服務項目代碼, 服務項目類別, 身分證字號, 姓名, 服務日期, 服務類別, 項目服務次數, 一般or原民區或離島, 項目單價, 申報費用, 部分負擔比例, 部分負擔費用, 補助比例, 補助費用, 民眾自費金額, 服務單位, 居服員姓名, 加班類型, 服務狀態, 排班時間, 排班時間長度, 服務子項目代碼) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 5, 1).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------拆 帳 明 細 表----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑2_tb.Text <> "" Then file_name = 路徑2_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制明細_仁寶 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%'" : CmdSet_For_dr() : Dim DSF(7) As String SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() If IsNothing(xlSheet.Cells(I + 4, 1).value) = False Then : DSF(0) = xlSheet.Cells(I + 4, 1).value : End If If IsNothing(xlSheet.Cells(I + 4, 2).value) = False Then : DSF(1) = xlSheet.Cells(I + 4, 2).value : End If If IsNothing(xlSheet.Cells(I + 4, 3).value) = False Then : DSF(2) = xlSheet.Cells(I + 4, 3).value : End If If IsNothing(xlSheet.Cells(I + 4, 4).value) = False Then : DSF(3) = xlSheet.Cells(I + 4, 4).value : End If If IsNothing(xlSheet.Cells(I + 4, 5).value) = False Then : DSF(4) = xlSheet.Cells(I + 4, 5).value : End If If IsNothing(xlSheet.Cells(I + 4, 6).value) = False Then : DSF(5) = xlSheet.Cells(I + 4, 6).value : End If If IsNothing(xlSheet.Cells(I + 4, 7).value) = False Then : DSF(6) = xlSheet.Cells(I + 4, 7).value : End If If IsNothing(xlSheet.Cells(I + 4, 8).value) = False Then : DSF(7) = xlSheet.Cells(I + 4, 8).value : End If SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & DSF(0) & "',N'" & DSF(1) & "', N'" & DSF(2) & "',N'" & DSF(3) & "',N'" & DSF(4) & "', N'" & DSF(5) & "',N'" & DSF(6) & "',N'" & DSF(7) & "', N'" & xlSheet.Cells(I + 4, 9).value & "',N'" & xlSheet.Cells(I + 4, 10).value & "',N'" & xlSheet.Cells(I + 4, 11).value & "', N'" & xlSheet.Cells(I + 4, 12).value & "',N'" & xlSheet.Cells(I + 4, 13).value & "',N'" & xlSheet.Cells(I + 4, 14).value & "', N'" & xlSheet.Cells(I + 4, 15).value & "',N'" & xlSheet.Cells(I + 4, 16).value & "',N'" & xlSheet.Cells(I + 4, 17).value & "', N'" & xlSheet.Cells(I + 4, 18).value & "',N'" & xlSheet.Cells(I + 4, 19).value & "',N'" & xlSheet.Cells(I + 4, 20).value & "', N'" & xlSheet.Cells(I + 4, 21).value & "',N'" & xlSheet.Cells(I + 4, 22).value & "',N'" & xlSheet.Cells(I + 4, 23).value & "')," If (I <> 0 And I Mod 100 = 0) Or IsNothing(xlSheet.Cells(I + 4, 9).value) = True Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制明細_仁寶 (流水號, 序號, 姓名, 身分證字號, 主責督導, 副督導, 總服務金額, 公司拆帳金額, 員工拆帳金額, 全額, 公司拆帳, 員工拆帳, 補助or自費, 編號, 項目名稱, 次數, 一般or偏鄉, 單價, 加班類型, 服務人員角色, 拆帳方式, 公司拆帳比, 員工拆帳比, 員工計次金額) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 4, 9).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------薪資報表明細----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑3_tb.Text <> "" Then file_name = 路徑3_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制薪資報表明細_仁寶 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%'" : CmdSet_For_dr() SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 7, 1).value & "',N'" & xlSheet.Cells(I + 7, 2).value & "', N'" & xlSheet.Cells(I + 7, 3).value & "',N'" & xlSheet.Cells(I + 7, 4).value & "',N'" & xlSheet.Cells(I + 7, 5).value & "', N'" & xlSheet.Cells(I + 7, 6).value & "',N'" & xlSheet.Cells(I + 7, 7).value & "',N'" & xlSheet.Cells(I + 7, 8).value & "', N'" & xlSheet.Cells(I + 7, 9).value & "',N'" & xlSheet.Cells(I + 7, 11).value & "',N'" & xlSheet.Cells(I + 7, 12).value & "', N'" & xlSheet.Cells(I + 7, 14).value & "',N'" & xlSheet.Cells(I + 7, 15).value & "',N'" & xlSheet.Cells(I + 7, 16).value & "', N'" & xlSheet.Cells(I + 7, 17).value & "',N'" & xlSheet.Cells(I + 7, 18).value & "',N'" & xlSheet.Cells(I + 7, 19).value & "', N'" & xlSheet.Cells(I + 7, 20).value & "',N'" & xlSheet.Cells(I + 7, 21).value & "',N'" & xlSheet.Cells(I + 7, 22).value & "', N'" & xlSheet.Cells(I + 7, 23).value & "',N'" & xlSheet.Cells(I + 7, 24).value & "',N'" & xlSheet.Cells(I + 7, 25).value & "', N'" & xlSheet.Cells(I + 7, 26).value & "',N'" & xlSheet.Cells(I + 7, 27).value & "',N'" & xlSheet.Cells(I + 7, 28).value & "', N'" & xlSheet.Cells(I + 7, 29).value & "',N'" & xlSheet.Cells(I + 7, 30).value & "',N'" & xlSheet.Cells(I + 7, 31).value & "', N'" & xlSheet.Cells(I + 7, 32).value & "',N'" & xlSheet.Cells(I + 7, 33).value & "',N'" & xlSheet.Cells(I + 7, 34).value & "', N'" & xlSheet.Cells(I + 7, 35).value & "',N'" & xlSheet.Cells(I + 7, 36).value & "',N'" & xlSheet.Cells(I + 7, 37).value & "', N'" & xlSheet.Cells(I + 7, 38).value & "',N'" & xlSheet.Cells(I + 7, 39).value & "',N'" & xlSheet.Cells(I + 7, 40).value & "', N'" & xlSheet.Cells(I + 7, 41).value & "',N'" & xlSheet.Cells(I + 7, 42).value & "',N'" & xlSheet.Cells(I + 7, 43).value & "', N'" & xlSheet.Cells(I + 7, 44).value & "',N'" & xlSheet.Cells(I + 7, 45).value & "',N'" & xlSheet.Cells(I + 7, 46).value & "', N'" & xlSheet.Cells(I + 7, 47).value & "',N'" & xlSheet.Cells(I + 7, 48).value & "',N'" & xlSheet.Cells(I + 7, 49).value & "', N'" & xlSheet.Cells(I + 7, 50).value & "',N'" & xlSheet.Cells(I + 7, 51).value & "',N'" & xlSheet.Cells(I + 7, 52).value & "', N'" & xlSheet.Cells(I + 7, 53).value & "',N'" & xlSheet.Cells(I + 7, 54).value & "',N'" & xlSheet.Cells(I + 7, 55).value & "', N'" & xlSheet.Cells(I + 7, 56).value & "',N'" & xlSheet.Cells(I + 7, 57).value & "',N'" & xlSheet.Cells(I + 7, 58).value & "', N'" & xlSheet.Cells(I + 7, 59).value & "',N'" & xlSheet.Cells(I + 7, 60).value & "',N'" & xlSheet.Cells(I + 7, 61).value & "', N'" & xlSheet.Cells(I + 7, 62).value & "',N'" & xlSheet.Cells(I + 7, 63).value & "',N'" & xlSheet.Cells(I + 7, 64).value & "', N'" & xlSheet.Cells(I + 7, 65).value & "',N'" & xlSheet.Cells(I + 7, 66).value & "',N'" & xlSheet.Cells(I + 7, 67).value & "', N'" & xlSheet.Cells(I + 7, 68).value & "',N'" & xlSheet.Cells(I + 7, 69).value & "',N'" & xlSheet.Cells(I + 7, 70).value & "', N'" & xlSheet.Cells(I + 7, 71).value & "',N'" & xlSheet.Cells(I + 7, 72).value & "',N'" & xlSheet.Cells(I + 7, 73).value & "', N'" & xlSheet.Cells(I + 7, 74).value & "',N'" & xlSheet.Cells(I + 7, 75).value & "',N'" & xlSheet.Cells(I + 7, 76).value & "', N'" & xlSheet.Cells(I + 7, 77).value & "',N'" & xlSheet.Cells(I + 7, 78).value & "',N'" & xlSheet.Cells(I + 7, 79).value & "', N'" & xlSheet.Cells(I + 7, 80).value & "',N'" & xlSheet.Cells(I + 7, 81).value & "',N'" & xlSheet.Cells(I + 7, 82).value & "', N'" & xlSheet.Cells(I + 7, 83).value & "',N'" & xlSheet.Cells(I + 7, 84).value & "',N'" & xlSheet.Cells(I + 7, 85).value & "', N'" & xlSheet.Cells(I + 7, 86).value & "',N'" & xlSheet.Cells(I + 7, 87).value & "',N'" & xlSheet.Cells(I + 7, 88).value & "', N'" & xlSheet.Cells(I + 7, 89).value & "')," If (I <> 0 And I Mod 100 = 0) Or IsNothing(xlSheet.Cells(I + 7, 1).value) = True Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制薪資報表明細_仁寶 (流水號, 序, 員工編號, 分類, 姓名, 主責督導, B碼時薪, G碼_S碼時薪, 平日排班轉場時間_分, 假日排班轉場時間_分, 平日轉場時薪, 假日轉場時薪, 平日轉場費, 假日轉場費, 服務時間_分, 平日班時數_分, 本薪, 加班時數_分, 加班費, B平日0_2小時, B平日3_8小時, B平日9_10小時, B平日11_12小時, B國假0_2小時, B國假3_8小時, B國假9_10小時, B國假11_12小時, B例假0_2小時, B例假3_8小時, B例假9_10小時, B例假11_12小時, B休假0_2小時, B休假3_8小時, B休假9_10小時, B休假11_12小時, B平日0_2薪資, B平日3_8薪資, B平日9_10薪資, B平日11_12薪資, B國假0_2薪資, B國假3_8薪資, B國假9_10薪資, B國假11_12薪資, B例假0_2薪資, B例假3_8薪資, B例假9_10薪資, B例假11_12薪資, B休假0_2薪資, B休假3_8薪資, B休假9_10薪資, B休假11_12薪資, B碼總計, GS平日0_2小時, GS平日3_8小時, GS平日9_10小時, GS平日11_12小時, GS國假0_2小時, GS國假3_8小時, GS國假9_10小時, GS國假11_12小時, GS例假0_2小時, GS例假3_8小時, GS例假9_10小時, GS例假11_12小時, GS休假0_2小時, GS休假3_8小時, GS休假9_10小時, GS休假11_12小時, GS平日0_2薪資, GS平日3_8薪資, GS平日9_10薪資, GS平日11_12薪資, GS國假0_2薪資, GS國假3_8薪資, GS國假9_10薪資, GS國假11_12薪資, GS例假0_2薪資, GS例假3_8薪資, GS例假9_10薪資, GS例假11_12薪資, GS休假0_2薪資, GS休假3_8薪資, GS休假9_10薪資, GS休假11_12薪資, GS碼總計, 服務紀錄B碼金額, 服務紀錄GS碼金額, 服務紀錄BGS碼金額) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 7, 1).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------每 日 明 細----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑4_tb.Text <> "" Then file_name = 路徑4_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制每日明細_仁寶 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%'" : CmdSet_For_dr() : Dim DSF(7) As String SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() DSF(0) = I + 1 If IsNothing(xlSheet.Cells(I + 7, 2).value) = False Then : DSF(1) = xlSheet.Cells(I + 7, 2).value : End If If IsNothing(xlSheet.Cells(I + 7, 3).value) = False Then : DSF(2) = xlSheet.Cells(I + 7, 3).value : End If If IsNothing(xlSheet.Cells(I + 7, 4).value) = False Then : DSF(3) = xlSheet.Cells(I + 7, 4).value : End If If IsNothing(xlSheet.Cells(I + 7, 5).value) = False Then : DSF(4) = xlSheet.Cells(I + 7, 5).value : End If If IsNothing(xlSheet.Cells(I + 7, 6).value) = False Then : DSF(5) = xlSheet.Cells(I + 7, 6).value : End If If IsNothing(xlSheet.Cells(I + 7, 7).value) = False Then : DSF(6) = xlSheet.Cells(I + 7, 7).value : End If If IsNothing(xlSheet.Cells(I + 7, 8).value) = False Then : DSF(7) = xlSheet.Cells(I + 7, 8).value : End If SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & DSF(0) & "',N'" & DSF(1) & "', N'" & DSF(2) & "',N'" & DSF(3) & "',N'" & DSF(4) & "', N'" & DSF(5) & "',N'" & DSF(6) & "',N'" & DSF(7) & "', N'" & xlSheet.Cells(I + 7, 9).value & "',N'" & xlSheet.Cells(I + 7, 11).value & "',N'" & xlSheet.Cells(I + 7, 12).value & "', N'" & xlSheet.Cells(I + 7, 14).value & "',N'" & xlSheet.Cells(I + 7, 15).value & "',N'" & xlSheet.Cells(I + 7, 16).value & "', N'" & xlSheet.Cells(I + 7, 17).value & "',N'" & xlSheet.Cells(I + 7, 18).value & "',N'" & xlSheet.Cells(I + 7, 19).value & "', N'" & xlSheet.Cells(I + 7, 20).value & "',N'" & xlSheet.Cells(I + 7, 21).value & "',N'" & xlSheet.Cells(I + 7, 22).value & "', N'" & xlSheet.Cells(I + 7, 23).value & "')," If (I <> 0 And I Mod 100 = 0) Or IsNothing(xlSheet.Cells(I + 7, 15).value) = True Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制每日明細_仁寶 (流水號, 序, 員工編號, 分類, 姓名, 主責督導, B碼時薪, G碼S碼時薪, 日期, 排班轉場時間_分, 交通時間小計_分, 轉場時薪, 轉場費, 加班類型, 服務個案, 個案主責督導, 身分別, 服務時間_分, 平日班時數_分, 本薪, 加班時數_分, 加班費) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 7, 15).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------個 案 總 表----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑5_tb.Text <> "" Then file_name = 路徑5_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳總表 WHERE 流水 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%'" : CmdSet_For_dr() : Dim DSF(7) As String SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 4, 1).value & "',N'" & xlSheet.Cells(I + 4, 2).value & "', N'" & xlSheet.Cells(I + 4, 3).value & "',N'" & xlSheet.Cells(I + 4, 4).value & "',N'" & xlSheet.Cells(I + 4, 5).value & "', N'" & xlSheet.Cells(I + 4, 6).value & "',N'" & xlSheet.Cells(I + 4, 7).value & "',N'" & xlSheet.Cells(I + 4, 8).value & "', N'" & xlSheet.Cells(I + 4, 9).value & "',N'" & xlSheet.Cells(I + 4, 10).value & "',N'" & xlSheet.Cells(I + 4, 11).value & "', N'" & xlSheet.Cells(I + 4, 12).value & "',N'" & xlSheet.Cells(I + 4, 13).value & "',N'" & xlSheet.Cells(I + 4, 14).value & "', N'" & xlSheet.Cells(I + 4, 15).value & "',N'" & xlSheet.Cells(I + 4, 16).value & "',N'" & xlSheet.Cells(I + 4, 17).value & "', N'" & xlSheet.Cells(I + 4, 18).value & "',N'" & xlSheet.Cells(I + 4, 19).value & "',N'" & xlSheet.Cells(I + 4, 20).value & "', N'" & xlSheet.Cells(I + 4, 21).value & "',N'" & xlSheet.Cells(I + 4, 22).value & "',N'" & xlSheet.Cells(I + 4, 23).value & "', N'" & xlSheet.Cells(I + 4, 24).value & "',N'" & xlSheet.Cells(I + 4, 25).value & "',N'" & xlSheet.Cells(I + 4, 26).value & "', N'" & xlSheet.Cells(I + 4, 27).value & "',N'" & xlSheet.Cells(I + 4, 28).value & "',N'" & xlSheet.Cells(I + 4, 29).value & "', N'" & xlSheet.Cells(I + 4, 30).value & "',N'" & xlSheet.Cells(I + 4, 31).value & "',N'" & xlSheet.Cells(I + 4, 33).value & "', N'" & xlSheet.Cells(I + 4, 34).value & "',N'" & xlSheet.Cells(I + 4, 35).value & "',N'" & xlSheet.Cells(I + 4, 36).value & "', N'" & xlSheet.Cells(I + 4, 37).value & "',N'" & xlSheet.Cells(I + 4, 38).value & "',N'" & xlSheet.Cells(I + 4, 39).value & "', N'" & xlSheet.Cells(I + 4, 40).value & "',N'" & xlSheet.Cells(I + 4, 41).value & "',N'" & xlSheet.Cells(I + 4, 42).value & "', N'" & xlSheet.Cells(I + 4, 43).value & "',N'" & xlSheet.Cells(I + 4, 44).value & "',N'" & xlSheet.Cells(I + 4, 45).value & "', N'" & xlSheet.Cells(I + 4, 46).value & "',N'" & xlSheet.Cells(I + 4, 47).value & "',N'" & xlSheet.Cells(I + 4, 48).value & "', N'" & xlSheet.Cells(I + 4, 49).value & "',N'" & xlSheet.Cells(I + 4, 50).value & "',N'" & xlSheet.Cells(I + 4, 51).value & "', N'" & xlSheet.Cells(I + 4, 52).value & "',N'" & xlSheet.Cells(I + 4, 53).value & "',N'" & xlSheet.Cells(I + 4, 54).value & "', N'" & xlSheet.Cells(I + 4, 55).value & "',N'" & xlSheet.Cells(I + 4, 56).value & "',N'" & xlSheet.Cells(I + 4, 57).value & "', N'" & xlSheet.Cells(I + 4, 58).value & "',N'" & xlSheet.Cells(I + 4, 59).value & "',N'" & xlSheet.Cells(I + 4, 60).value & "', N'" & xlSheet.Cells(I + 4, 61).value & "',N'" & xlSheet.Cells(I + 4, 62).value & "',N'" & xlSheet.Cells(I + 4, 63).value & "', N'" & xlSheet.Cells(I + 4, 64).value & "',N'" & xlSheet.Cells(I + 4, 65).value & "',N'" & xlSheet.Cells(I + 4, 66).value & "', N'" & xlSheet.Cells(I + 4, 67).value & "',N'" & xlSheet.Cells(I + 4, 68).value & "',N'" & xlSheet.Cells(I + 4, 69).value & "', N'" & xlSheet.Cells(I + 4, 70).value & "',N'" & xlSheet.Cells(I + 4, 71).value & "',N'" & xlSheet.Cells(I + 4, 72).value & "', N'" & xlSheet.Cells(I + 4, 73).value & "',N'" & xlSheet.Cells(I + 4, 74).value & "',N'" & xlSheet.Cells(I + 4, 75).value & "', N'" & xlSheet.Cells(I + 4, 76).value & "',N'" & xlSheet.Cells(I + 4, 77).value & "',N'" & xlSheet.Cells(I + 4, 78).value & "', N'" & xlSheet.Cells(I + 4, 79).value & "',N'" & xlSheet.Cells(I + 4, 80).value & "',N'" & xlSheet.Cells(I + 4, 81).value & "', N'" & xlSheet.Cells(I + 4, 84).value & "',N'" & xlSheet.Cells(I + 4, 85).value & "',N'" & xlSheet.Cells(I + 4, 86).value & "', N'" & xlSheet.Cells(I + 4, 87).value & "',N'" & xlSheet.Cells(I + 4, 88).value & "',N'" & xlSheet.Cells(I + 4, 89).value & "', N'" & xlSheet.Cells(I + 4, 90).value & "',N'" & xlSheet.Cells(I + 4, 91).value & "',N'" & xlSheet.Cells(I + 4, 92).value & "', N'" & xlSheet.Cells(I + 4, 93).value & "',N'" & xlSheet.Cells(I + 4, 94).value & "',N'" & xlSheet.Cells(I + 4, 95).value & "', N'" & xlSheet.Cells(I + 4, 96).value & "',N'" & xlSheet.Cells(I + 4, 97).value & "',N'" & xlSheet.Cells(I + 4, 98).value & "', N'" & xlSheet.Cells(I + 4, 99).value & "',N'" & xlSheet.Cells(I + 4, 100).value & "',N'" & xlSheet.Cells(I + 4, 101).value & "', N'" & xlSheet.Cells(I + 4, 102).value & "',N'" & xlSheet.Cells(I + 4, 103).value & "',N'" & xlSheet.Cells(I + 4, 104).value & "', N'" & xlSheet.Cells(I + 4, 105).value & "',N'" & xlSheet.Cells(I + 4, 106).value & "',N'" & xlSheet.Cells(I + 4, 107).value & "', N'" & xlSheet.Cells(I + 4, 108).value & "',N'" & xlSheet.Cells(I + 4, 109).value & "',N'" & xlSheet.Cells(I + 4, 110).value & "', N'" & xlSheet.Cells(I + 4, 111).value & "',N'" & xlSheet.Cells(I + 4, 112).value & "',N'" & xlSheet.Cells(I + 4, 113).value & "', N'" & xlSheet.Cells(I + 4, 121).value & "',N'" & xlSheet.Cells(I + 4, 122).value & "',N'" & xlSheet.Cells(I + 4, 123).value & "', N'" & xlSheet.Cells(I + 4, 124).value & "',N'" & xlSheet.Cells(I + 4, 125).value & "',N'" & xlSheet.Cells(I + 4, 126).value & "', N'" & xlSheet.Cells(I + 4, 127).value & "',N'" & xlSheet.Cells(I + 4, 128).value & "',N'" & xlSheet.Cells(I + 4, 129).value & "', N'" & xlSheet.Cells(I + 4, 130).value & "',N'" & xlSheet.Cells(I + 4, 131).value & "',N'" & xlSheet.Cells(I + 4, 132).value & "')," If (I <> 0 And I Mod 100 = 0) Or IsNothing(xlSheet.Cells(I + 4, 1).value) = True Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳總表 (流水, 編號, 目前狀態, 個案來源, 案號, 衛福案號, 分類, 姓名, 性別, 出生年月日, 年齡, 身分證字號, 電話, 身高, 體重, 小腿圍, 原住民身份, 原住民族別, 常用語言, CMS等級, 福利身份別, 補助比例, 計價類別, 失能等級, 障礙等級, 請外勞照護或領有特照津貼, 身障類別_新制, 身障類別_舊制, 身障項目別, 是否具備身心障礙失智症手冊or證明或CDR1分以上, 主要照顧者, 主要照顧者關係, 次要照顧者, 次要照顧者關係, 主責督導, 副督導, 主責居服員, 代理人, 代理人電話, 代理人手機號碼, 代理人地址, 個案戶籍縣市, 鄉鎮區, 里別, 個案戶籍地址, 個案居住縣市, 鄉鎮區1, 里別1, 個案居住地址, 居住狀況, 帳單地址, 個案教育程度, 罹患疾病, 疾病史, 行為與情緒, 申請服務種類, 備註, 服務開始時間, 暫停日期, 暫停備註, 結案日期, 結案原因, 結案備註, 機構到案家距離, 護照號碼, 國籍, 性別1, 工作縣市, 核准招募文號, 最新聘僱函文號, 聘僱函核准日期, 工作起始日, 契約期滿日, 建立日期, A單位名稱, A個管姓名, 聯絡電話, 電子郵件, 給付額度, 計價類別1, 請外勞照護或領有特照津貼1, 排班時數, 居服員, 服務項目總數_補助, 服務項目總數_自費, 補助人次, 自費人次, 服務天數, 服務項目, 服務總次數, 服務總次數_補助, 服務總次數_自費, 使用額度, 補助金額, 民眾負擔, 自費, 民眾總花費, 服務項目1, 服務次數1, 使用額度1, 補助金額1, 民眾負擔1, 自費1, 民眾總花費1, 服務項目2, 服務次數2, 使用額度2, 補助金額2, 民眾負擔2, 自費2, 民眾總花費2, 服務次數3, 給付價格3, 服務次數4, 給付價格4, 服務項目5, 服務次數5, 使用額度5, 補助金額5, 民眾負擔5, 自費5, 民眾總花費5, 照顧計畫) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 4, 1).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------A碼項目清冊----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑6_tb.Text <> "" Then file_name = 路徑6_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制A碼項目清冊 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%'" : CmdSet_For_dr() SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 5, 1).value & "',N'" & xlSheet.Cells(I + 5, 2).value & "', N'" & xlSheet.Cells(I + 5, 3).value & "',N'" & xlSheet.Cells(I + 5, 4).value & "',N'" & xlSheet.Cells(I + 5, 5).value & "', N'" & xlSheet.Cells(I + 5, 6).value & "',N'" & xlSheet.Cells(I + 5, 7).value & "',N'" & xlSheet.Cells(I + 5, 8).value & "', N'" & xlSheet.Cells(I + 5, 9).value & "',N'" & xlSheet.Cells(I + 5, 10).value & "',N'" & xlSheet.Cells(I + 5, 11).value & "', N'" & xlSheet.Cells(I + 5, 12).value & "',N'" & xlSheet.Cells(I + 5, 13).value & "',N'" & xlSheet.Cells(I + 5, 14).value & "', N'" & xlSheet.Cells(I + 5, 15).value & "',N'" & xlSheet.Cells(I + 5, 16).value & "',N'" & xlSheet.Cells(I + 5, 17).value & "', N'" & xlSheet.Cells(I + 5, 18).value & "')," If (I <> 0 And I Mod 100 = 0) Or (IsNothing(xlSheet.Cells(I + 5, 1).value) = True And IsNothing(xlSheet.Cells(I + 5, 2).value) = True) Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制A碼項目清冊 (流水號, 序號, 服務代碼, 採用計畫, CMS等級, 服務項目類別, 身分證號, 個案姓名, 給付價格, 數量, 小計, 服務日期, 服務單位, 服務當下居住縣市, 目前居住縣市, 目前居住行政區, 照管專員, 服務人員, 備註) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 5, 1).value) = True And IsNothing(xlSheet.Cells(I + 5, 2).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------A碼長照所----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑7_tb.Text <> "" Then file_name = 路徑7_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制A碼項目長照所 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%' AND AAORSC IS NULL" : CmdSet_For_dr() SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 5, 1).value & "',N'" & xlSheet.Cells(I + 5, 2).value & "', N'" & xlSheet.Cells(I + 5, 3).value & "',N'" & xlSheet.Cells(I + 5, 4).value & "',N'" & xlSheet.Cells(I + 5, 5).value & "', N'" & xlSheet.Cells(I + 5, 6).value & "',N'" & xlSheet.Cells(I + 5, 7).value & "',N'" & xlSheet.Cells(I + 5, 8).value & "', N'" & xlSheet.Cells(I + 5, 9).value & "',N'" & xlSheet.Cells(I + 5, 10).value & "',N'" & xlSheet.Cells(I + 5, 11).value & "', N'" & xlSheet.Cells(I + 5, 12).value & "',N'" & xlSheet.Cells(I + 5, 13).value & "',N'" & xlSheet.Cells(I + 5, 14).value & "', N'" & xlSheet.Cells(I + 5, 15).value & "',N'" & xlSheet.Cells(I + 5, 16).value & "',N'" & xlSheet.Cells(I + 5, 17).value & "', N'" & xlSheet.Cells(I + 5, 18).value & "')," If (I <> 0 And I Mod 100 = 0) Or (IsNothing(xlSheet.Cells(I + 5, 1).value) = True And IsNothing(xlSheet.Cells(I + 5, 2).value) = True) Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制A碼項目長照所 (流水號, 序號, 服務代碼, 採用計畫, CMS等級, 服務項目類別, 身分證號, 個案姓名, 給付價格, 數量, 小計, 服務日期, 服務單位, 服務當下居住縣市, 目前居住縣市, 目前居住行政區, 照管專員, 服務人員, 備註) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 5, 1).value) = True And IsNothing(xlSheet.Cells(I + 5, 2).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------BA碼長照所----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑8_tb.Text <> "" Then file_name = 路徑8_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制BA碼項目長照所 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%' AND BAORSC IS NULL" : CmdSet_For_dr() SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 6, 1).value & "',N'" & xlSheet.Cells(I + 6, 2).value & "', N'" & xlSheet.Cells(I + 6, 3).value & "',N'" & xlSheet.Cells(I + 6, 4).value & "',N'" & xlSheet.Cells(I + 6, 5).value & "', N'" & xlSheet.Cells(I + 6, 6).value & "',N'" & xlSheet.Cells(I + 6, 7).value & "',N'" & xlSheet.Cells(I + 6, 8).value & "', N'" & xlSheet.Cells(I + 6, 9).value & "',N'" & xlSheet.Cells(I + 6, 10).value & "',N'" & xlSheet.Cells(I + 6, 11).value & "', N'" & xlSheet.Cells(I + 6, 12).value & "',N'" & xlSheet.Cells(I + 6, 13).value & "',N'" & xlSheet.Cells(I + 6, 14).value & "', N'" & xlSheet.Cells(I + 6, 15).value & "',N'" & xlSheet.Cells(I + 6, 16).value & "',N'" & xlSheet.Cells(I + 6, 17).value & "', N'" & xlSheet.Cells(I + 6, 18).value & "',N'" & xlSheet.Cells(I + 6, 19).value & "',N'" & xlSheet.Cells(I + 6, 20).value & "', N'" & xlSheet.Cells(I + 6, 21).value & "',N'" & xlSheet.Cells(I + 6, 22).value & "',N'" & xlSheet.Cells(I + 6, 23).value & "')," If (I <> 0 And I Mod 100 = 0) Or (IsNothing(xlSheet.Cells(I + 6, 1).value) = True And IsNothing(xlSheet.Cells(I + 6, 2).value) = True) Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制BA碼項目長照所 (流水號, 序號, 身分證號, 個案名稱, 採用計畫, CMS等級, 福利身分, 類別, 服務日期, 價格, 價格_原民, 次數, 申報備用, 部分負擔率, 部分費用, 補助比率, 申請費用, 申請費用_原民, 補助金額, 服務城市, 居住城市, 行政區, 照管專員, 服務人員) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 6, 1).value) = True And IsNothing(xlSheet.Cells(I + 6, 2).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------A碼長照所----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑9_tb.Text <> "" Then file_name = 路徑9_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制A碼項目長照所 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%' AND AAORSC LIKE N'短照'" : CmdSet_For_dr() SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 5, 1).value & "',N'" & xlSheet.Cells(I + 5, 2).value & "', N'" & xlSheet.Cells(I + 5, 3).value & "',N'" & xlSheet.Cells(I + 5, 4).value & "',N'" & xlSheet.Cells(I + 5, 5).value & "', N'" & xlSheet.Cells(I + 5, 6).value & "',N'" & xlSheet.Cells(I + 5, 7).value & "',N'" & xlSheet.Cells(I + 5, 8).value & "', N'" & xlSheet.Cells(I + 5, 9).value & "',N'" & xlSheet.Cells(I + 5, 10).value & "',N'" & xlSheet.Cells(I + 5, 11).value & "', N'" & xlSheet.Cells(I + 5, 12).value & "',N'" & xlSheet.Cells(I + 5, 13).value & "',N'" & xlSheet.Cells(I + 5, 14).value & "', N'" & xlSheet.Cells(I + 5, 15).value & "',N'" & xlSheet.Cells(I + 5, 16).value & "',N'" & xlSheet.Cells(I + 5, 17).value & "', N'" & xlSheet.Cells(I + 5, 18).value & "',N'短照')," If (I <> 0 And I Mod 100 = 0) Or (IsNothing(xlSheet.Cells(I + 5, 1).value) = True And IsNothing(xlSheet.Cells(I + 5, 1).value) = True) Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制A碼項目長照所 (流水號, 序號, 服務代碼, 採用計畫, CMS等級, 服務項目類別, 身分證號, 個案姓名, 給付價格, 數量, 小計, 服務日期, 服務單位, 服務當下居住縣市, 目前居住縣市, 目前居住行政區, 照管專員, 服務人員, 備註,AAORSC) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 5, 1).value) = True And IsNothing(xlSheet.Cells(I + 5, 2).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------SC碼長照所----------------------------------------------------------------------------------------------------------------------------------------------- If 路徑10_tb.Text <> "" Then file_name = 路徑10_tb.Text : xlApp = CreateObject("Excel.Application") : xlApp.DisplayAlerts = False : xlApp.Visible = False : xlApp.Workbooks.Open(file_name) xlSheet = xlApp.Worksheets(1) : xlSheet.Activate() ConnOpen() : SQL1 = "DELETE 人事拆帳制BA碼項目長照所 WHERE 流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%' AND BAORSC LIKE N'SC'" : CmdSet_For_dr() SQL2 = "" For I As Integer = 0 To 10000 : MyModule1.進度條() SQL2 &= "(N'" & 年份_cb.Text & 月份_cb.Text & "',N'" & xlSheet.Cells(I + 6, 1).value & "',N'" & xlSheet.Cells(I + 6, 2).value & "', N'" & xlSheet.Cells(I + 6, 3).value & "',N'" & xlSheet.Cells(I + 6, 4).value & "',N'" & xlSheet.Cells(I + 6, 5).value & "', N'" & xlSheet.Cells(I + 6, 6).value & "',N'" & xlSheet.Cells(I + 6, 7).value & "',N'" & xlSheet.Cells(I + 6, 8).value & "', N'" & xlSheet.Cells(I + 6, 9).value & "',N'" & xlSheet.Cells(I + 6, 10).value & "',N'" & xlSheet.Cells(I + 6, 11).value & "', N'" & xlSheet.Cells(I + 6, 12).value & "',N'" & xlSheet.Cells(I + 6, 13).value & "',N'" & xlSheet.Cells(I + 6, 14).value & "', N'" & xlSheet.Cells(I + 6, 15).value & "',N'" & xlSheet.Cells(I + 6, 16).value & "',N'" & xlSheet.Cells(I + 6, 17).value & "', N'" & xlSheet.Cells(I + 6, 18).value & "',N'" & xlSheet.Cells(I + 6, 19).value & "',N'" & xlSheet.Cells(I + 6, 20).value & "', N'" & xlSheet.Cells(I + 6, 21).value & "',N'" & xlSheet.Cells(I + 6, 22).value & "',N'" & xlSheet.Cells(I + 6, 23).value & "',N'SC')," If (I <> 0 And I Mod 100 = 0) Or (IsNothing(xlSheet.Cells(I + 6, 1).value) = True And IsNothing(xlSheet.Cells(I + 6, 2).value) = True) Then : MyModule1.進度條() If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制BA碼項目長照所 (流水號, 序號, 身分證號, 個案名稱, 採用計畫, CMS等級, 福利身分, 類別, 服務日期, 價格, 價格_原民, 次數, 申報備用, 部分負擔率, 部分費用, 補助比率, 申請費用, 申請費用_原民, 補助金額, 服務城市, 居住城市, 行政區, 照管專員, 服務人員,BAORSC) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" If IsNothing(xlSheet.Cells(I + 6, 1).value) = True And IsNothing(xlSheet.Cells(I + 6, 2).value) = True Then : Exit For : End If End If Next : xlApp.Visible = True : xlApp.Quit() : xlApp = Nothing End If '----------自動拆分A碼項目清冊(仁寶)----------------------------------------------------------------------------------------------------------------------------------------------- Dim ds As New DataSet 清單_dgv.DataSource = Nothing : ds.Clear() 清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 清單_dgv.ColumnHeadersHeight = 25 : 清單_dgv.AllowUserToAddRows = False : 清單_dgv.RowTemplate.Height = 35 ConnOpen() SQL1 = "SELECT 服務代碼, 個案姓名, SUM(CAST(數量 AS INT)) AS 總數量, SUM(CAST(小計 AS MONEY)) AS 總小計, STRING_AGG(服務人員, N'、') AS 服務人員合併 FROM 人事拆帳制A碼項目清冊 WHERE (流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "') AND (服務人員 LIKE N'%、%') GROUP BY 服務代碼, 個案姓名" CmdSet_For_DGV() da.Fill(ds) : 清單_dgv.DataSource = ds.Tables(0) : conn.Close() Set_權限清單("%", "%") If 清單_dgv.Rows.Count > 0 And 總和_dgv.Rows.Count > 0 Then MsgBox("偵測到導入的資料需要解析拆分,機將開始進行分析!!") 拆分_dgv.Rows.Clear() : 拆分_dgv.Columns.Clear() : 拆分_dgv.AllowUserToAddRows = False : Dim 差異字串 As String = "" Set_取資料("%", "%") For Each col As DataGridViewColumn In 取資料_dgv.Columns ' 初始化拆分_dgv 的欄位與清單_dgv 一樣 拆分_dgv.Columns.Add(DirectCast(col.Clone(), DataGridViewColumn)) Next For I As Integer = 0 To 清單_dgv.Rows.Count - 1 : MyModule1.進度條() Dim 姓名 As String = 清單_dgv.Rows(I).Cells("個案姓名").Value.ToString() Dim 服務代碼 As String = 清單_dgv.Rows(I).Cells("服務代碼").Value.ToString() Dim 數量 As Integer = 清單_dgv.Rows(I).Cells("總數量").Value.ToString() Dim 原始服務人員 As String = 清單_dgv.Rows(I).Cells("服務人員合併").Value.ToString() Set_取資料(姓名, 服務代碼) Dim 原始人員清單 As List(Of String) = 原始服務人員.Split({"、"}, StringSplitOptions.RemoveEmptyEntries).Select(Function(x) x.Trim()).ToList() ' 將原始服務人員以 "、" 拆分為清單 Set_權限清單(姓名, 服務代碼) ' 呼叫查詢,填入總和_dgv If 總和_dgv.Rows.Count = 0 Then Continue For Dim 拆完數量 As Integer = 0 : Dim 已比對人員 As New List(Of String) For J As Integer = 0 To 總和_dgv.Rows.Count - 1 Dim 新列 As New DataGridViewRow() : 新列 = DirectCast(取資料_dgv.Rows(0).Clone(), DataGridViewRow) For k As Integer = 0 To 取資料_dgv.Columns.Count - 1 : 新列.Cells(k).Value = 取資料_dgv.Rows(0).Cells(k).Value : Next Dim col_服務人員 As Integer = 拆分_dgv.Columns("服務人員").Index : Dim col_數量 As Integer = 拆分_dgv.Columns("數量").Index Dim col_小計 As Integer = 拆分_dgv.Columns("小計").Index : Dim 居服員姓名 As String = 總和_dgv.Rows(J).Cells("居服員姓名").Value.ToString().Trim() 新列.Cells(col_服務人員).Value = 居服員姓名 : 新列.Cells(col_數量).Value = 總和_dgv.Rows(J).Cells("總服務次數").Value.ToString() 拆完數量 += 總和_dgv.Rows(J).Cells("總服務次數").Value.ToString() : 新列.Cells(col_小計).Value = 總和_dgv.Rows(J).Cells("總申報費用").Value.ToString() 拆分_dgv.Rows.Add(新列) : 已比對人員.Add(居服員姓名) ' 記錄已比對成功的居服員 Next Dim 未比對人員 As List(Of String) = 原始人員清單.Except(已比對人員).ToList() ' 計算未比對到的人員 If 拆完數量 <> 數量 OrElse 未比對人員.Count > 0 Then 差異字串 &= 清單_dgv.Rows(I).Cells("個案姓名").Value.ToString() & " / " & 服務代碼 & " 拆分資料異常!! [數量差異(原/拆)" & 數量 & "/" & 拆完數量 & "]" & vbCrLf If 未比對人員.Count > 0 Then : 差異字串 &= "  未比對到的人員:" & String.Join("、", 未比對人員) & vbCrLf : End If End If Next If 差異字串 <> "" Then 可複製訊息通知框.訊息_tb.Text = "請注意拆分資料過程發現資料核對異常,清單如下 : " & vbCrLf & 差異字串 & "無法完資料拆分,請確認資料正確並重新導入!!" 可複製訊息通知框.ShowDialog() : Exit Sub End If ConnOpen() ' 刪除未拆分的資料 SQL1 = "DELETE 人事拆帳制A碼項目清冊 WHERE (流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "') AND (服務人員 LIKE N'%、%')" CmdSet_For_dr() For I As Integer = 0 To 拆分_dgv.Rows.Count - 1 : MyModule1.進度條() SQL2 &= "(N'" & 拆分_dgv.Rows(I).Cells(0).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(1).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(2).Value.ToString() & "', N'" & 拆分_dgv.Rows(I).Cells(3).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(4).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(5).Value.ToString() & "', N'" & 拆分_dgv.Rows(I).Cells(6).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(7).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(8).Value.ToString() & "', N'" & 拆分_dgv.Rows(I).Cells(9).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(10).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(11).Value.ToString() & "', N'" & 拆分_dgv.Rows(I).Cells(12).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(13).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(14).Value.ToString() & "', N'" & 拆分_dgv.Rows(I).Cells(15).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(16).Value.ToString() & "',N'" & 拆分_dgv.Rows(I).Cells(17).Value.ToString() & "', N'" & 拆分_dgv.Rows(I).Cells(18).Value.ToString() & "')," Next If Not String.IsNullOrEmpty(SQL2) AndAlso SQL2.Length > 0 Then : SQL2 = SQL2.Substring(0, SQL2.Length - 1) : End If ConnOpen() SQL1 = "INSERT INTO 人事拆帳制A碼項目清冊 (序號, 服務代碼, 採用計畫, CMS等級, 服務項目類別, 身分證號, 個案姓名, 給付價格, 數量, 小計, 服務日期, 服務單位, 服務當下居住縣市, 目前居住縣市, 目前居住行政區, 照管專員, 服務人員, 備註, 流水號) VALUES " & SQL2 CmdSet_For_dr() : SQL2 = "" End If MsgBox("導入完成!!") : 最終數 = 0 : ICS_ASMS_ERP_SYS.ToolStripProgressBar1.Value = 最終數 首次開啟 = True BBL1 = "" : BBL2 = "" : BBL3 = "" : BBL4 = "" : BBL5 = "" : BBL6 = "" : PA = "" : PA1 = "" : PA2 = "" : PA3 = "" : PA4 = "" : PA5 = "" : PA6 = "" : PA7 = "" : PA8 = "" : PA9 = "" PA10 = "" : PA11 = "" : PA12 = "" : PA13 = "" : PA14 = "" : PA15 = "" : PA16 = "" : PA17 = "" : PA18 = "" : PA19 = "" : PA20 = "" : PA21 = "" : PA22 = "" : PA23 = "" : PA24 = "" PA25 = "" : PA26 = "" : PA27 = "" : PA28 = "" : PA29 = "" : PA30 = "" : PA31 = "" : PA32 = "" : PA33 = "" : PA34 = "" : PA35 = "" : PA36 = "" : PA37 = "" : PA38 = "" : PA39 = "" PA40 = "" : PA41 = "" : PA42 = "" : PA43 = "" : PA44 = "" : PA45 = "" : PA46 = "" : PA47 = "" : DTP = "" : DTP1 = "" : DTP2 = "" DTP3 = "" : 列印用SQL = "" Dim aa As MsgBoxResult = MsgBox("導入完成, 是否要開啟拆帳制薪資試算表!!", MsgBoxStyle.OkCancel) If aa = MsgBoxResult.Ok Then : 拆帳制薪資試算表.Show() : Me.Close() : Else : End If Else : MsgBox("請先選擇日期!!") : End If End Sub Private Sub Set_權限清單(姓名 As String, 服務項目代碼 As String) Dim ds1 As New DataSet 總和_dgv.DataSource = Nothing : ds1.Clear() 總和_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 總和_dgv.ColumnHeadersHeight = 25 : 總和_dgv.AllowUserToAddRows = False : 總和_dgv.RowTemplate.Height = 35 ConnOpen() SQL1 = "SELECT SUM(CAST(項目服務次數 AS int)) AS 總服務次數, SUM(CAST(申報費用 AS money)) AS 總申報費用, 居服員姓名 FROM 人事拆帳制服務紀錄_仁寶 WHERE (流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "%') AND (姓名 LIKE N'" & 姓名 & "') AND (服務項目代碼 LIKE N'" & 服務項目代碼 & "%') GROUP BY 居服員姓名" CmdSet_For_DGV() da.Fill(ds1) : 總和_dgv.DataSource = ds1.Tables(0) : conn.Close() End Sub Private Sub Set_取資料(姓名 As String, 服務代碼 As String) Dim ds2 As New DataSet 取資料_dgv.DataSource = Nothing : ds2.Clear() 取資料_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 取資料_dgv.ColumnHeadersHeight = 25 : 取資料_dgv.AllowUserToAddRows = False : 取資料_dgv.RowTemplate.Height = 35 ConnOpen() SQL1 = "SELECT TOP (1) 序號, 服務代碼, 採用計畫, CMS等級, 服務項目類別, 身分證號, 個案姓名, 給付價格, 數量, 小計, 服務日期, 服務單位, 服務當下居住縣市, 目前居住縣市, 目前居住行政區, 照管專員, 服務人員, 備註, 流水號 FROM 人事拆帳制A碼項目清冊 WHERE (流水號 LIKE N'" & 年份_cb.Text & 月份_cb.Text & "') AND (個案姓名 LIKE N'" & 姓名 & "') AND (服務代碼 LIKE N'" & 服務代碼 & "')" CmdSet_For_DGV() da.Fill(ds2) : 取資料_dgv.DataSource = ds2.Tables(0) : conn.Close() End Sub End Class