Private Sub Show_Table(ByVal Query As String, ByVal Day As String, ByVal null_d As Integer, ByVal colorS As Integer)
'Day = CInt(Day) + null_d
Dim chk_end As String = Day
Day += 6
Dim dt As New DataTable()
Dim row As Integer = 0
Dim rows As Integer = 0
Dim count As Integer = 0
Dim chk As Integer = 0
Dim column As Integer
Dim chk_head As Integer = 0
dt = dbb.Query(Query)
'If gv.Rows.Count >= 1 Then
rows = Day \ 7
If rows = 4 Then
rows = 5
End If
While row <= rows
Dim tr As New TableRow()
While column < 7
Dim tcell As New TableCell()
Dim dataTable As New Table()
Dim datarow1 As New TableRow()
Dim datarow2 As New TableRow()
Dim datarow3 As New TableRow()
Dim datacell1_1 As New TableCell() 'เวลา
Dim datacell2_1 As New TableCell() 'วันที่
Dim datacell3_1 As New TableCell() 'part
If count < 7 And chk_head = 0 Then
dataTable.BorderStyle = WebControls.BorderStyle.Solid
dataTable.BorderWidth = Unit.Pixel(3)
If count = 0 Then
datacell1_1.Text = "จันทร์"
ElseIf count = 1 Then
datacell1_1.Text = "อังคาร"
ElseIf count = 2 Then
datacell1_1.Text = "พุธ"
ElseIf count = 3 Then
datacell1_1.Text = "พฤหัสบดี"
ElseIf count = 4 Then
datacell1_1.Text = "ศุกร์"
ElseIf count = 5 Then
datacell1_1.Text = "เสาร์"
ElseIf count = 6 Then
datacell1_1.Text = "อาทิตย์"
End If
datacell1_1.HorizontalAlign = HorizontalAlign.Center
dataTable.BorderColor = Drawing.Color.LightBlue
dataTable.BackColor = Drawing.Color.LightYellow
datarow1.Cells.Add(datacell1_1)
dataTable.Rows.Add(datarow1)
dataTable.Width = Unit.Parse("100%")
dataTable.Height = Unit.Parse("20px")
dataTable.Attributes.Add("style", "table-layout:fixed")
dataTable.Font.Name = "verdana"
tcell.Controls.Add(dataTable)
tr.Cells.Add(tcell)
ElseIf count < null_d And chk = 0 And chk_head <> 0 Then
dataTable.BorderStyle = WebControls.BorderStyle.Solid
dataTable.BorderWidth = Unit.Pixel(3)
dataTable.BorderColor = Drawing.Color.LightBlue
datarow1.Cells.Add(datacell1_1)
dataTable.Rows.Add(datarow1)
dataTable.Width = Unit.Parse("100%")
dataTable.Height = Unit.Parse("100px")
dataTable.Attributes.Add("style", "table-layout:fixed")
dataTable.Font.Name = "verdana"
tcell.Controls.Add(dataTable)
tr.Cells.Add(tcell)
Else
dataTable.BorderStyle = WebControls.BorderStyle.Solid
dataTable.BorderWidth = Unit.Pixel(3)
dataTable.BorderColor = Drawing.Color.LightBlue
If count = colorS - 1 Then
dataTable.BackColor = Drawing.Color.LightGray
Else
dataTable.BackColor = Drawing.Color.LightYellow
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''
' เริ่มต้นการสร้างปุ่ม linkbutton
IB = New LinkButton
IB.Text = count + 1
IB.CommandArgument = CStr(count + 1)
AddHandler IB.Click, AddressOf ButtonClick
datacell1_1.Controls.Add(IB)
'''''''''''''''''''''''''''''''''''''''''''''''
If Chk_date(dt, count + 1) = True Then
datacell2_1.Text = Search_val(dt.Rows(0)("numbill"))
datacell3_1.Text = Search_val(dt.Rows(1)("numbill"))
Else
datacell2_1.Text = Chk_workday(dt, count + 1)
End If
datarow1.Cells.Add(datacell1_1)
datarow2.Cells.Add(datacell2_1)
datarow3.Cells.Add(datacell3_1)
datarow1.Height = 34
datarow2.Height = 33
datarow3.Height = 33
dataTable.Rows.Add(datarow1)
dataTable.Rows.Add(datarow2)
dataTable.Rows.Add(datarow3)
dataTable.Width = Unit.Parse("100%")
dataTable.Height = Unit.Parse("100px")
dataTable.Attributes.Add("style", "table-layout:fixed")
dataTable.Font.Name = "verdana"
tcell.Controls.Add(dataTable)
tr.Cells.Add(tcell)
End If
System.Math.Max(System.Threading.Interlocked.Increment(count), count - 1)
System.Math.Max(System.Threading.Interlocked.Increment(column), column - 1)
If count = 7 And chk_head = 0 Then
chk_head = 1
count = 0
End If
If count = null_d And chk_head <> 0 Then
chk = 1
count = 0
null_d = 100
End If
If count = chk_end Then
column = 10
row = rows
End If
End While
Table1.Rows.Add(tr)
Table1.Attributes.Add("style", "table-layout:fixed")
'If Table1.Rows.Count > 0 Then
' Table1.Width = (100 * (Table1.Rows(0).Cells.Count))
' Table1.Height = (100 * (Table1.Rows.Count))
'End If
column = 0
System.Math.Max(System.Threading.Interlocked.Increment(row), row - 1)
End While
'End If
End Sub
ส่วนของ event จากการคลิ้กปุ่ม Code (VB.NET)
Private Sub ButtonClick(ByVal sender As Object, ByVal e As CommandEventArgs)
Dim lb As LinkButton = CType(sender, LinkButton)
'displayObjects(lb.CommandArgument)
End Sub
Private Sub ButtonClick(ByVal sender As Object, ByVal e As CommandEventArgs)
Dim lb As LinkButton = CType(sender, LinkButton)
'displayObjects(lb.CommandArgument)
End Sub