Skip to content

Commit

Permalink
Spring 2 - AnjaniWelagedara
Browse files Browse the repository at this point in the history
  • Loading branch information
KusalPriyanka authored Oct 2, 2020
2 parents 8b37093 + 8437d3a commit ff17dd8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 32 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 17 additions & 27 deletions TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void initForm()
listBox1.Items.Clear();
listBox2.Items.Clear();
comboBox1.Items.Clear();
ActionResult SesResult = formCtrl._getFormData(typeof(SessionsSubFormModel), "Sessions");
ActionResult SesResult = formCtrl._getFormData(typeof(SessionsSubFormModel), "Session");
if (SesResult.State)
{
List<SessionsSubFormModel> SesList = SesResult.Data;
Expand All @@ -58,12 +58,12 @@ private void updateLecturer()
listBox1.Items.Clear();
listBox2.Items.Clear();

ActionResult roomsWithLecResult = formCtrl._getFormData(typeof(RoomsforSessionModel), "RoomsforaLecturer");
if (roomsWithLecResult.State)
ActionResult roomsWithSesResult = formCtrl._getFormData(typeof(RoomsforSessionModel), "RoomsforSession");
if (roomsWithSesResult.State)
{

List<RoomsforSessionModel> RoomsWithLecModalList = roomsWithLecResult.Data;
var SelectedRWTList = RoomsWithLecModalList.Where(RWT => RWT.SessionId.ToString() == comboBox1.SelectedItem.ToString()).ToList();
List<RoomsforSessionModel> RoomsWithSesModalList = roomsWithSesResult.Data;
var SelectedRWTList = RoomsWithSesModalList.Where(RWT => RWT.SessionId.ToString() == comboBox1.SelectedItem.ToString()).ToList();
SelectedRWTList.ForEach(RWT =>
listBox2.Items.Add(RWT.Room)
);
Expand Down Expand Up @@ -94,8 +94,8 @@ private void updateLecturer()
});
}

dataGridView1.DataSource = roomsWithLecResult.Data;
dataGridView1.Columns[1].HeaderCell.Value = "Lecturer";
dataGridView1.DataSource = roomsWithSesResult.Data;
dataGridView1.Columns[1].HeaderCell.Value = "Seesion Id";
dataGridView1.Columns[2].HeaderCell.Value = "Room";
dataGridView1.Columns[0].Visible = false;
dataGridView1.RowHeadersVisible = false;
Expand All @@ -110,7 +110,7 @@ private void btnInsert_Click(object sender, EventArgs e)

if (selected is null)
{
MessageBox.Show("Please Select Lecturer", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
Expand All @@ -124,7 +124,7 @@ private void btnInsert_Click(object sender, EventArgs e)
if (saveResult.State)
{
RoomsforSessionModel saveObj = saveResult.Data;
MessageBox.Show("Rooms With Lecturer : " + saveObj.Room + "-" + saveObj.SessionId + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("Rooms With Session : " + saveObj.Room + "-" + saveObj.SessionId + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
initForm();
}
else
Expand All @@ -138,7 +138,7 @@ private void btnInsert_Click(object sender, EventArgs e)

private void btnDelete_Click(object sender, EventArgs e)
{
/*var selected = listBox2.SelectedItem;
var selected = listBox2.SelectedItem;


if (selected is null)
Expand All @@ -149,22 +149,22 @@ private void btnDelete_Click(object sender, EventArgs e)
{
int id = 0;

ActionResult roomsWithLecResult = formCtrl._getFormData(typeof(RoomsforSessionModel), "RoomsforaLecturer");
if (roomsWithLecResult.State)
ActionResult roomsWithSesResult = formCtrl._getFormData(typeof(RoomsforSessionModel), "RoomsforSession");
if (roomsWithSesResult.State)
{

foreach (RoomsforSessionModel room in roomsWithLecResult.Data)
foreach (RoomsforSessionModel room in roomsWithSesResult.Data)
{
if (room.Room == (string)selected && room.Lecturer == comboBox1.SelectedItem.ToString())
if (room.Room == (string)selected && room.SessionId.ToString() == comboBox1.SelectedItem.ToString())
{
id = room.RoomWithLectureID;
id = room.RoomWithSessionID;
}
}

}


ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforSessionModel() { RoomWithLectureID = id });
ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforSessionModel() { RoomWithSessionID = id });

if (deleteResult.State)
{
Expand All @@ -176,7 +176,7 @@ private void btnDelete_Click(object sender, EventArgs e)
{
MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}*/
}
}


Expand All @@ -185,15 +185,5 @@ private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
selectedSec = comboBox1.SelectedIndex;
updateLecturer();
}

private void label1_Click(object sender, EventArgs e)
{

}

private void lblCaption_Click(object sender, EventArgs e)
{

}
}
}
3 changes: 0 additions & 3 deletions TimeTable_App/Global/TimeTableDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ public TimeTableDbContext() : base("DBCON")
public DbSet<RoomsForASubjectModel> RoomsForASubject { get; set; }
public DbSet<RoomsforaLecturerModel> RoomsforaLecturer { get; set; }
public DbSet<RoomsforaSubGroupModel> RoomsforaSubGroup { get; set; }
public DbSet<RoomsforTimeNotReservedModel> RoomsforTimeNotReserved { get; set; }
public DbSet<ConsectiveSessionsModel> ConsectiveSessions { get; set; }
public DbSet<RoomsforConsectiveSessionModel> RoomsforConsectiveSession { get; set; }
public DbSet<RoomsforSessionModel> RoomsforSession { get; set; }
public DbSet<SessionsSubFormModel> Sessions { get; set; }
}
}

0 comments on commit ff17dd8

Please sign in to comment.