Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click, Button3.Click
Dim dt As New DataTable()
Image1.Visible = True
Dim i As Integer = 0
dt = dbm.query("SELECT * from time_log_track ")
Gv.DataSource = dt
Gv.DataBind()
End Sub
Private Sub ProgressBar1_RunTask(ByVal sender As Object, ByVal e As EO.Web.ProgressTaskEventArgs) Handles ProgressBar1.RunTask
Dim datein As String = Replace(CP_In.PostedDate, "/", " ")
Dim dateout As String = Replace(CP_Out.PostedDate, "/", " ")
Dim dateinarray() As String = Split(datein)
Dim dateoutarray() As String = Split(dateout)
If dateinarray(0).Length = 1 Then
dateinarray(0) = "0" + dateinarray(0)
End If
If dateinarray(1).Length = 1 Then
dateinarray(1) = "0" + dateinarray(1)
End If
If dateinarray(2).Length = 4 Then
dateinarray(2) = dateinarray(2).Substring(2, 2)
End If
If dateoutarray(0).Length = 1 Then
dateoutarray(0) = "0" + dateoutarray(0)
End If
If dateoutarray(1).Length = 1 Then
dateoutarray(1) = "0" + dateoutarray(1)
End If
If dateoutarray(2).Length = 4 Then
dateoutarray(2) = dateoutarray(2).Substring(2, 2)
End If
Dim date_start As String = dateinarray(2) + "/" + dateinarray(1) + "/" + dateinarray(0)
Dim date_end As String = dateoutarray(2) + "/" + dateoutarray(1) + "/" + dateoutarray(0)
Dim dt As New DataTable()
Dim txt_type As String
If CK_B_date.Checked = False And CK_B_time.Checked = False Then
txt_type = "00"
ElseIf CK_B_date.Checked = False And CK_B_time.Checked = True Then
txt_type = "01"
ElseIf CK_B_date.Checked = True And CK_B_time.Checked = False Then
txt_type = "10"
ElseIf CK_B_date.Checked = True And CK_B_time.Checked = True Then
txt_type = "11"
End If
Dim time_in As String = DDL_In_H.Text + ":" + DDL_In_M.Text
Dim time_out As String = DDL_Out_H.Text + ":" + DDL_Out_M.Text
Dim Fill As String
Dim where As String
Dim condition As String
Dim Table As String
Dim Group As String
Dim where_time As String
Dim Fill_log As String
Dim condition_log As String
Dim where_log As String
Dim Table_log As String
Dim Group_log As String
Dim where_time_log As String
Dim where_part As String
Dim Mode As String
If RD_present.Checked = True Then
Fill = "time.DATA_ID"
where = "time.time"
condition = "time.Part_id"
Table = "part,time"
Group = "time.DATA_ID"
Fill_log = "time_log.DATA_ID"
where_log = "time_log.time"
condition_log = "time_log.Part_id"
Table_log = "part,time_log"
Group_log = "time_log.DATA_ID"
Mode = "present"
where_part = "part."
where_time = "time."
where_time_log = "time_log."
Else
Fill = "time_log_track.DATA_ID"
where = "time_log_track.time"
condition = "time_log_track.Part_id"
Table = "part_track,time_log_track"
Group = "time_log_track.DATA_ID"
Fill_log = "time_log_track.DATA_ID"
where_log = "time_log_track.time"
condition_log = "time_log_track.Part_id"
Table_log = "part_track,time_log_track"
Group_log = "time_log_track.DATA_ID"
Mode = "back"
where_part = "part_track."
where_time = "time_log_track."
where_time_log = "time_log_track."
End If
If txt_type = "00" Then 'เลือกวันที่และเวลา
dt = UnNo_DateTimeNo_Time(DL_Part_name.Text.Length, TB_Product.Text.Length, TB_DCM.Text.Length, DL_Part_name.Text, TB_Product.Text, TB_DCM.Text, DL_Size.Text, TB_Status.Text.Length, TB_Status.Text, TB_Eval.Text.Length, TB_Eval.Text, DL_Phase.Text, date_start, date_end, time_in, time_out, Fill, Table, Group, Fill_log, Table_log, Group_log, where, condition, where_log, condition_log, where_part, where_time, where_time_log)
ElseIf txt_type = "01" Then 'ไม่เอาเวลา
dt = No_Time(DL_Part_name.Text.Length, TB_Product.Text.Length, TB_DCM.Text.Length, DL_Part_name.Text, TB_Product.Text, TB_DCM.Text, DL_Size.Text, TB_Status.Text.Length, TB_Status.Text, TB_Eval.Text.Length, TB_Eval.Text, DL_Phase.Text, date_start, date_end, time_in, time_out, Fill, Table, Group, Fill_log, Table_log, Group_log, where, condition, where_log, condition_log, where_part, where_time, where_time_log)
ElseIf txt_type = "10" Then 'ไม่เอาวันที่
dt = No_Date(DL_Part_name.Text.Length, TB_Product.Text.Length, TB_DCM.Text.Length, DL_Part_name.Text, TB_Product.Text, TB_DCM.Text, DL_Size.Text, TB_Status.Text.Length, TB_Status.Text, TB_Eval.Text.Length, TB_Eval.Text, DL_Phase.Text, date_start, date_end, time_in, time_out, Fill, Table, Group, Fill_log, Table_log, Group_log, where, condition, where_log, condition_log, where_part, where_time, where_time_log)
ElseIf txt_type = "11" Then 'ไม่เอาวันที่และเวลา
dt = No_DateTime(DL_Part_name.Text.Length, TB_Product.Text.Length, TB_DCM.Text.Length, DL_Part_name.Text, TB_Product.Text, TB_DCM.Text, DL_Size.Text, TB_Status.Text.Length, TB_Status.Text, TB_Eval.Text.Length, TB_Eval.Text, DL_Phase.Text, date_start, date_end, time_in, time_out, Fill, Table, Group, Fill_log, Table_log, Group_log, where, condition, where_log, condition_log, where_part, where_time, where_time_log)
End If
Dim gv As New GridView()
gv.DataSource = dt
gv.DataBind()
Dim i As Integer = 0
Dim da_track As New MySqlDataAdapter
Dim da_track_log As New MySqlDataAdapter
Dim dt_track As New DataTable
If Mode = "present" Then
While i < gv.Rows.Count
Dim dt_time As New DataTable()
da_track = New MySqlDataAdapter("SELECT part.Part_ID,time.DATA_ID,part.Part_Name,part.Product_Name,part.DCM,part.Part_Status,part.Eval_Name,part.Size,time.Time_Date,time.Time,time.Time_Status FROM part,time WHERE part.Part_ID = time.Part_id AND time.data_id ='" + gv.Rows(i).Cells(0).Text + "' ORDER BY part.part_name = 'BVCM',part.part_name='TVCM',part.part_name='MOTORBASE',part.part_name='TOP_COVER',part.part_name='MEDIA',part.part_name='HSA',time.DATA_ID,SUBSTRING(time.Time_Date,7,2),SUBSTRING(time.Time_Date,4,2),SUBSTRING(time.Time_Date,1,2),time.Time ", Conn)
da_track.Fill(dt_time)
If dt_time.Rows.Count = 0 Then
da_track_log = New MySqlDataAdapter("SELECT part.Part_ID,time_log.DATA_ID,part.Part_Name,part.Product_Name,part.DCM,part.Part_Status,part.Eval_Name,part.Size,time_log.Time_Date,time_log.Time,time_log.Time_Status FROM part,time_log WHERE part.Part_ID = time_log.Part_id AND time_log.data_id ='" + gv.Rows(i).Cells(0).Text + "' ORDER BY part.part_name = 'BVCM',part.part_name='TVCM',part.part_name='MOTORBASE',part.part_name='TOP_COVER',part.part_name='MEDIA',part.part_name='HSA',time_log.DATA_ID,SUBSTRING(time_log.Time_Date,7,2),SUBSTRING(time_log.Time_Date,4,2),SUBSTRING(time_log.Time_Date,1,2),time_log.Time ", Conn)
da_track_log.Fill(dt_track)
Else
da_track.Fill(dt_track)
End If
i = i + 1
End While
Else
Dim count As Integer = 0
Dim values As Integer = gv.Rows.Count / 100
Dim chk_count As Integer = 0
While i < gv.Rows.Count
Dim dt_time As New DataTable()
da_track = New MySqlDataAdapter("SELECT part_track.Part_ID,time_log_track.DATA_ID,part_track.Part_Name,part_track.Product_Name,part_track.DCM,part_track.Part_Status,part_track.Eval_Name,part_track.Size,time_log_track.Time_Date,time_log_track.Time,time_log_track.Time_Status FROM part_track,time_log_track WHERE part_track.Part_ID = time_log_track.Part_id AND time_log_track.data_id ='" + gv.Rows(i).Cells(0).Text + "' ORDER BY part_track.part_name = 'BVCM',part_track.part_name='TVCM',part_track.part_name='MOTORBASE',part_track.part_name='TOP_COVER',part_track.part_name='MEDIA',part_track.part_name='HSA',time_log_track.DATA_ID,SUBSTRING(time_log_track.Time_Date,7,2),SUBSTRING(time_log_track.Time_Date,4,2),SUBSTRING(time_log_track.Time_Date,1,2),time_log_track.Time ", Conn)
da_track.Fill(dt_time)
If dt_time.Rows.Count = 0 Then
da_track_log = New MySqlDataAdapter("SELECT part_track.Part_ID,time_log_track.DATA_ID,part_track.Part_Name,part_track.Product_Name,part_track.DCM,part_track.Part_Status,part_track.Eval_Name,part_track.Size,time_log_track.Time_Date,time_log_track.Time,time_log_track.Time_Status FROM part_track,time_log_track WHERE part_track.Part_ID = time_log_track.Part_id AND time_log_track.data_id ='" + gv.Rows(i).Cells(0).Text + "' ORDER BY part_track.part_name = 'BVCM',part_track.part_name='TVCM',part_track.part_name='MOTORBASE',part_track.part_name='TOP_COVER',part_track.part_name='MEDIA',part_track.part_name='HSA',time_log_track.DATA_ID,SUBSTRING(time_log_track.Time_Date,7,2),SUBSTRING(time_log_track.Time_Date,4,2),SUBSTRING(time_log_track.Time_Date,1,2),time_log_track.Time ", Conn)
da_track_log.Fill(dt_track)
Else
da_track.Fill(dt_track)
End If
i = i + 1
If chk_count <= i Then
chk_count = chk_count + values
e.UpdateProgress(count)
count = count + 1
End If
End While
e.UpdateProgress(100)
Response.Write("Test")
End If
'''''''''''''''''''''''''''''''''''''''''
GV_Index.DataSource = dt_track
GV_Index.DataBind()
Clear_Gv()
Label1.Text = GV_Index.Rows.Count
End Sub