Public Class 人員排班條件設定 Private Sub 讀取人員資料表() Dim ds As New DataSet : Dim 穩定(7), 不穩定(7) As Integer 人員_dgv.DataSource = Nothing : ds.Clear() 人員_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing 人員_dgv.ColumnHeadersHeight = 25 : 人員_dgv.AllowUserToAddRows = False 人員_dgv.RowTemplate.Height = 70 SQL_人員備註清單() da.Fill(ds) : 人員_dgv.DataSource = ds.Tables(0) : conn.Close() 人員_dgv.Columns(0).FillWeight = 50 : 人員_dgv.Columns(1).Visible = False : 人員_dgv.Columns(2).FillWeight = 70 : 人員_dgv.Columns(3).FillWeight = 70 人員_dgv.Columns(4).FillWeight = 50 : 人員_dgv.Columns(5).FillWeight = 50 : 人員_dgv.Columns(6).FillWeight = 50 : 人員_dgv.Columns(7).FillWeight = 80 人員_dgv.Columns(8).FillWeight = 80 : 人員_dgv.Columns(9).FillWeight = 80 : 人員_dgv.Columns(10).FillWeight = 80 : 人員_dgv.Columns(11).FillWeight = 80 人員_dgv.Columns(12).FillWeight = 80 : 人員_dgv.Columns(13).FillWeight = 80 : 人員_dgv.Columns(14).FillWeight = 80 : 人員_dgv.Columns(15).FillWeight = 50 人員_dgv.Columns(16).FillWeight = 400 人員_dgv.EditMode = DataGridViewEditMode.EditOnEnter 人員_dgv.Columns(0).ReadOnly = True : 人員_dgv.Columns(2).ReadOnly = True : 人員_dgv.Columns(5).ReadOnly = True : 人員_dgv.Columns(6).ReadOnly = True 人員_dgv.Columns(7).ReadOnly = True : 人員_dgv.Columns(8).ReadOnly = True : 人員_dgv.Columns(9).ReadOnly = True : 人員_dgv.Columns(10).ReadOnly = True 人員_dgv.Columns(11).ReadOnly = True : 人員_dgv.Columns(12).ReadOnly = True : 人員_dgv.Columns(13).ReadOnly = True : 人員_dgv.Columns(14).ReadOnly = True 人員_dgv.Columns(15).ReadOnly = True For i As Integer = 0 To 7 : 穩定(i) = 0 : 不穩定(i) = 0 : Next For i As Integer = 0 To 人員_dgv.Rows.Count - 1 : 人員_dgv.Rows(i).Cells("No.").Value = i + 1 If IsDBNull(人員_dgv.Rows(i).Cells(5).Value) Then : 人員_dgv.Rows(i).Cells(5).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(6).Value) Then : 人員_dgv.Rows(i).Cells(6).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(7).Value) Then : 人員_dgv.Rows(i).Cells(7).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(8).Value) Then : 人員_dgv.Rows(i).Cells(8).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(9).Value) Then : 人員_dgv.Rows(i).Cells(9).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(10).Value) Then : 人員_dgv.Rows(i).Cells(10).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(11).Value) Then : 人員_dgv.Rows(i).Cells(11).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(12).Value) Then : 人員_dgv.Rows(i).Cells(12).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(13).Value) Then : 人員_dgv.Rows(i).Cells(13).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(14).Value) Then : 人員_dgv.Rows(i).Cells(14).Value = False : End If If IsDBNull(人員_dgv.Rows(i).Cells(15).Value) Then : 人員_dgv.Rows(i).Cells(15).Value = False : End If If 人員_dgv.Rows(i).Cells(3).Value.ToString <> "" Then If 人員_dgv.Rows(i).Cells(15).Value = True Then If 人員_dgv.Rows(i).Cells("1F掛號").Value = True Then : 穩定(0) += 1 : End If If 人員_dgv.Rows(i).Cells("1F掛號(實)").Value = True Then : 穩定(1) += 1 : End If If 人員_dgv.Rows(i).Cells("1F跟診").Value = True Then : 穩定(2) += 1 : End If If 人員_dgv.Rows(i).Cells("1F治療").Value = True Then : 穩定(3) += 1 : End If If 人員_dgv.Rows(i).Cells("1F治療(實)").Value = True Then : 穩定(4) += 1 : End If If 人員_dgv.Rows(i).Cells("2F櫃台").Value = True Then : 穩定(5) += 1 : End If If 人員_dgv.Rows(i).Cells("2F醫美").Value = True Then : 穩定(6) += 1 : End If If 人員_dgv.Rows(i).Cells("行政").Value = True Then : 穩定(7) += 1 : End If Else If 人員_dgv.Rows(i).Cells("1F掛號").Value = True Then : 不穩定(0) += 1 : End If If 人員_dgv.Rows(i).Cells("1F掛號(實)").Value = True Then : 不穩定(1) += 1 : End If If 人員_dgv.Rows(i).Cells("1F跟診").Value = True Then : 不穩定(2) += 1 : End If If 人員_dgv.Rows(i).Cells("1F治療").Value = True Then : 不穩定(3) += 1 : End If If 人員_dgv.Rows(i).Cells("1F治療(實)").Value = True Then : 不穩定(4) += 1 : End If If 人員_dgv.Rows(i).Cells("2F櫃台").Value = True Then : 不穩定(5) += 1 : End If If 人員_dgv.Rows(i).Cells("2F醫美").Value = True Then : 不穩定(6) += 1 : End If If 人員_dgv.Rows(i).Cells("行政").Value = True Then : 不穩定(7) += 1 : End If End If End If Next 崗位01_Y.Text = 穩定(0) : 崗位02_Y.Text = 穩定(1) : 崗位03_Y.Text = 穩定(2) : 崗位04_Y.Text = 穩定(3) 崗位05_Y.Text = 穩定(4) : 崗位06_Y.Text = 穩定(5) : 崗位07_Y.Text = 穩定(6) : 崗位08_Y.Text = 穩定(7) 崗位01_N.Text = 不穩定(0) : 崗位02_N.Text = 不穩定(1) : 崗位03_N.Text = 不穩定(2) : 崗位04_N.Text = 不穩定(3) 崗位05_N.Text = 不穩定(4) : 崗位06_N.Text = 不穩定(5) : 崗位07_N.Text = 不穩定(6) : 崗位08_N.Text = 不穩定(7) End Sub 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 讀取人員資料表() End Sub Private Sub 備註存檔_tb_Click(sender As Object, e As EventArgs) Handles 備註存檔_tb.Click If 編號_tb.Text <> "" Then PA10 = 問題備註_tb.Text : PA11 = 人員職位_tb.Text : PA12 = 職務性質_tb.Text : PA13 = 早班_ch.Checked : PA14 = 晚班_ch.Checked : PA = 編號_tb.Text PA9 = 崗位01_ch.Checked : PA8 = 崗位02_ch.Checked : PA7 = 崗位03_ch.Checked : PA6 = 崗位04_ch.Checked : PA5 = 崗位05_ch.Checked : PA4 = 崗位06_ch.Checked PA3 = 崗位07_ch.Checked : PA2 = 崗位08_ch.Checked : PA1 = 穩定_ch.Checked SQL_人員備註修改() End If For I As Integer = 0 To 人員_dgv.Rows.Count - 1 PA = 人員_dgv("編號", I).Value.ToString : PA10 = 人員_dgv("人員備註", I).Value.ToString PA11 = 人員_dgv("職位", I).Value.ToString : PA12 = 人員_dgv("性質", I).Value.ToString PA13 = 人員_dgv("早班", I).Value : PA14 = 人員_dgv("晚班", I).Value PA9 = 人員_dgv(7, I).Value : PA8 = 人員_dgv(8, I).Value : PA7 = 人員_dgv(9, I).Value PA6 = 人員_dgv(10, I).Value : PA5 = 人員_dgv(11, I).Value : PA4 = 人員_dgv(12, I).Value PA3 = 人員_dgv(13, I).Value : PA2 = 人員_dgv(14, I).Value : PA1 = 人員_dgv(15, I).Value SQL_人員備註修改() Next : MsgBox("存檔完成!!") : 讀取人員資料表() End Sub Private Sub 人員_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 人員_dgv.MouseUp 'If 報價總表_dgv.SelectedCells.Count = 1 Then : 通知訊息 = 報價總表_dgv.SelectedCells(0).ColumnIndex & " " & 報價總表_dgv.SelectedCells(0).RowIndex) : End If If 人員_dgv.SelectedCells.Count > 0 Then If 人員_dgv.SelectedCells(0).ColumnIndex = 5 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(5).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(5).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(5).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 6 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(6).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(6).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(6).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 7 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(7).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(7).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(7).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 8 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(8).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(8).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(8).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 9 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(9).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(9).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(9).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 10 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(10).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(10).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(10).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 11 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(11).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(11).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(11).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 12 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(12).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(12).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(12).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 13 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(13).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(13).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(13).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 14 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(14).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(14).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(14).Value = True : End If ElseIf 人員_dgv.SelectedCells(0).ColumnIndex = 15 Then If 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(15).Value = True Then 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(15).Value = False Else : 人員_dgv.Rows(人員_dgv.SelectedCells(0).RowIndex).Cells(15).Value = True : End If End If End If End Sub Private Sub 人員_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 人員_dgv.CellClick If e.RowIndex = -1 Then : Else PA = 人員_dgv("編號", e.RowIndex).Value.ToString : PA1 = 人員_dgv("姓名", e.RowIndex).Value.ToString 編號_tb.Text = 人員_dgv("編號", e.RowIndex).Value.ToString : 人員名稱_tb.Text = 人員_dgv("姓名", e.RowIndex).Value.ToString SQL_人員備註() If dr.Read Then 人員職位_tb.Text = dr("職位").ToString : 職務性質_tb.Text = dr("性質").ToString : 問題備註_tb.Text = dr("人員備註").ToString If IsDBNull(dr("早班")) Then : Else : 早班_ch.Checked = dr("早班") : End If : If IsDBNull(dr("晚班")) Then : Else : 晚班_ch.Checked = dr("晚班") : End If If IsDBNull(dr("崗位01")) Then : Else : 崗位01_ch.Checked = dr("崗位01") : End If : If IsDBNull(dr("崗位02")) Then : Else : 崗位02_ch.Checked = dr("崗位02") : End If If IsDBNull(dr("崗位03")) Then : Else : 崗位03_ch.Checked = dr("崗位03") : End If : If IsDBNull(dr("崗位04")) Then : Else : 崗位04_ch.Checked = dr("崗位04") : End If If IsDBNull(dr("崗位05")) Then : Else : 崗位05_ch.Checked = dr("崗位05") : End If : If IsDBNull(dr("崗位06")) Then : Else : 崗位06_ch.Checked = dr("崗位06") : End If If IsDBNull(dr("崗位07")) Then : Else : 崗位07_ch.Checked = dr("崗位07") : End If : If IsDBNull(dr("崗位08")) Then : Else : 崗位08_ch.Checked = dr("崗位08") : End If If IsDBNull(dr("穩定")) Then : Else : 穩定_ch.Checked = dr("穩定") : End If End If End If End Sub End Class