Public Class 醫師下診紀錄
    ReadOnly ds1 As New DataSet
    Private Sub Set_下診明細()
        月清單_DGV.DataSource = Nothing : ds1.Clear()
        月清單_DGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        月清單_DGV.ColumnHeadersHeight = 40
        月清單_DGV.AllowUserToAddRows = False
        PA1 = 年份_cb.Text : PA2 = 月份_cb.Text : SQL_下診時間設設定()
        da.Fill(ds1) : 月清單_DGV.DataSource = ds1.Tables(0) : conn.Close()
        月清單_DGV.Columns(0).FillWeight = 70 : 月清單_DGV.Columns(1).FillWeight = 60 : 月清單_DGV.Columns(2).FillWeight = 100
    End Sub
    Private Sub 年份_下拉表單資料載入()
        SQL_考勤明細表_年份_下拉()
        年份_cb.Items.Clear()
        While (dr.Read()) : 年份_cb.Items.Add(dr("年份")) : End While
        conn.Close()
    End Sub
    Private Sub 醫師下診紀錄_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        年份_下拉表單資料載入()
        年份_cb.Text = Year(Today) : 月份_cb.SelectedIndex = Month(Today) - 1
        Set_下診明細()
    End Sub
    Private Sub 月清單_DGV_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 月清單_DGV.RowPostPaint
        For I As Integer = 0 To 月清單_DGV.Rows.Count - 1
            If 月清單_DGV.Rows(I).Cells("星期").Value.ToString = "星期六" Then : 月清單_DGV.Rows(I).DefaultCellStyle.BackColor = Color.LightPink
            ElseIf 月清單_DGV.Rows(I).Cells("星期").Value.ToString = "星期日" Then : 月清單_DGV.Rows(I).DefaultCellStyle.BackColor = Color.LightPink
            End If
        Next
    End Sub
    Private Sub 月清單_DGV_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 月清單_DGV.CellClick
        If e.RowIndex = -1 Then : Else
            If 月清單_DGV(2, e.RowIndex).Value.ToString = "" Then
                時間_dtp.Value = 月清單_DGV(0, e.RowIndex).Value.ToString
            Else
                時間_dtp.Value = 月清單_DGV(2, e.RowIndex).Value.ToString
            End If
        End If
    End Sub
    Private Sub 月份_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 月份_cb.SelectedIndexChanged
        Set_下診明細()
    End Sub
    Private Sub 修改該筆資料_bt_Click(sender As Object, e As EventArgs) Handles 修改該筆資料_bt.Click
        PA = Strings.Left(時間_dtp.Text, 10) : PA1 = Strings.Right(時間_dtp.Text, 8)
        SQL_下診時間設新增() : Set_下診明細()
    End Sub
    Private Sub 刪除該筆資料_bt_Click(sender As Object, e As EventArgs) Handles 刪除該筆資料_bt.Click
        PA = Strings.Left(時間_dtp.Text, 10)
        SQL_下診時間設刪除() : Set_下診明細()
    End Sub
End Class