From a755e00cb6218048611c074882f27047d8ec8ce4 Mon Sep 17 00:00:00 2001 From: Dimuthu Date: Fri, 2 Oct 2020 23:26:37 +0530 Subject: [PATCH] Update rooms for sessions form --- .../Forms/SubForms/RoomsforSessionSubForm.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs index 75749bd..f9dc77a 100644 --- a/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs +++ b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs @@ -125,6 +125,19 @@ private void btnInsert_Click(object sender, EventArgs e) { RoomsforSessionModel saveObj = saveResult.Data; MessageBox.Show("Rooms With Session : " + saveObj.Room + "-" + saveObj.SessionId + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + + //Added by Dimuthu + int intSelectSessCode = Int32.Parse(comboBox1.SelectedItem.ToString()); + string strSelectRoom = (string)selected; + using (var db = new TimeTableDbContext()) + { + var tm = db.Sessions.Where(f => f.SessionCode == intSelectSessCode).ToList(); + tm.ForEach(a => { + a.Room = strSelectRoom; + }); + db.SaveChanges(); + } + initForm(); } else @@ -170,6 +183,19 @@ private void btnDelete_Click(object sender, EventArgs e) { RoomsforSessionModel deleteObj = deleteResult.Data; MessageBox.Show("Room " + (string)selected + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + + //Added by Dimuthu + int intSelectSessCode = Int32.Parse(comboBox1.SelectedItem.ToString()); + string strSelectRoom = (string)selected; + using (var db = new TimeTableDbContext()) + { + var tm = db.Sessions.Where(f => f.SessionCode == intSelectSessCode).ToList(); + tm.ForEach(a => { + a.Room = ""; + }); + db.SaveChanges(); + } + initForm(); } else