123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573 |
- Option Strict Off
- Imports System.Drawing.Imaging
- Imports System.IO
-
- Public Class 排班明細
- ReadOnly ds, ds1 As New DataSet
- Dim X1, XX, XXX, AA As Double
- Dim Q, 開始位置1, 開始位置2, 標準長度, 行(20), 選擇項, 選擇處 As Integer
- Dim 開始使用 As Boolean = False
- Private Sub 讀取人員資料表()
- 人員_dgv.DataSource = Nothing : ds.Clear()
- 人員_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- 人員_dgv.ColumnHeadersHeight = 25 : 人員_dgv.AllowUserToAddRows = False
- If 全_ch.Checked = False Then
- SQL_排班系統_班別_人員()
- Else
- SQL_排班系統_班別_人員_全()
- End If
- da.Fill(ds) : 人員_dgv.DataSource = ds.Tables(0) : conn.Close()
- 人員_dgv.Columns(0).FillWeight = 70 : 人員_dgv.Columns(1).Visible = False : 人員_dgv.Columns(2).FillWeight = 100
- For i As Integer = 0 To 人員_dgv.Rows.Count - 1 : 人員_dgv.Rows(i).Cells("No.").Value = i + 1 : Next
- End Sub
- Private Sub 讀取排班資料表()
- 排班明細_dgv.DataSource = Nothing : ds1.Clear()
- 排班明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- 排班明細_dgv.ColumnHeadersHeight = 25: 排班明細_dgv.AllowUserToAddRows = False
- SQL_排班系統_班別_排班()
- da.Fill(ds1) : 排班明細_dgv.DataSource = ds1.Tables(0) : conn.Close()
- 排班明細_dgv.Sort(排班明細_dgv.Columns("項"), System.ComponentModel.ListSortDirection.Ascending)
- For i As Integer = 0 To 排班明細_dgv.Rows.Count - 1
- If IsDBNull(排班明細_dgv.Rows(i).Cells("請假類別").Value) = True Then
- 排班明細_dgv.Rows(i).Cells("請假類別").Value = ""
- End If
- If CInt(排班明細_dgv.Rows(i).Cells("項次").Value.ToString) < 10 Then
- 排班明細_dgv.Rows(i).Cells("項次").Value = ("0" & i + 1)
- Else : 排班明細_dgv.Rows(i).Cells("項次").Value = (i + 1) : End If
- Next
- End Sub
- Private Sub 班別_下拉表單資料載入()
- SQL_排班系統_班別_下拉()
- Dim cbList As ComboBox() = {班別_cb1, 班別_cb2, 班別_cb3, 班別_cb4, 班別_cb5, 班別_cb6, 班別_cb7, 班別_cb8, 班別_cb9, 班別_cb10, 班別_cb11, 班別_cb12, 班別_cb13, 班別_cb14, 班別_cb15,
- 班別_cb16, 班別_cb17, 班別_cb18, 班別_cb19, 班別_cb20} ' 將所有班別_cb放入陣列中
- For Each cb As ComboBox In cbList : cb.Items.Clear() : Next ' 清空每個 ComboBox 的項目
- While dr.Read() : For Each cb As ComboBox In cbList : cb.Items.Add(dr("時段")) : Next : End While : conn.Close() ' 讀取資料,將相同的時段加入所有 ComboBox
- End Sub
- Private Sub 職務_下拉表單資料載入()
- SQL_排班系統_職務_下拉()
- Dim cbList As ComboBox() = {ComboBox1, ComboBox2, ComboBox3, ComboBox4, ComboBox5, ComboBox6, ComboBox7, ComboBox8, ComboBox9, ComboBox10, ComboBox11, ComboBox12, ComboBox13,
- ComboBox14, ComboBox15, ComboBox16, ComboBox17, ComboBox18, ComboBox19, ComboBox20, ComboBox21, ComboBox22, ComboBox23, ComboBox24, ComboBox25,
- ComboBox26, ComboBox27, ComboBox28, ComboBox29, ComboBox30, ComboBox31, ComboBox32, ComboBox33, ComboBox34, ComboBox35, ComboBox36, ComboBox37,
- ComboBox38, ComboBox39, ComboBox40} ' 將所有 ComboBox 放入陣列中
- For Each cb As ComboBox In cbList : cb.Items.Clear() : Next ' 清除所有 ComboBox 的項目
- While dr.Read() : For Each cb As ComboBox In cbList : cb.Items.Add(dr("職務")) : Next : End While : conn.Close() ' 讀取資料,每一筆資料的 "職務" 加入到所有 ComboBox 中
- End Sub
- Private Sub 班表鎖定變化()
- If gUserName = "*系統管理者" Then 'Or gUserName = "蔡紋婷"
- 存檔_bt.Enabled = True : 人員_dgv.Enabled = True : 全_ch.Enabled = True
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- 姓名_tbS.Enabled = True : 班別_cbS.Enabled = True : CheckBoxS.Enabled = True : NumericUpDownS.Enabled = True : NUPS.Enabled = True : BUPS.Enabled = True
- Next
- Else
- If CC(17) = False Then
- 存檔_bt.Enabled = False : 人員_dgv.Enabled = False : 全_ch.Enabled = False
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- 姓名_tbS.Enabled = False : 班別_cbS.Enabled = False : CheckBoxS.Enabled = False : NumericUpDownS.Enabled = False : NUPS.Enabled = False : BUPS.Enabled = False
- Next
- Else
- 存檔_bt.Enabled = True : 人員_dgv.Enabled = True : 全_ch.Enabled = True
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- 姓名_tbS.Enabled = True : 班別_cbS.Enabled = True : CheckBoxS.Enabled = True : NumericUpDownS.Enabled = True : NUPS.Enabled = True : BUPS.Enabled = True
- Next
- End If
- End If
- End Sub
- Private Sub 進度條變化(ByVal index As Integer)
- If 開始使用 = True Then
- ' 根據 index 找到對應的控制項
- Dim 姓名_tb As TextBox = CType(Me.Controls.Find("姓名_tb" + index.ToString(), True)(0), TextBox)
- Dim 班別_cb As ComboBox = CType(Me.Controls.Find("班別_cb" + index.ToString(), True)(0), ComboBox)
- Dim numUD As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" & index.ToString(), True)(0), NumericUpDown)
- Dim bupUD As NumericUpDown = CType(Me.Controls.Find("BUP" & index.ToString(), True)(0), NumericUpDown)
- Dim chk As CheckBox = CType(Me.Controls.Find("CheckBox" & index.ToString(), True)(0), CheckBox)
- ' 假設第一組 ComboBox 的編號為 (index*2-1),第二組為 (index*2)
- Dim cbA As ComboBox = CType(Me.Controls.Find("ComboBox" & ((index * 2) - 1).ToString(), True)(0), ComboBox)
- Dim cbB As ComboBox = CType(Me.Controls.Find("ComboBox" & (index * 2).ToString(), True)(0), ComboBox)
- If 姓名_tb.Text <> "" OrElse 班別_cb.Text <> "休" Then ' 只有當姓名不空或班別不為 "休" 時才處理
- Do2 = numUD.Value : 班條長度() ' 設定進度相關參數
- cbA.Size = New Size(標準長度 + XXX, 32) : cbB.Size = New Size(標準長度 - XXX, 25) ' 調整第一組 ComboBox 大小
- Do2 = bupUD.Value : 班條長度() : cbB.Size = New Size(cbB.Size.Width + XXX, 25) ' 根據 BUP 值調整第二組 ComboBox 大小
- Dim firstTwo As Integer = Val(Strings.Left(班別_cb.Text, 2)) ' 設定 cbB 是否顯示
- If chk.Checked = False AndAlso firstTwo < 17 Then : cbB.Visible = True : Else : cbB.Visible = False : End If ' 這裡先取得班別文字前兩個字轉成數值來比較
- End If
- End If
- End Sub
- Private Sub 休息變化(ByVal index As Integer)
- If 開始使用 = True Then
- ' 找到對應的控制項
- Dim 班別_cb As ComboBox = CType(Me.Controls.Find("班別_cb" & index.ToString(), True)(0), ComboBox)
- Dim NUP As NumericUpDown = CType(Me.Controls.Find("NUP" & index.ToString(), True)(0), NumericUpDown)
- Dim numUD As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" & index.ToString(), True)(0), NumericUpDown)
- Dim cbA As ComboBox = CType(Me.Controls.Find("ComboBox" & ((index * 2) - 1).ToString(), True)(0), ComboBox)
- Dim cbB As ComboBox = CType(Me.Controls.Find("ComboBox" & (index * 2).ToString(), True)(0), ComboBox)
- XX = Val(Strings.Left(班別_cb.Text, 2)) * 60 + Val(Strings.Mid(班別_cb.Text, 4, 2)) : 班別圖示計算載入() ' 計算時間
- X1 = NUP.Value : 休息長度() : Do2 = numUD.Value : 班條長度() ' 設定長度與進度條
- cbA.Location = New Point(開始位置1 + XX, 行(index)) : cbB.Location = New Point(開始位置2 + XX + X1 + XXX, 行(index)) ' 設定 ComboBox 位置
- 進度條變化(index) ' 進度條變化
- End If
- End Sub
- Private Sub 半天變化(ByVal index As Integer)
- If 開始使用 = True Then
- Dim chk As CheckBox = CType(Me.Controls.Find("CheckBox" & index.ToString(), True)(0), CheckBox)
- Dim cbA As ComboBox = CType(Me.Controls.Find("ComboBox" & ((index * 2) - 1).ToString(), True)(0), ComboBox)
- Dim cbB As ComboBox = CType(Me.Controls.Find("ComboBox" & (index * 2).ToString(), True)(0), ComboBox)
- If chk IsNot Nothing AndAlso cbA IsNot Nothing AndAlso cbB IsNot Nothing Then : cbA.Visible = True : cbB.Visible = Not chk.Checked : End If
- End If
- End Sub
- Private Sub 回復預設()
- For no As Integer = 1 To 20 : Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown) : NUPS.Value = 1 : Next
- XX = 0 : Q = 0
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim ComboBoxsS1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxsS2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + 1 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 1 + Q).ToString(), True)(0), ComboBox)
- 姓名_tbS.Text = "" : 班別_cbS.Text = "休" : ComboBoxsS1.SelectedIndex = 0 : ComboBoxsS2.SelectedIndex = 0
- If 姓名_tbS.Text = "" Then : ComboBoxs1.Visible = False : ComboBoxs2.Visible = False
- Else : ComboBoxs1.Visible = True : ComboBoxs2.Visible = True : End If
- Next
- For i As Integer = 1 To 20
- ' 第一欄:奇數的 ComboBox
- Dim cb1Name As String = "ComboBox" & ((i * 2) - 1).ToString() : Dim cb1 As ComboBox = TryCast(Me.Controls(cb1Name), ComboBox)
- If cb1 IsNot Nothing Then : cb1.Location = New Point(開始位置1 + XX, 行(i)) : End If
- ' 第二欄:偶數的 ComboBox
- Dim cb2Name As String = "ComboBox" & (i * 2).ToString() : Dim cb2 As ComboBox = TryCast(Me.Controls(cb2Name), ComboBox)
- If cb2 IsNot Nothing Then : cb2.Location = New Point(開始位置2 + XX, 行(i)) : End If
- Next
- End Sub
- Private Sub 重新讀取()
- SQL_排班簽核讀取()
- If dr.Read Then
- 值日生1_bt.Text = dr("值日生1").ToString : 值日生2_bt.Text = dr("值日生2").ToString
- If dr("位置1").ToString = "" Then : 紅1_nud.Value = 8 : Else : 紅1_nud.Value = dr("位置1").ToString : End If
- If dr("面積1").ToString = "" Then : 面1_nud.Value = 0 : Else : 面1_nud.Value = dr("面積1").ToString : End If
- If dr("位置2").ToString = "" Then : 紅2_nud.Value = 8 : Else : 紅2_nud.Value = dr("位置2").ToString : End If
- If dr("面積2").ToString = "" Then : 面2_nud.Value = 0 : Else : 面2_nud.Value = dr("面積2").ToString : End If
- If dr("位置3").ToString = "" Then : 紅3_nud.Value = 8 : Else : 紅3_nud.Value = dr("位置3").ToString : End If
- If dr("面積3").ToString = "" Then : 面3_nud.Value = 0 : Else : 面3_nud.Value = dr("面積3").ToString : End If
- If dr("位置4").ToString = "" Then : 紅4_nud.Value = 8 : Else : 紅4_nud.Value = dr("位置4").ToString : End If
- If dr("面積4").ToString = "" Then : 面4_nud.Value = 0 : Else : 面4_nud.Value = dr("面積4").ToString : End If
- If dr("班表簽認") = "Y" Then : 鎖定_bt.Enabled = False : Else : 鎖定_bt.Enabled = True : End If : Else : 鎖定_bt.Enabled = True
- End If
- 班表鎖定變化()
-
- SQL_排班系統_星期() : If dr.Read Then : 星期_lb.Text = dr("星期") : End If : PA6 = 星期_lb.Text
- SQL_門診_健保()
- If dr.Read Then : B1_lb.Text = dr("早") : B2_lb.Text = dr("中") : B3_lb.Text = dr("晚") : Else : B1_lb.Text = "" : B2_lb.Text = "" : B3_lb.Text = "" : End If
- SQL_門診_美容()
- If dr.Read Then : B4_lb.Text = dr("早") : B5_lb.Text = dr("中") : B6_lb.Text = dr("晚") : Else : B4_lb.Text = "" : B5_lb.Text = "" : B6_lb.Text = "" : End If
- 讀取排班資料表() : 排班()
- End Sub
- Private Sub 排班()
- If 排班明細_dgv.Rows.Count > 0 Then
- Q = 0
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 請假_tbS As TextBox = CType(Me.Controls.Find("請假_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- Dim ComboBoxsS1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxsS2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + 1 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 1 + Q).ToString(), True)(0), ComboBox) : Q += 1
-
- ComboBoxs1.Text = 排班明細_dgv.Rows(no - 1).Cells("一段").Value
- ComboBoxs2.Text = 排班明細_dgv.Rows(no - 1).Cells("二段").Value
- ComboBoxsS1.Text = 排班明細_dgv.Rows(no - 1).Cells("顏色1").Value
- ComboBoxsS2.Text = 排班明細_dgv.Rows(no - 1).Cells("顏色2").Value
- NUPS.Value = 排班明細_dgv.Rows(no - 1).Cells("休息").Value
- BUPS.Value = 排班明細_dgv.Rows(no - 1).Cells("後段").Value
- NumericUpDownS.Value = 排班明細_dgv.Rows(no - 1).Cells("時數").Value
- CheckBoxS.Checked = 排班明細_dgv.Rows(no - 1).Cells("半天").Value
- 班別_cbS.Text = 排班明細_dgv.Rows(no - 1).Cells("班別").Value.ToString
- 姓名_tbS.Text = 排班明細_dgv.Rows(no - 1).Cells("姓名").Value.ToString
- 請假_tbS.Text = 排班明細_dgv.Rows(no - 1).Cells("請假類別").Value.ToString
- ComboBoxs1.SelectionLength = 0 : ComboBoxs2.SelectionLength = 0
- Next
- End If
- End Sub
- Private Sub 班別圖示計算載入()
- XX = (XX - 480) * 1.25
- End Sub
- Private Sub 班條長度()
- Dim 小時 As Double = 75
- If Do2 = 4 Then : XXX = 0 : ElseIf Do2 = 1 Then : XXX = -(小時 * 3) : ElseIf Do2 = 1.5 Then : XXX = -(小時 * 2.5)
- ElseIf Do2 = 2 Then : XXX = -(小時 * 2) : ElseIf Do2 = 2.5 Then : XXX = -(小時) + (-(小時 / 2)) : ElseIf Do2 = 3 Then : XXX = -(小時) : ElseIf Do2 = 3.5 Then : XXX = -(小時 / 2)
- ElseIf Do2 = 4.5 Then : XXX = 小時 / 2 : ElseIf Do2 = 5 Then : XXX = 小時 : ElseIf Do2 = 5.5 Then : XXX = 小時 + (小時 / 2) : ElseIf Do2 = 6 Then : XXX = 小時 * 2
- ElseIf Do2 = 6.5 Then : XXX = 小時 * 2.5 : ElseIf Do2 = 7 Then : XXX = 小時 * 3 : ElseIf Do2 = 7.5 Then : XXX = 小時 * 3.5 : ElseIf Do2 = 8 Then : XXX = 小時 * 4 : End If
- End Sub
- Private Sub 休息長度()
- X1 = (X1 - 1) * 8 * 10
- End Sub
- ' 定義顏色對應的陣列
- Private ReadOnly colors As Color() = {
- Color.LawnGreen, Color.LightBlue, Color.LightCoral, Color.LightCyan,
- Color.LightGoldenrodYellow, Color.LightGray, Color.LightGreen, Color.LightPink,
- Color.LightSalmon, Color.Gray
- }
- Private Sub 排班明細_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- '--------------初始設定---------------------------
- For i As Integer = 41 To 80 ' 動態綁定 ComboBox41~ComboBox80 的 SelectedIndexChanged 事件
- Dim cb As ComboBox = CType(Me.Controls("ComboBox" & i), ComboBox)
- If cb IsNot Nothing Then : AddHandler cb.SelectedIndexChanged, AddressOf ComboBox_SelectedIndexChanged : End If
- Next
- For i As Integer = 1 To 20
- Dim nup As NumericUpDown = CType(Me.Controls("NUP" & i), NumericUpDown) : Dim cb As ComboBox = CType(Me.Controls("班別_cb" & i), ComboBox)
- If nup IsNot Nothing AndAlso cb IsNot Nothing Then : nup.Tag = i : AddHandler nup.ValueChanged, AddressOf NUP_ValueChanged : End If
- Next
- For i As Integer = 1 To 20
- Dim tb As TextBox = CType(Me.Controls("姓名_tb" & i), TextBox) : AddHandler tb.Click, AddressOf 姓名_tb_Click
- Next
- For i As Integer = 1 To 20
- Dim chk As CheckBox = CType(Me.Controls("CheckBox" & i), CheckBox) : AddHandler chk.CheckedChanged, AddressOf CheckBox_CheckedChanged
- Next
- For i As Integer = 1 To 20
- Dim numUpDown As NumericUpDown = CType(Me.Controls("NumericUpDown" & i), NumericUpDown)
- If numUpDown IsNot Nothing Then : numUpDown.Tag = i : AddHandler numUpDown.ValueChanged, AddressOf NumericUpDown_ValueChanged : End If
- Next
- For i As Integer = 1 To 20
- Dim num As Integer = i : Dim bup As NumericUpDown = CType(Me.Controls("BUP" & num), NumericUpDown) : AddHandler bup.ValueChanged, Sub() 進度條變化檢查(num)
- Next
- For i As Integer = 1 To 4
- Dim num As Integer = i : Dim nud As NumericUpDown = CType(Me.Controls("紅" & num & "_nud"), NumericUpDown) : AddHandler nud.ValueChanged, Sub() 更新紅點位置(num)
- Next
- '--------------坐標系設定---------------------------
- 開始位置1 = 592 : 開始位置2 = 967 : 行(0) = 27 : 標準長度 = 297
- 行(1) = 108 : 行(2) = 行(1) + 行(0) : 行(3) = 行(2) + 行(0) : 行(4) = 行(3) + 行(0) : 行(5) = 行(4) + 行(0) : 行(6) = 行(5) + 行(0) : 行(7) = 行(6) + 行(0) : 行(8) = 行(7) + 行(0)
- 行(9) = 行(8) + 行(0) : 行(10) = 行(9) + 行(0) : 行(11) = 行(10) + 行(0) : 行(12) = 行(11) + 行(0) : 行(13) = 行(12) + 行(0) : 行(14) = 行(13) + 行(0) : 行(15) = 行(14) + 行(0)
- 行(16) = 行(15) + 行(0) : 行(17) = 行(16) + 行(0) : 行(18) = 行(17) + 行(0) : 行(19) = 行(18) + 行(0) : 行(20) = 行(19) + 行(0)
- '--------------複製權限---------------------------
- 開始使用 = True
- If gUserName = "*系統管理者" Then : 存檔_bt.Enabled = True : 複製班表_bt.Enabled = True : 人員_dgv.Enabled = True : 全_ch.Enabled = True : 備註存檔_tb.Enabled = True
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- 姓名_tbS.Enabled = True : 班別_cbS.Enabled = True : CheckBoxS.Enabled = True : NumericUpDownS.Enabled = True : NUPS.Enabled = True : BUPS.Enabled = True
- Next
- Else
- If CC(17) = False Then : 存檔_bt.Enabled = False : 複製班表_bt.Enabled = False : 人員_dgv.Enabled = False : 全_ch.Enabled = False : 備註存檔_tb.Enabled = False
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- 姓名_tbS.Enabled = False : 班別_cbS.Enabled = False : CheckBoxS.Enabled = False : NumericUpDownS.Enabled = False : NUPS.Enabled = False : BUPS.Enabled = False
- Next
- Else : 存檔_bt.Enabled = True : 複製班表_bt.Enabled = True : 人員_dgv.Enabled = True : 全_ch.Enabled = True : 備註存檔_tb.Enabled = True
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- 姓名_tbS.Enabled = True : 班別_cbS.Enabled = True : CheckBoxS.Enabled = True : NumericUpDownS.Enabled = True : NUPS.Enabled = True : BUPS.Enabled = True
- Next
- End If
- End If : 年_lb.Text = PA : 月_lb.Text = PA1
- End Sub
- Private Sub 排班明細_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
- 班別_下拉表單資料載入() : 職務_下拉表單資料載入() : 讀取人員資料表() : If Val(PA2) > 9 Then : 日_lb.Text = PA2 : Else : 日_lb.Text = "0" & PA2 : End If : 回復預設()
- 年_cb.Text = 年_lb.Text : 月_cb.Text = 月_lb.Text : 日_cb.Text = 日_lb.Text : PA = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text : 重新讀取()
- End Sub
- Private Sub 設定尺寸(面_nud As NumericUpDown, 紅_pb As PictureBox)
- Dim 欄距 As Double = 37.5 : 紅_pb.Size = New Size(欄距 * (面_nud.Value * 2), 544) ' 根據數值設定尺寸
- If 面_nud.Value = 0 Then : 紅_pb.Size = New Size(3, 544) : End If ' 當值為0時,寬度設為 3
- End Sub
- Private Sub 面1_nud_ValueChanged(sender As Object, e As EventArgs) Handles 面1_nud.ValueChanged
- 設定尺寸(面1_nud, 紅1_pb)
- End Sub
- Private Sub 面2_nud_ValueChanged(sender As Object, e As EventArgs) Handles 面2_nud.ValueChanged
- 設定尺寸(面2_nud, 紅2_pb)
- End Sub
- Private Sub 面3_nud_ValueChanged(sender As Object, e As EventArgs) Handles 面3_nud.ValueChanged
- 設定尺寸(面3_nud, 紅3_pb)
- End Sub
- Private Sub 面4_nud_ValueChanged(sender As Object, e As EventArgs) Handles 面4_nud.ValueChanged
- 設定尺寸(面4_nud, 紅4_pb)
- End Sub
- ' 共用的事件處理函數
- Private Sub 更新紅點位置(index As Integer)
- Dim 欄距 As Double = 37.5 : Dim 起始值 As Decimal = 8D : Dim nud As NumericUpDown = CType(Me.Controls("紅" & index & "_nud"), NumericUpDown)
- Dim pb As PictureBox = CType(Me.Controls("紅" & index & "_pb"), PictureBox) : Dim AXX As Double = 590 + (欄距 * CInt((nud.Value - 起始值) * 2))
- pb.Location = New Point(AXX, 105) : pb.Visible = (nud.Value <> 8)
- End Sub
- Private Sub 進度條變化檢查(index As Integer)
- Dim 班別_cb As ComboBox = CType(Me.Controls("班別_cb" & index), ComboBox) : If 班別_cb.Text <> "休" Then 進度條變化(index)
- End Sub
- Private Sub NumericUpDown_ValueChanged(sender As Object, e As EventArgs)
- Dim numUpDown As NumericUpDown = CType(sender, NumericUpDown) : Dim index As Integer = CInt(numUpDown.Tag)
- Dim comboBox As ComboBox = CType(Me.Controls("班別_cb" & index), ComboBox)
- If comboBox IsNot Nothing AndAlso comboBox.Text <> "休" Then : 休息變化(index) : End If ' 只有當對應的 ComboBox 不是 "休" 時才執行
- End Sub
- Private Sub CheckBox_CheckedChanged(sender As Object, e As EventArgs)
- Dim chk As CheckBox = CType(sender, CheckBox) : Dim index As Integer = Integer.Parse(chk.Name.Replace("CheckBox", "")) ' 取得數字部分
- Dim cb As ComboBox = CType(Me.Controls("班別_cb" & index), ComboBox) : If cb.Text <> "休" Then : 休息變化(index) : End If
- End Sub
- Private Sub 姓名_tb_Click(sender As Object, e As EventArgs)
- Dim tb As TextBox = DirectCast(sender, TextBox) : Dim index As Integer = Integer.Parse(tb.Name.Replace("姓名_tb", "")) : 選擇項 = index ' 取得數字部分
- For i As Integer = 0 To 人員_dgv.Rows.Count - 1
- If tb.Text = 人員_dgv.Rows(i).Cells("姓名").Value.ToString Then : 選擇處 = i : 人員資料讀取() : Exit For : End If ' 找到就退出迴圈,提高效能
- Next
- End Sub
- Private Sub NUP_ValueChanged(sender As Object, e As EventArgs)
- Dim nup As NumericUpDown = CType(sender, NumericUpDown) : Dim index As Integer = CInt(nup.Tag)
- Dim 班別_cb As ComboBox = CType(Me.Controls.Find("班別_cb" & index, True)(0), ComboBox)
- Dim cb1 As ComboBox = CType(Me.Controls.Find("ComboBox" & (index * 2 - 1), True)(0), ComboBox)
- Dim cb2 As ComboBox = CType(Me.Controls.Find("ComboBox" & (index * 2), True)(0), ComboBox)
- If 班別_cb IsNot Nothing AndAlso 班別_cb.Text <> "休" Then : 休息變化(index) : 半天變化(index)
- Else : If cb1 IsNot Nothing Then cb1.Visible = False : If cb2 IsNot Nothing Then cb2.Visible = False
- End If
- End Sub
- Private Sub ComboBox_SelectedIndexChanged(sender As Object, e As EventArgs)
- Dim cb As ComboBox = CType(sender, ComboBox) : Dim index As Integer = cb.SelectedIndex
- Dim num As Integer = Integer.Parse(cb.Name.Replace("ComboBox", "")) ' 獲取對應的 ComboBox 編號 (41~80)
- Dim targetComboBox As ComboBox = CType(Me.Controls("ComboBox" & (num - 40)), ComboBox) ' 找到對應的 ComboBox (例如 ComboBox41 對應 ComboBox1)
- If targetComboBox IsNot Nothing AndAlso index >= 0 AndAlso index < colors.Length Then : targetComboBox.BackColor = colors(index) : End If
- End Sub
- Private Sub 截圖_bt_Click(sender As Object, e As EventArgs) Handles 截圖_bt.Click
- Dim captureRectangle As New Rectangle(123, 0, 1698, 647) ' 指定要截取的範圍
- Dim bm As New Bitmap(captureRectangle.Width, captureRectangle.Height)
- Using g As Graphics = Graphics.FromImage(bm) ' 設定截圖的起點為 captureRectangle 左上角的位置
- g.CopyFromScreen(Me.PointToScreen(captureRectangle.Location), Point.Empty, captureRectangle.Size)
- End Using
- Me.Controls.SetChildIndex(PictureBox1, 0)
- My.Computer.Clipboard.SetImage(bm)
- PictureBox1.SendToBack()
- If 存檔_ch.Checked = True Then ' 保存圖片到桌面
- Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
- Dim filePath As String = Path.Combine(desktopPath, 年_lb.Text & 月_lb.Text & 日_lb.Text & 星期_lb.Text & ".png")
- bm.Save(filePath, ImageFormat.Png) : MsgBox("已將圖片存檔到桌面!!")
- End If
- End Sub
- Private Sub 上移_bt_Click(sender As Object, e As EventArgs) Handles 上移_bt.Click
- If 選擇項 <= 1 Then : Else
- If CInt(排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value) < 12 Then
- 排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value = "0" & CInt(排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value) - 2 & "-1"
- Else
- 排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value = CInt(排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value) - 2 & "-1"
- End If
- 排班明細_dgv.Sort(排班明細_dgv.Columns("項次"), System.ComponentModel.ListSortDirection.Ascending)
- For i As Integer = 0 To 排班明細_dgv.Rows.Count - 1 : 排班明細_dgv.Rows(i).Cells("項").Value = i + 1 : Next
- 排班明細_dgv.Sort(排班明細_dgv.Columns("項"), System.ComponentModel.ListSortDirection.Ascending)
- For i As Integer = 0 To 排班明細_dgv.Rows.Count - 1
- 排班明細_dgv.Rows(i).Cells("項次").Value = i + 1
- If CInt(排班明細_dgv.Rows(i).Cells("項次").Value) < 10 Then
- 排班明細_dgv.Rows(i).Cells("項次").Value = "0" & i + 1
- Else : 排班明細_dgv.Rows(i).Cells("項次").Value = i + 1 : End If
- Next : 選擇項 -= 1
- If 選擇項 <= 0 Then : 選擇項 = 0 : End If : 排班()
- End If
- End Sub
- Private Sub 下移_bt_Click(sender As Object, e As EventArgs) Handles 下移_bt.Click
- If 選擇項 = 0 Or 選擇項 = 1 Then : Else
- If CInt(排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value) < 9 Then
- 排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value = "0" & CInt(排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value) + 1 & "-1"
- Else
- 排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value = CInt(排班明細_dgv.Rows(選擇項 - 1).Cells("項次").Value) + 1 & "-1"
- End If
- 排班明細_dgv.Sort(排班明細_dgv.Columns("項次"), System.ComponentModel.ListSortDirection.Ascending)
- For i As Integer = 0 To 排班明細_dgv.Rows.Count - 1 : 排班明細_dgv.Rows(i).Cells("項").Value = i + 1 : Next
- 排班明細_dgv.Sort(排班明細_dgv.Columns("項"), System.ComponentModel.ListSortDirection.Ascending)
- For i As Integer = 0 To 排班明細_dgv.Rows.Count - 1
- 排班明細_dgv.Rows(i).Cells("項次").Value = i + 1
- If CInt(排班明細_dgv.Rows(i).Cells("項次").Value) < 10 Then
- 排班明細_dgv.Rows(i).Cells("項次").Value = "0" & i + 1
- Else : 排班明細_dgv.Rows(i).Cells("項次").Value = i + 1 : End If
- Next : 選擇項 += 1
- If 選擇項 >= 20 Then : 選擇項 = 20 : End If : 排班()
- End If
- 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_人員備註修改() : MsgBox("存檔完成!!")
- End If
- End Sub
- Private Sub 人員資料讀取()
- PA = 人員_dgv("編號", 選擇處).Value.ToString : PA1 = 人員_dgv("姓名", 選擇處).Value.ToString
- 編號_tb.Text = 人員_dgv("編號", 選擇處).Value.ToString : 人員名稱_tb.Text = 人員_dgv("姓名", 選擇處).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 Sub
- Private Sub 人員_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 人員_dgv.CellClick
- If e.RowIndex = -1 Then : Else : 選擇處 = e.RowIndex : 人員資料讀取() : End If
- End Sub
- Private Sub 班別_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles _
- 班別_cb1.SelectedIndexChanged, 班別_cb2.SelectedIndexChanged, 班別_cb3.SelectedIndexChanged, 班別_cb4.SelectedIndexChanged, 班別_cb5.SelectedIndexChanged, 班別_cb6.SelectedIndexChanged,
- 班別_cb7.SelectedIndexChanged, 班別_cb8.SelectedIndexChanged, 班別_cb9.SelectedIndexChanged, 班別_cb10.SelectedIndexChanged, 班別_cb11.SelectedIndexChanged, 班別_cb12.SelectedIndexChanged,
- 班別_cb13.SelectedIndexChanged, 班別_cb14.SelectedIndexChanged, 班別_cb15.SelectedIndexChanged, 班別_cb16.SelectedIndexChanged, 班別_cb17.SelectedIndexChanged, 班別_cb18.SelectedIndexChanged,
- 班別_cb19.SelectedIndexChanged, 班別_cb20.SelectedIndexChanged
-
- Dim cb As ComboBox = DirectCast(sender, ComboBox) : Dim index As Integer = Integer.Parse(cb.Name.Replace("班別_cb", "")) ' 取得數字部分
- Dim cb休息 As ComboBox = CType(Me.Controls.Find("ComboBox" & (index * 2 - 1), True)(0), ComboBox)
- Dim cb半天 As ComboBox = CType(Me.Controls.Find("ComboBox" & (index * 2), True)(0), ComboBox)
- If cb.Text <> "休" Then : 休息變化(index) : 半天變化(index) : Else : cb休息.Visible = False : cb半天.Visible = False : End If
- End Sub
- Private Sub 全_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 全_ch.CheckedChanged
- 讀取人員資料表()
- End Sub
- Private Sub 減一天_bt_Click(sender As Object, e As EventArgs) Handles 減一天_bt.Click
- 年_lb.Text = 年_cb.Text : 月_lb.Text = 月_cb.Text : 日_lb.Text = 日_cb.Text
- DTP1.Value = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text
- DTP1.Value = DTP1.Value.AddDays(-1)
- PA = Format(DTP1.Value, "yyyy/MM/dd")
- 年_lb.Text = Strings.Left(PA, 4) : 月_lb.Text = Strings.Mid(PA, 6, 2) : PA2 = Strings.Right(PA, 2)
- '----------------回復預設-----------------------------------------------------------------------------------------------
- If Val(PA2) > 9 Then : 日_lb.Text = PA2 : Else : 日_lb.Text = "0" & Val(PA2) : End If
- 年_cb.Text = 年_lb.Text : 月_cb.Text = 月_lb.Text : 日_cb.Text = 日_lb.Text
- 回復預設() : 重新讀取()
- End Sub
- Private Sub 加一天_bt1_Click(sender As Object, e As EventArgs) Handles 加一天_bt1.Click
- 年_lb.Text = 年_cb.Text : 月_lb.Text = 月_cb.Text : 日_lb.Text = 日_cb.Text
- DTP1.Value = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text
- DTP1.Value = DTP1.Value.AddDays(+1)
- PA = Format(DTP1.Value, "yyyy/MM/dd")
- 年_lb.Text = Strings.Left(PA, 4) : 月_lb.Text = Strings.Mid(PA, 6, 2) : PA2 = Strings.Right(PA, 2)
- '----------------回復預設-----------------------------------------------------------------------------------------------
- If Val(PA2) > 9 Then : 日_lb.Text = PA2 : Else : 日_lb.Text = "0" & Val(PA2) : End If
- 年_cb.Text = 年_lb.Text : 月_cb.Text = 月_lb.Text : 日_cb.Text = 日_lb.Text
- 回復預設() : 重新讀取()
- End Sub
- Private Sub 更新日期_bt_Click(sender As Object, e As EventArgs) Handles 更新日期_bt.Click
- 年_lb.Text = 年_cb.Text : 月_lb.Text = 月_cb.Text : 日_lb.Text = 日_cb.Text
- Dim dateStr As String = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text
- Dim validDate As Boolean : Dim parsedDate As DateTime
- validDate = DateTime.TryParseExact(dateStr, "yyyy/M/d", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, parsedDate)
- If validDate Then
- DTP1.Value = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text : PA = Format(DTP1.Value, "yyyy/MM/dd")
- If Val(PA2) > 9 Then : 日_lb.Text = PA2 : Else : 日_lb.Text = "0" & Val(PA2) : End If
- 回復預設() : 重新讀取()
- Else : MsgBox("無效的日期!!") : End If
- End Sub
- Private Sub 鎖定_bt_Click(sender As Object, e As EventArgs) Handles 鎖定_bt.Click
- PA = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text : SQL_排班簽核() : MsgBox("簽核完畢!!!")
- 年_cb.Text = 年_lb.Text : 月_cb.Text = 月_lb.Text : 日_cb.Text = 日_lb.Text
- 鎖定_bt.Enabled = False
- 班表鎖定變化()
- End Sub
- Private Sub 解鎖_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 解鎖_ch.Click
- If 解鎖_ch.Checked = True Then : PA = InputBox("修改已鎖定班表請輸入密碼!!")
- If PA = "0003065795" Then : 解鎖_ch.Checked = True : 鎖定_bt.Enabled = True : 班表鎖定變化()
- Else : MsgBox("密碼錯誤!!") : 解鎖_ch.Checked = False : 鎖定_bt.Enabled = False : 班表鎖定變化() : End If
- ElseIf 解鎖_ch.Checked = False Then : 解鎖_ch.Checked = False : 鎖定_bt.Enabled = False : 班表鎖定變化() : End If
- End Sub
- Private Sub ComboBox40_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox40.TextChanged
- If ComboBox40.Text = "" Then : ComboBox40.DropDownStyle = 1 : Else : ComboBox40.DropDownStyle = 0 : End If
- End Sub
- Private Sub 存檔_bt_Click(sender As Object, e As EventArgs) Handles 存檔_bt.Click
- 年_lb.Text = 年_cb.Text : 月_lb.Text = 月_cb.Text : 日_lb.Text = 日_cb.Text
- PA = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text
- SQL_排班明細_判斷是否有資料() : If dr.Read() Then : SQL_排班明細_刪除當天() : End If : Q = 0
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- Dim ComboBoxsS1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxsS2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + 1 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 1 + Q).ToString(), True)(0), ComboBox) : Q += 1
-
- PA1 = A_lbS.Text : PA2 = 姓名_tbS.Text : PA3 = 班別_cbS.Text : BL1 = CheckBoxS.Checked : Do1 = NUPS.Value
- PA5 = ComboBoxs1.Text : PA6 = ComboBoxs2.Text : PA7 = ComboBoxsS1.Text : PA8 = ComboBoxsS2.Text : PA9 = BUPS.Value
- SQL_排班明細_上午上班()
- If dr.Read() Then : PA4 = dr("上午上班") : End If
- If CheckBoxS.Checked = False Then : Do3 = 8 : Else : Do3 = NumericUpDownS.Value : End If
- Do2 = NumericUpDownS.Value
- SQL_排班明細_新增當天()
- Next
- PA = 年_lb.Text & "/" & 月_lb.Text & "/" & 日_lb.Text : PA13 = 值日生1_bt.Text : PA14 = 值日生2_bt.Text
- SQL_值日生存檔(紅1_nud.Value, 面1_nud.Value, 紅2_nud.Value, 面2_nud.Value, 紅3_nud.Value, 面3_nud.Value, 紅4_nud.Value, 面4_nud.Value)
- 解鎖_ch.Checked = False : 重新讀取() : MsgBox("存檔完成!!")
- End Sub
- Private Sub 複製班表_bt_Click(sender As Object, e As EventArgs) Handles 複製班表_bt.Click
- Dim FF = MsgBox("確定要已該班表做模板複製到 " & Format(指定日期_dtp.Value, "yyyy/MM/dd") & " 去嗎 ?", MsgBoxStyle.OkCancel)
- If FF = MsgBoxResult.Ok Then
- PA = Format(指定日期_dtp.Value, "yyyy/MM/dd")
- SQL_排班明細_判斷是否有資料() : If dr.Read() Then : SQL_排班明細_刪除當天() : End If
- Q = 0
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- Dim 班別_cbS As ComboBox = CType(Me.Controls.Find("班別_cb" + no.ToString(), True)(0), ComboBox)
- Dim A_lbS As Label = CType(Me.Controls.Find("A_lb" + no.ToString(), True)(0), Label)
- Dim CheckBoxS As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
- Dim NumericUpDownS As NumericUpDown = CType(Me.Controls.Find("NumericUpDown" + no.ToString(), True)(0), NumericUpDown)
- Dim NUPS As NumericUpDown = CType(Me.Controls.Find("NUP" + no.ToString(), True)(0), NumericUpDown)
- Dim BUPS As NumericUpDown = CType(Me.Controls.Find("BUP" + no.ToString(), True)(0), NumericUpDown)
- Dim ComboBoxsS1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxsS2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 40 + 1 + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs1 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + Q).ToString(), True)(0), ComboBox)
- Dim ComboBoxs2 As ComboBox = CType(Me.Controls.Find("ComboBox" + (no + 1 + Q).ToString(), True)(0), ComboBox) : Q += 1
-
- PA1 = A_lbS.Text : PA2 = 姓名_tbS.Text : PA3 = 班別_cbS.Text : BL1 = CheckBoxS.Checked : Do1 = NUPS.Value
- PA5 = ComboBoxs1.Text : PA6 = ComboBoxs2.Text : PA7 = ComboBoxsS1.Text : PA8 = ComboBoxsS2.Text : PA9 = BUPS.Value
- SQL_排班明細_上午上班()
- If dr.Read() Then : PA4 = dr("上午上班") : End If
- If CheckBoxS.Checked = False Then : Do3 = 8 : Else : Do3 = NumericUpDownS.Value : End If
- Do2 = NumericUpDownS.Value
- SQL_排班明細_新增當天()
- Next : MsgBox("存檔完成,請切換到指定日期去查看!!")
- End If
- End Sub
- Private Sub 人員_dgv_CellContentClick_1(sender As Object, e As DataGridViewCellEventArgs) Handles 人員_dgv.CellDoubleClick
- If e.RowIndex = -1 Then : Else : PA = 人員_dgv("編號", e.RowIndex).Value.ToString : PA1 = 人員_dgv("姓名", e.RowIndex).Value.ToString : End If
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- If 姓名_tbS.Text = PA1 Then : MsgBox("該人員已在班表內,無須再新增!!") : Exit Sub : End If
- Next
- For no As Integer = 1 To 20
- Dim 姓名_tbS As TextBox = CType(Me.Controls.Find("姓名_tb" + no.ToString(), True)(0), TextBox)
- If 姓名_tbS.Text <> "" Then : Else : 姓名_tbS.Text = PA1 : Exit For : End If
- Next
- End Sub
- End Class
|