hi ,
I took attandance field in my table tbl_Attandance,so i need to satisfy the condition of the attandance out of 100.Its not satisfying..Wats the problem in this code .Can anyone help me
This is my Code.
private void SaveData()
{
int attendance = 100;
if (txtsn.Text == "")
{
MessageBox.Show("Select The Student Name");
txtsn.Focus();
}
else
if (cbosem.Text == "---Select Semister---")
{
MessageBox.Show("Select The Semister");
cbosem.Focus();
}
else
if (txtdep.Text == "")
{
MessageBox.Show("Select The Department");
txtdep.Focus();
}
else
if (cbosub.Text == "---Select Subject---")
{
MessageBox.Show("Select The Subject");
cbosub.Focus();
}
else
if (txtattnd.Text == "")
{
MessageBox.Show("Enter The Attandance");
txtattnd.Focus();
}
else
if (attendance >= 80)
{
MessageBox.Show("Eligible for The Exam ");
}
else if (attendance >= 75)
{
MessageBox.Show("Not Eligible for The Exam ");
}
else if (attendance == 40){
MessageBox.Show("Shortage Of Attandance");
}
else
{
MessageBox.Show("Do You Like To Insert Into Attandance Record?", "Save", MessageBoxButtons.YesNo);
SqlConnection con = new SqlConnection(connectionString);
try
{
string Query = "insert into tbl_attendance(studentid,semid,subjectid,attend)values('" + label15.Text + "','" + label6.Text + "','" + label5.Text + "','"+txtattnd .Text +"') ";
SqlCommand cmd = new SqlCommand(Query, con);
cmd.CommandText = Query;
con.Open();
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("Successfully Inserted...");
return;
}
}
catch
{
MessageBox.Show("Error in Connection");
}
Display();
clear(); //close the connection
con.Close();
GroupBox1.Enabled = false;
}
}