Public Class 訪談日報表
    Private Sub Set_訪談清單()
        Dim ds1 As New DataSet
        訪談紀錄_dgv.DataSource = Nothing : ds1.Clear()
        訪談紀錄_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        訪談紀錄_dgv.ColumnHeadersHeight = 25 : 訪談紀錄_dgv.AllowUserToAddRows = False : 訪談紀錄_dgv.RowTemplate.Height = 35
        PA40 = 關鍵字_tb.Text : PA41 = 分類1_cb.Text : SQL_訪談日報表()
        da.Fill(ds1) : 訪談紀錄_dgv.DataSource = ds1.Tables(0) : conn.Close()
        訪談紀錄_dgv.Columns(0).FillWeight = 15 : 訪談紀錄_dgv.Columns(1).Visible = False : 訪談紀錄_dgv.Columns(2).Visible = False
        訪談紀錄_dgv.Columns(3).FillWeight = 30 : 訪談紀錄_dgv.Columns(4).FillWeight = 30 : 訪談紀錄_dgv.Columns(5).FillWeight = 30
        訪談紀錄_dgv.Columns(6).FillWeight = 50 : 訪談紀錄_dgv.Columns(7).FillWeight = 50 : 訪談紀錄_dgv.Columns(8).FillWeight = 50
        訪談紀錄_dgv.Columns(9).FillWeight = 160
        訪談紀錄_dgv.Columns(0).ReadOnly = True : 訪談紀錄_dgv.Columns(3).ReadOnly = True : 訪談紀錄_dgv.Columns(4).ReadOnly = True
        訪談紀錄_dgv.Columns(5).ReadOnly = True : 訪談紀錄_dgv.Columns(6).ReadOnly = True : 訪談紀錄_dgv.Columns(7).ReadOnly = True
        訪談紀錄_dgv.EditMode = DataGridViewEditMode.EditOnEnter
        For i As Integer = 0 To 訪談紀錄_dgv.Rows.Count - 1 : 訪談紀錄_dgv.Rows(i).Cells(0).Value = i + 1 : Next
    End Sub
    Private Sub 確認新增_bt_MouseEnter(sender As Object, e As EventArgs) Handles 確認新增_bt.MouseEnter
        ToolTip1.SetToolTip(Me.確認新增_bt, "資料存檔")
    End Sub
    Private Sub 列印資料表_bt_MouseEnter(sender As Object, e As EventArgs) Handles 列印資料表_bt.MouseEnter
        ToolTip1.SetToolTip(Me.列印資料表_bt, "列印訪談日報表")
    End Sub
    Private Sub 訪談日報表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = YS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
    End Sub
    Private Sub 訪談日報表_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        SQL_客戶類別() : 分類1_cb.Items.Clear() : 分類1_cb.Items.Add("") : While (dr.Read()) : 分類1_cb.Items.Add(dr("類別")) : End While : conn.Close()
        Set_訪談清單()
    End Sub
    Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
        timeNow = 0 : YS_ERP_SYS.Timer1.Enabled = False : YS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
        timeNow = 0 : YS_ERP_SYS.Timer1.Enabled = False : YS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 訪談紀錄_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 訪談紀錄_dgv.RowPostPaint
        Dim linePen As New Pen(Color.Blue, 1.5)
        If e.RowIndex = 訪談紀錄_dgv.Rows.Count - 1 Then
            Exit Sub
        Else
            If 分類1_cb.Text = "" Then
                If 訪談紀錄_dgv("日期", e.RowIndex).Value.ToString <> 訪談紀錄_dgv("日期", e.RowIndex + 1).Value.ToString Then
                    Dim startX As Integer = IIf(訪談紀錄_dgv.RowHeadersVisible, 訪談紀錄_dgv.RowHeadersWidth, 0)
                    Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + 訪談紀錄_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 訪談紀錄_dgv.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
                    Exit Sub
                End If
            Else
                If 訪談紀錄_dgv("客戶名稱", e.RowIndex).Value.ToString <> 訪談紀錄_dgv("客戶名稱", e.RowIndex + 1).Value.ToString Then
                    Dim startX As Integer = IIf(訪談紀錄_dgv.RowHeadersVisible, 訪談紀錄_dgv.RowHeadersWidth, 0)
                    Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + 訪談紀錄_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 訪談紀錄_dgv.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
                    Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 一日_bt_Click(sender As Object, e As EventArgs) Handles 一日_bt.Click
        開始日期_dtp.Value = 結束日期_dtp.Value : Set_訪談清單()
    End Sub
    Private Sub 一周_bt_Click(sender As Object, e As EventArgs) Handles 一周_bt.Click
        開始日期_dtp.Value = 結束日期_dtp.Value.AddDays(-6) : Set_訪談清單()
    End Sub
    Private Sub 一月_bt_Click(sender As Object, e As EventArgs) Handles 一月_bt.Click
        開始日期_dtp.Value = 結束日期_dtp.Value.AddDays(-30) : Set_訪談清單()
    End Sub
    Private Sub 一年_bt_Click(sender As Object, e As EventArgs) Handles 一年_bt.Click
        開始日期_dtp.Value = 結束日期_dtp.Value.AddDays(-364) : Set_訪談清單()
    End Sub
    Private Sub 關鍵字_tb_KeyDown(sender As Object, e As KeyEventArgs) Handles 關鍵字_tb.KeyDown
        If e.KeyCode = Keys.Enter Then : Set_訪談清單() : End If
    End Sub
    Private Sub 分類1_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 分類1_cb.SelectedIndexChanged
        Set_訪談清單()
    End Sub
    Private Sub 查詢_bt_Click(sender As Object, e As EventArgs) Handles 查詢_bt.Click
        Set_訪談清單()
    End Sub
    Private Sub 確認新增_bt_Click(sender As Object, e As EventArgs) Handles 確認新增_bt.Click
        For I As Integer = 0 To 訪談紀錄_dgv.Rows.Count - 1
            PA1 = 訪談紀錄_dgv.Rows(I).Cells("流水號").Value.ToString : PA2 = 訪談紀錄_dgv.Rows(I).Cells("訪談內容").Value.ToString
            PA3 = 訪談紀錄_dgv.Rows(I).Cells("內容追蹤").Value.ToString : PA4 = 訪談紀錄_dgv.Rows(I).Cells("地點").Value.ToString : SQL_訪談表修改()
        Next : MsgBox("存檔完成!!")
    End Sub
    Private Sub 列印資料表_bt_Click(sender As Object, e As EventArgs) Handles 列印資料表_bt.Click
        MsgBox("功能開發中!!")
    End Sub
End Class