Public Sub CheckEmptyTextbox(ByVal groupbox As GroupBox)
Dim txt As Control
For Each txt In groupbox.Controls
If TypeOf txt Is TextBox Then
If txt.Text = "" Then
MsgBox("Fill Details To Proceed",MsgBoxStyle.Exclamation)
Exit For
End If
End If
Next
End Sub
----------------------------------------------------------------------------------
CheckEmptyTextbox(GroupBox1)
'Dim con As New SqlConnection("Data Source=ASHUTOSH-PC\SQLEXPRESS;Initial Catalog=Art Station Management System;Integrated Security=True")
Dim com As SqlCommand
Dim com1 As New SqlCommand
Dim str As String
Dim str1 As String
Dim i = Convert.ToInt32(stuidcmb.Text)
Dim a = Convert.ToInt32(stuagetxt.Text)
Dim gender As String = String.Empty
If stumalerd.Checked Then
gender = "Male"
ElseIf stufemalerd.Checked Then
gender = "Female"
End If
' Try
con.Open()
str = "Insert into StudentRegister values (@sstudentid,@sname,@smiddlename,@ssurname,@sdob,@ccoursename,@btbatchid,@sage,@sgender,@scontact,@saddress,@semailid,@sdatereg)"
com = New SqlCommand(str, con)
com.Parameters.AddWithValue("@sstudentid", i)
com.Parameters.AddWithValue("@sname", stufnametxt.Text)
com.Parameters.AddWithValue("@smiddlename", stumnametxt.Text)
com.Parameters.AddWithValue("@ssurname", stulnametxt.Text)
com.Parameters.AddWithValue("@sdob", DateTimePicker2.Value.Date)
com.Parameters.AddWithValue("@ccoursename", coursenamecmb.Text)
com.Parameters.AddWithValue("@btbatchid", batchidcmb.Text)
com.Parameters.AddWithValue("@sage", a)
com.Parameters.AddWithValue("@sgender", gender)
com.Parameters.AddWithValue("@scontact", stucntcttxt.Text)
com.Parameters.AddWithValue("@saddress", stuaddtxt.Text)
com.Parameters.AddWithValue("@semailid", stuemailtxt.Text)
com.Parameters.AddWithValue("@sdatereg", DateTimePicker1.Value.Date)
com.CommandText = str
com.ExecuteNonQuery()
con.Close()
con.Open()
str1 = "Insert into AttendanceStudent values (@sstudentid,@sname,@btbatchid,@ccoursename,@atsdate,'ABSENT')"
com1 = New SqlCommand(str1, con)
com1.Parameters.AddWithValue("@sstudentid", i)
com1.Parameters.AddWithValue("@sname", stufnametxt.Text)
com1.Parameters.AddWithValue("@btbatchid", batchidcmb.Text)
com1.Parameters.AddWithValue("@ccoursename", coursenamecmb.Text)
com1.Parameters.AddWithValue("@atsdate", DateTimePicker1.Value.Date)
com1.CommandText = str1
com1.ExecuteNonQuery()
con.Close()
MsgBox("Record Inserted Successfully", MsgBoxStyle.Information)
Display()
clear()
'Catch ex As Exception
'End Try