Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim colunSum As Integer = Ds.Tables("Graduate").Rows.Count
Dim tmpMaxSeat As String = colunSum
lblMaxSeat.Text = txtRow.Text * txtColumn.Text
If (txtRow.Text = "0") Or (txtColumn.Text = "0") Then
MessageBox.Show("กรุณาป้อนข้อมูลให้ครบ !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtRow.Text = "0"
txtColumn.Text = "0"
txtRow.Focus()
Exit Sub
End If
If txtColumn.Text > 110 Then
MessageBox.Show("จำนวน แถวตอนลึกมากเกินไป กรุณากรอกใหม่", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtColumn.Focus()
Exit Sub
End If
Dim Row As Integer = txtRow.Text
Dim Column As Integer = txtColumn.Text
Dim sum As String = ""
Dim j As Integer
Dim Array1(110) As String
Dim colunSum As Integer = Ds.Tables("Graduate").Rows.Count
Dim tmpMaxSeat As String = colunSum
lblMaxSeat.Text = txtRow.Text * txtColumn.Text
If (txtRow.Text = "0") Or (txtColumn.Text = "0") Then
MessageBox.Show("กรุณาป้อนข้อมูลให้ครบ !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtRow.Text = "0"
txtColumn.Text = "0"
txtRow.Focus()
Exit Sub
End If
If txtColumn.Text > 110 Then
MessageBox.Show("จำนวน แถวตอนลึกมากเกินไป กรุณากรอกใหม่", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtColumn.Focus()
Exit Sub
End If
Dim Row As Integer = txtRow.Text
Dim Column As Integer = txtColumn.Text
Dim sum As String = ""
Dim j As Integer
Dim Array1(110) As String
Array1(1) = "A"
Array1(2) = "B"
Array1(3) = "C"
'....................
'.............
Array1(18) = "AH"
Array1(19) = "AI"
Array1(20) = "AJ"
'....................
'.............
Array1(108) = "JH"
Array1(109) = "JI"
Array1(110) = "JJ"
For Column = 1 To Column
For j = 1 To Row
sum += Array1(Column) & j & " "
Next j
sum += vbCrLf 'ขึ้นแถวใหม่เมื่อสิ้นสุดแต่ละบรรทัด
Next Column
tmpSum = CStr(sum)
btnAdd.Enabled = False
btnSave.Enabled = True
btnCancle.Enabled = True
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim sqlAdd As String = ""
Dim ComAdd As New SqlCommand
Dim i As Integer = 0
For i = 0 To lsvGraduate.Items.Count - 1
sqlAdd = "INSERT INTO Seat(SeatID,GdtID)" 'RowName
sqlAdd &= "VALUES ('" & tmpSum & "',"
sqlAdd &= "'" & Val(lsvGraduate.Items(i).SubItems(0).Text) & "')"
MsgBox(sqlAdd)
With ComAdd
.CommandType = CommandType.Text
.CommandText = sqlAdd
.Connection = Conn
.ExecuteNonQuery()
End With
Next i
MessageBox.Show("บันทึกบัณฑิตขาดซ้อม เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
btnAdd.Enabled = True
btnEdit.Enabled = True
btnSave.Enabled = False
btnCancle.Enabled = False
End Sub
For Column = 1 To Column
For j = 1 To Row
sum += Array1(Column) & j & " "
Next j
sum += vbCrLf 'ขึ้นแถวใหม่เมื่อสิ้นสุดแต่ละบรรทัด
Next Column
tmpArray = (Array1(Column - 1))
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim sqlAdd As String = ""
Dim ComAdd As New SqlCommand
Dim i As Integer = 0
MsgBox(tmpArray)
Dim row As Integer
For row = 1 To txtRow.Text
For i = 0 To lsvGraduate.Items.Count - 1
sqlAdd = "INSERT INTO Seat(SeatID,GdtID)" 'RowName
sqlAdd &= "VALUES ('" & Val(tmpArray) & row & "',"
sqlAdd &= "'" & Val(lsvGraduate.Items(i).SubItems(0).Text) & "')"
MsgBox(sqlAdd)
' With ComAdd
'.CommandType = CommandType.Text
' .CommandText = sqlAdd
'.Connection = Conn
'.ExecuteNonQuery()
'End With
Next i
Next row
End Sub