In gridview as follows;
Room Course Room Course
11 AFF 21 MFA
12 REO 22
13 RM 23 EFA
14 24 ERS
when i click the edit button the roomno and course will be open in the dropdownlist.
Roomno dropdownlist1
Course dropdownlist2
protected void btnSaveRoom_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in gvClassRooms.Rows)
{
Sql = "Select Minor_Code from TB_Room_Allocation_SMS where RoomNo = "+ddlroom.SelectedItem.Text ;
roomdr = scon.ReadSql(Sql);
if (roomdr.Read())
{
MessageBox.Show("selected Room and course is already alloted. Do you want to replace or add. Press yes to replace, No to add the new course");
return;
}
else
{
string coursemessage = "Already course is alloted. Do you want to replace or add. Press yes to replace, No to add the new course";
DialogResult Courseresults;
Courseresults = MessageBox.Show(coursemessage, "Replace", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (Courseresults == System.Windows.Forms.DialogResult.Yes)
{
Sql = "insert into TB_Room_Allocation_SMS (RoomNo,Minor_Code) " +
"values('" + row.Cells[10].Text + "','" + row.Cells[11].Text + "')";
scon.ExecSql(Sql);
}
else if (Courseresults == DialogResult.No)
{
}
}
roomdr.Close();
scon.Con.Close();
}
for the room course is allocated shows the message as follows
MessageBox.Show("selected Room and course is already alloted. Do you want to replace or add. Press yes to replace, No to add the new course.
if suppose user want to press yes button select the room no and course from the dropdownlist and inserte the updated course in the database.
for that i written the code above.
is it correct?
Regards,
Narasiman P.