Click here to Skip to main content
15,917,808 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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.
Posted
Comments
ZurdoDev 10-Jul-13 7:50am    
Is it correct? I don't know. Did you try it?
nikhil-vartak 10-Jul-13 14:43pm    
Only you can tell that after executing it. If you face any error, post it here.
Aatif Ali from Bangalore 12-Jul-13 7:31am    
First execute your query..then only know is it correct or error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900