diff --git a/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.Designer.cs new file mode 100644 index 0000000..717532e --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.Designer.cs @@ -0,0 +1,205 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class RoomsForASubjectSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnInsert = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.comboTag = new System.Windows.Forms.ComboBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.btnDelete = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.comboSub = new System.Windows.Forms.ComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(397, 149); + this.btnInsert.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(105, 26); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = ">>"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(346, 10); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(233, 30); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Rooms With Subject"; + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 15; + this.listBox1.Location = new System.Drawing.Point(46, 131); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(313, 139); + this.listBox1.TabIndex = 3; + // + // comboTag + // + this.comboTag.FormattingEnabled = true; + this.comboTag.Location = new System.Drawing.Point(46, 57); + this.comboTag.Name = "comboTag"; + this.comboTag.Size = new System.Drawing.Size(313, 23); + this.comboTag.TabIndex = 10; + this.comboTag.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // listBox2 + // + this.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 15; + this.listBox2.Location = new System.Drawing.Point(535, 131); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(313, 139); + this.listBox2.TabIndex = 3; + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(397, 192); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(105, 26); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "<<"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + this.dataGridView1.AllowUserToResizeRows = false; + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.Location = new System.Drawing.Point(46, 293); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(802, 141); + this.dataGridView1.TabIndex = 9; + this.dataGridView1.Text = "dataGridView1"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(141, 96); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 21); + this.label1.TabIndex = 2; + this.label1.Text = "All Rooms"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(639, 96); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(143, 21); + this.label2.TabIndex = 2; + this.label2.Text = "Allocated Rooms"; + // + // comboSub + // + this.comboSub.FormattingEnabled = true; + this.comboSub.Location = new System.Drawing.Point(535, 57); + this.comboSub.Name = "comboSub"; + this.comboSub.Size = new System.Drawing.Size(313, 23); + this.comboSub.TabIndex = 10; + this.comboSub.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); + // + // RoomsForASubjectSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.comboSub); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.listBox2); + this.Controls.Add(this.comboTag); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnInsert); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "RoomsForASubjectSubForm"; + this.Size = new System.Drawing.Size(890, 450); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ListBox listBox2; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox comboTag; + private System.Windows.Forms.ComboBox comboSub; + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.cs new file mode 100644 index 0000000..665da85 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.cs @@ -0,0 +1,213 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using TimeTable_App.Global; +using TimeTable_App.Models; +using System.Linq; + +namespace TimeTable_App.Forms.SubForms +{ + public partial class RoomsForASubjectSubForm : UserControl + { + private static RoomsForASubjectSubForm _instance; + private FormCtrl formCtrl; + private int selectedTag = 0; + private int selectedSubject = 0; + + public static RoomsForASubjectSubForm Instance + { + get + { + if (_instance == null) _instance = new RoomsForASubjectSubForm(); + return _instance; + } + } + public RoomsForASubjectSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + + + private void initForm() + { + + int count = 0; + listBox1.Items.Clear(); + listBox2.Items.Clear(); + comboSub.Items.Clear(); + comboTag.Items.Clear(); + ActionResult tagsResult = formCtrl._getFormData(typeof(TagsModel), "Tags"); + if (tagsResult.State) + { + List tagsList = tagsResult.Data; + tagsList.ForEach(tag => comboTag.Items.Insert(count, tag.Tag)); + count++; + } + + count = 0; + ActionResult subjectResult = formCtrl._getFormData(typeof(SubjectsFormModel), "Subjects"); + if (subjectResult.State) + { + List subjectList = subjectResult.Data; + subjectList.ForEach(sub => comboSub.Items.Insert(count, sub.SubjectName)); + count++; + } + comboTag.SelectedIndex = selectedTag; + + + } + + private void updateTag() + { + listBox1.Items.Clear(); + listBox2.Items.Clear(); + + ActionResult roomsWithSubResult = formCtrl._getFormData(typeof(RoomsForASubjectModel), "RoomsForASubject"); + if (roomsWithSubResult.State) + { + + List roomsWithSubResultList = roomsWithSubResult.Data; + var SelectedRWSList = roomsWithSubResultList.Where(RWS => RWS.Subject == comboSub.SelectedItem.ToString() && RWS.Tag == comboTag.SelectedItem.ToString()).ToList(); + SelectedRWSList.ForEach(RWS => + listBox2.Items.Add(RWS.Room) + ); + + ActionResult roomsResult = formCtrl._getFormData(typeof(RoomsModel), "Rooms"); + if (roomsResult.State) + { + + List roomsList = roomsResult.Data; + + + for (int i = roomsList.Count - 1; i >= 0; --i) + { + + RoomsModel room = roomsList[i]; + SelectedRWSList.ForEach(selected => + { + if (selected.Room == room.RoomNumber) + { + roomsList.RemoveAt(i); + } + }); + } + + roomsList.ForEach(room => + { + listBox1.Items.Add(room.RoomNumber); + }); + } + + dataGridView1.DataSource = roomsWithSubResult.Data; + dataGridView1.Columns[1].HeaderCell.Value = "Tag"; + dataGridView1.Columns[2].HeaderCell.Value = "Subject"; + dataGridView1.Columns[3].HeaderCell.Value = "Room"; + dataGridView1.Columns[0].Visible = false; + dataGridView1.RowHeadersVisible = false; + + } + } + + private void btnInsert_Click(object sender, EventArgs e) + { + var selected = listBox1.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + ActionResult saveResult = formCtrl._saveFormData(new RoomsForASubjectModel() + { + Room = (string)selected, + Tag = comboTag.SelectedItem.ToString(), + Subject = comboSub.SelectedItem.ToString(), + + + }); + + if (saveResult.State) + { + RoomsForASubjectModel saveObj = saveResult.Data; + MessageBox.Show("Rooms With Subject : " + saveObj.Room + "-" + saveObj.Subject + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + var selected = listBox2.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + int id = 0; + + ActionResult roomsWithSubResult = formCtrl._getFormData(typeof(RoomsForASubjectModel), "RoomsForASubject"); + if (roomsWithSubResult.State) + { + + foreach (RoomsForASubjectModel room in roomsWithSubResult.Data) + { + if (room.Room == (string)selected && room.Subject == comboSub.SelectedItem.ToString() && room.Tag == comboTag.SelectedItem.ToString()) + { + id = room.RoomsForASubjectModelID; + } + } + + } + + + ActionResult deleteResult = formCtrl._deleteFormData(new RoomsForASubjectModel() { RoomsForASubjectModelID = id }); + + if (deleteResult.State) + { + RoomsForASubjectModel deleteObj = deleteResult.Data; + MessageBox.Show("Room " + (string)selected + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + comboSub.SelectedIndex = selectedSubject; + selectedTag = comboTag.SelectedIndex; + selectedSubject = comboSub.SelectedIndex; + updateTag(); + } + + private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) + { + comboSub.SelectedIndex = selectedTag; + selectedTag = comboTag.SelectedIndex; + selectedSubject = comboSub.SelectedIndex; + updateTag(); + } + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.resx b/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsForASubjectSubForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.Designer.cs new file mode 100644 index 0000000..ed01271 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.Designer.cs @@ -0,0 +1,193 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class RoomsWithTagsSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnInsert = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.btnDelete = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(397, 149); + this.btnInsert.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(105, 26); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = ">>"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(346, 10); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(204, 30); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Rooms With Tags"; + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 15; + this.listBox1.Location = new System.Drawing.Point(46, 131); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(313, 139); + this.listBox1.TabIndex = 3; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(46, 57); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(313, 23); + this.comboBox1.TabIndex = 10; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // listBox2 + // + this.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 15; + this.listBox2.Location = new System.Drawing.Point(535, 131); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(313, 139); + this.listBox2.TabIndex = 3; + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(397, 192); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(105, 26); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "<<"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + this.dataGridView1.AllowUserToResizeRows = false; + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle4; + this.dataGridView1.Location = new System.Drawing.Point(46, 293); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(802, 141); + this.dataGridView1.TabIndex = 9; + this.dataGridView1.Text = "dataGridView1"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(141, 96); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 21); + this.label1.TabIndex = 2; + this.label1.Text = "All Rooms"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(639, 96); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(143, 21); + this.label2.TabIndex = 2; + this.label2.Text = "Allocated Rooms"; + // + // RoomsWithTagsSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.listBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnInsert); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "RoomsWithTagsSubForm"; + this.Size = new System.Drawing.Size(890, 450); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ListBox listBox2; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.cs new file mode 100644 index 0000000..948760f --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.cs @@ -0,0 +1,187 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using TimeTable_App.Global; +using TimeTable_App.Models; +using System.Linq; + +namespace TimeTable_App.Forms.SubForms +{ + public partial class RoomsWithTagsSubForm : UserControl + { + private static RoomsWithTagsSubForm _instance; + private FormCtrl formCtrl; + private int selectedTag = 0; + + public static RoomsWithTagsSubForm Instance + { + get + { + if (_instance == null) _instance = new RoomsWithTagsSubForm(); + return _instance; + } + } + + public RoomsWithTagsSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + + + private void initForm() + { + + int count = 0; + listBox1.Items.Clear(); + listBox2.Items.Clear(); + comboBox1.Items.Clear(); + ActionResult tagsResult = formCtrl._getFormData(typeof(TagsModel), "Tags"); + if (tagsResult.State) + { + List tagsList = tagsResult.Data; + tagsList.ForEach(tag => comboBox1.Items.Insert(count, tag.Tag)); + count++; + } + comboBox1.SelectedIndex = selectedTag; + + } + + private void updateTag() + { + listBox1.Items.Clear(); + listBox2.Items.Clear(); + + ActionResult roomsWithTagsResult = formCtrl._getFormData(typeof(RoomsWithTagsModal), "RoomsWithTags"); + if (roomsWithTagsResult.State) + { + + List RoomsWithTagsModalList = roomsWithTagsResult.Data; + var SelectedRWTList = RoomsWithTagsModalList.Where(RWT => RWT.Tag == comboBox1.SelectedItem.ToString()).ToList(); + SelectedRWTList.ForEach(RWT => + listBox2.Items.Add(RWT.Room) + ); + + ActionResult roomsResult = formCtrl._getFormData(typeof(RoomsModel), "Rooms"); + if (roomsResult.State) + { + + List roomsList = roomsResult.Data; + + + for (int i = roomsList.Count - 1; i >= 0; --i) + { + + RoomsModel room = roomsList[i]; + SelectedRWTList.ForEach(selected => + { + if (selected.Room == room.RoomNumber) + { + roomsList.RemoveAt(i); + } + }); + } + + roomsList.ForEach(room => + { + listBox1.Items.Add(room.RoomNumber); + }); + } + + dataGridView1.DataSource = roomsWithTagsResult.Data; + dataGridView1.Columns[1].HeaderCell.Value = "Tag"; + dataGridView1.Columns[2].HeaderCell.Value = "Room"; + dataGridView1.Columns[0].Visible = false; + dataGridView1.RowHeadersVisible = false; + + } + } + + private void btnInsert_Click(object sender, EventArgs e) + { + var selected = listBox1.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Tag", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + ActionResult saveResult = formCtrl._saveFormData(new RoomsWithTagsModal() + { + Room = (string) selected, + Tag = comboBox1.SelectedItem.ToString(), + + }); + + if (saveResult.State) + { + RoomsWithTagsModal saveObj = saveResult.Data; + MessageBox.Show("Rooms With Tag : " + saveObj.Room + "-" +saveObj.Tag + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + var selected = listBox2.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + int id = 0; + + ActionResult roomsWithTagsResult = formCtrl._getFormData(typeof(RoomsWithTagsModal), "RoomsWithTags"); + if (roomsWithTagsResult.State) + { + + foreach (RoomsWithTagsModal room in roomsWithTagsResult.Data) { + if (room.Room == (string)selected && room.Tag == comboBox1.SelectedItem.ToString()) { + id = room.RoomsWithTagsID; + } + } + + } + + + ActionResult deleteResult = formCtrl._deleteFormData(new RoomsWithTagsModal() { RoomsWithTagsID = id }); + + if (deleteResult.State) + { + RoomsWithTagsModal deleteObj = deleteResult.Data; + MessageBox.Show("Room " + (string)selected + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + selectedTag = comboBox1.SelectedIndex; + updateTag(); + } + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.resx b/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsWithTagsSubForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.Designer.cs new file mode 100644 index 0000000..7e4e273 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.Designer.cs @@ -0,0 +1,192 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class RoomsforConsectiveSessionSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnInsert = new System.Windows.Forms.Button(); + this.btnUpdate = new System.Windows.Forms.Button(); + this.btnDelete = new System.Windows.Forms.Button(); + this.btnCansel = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.comboYear = new System.Windows.Forms.ComboBox(); + this.comboSemester = new System.Windows.Forms.ComboBox(); + this.comboRoom = new System.Windows.Forms.ComboBox(); + this.gridGroupDetails = new System.Windows.Forms.DataGridView(); + this.comboConsective = new System.Windows.Forms.ComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.gridGroupDetails)).BeginInit(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(763, 79); + this.btnInsert.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(105, 26); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = "Insert"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // btnUpdate + // + this.btnUpdate.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnUpdate.Location = new System.Drawing.Point(763, 118); + this.btnUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnUpdate.Name = "btnUpdate"; + this.btnUpdate.Size = new System.Drawing.Size(105, 26); + this.btnUpdate.TabIndex = 0; + this.btnUpdate.Text = "Update"; + this.btnUpdate.UseVisualStyleBackColor = true; + this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(763, 158); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(105, 26); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "Delete"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // btnCansel + // + this.btnCansel.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnCansel.Location = new System.Drawing.Point(763, 198); + this.btnCansel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnCansel.Name = "btnCansel"; + this.btnCansel.Size = new System.Drawing.Size(105, 26); + this.btnCansel.TabIndex = 0; + this.btnCansel.Text = "Cancel"; + this.btnCansel.UseVisualStyleBackColor = true; + this.btnCansel.Click += new System.EventHandler(this.btnCansel_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(305, 18); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(330, 30); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Room For Consective Session"; + // + // comboYear + // + this.comboYear.FormattingEnabled = true; + this.comboYear.Location = new System.Drawing.Point(60, 79); + this.comboYear.Name = "comboYear"; + this.comboYear.Size = new System.Drawing.Size(307, 23); + this.comboYear.TabIndex = 10; + this.comboYear.SelectedIndexChanged += new System.EventHandler(this.comboYear_SelectedIndexChanged); + // + // comboSemester + // + this.comboSemester.FormattingEnabled = true; + this.comboSemester.Location = new System.Drawing.Point(399, 79); + this.comboSemester.Name = "comboSemester"; + this.comboSemester.Size = new System.Drawing.Size(307, 23); + this.comboSemester.TabIndex = 11; + this.comboSemester.SelectedIndexChanged += new System.EventHandler(this.comboSemester_SelectedIndexChanged); + // + // comboRoom + // + this.comboRoom.FormattingEnabled = true; + this.comboRoom.Location = new System.Drawing.Point(399, 118); + this.comboRoom.Name = "comboRoom"; + this.comboRoom.Size = new System.Drawing.Size(307, 23); + this.comboRoom.TabIndex = 10; + // + // gridGroupDetails + // + this.gridGroupDetails.AllowUserToAddRows = false; + this.gridGroupDetails.AllowUserToDeleteRows = false; + this.gridGroupDetails.AllowUserToResizeColumns = false; + this.gridGroupDetails.AllowUserToResizeRows = false; + this.gridGroupDetails.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.gridGroupDetails.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.gridGroupDetails.Location = new System.Drawing.Point(60, 270); + this.gridGroupDetails.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.gridGroupDetails.Name = "gridGroupDetails"; + this.gridGroupDetails.ReadOnly = true; + this.gridGroupDetails.RowHeadersWidth = 51; + this.gridGroupDetails.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.gridGroupDetails.Size = new System.Drawing.Size(808, 141); + this.gridGroupDetails.TabIndex = 9; + this.gridGroupDetails.Text = "dataGridView1"; + this.gridGroupDetails.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridGroupDetails_CellDoubleClick); + // + // comboConsective + // + this.comboConsective.FormattingEnabled = true; + this.comboConsective.Location = new System.Drawing.Point(60, 118); + this.comboConsective.Name = "comboConsective"; + this.comboConsective.Size = new System.Drawing.Size(307, 23); + this.comboConsective.TabIndex = 10; + this.comboConsective.SelectedIndexChanged += new System.EventHandler(this.comboConsective_SelectedIndexChanged); + // + // RoomsforConsectiveSessionSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.comboConsective); + this.Controls.Add(this.gridGroupDetails); + this.Controls.Add(this.comboYear); + this.Controls.Add(this.comboSemester); + this.Controls.Add(this.comboRoom); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnCansel); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.btnUpdate); + this.Controls.Add(this.btnInsert); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "RoomsforConsectiveSessionSubForm"; + this.Size = new System.Drawing.Size(890, 450); + ((System.ComponentModel.ISupportInitialize)(this.gridGroupDetails)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Button btnUpdate; + private System.Windows.Forms.Button btnCansel; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.ComboBox comboYear; + private System.Windows.Forms.ComboBox comboSemester; + private System.Windows.Forms.ComboBox comboConsective; + private System.Windows.Forms.DataGridView gridGroupDetails; + private System.Windows.Forms.ComboBox comboRoom; + private System.Windows.Forms.ComboBox combo; + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.cs new file mode 100644 index 0000000..2bb8a61 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.cs @@ -0,0 +1,356 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using TimeTable_App.Global; +using TimeTable_App.Models; +using System.Linq; + +namespace TimeTable_App.Forms.SubForms +{ + public partial class RoomsforConsectiveSessionSubForm : UserControl + { + private static RoomsforConsectiveSessionSubForm _instance; + private FormCtrl formCtrl; + private int ID = 0; + public RoomsforConsectiveSessionSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + + + private void initForm() + { + + ID = 0; + comboYear.Items.Clear(); + comboSemester.Items.Clear(); + comboRoom.Items.Clear(); + comboConsective.Items.Clear(); + + + + comboYear.Items.Insert(0, "Select Year"); + comboSemester.Items.Insert(0, "Select Semester"); + comboRoom.Items.Insert(0, "Select Room"); + comboConsective.Items.Insert(0, "Select Consective Session"); + + ActionResult ASYResult = formCtrl._getFormData(typeof(ASYModel), "ASY"); + if (ASYResult.State) + { + List ASYList = ASYResult.Data; + List ASYDistinctList = ASYList + .GroupBy(ASY => ASY.Year) + .Select(g => g.First()) + .ToList(); + int count = 1; + ASYDistinctList.ForEach(ASY => { + comboYear.Items.Insert(count, ASY.Year); + ++count; + }); + } + + + + + comboYear.SelectedIndex = 0; + comboSemester.SelectedIndex = 0; + comboRoom.SelectedIndex = 0; + comboConsective.SelectedIndex = 0; + + comboSemester.Enabled = false; + comboRoom.Enabled = false; + comboConsective.Enabled = false; + + + btnInsert.Enabled = true; + btnCansel.Enabled = true; + btnUpdate.Enabled = false; + btnDelete.Enabled = false; + + + + ActionResult groupResult = formCtrl._getFormData(typeof(RoomsforConsectiveSessionModel), "RoomsforConsectiveSession"); + if (groupResult.State) + { + + + gridGroupDetails.DataSource = groupResult.Data; + + gridGroupDetails.Columns[1].HeaderCell.Value = "Year"; + gridGroupDetails.Columns[2].HeaderCell.Value = "Semester"; + gridGroupDetails.Columns[3].HeaderCell.Value = "ConSective Session"; + gridGroupDetails.Columns[4].HeaderCell.Value = "Room"; + + + gridGroupDetails.Columns[0].Visible = false; + + gridGroupDetails.RowHeadersVisible = false; + + } + } + + private void comboYear_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboYear.SelectedIndex != 0) + { + ActionResult ASYResult = formCtrl._getFormData(typeof(ASYModel), "ASY"); + if (ASYResult.State) + { + comboSemester.Items.Clear(); + comboSemester.Items.Insert(0, "Select Semester"); + + + comboRoom.Items.Clear(); + comboRoom.Items.Insert(0, "Select Room"); + + comboConsective.Items.Clear(); + comboConsective.Items.Insert(0, "Select Consective Session"); + + List ASYList = ASYResult.Data; + var SemesterList = ASYList.Where(ASY => ASY.Year == comboYear.SelectedItem.ToString()).ToList(); + int count = 1; + SemesterList.ForEach(ASY => + { + comboSemester.Items.Insert(count, ASY.Semester); + ++count; + } + ); + + comboSemester.SelectedIndex = 0; + comboRoom.SelectedIndex = 0; + comboConsective.SelectedIndex = 0; + + comboSemester.Enabled = true; + comboRoom.Enabled = false; + comboConsective.Enabled = false; + + + } + } + } + + private void comboSemester_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboSemester.SelectedIndex != 0) + { + ActionResult ConResult = formCtrl._getFormData(typeof(ConsectiveSessionsModel), "ConsectiveSessions"); + if (ConResult.State) + { + + comboRoom.Items.Clear(); + comboRoom.Items.Insert(0, "Select Room"); + + + comboConsective.Items.Clear(); + comboConsective.Items.Insert(0, "Select Consective Session"); + + + List ConList = ConResult.Data; + var SelectedCon = ConList.Where(con => con.Year == comboYear.SelectedItem.ToString() && con.Semester == comboSemester.SelectedItem.ToString()).ToList(); + int count = 1; + SelectedCon.ForEach(con => + { + comboConsective.Items.Insert(count, con.Id); + ++count; + } + ); + + comboRoom.SelectedIndex = 0; + comboConsective.SelectedIndex = 0; + + comboSemester.Enabled = true; + comboRoom.Enabled = false; + comboConsective.Enabled = true; + + } + } + } + + private void comboConsective_SelectedIndexChanged(object sender, EventArgs e) + { + + + if (comboConsective.SelectedIndex != 0) + { + comboRoom.Items.Clear(); + comboRoom.Items.Insert(0, "Select Room"); + int proCount = 1; + ActionResult roomResult = formCtrl._getFormData(typeof(RoomsModel), "Rooms"); + if (roomResult.State) + { + List roomList = roomResult.Data; + roomList.ForEach(room => comboRoom.Items.Insert(proCount, room.RoomNumber)); + ++proCount; + } + comboRoom.SelectedIndex = 0; + comboRoom.Enabled = true; + } + + + } + + + + private void gridGroupDetails_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + DataGridViewRow selectedRow = this.gridGroupDetails.SelectedRows[0]; + if (selectedRow != null) + { + ID = Int32.Parse(selectedRow.Cells[0].Value.ToString()); + comboYear.SelectedIndex = comboYear.FindStringExact(selectedRow.Cells[1].Value.ToString()); + comboSemester.SelectedIndex = comboSemester.FindStringExact(selectedRow.Cells[2].Value.ToString()); + comboConsective.SelectedIndex = comboConsective.FindStringExact(selectedRow.Cells[3].Value.ToString()); + comboRoom.SelectedIndex = comboRoom.FindStringExact(selectedRow.Cells[4].Value.ToString()); + + btnInsert.Enabled = false; + btnUpdate.Enabled = true; + btnDelete.Enabled = true; + + } + } + + private void btnCansel_Click(object sender, EventArgs e) + { + initForm(); + } + + private void btnInsert_Click(object sender, EventArgs e) + { + + if (comboYear.SelectedIndex == 0) + { + MessageBox.Show("Please Select Year!If Year List Empty Please Add Academic Year And Semster", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboYear.Focus(); + } + else if (comboSemester.SelectedIndex == 0) + { + MessageBox.Show("Please Select Year!If Year List Empty Please Add Academic Year And Semster", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboSemester.Focus(); + } + + else if (comboConsective.SelectedIndex == 0) + { + MessageBox.Show("Please Select Consective Session!If Year List Empty Please Add Consective Session", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboConsective.Focus(); + } + else if (comboRoom.SelectedIndex == 0) + { + MessageBox.Show("Please Select Room!If Year List Empty Please Add Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboRoom.Focus(); + } + + + + else + { + ActionResult saveResult = formCtrl._saveFormData(new RoomsforConsectiveSessionModel() + { + Year = comboYear.SelectedItem.ToString(), + Semester = comboSemester.SelectedItem.ToString(), + ConsectiveSessionId = Int32.Parse(comboConsective.SelectedItem.ToString()), + Room = comboRoom.SelectedItem.ToString() + + + }); + + if (saveResult.State) + { + RoomsforConsectiveSessionModel saveObj = saveResult.Data; + MessageBox.Show("Room " + saveObj.Room + "allocated for Consective Session-" + saveObj.ConsectiveSessionId + " Sucessfully!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + if (ID == 0) + { + MessageBox.Show("Please select Consective Session first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + initForm(); + } + else + { + ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforConsectiveSessionModel() { Id = ID }); + + if (deleteResult.State) + { + RoomsforConsectiveSessionModel deleteObj = deleteResult.Data; + MessageBox.Show("Allocated Room For Consective Session Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + private void btnUpdate_Click(object sender, EventArgs e) + { + if (comboYear.SelectedIndex == 0) + { + MessageBox.Show("Please Select Year!If Year List Empty Please Add Academic Year And Semster", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboYear.Focus(); + } + else if (comboSemester.SelectedIndex == 0) + { + MessageBox.Show("Please Select Year!If Year List Empty Please Add Academic Year And Semster", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboSemester.Focus(); + } + + else if (comboConsective.SelectedIndex == 0) + { + MessageBox.Show("Please Select Consective Session!If Year List Empty Please Add Consective Session", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboConsective.Focus(); + } + else if (comboRoom.SelectedIndex == 0) + { + MessageBox.Show("Please Select Room!If Year List Empty Please Add Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboRoom.Focus(); + } + else + { + + ActionResult updateResult = formCtrl._updateFormData(new RoomsforConsectiveSessionModel() + { + Id = ID, + Year = comboYear.SelectedItem.ToString(), + Semester = comboSemester.SelectedItem.ToString(), + ConsectiveSessionId = Int32.Parse(comboConsective.SelectedItem.ToString()), + Room = comboRoom.SelectedItem.ToString() + + }); + + if (updateResult.State) + { + RoomsforConsectiveSessionModel updateObj = updateResult.Data; + MessageBox.Show("Allocated Room For Consective Session Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.resx b/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforConsectiveSessionSubForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.Designer.cs new file mode 100644 index 0000000..0e06616 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.Designer.cs @@ -0,0 +1,195 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class RoomsforSessionSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnInsert = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.btnDelete = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(397, 149); + this.btnInsert.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(105, 26); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = ">>"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(346, 10); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(254, 30); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Rooms With Lecturers"; + this.lblCaption.Click += new System.EventHandler(this.lblCaption_Click); + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 15; + this.listBox1.Location = new System.Drawing.Point(46, 131); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(313, 139); + this.listBox1.TabIndex = 3; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(46, 57); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(313, 23); + this.comboBox1.TabIndex = 10; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // listBox2 + // + this.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 15; + this.listBox2.Location = new System.Drawing.Point(535, 131); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(313, 139); + this.listBox2.TabIndex = 3; + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(397, 192); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(105, 26); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "<<"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + this.dataGridView1.AllowUserToResizeRows = false; + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle4; + this.dataGridView1.Location = new System.Drawing.Point(46, 293); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(802, 141); + this.dataGridView1.TabIndex = 9; + this.dataGridView1.Text = "dataGridView1"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(141, 96); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 21); + this.label1.TabIndex = 2; + this.label1.Text = "All Rooms"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(639, 96); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(143, 21); + this.label2.TabIndex = 2; + this.label2.Text = "Allocated Rooms"; + // + // RoomsforaLecturerSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.listBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnInsert); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "RoomsforaLecturerSubForm"; + this.Size = new System.Drawing.Size(890, 450); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ListBox listBox2; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + } +} diff --git a/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs new file mode 100644 index 0000000..317e782 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using TimeTable_App.Global; +using TimeTable_App.Models; +using System.Linq; + +namespace TimeTable_App.Forms.SubForms +{ + public partial class RoomsforSessionSubForm : UserControl + { + private static RoomsforSessionSubForm _instance; + private FormCtrl formCtrl; + private int selectedSec = 0; + + public static RoomsforSessionSubForm Instance + { + get + { + if (_instance == null) _instance = new RoomsforSessionSubForm(); + return _instance; + } + } + + public RoomsforSessionSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + + + private void initForm() + { + + int count = 0; + listBox1.Items.Clear(); + listBox2.Items.Clear(); + comboBox1.Items.Clear(); + ActionResult SesResult = formCtrl._getFormData(typeof(SessionsSubFormModel), "Sessions"); + if (SesResult.State) + { + List SesList = SesResult.Data; + SesList.ForEach(ses => comboBox1.Items.Insert(count, ses.SessionCode)); + count++; + } + comboBox1.SelectedIndex = selectedSec; + + } + + private void updateLecturer() + { + listBox1.Items.Clear(); + listBox2.Items.Clear(); + + ActionResult roomsWithLecResult = formCtrl._getFormData(typeof(RoomsforSessionModel), "RoomsforaLecturer"); + if (roomsWithLecResult.State) + { + + List RoomsWithLecModalList = roomsWithLecResult.Data; + var SelectedRWTList = RoomsWithLecModalList.Where(RWT => RWT.SessionId.ToString() == comboBox1.SelectedItem.ToString()).ToList(); + SelectedRWTList.ForEach(RWT => + listBox2.Items.Add(RWT.Room) + ); + + ActionResult roomsResult = formCtrl._getFormData(typeof(RoomsModel), "Rooms"); + if (roomsResult.State) + { + + List roomsList = roomsResult.Data; + + + for (int i = roomsList.Count - 1; i >= 0; --i) + { + + RoomsModel room = roomsList[i]; + SelectedRWTList.ForEach(selected => + { + if (selected.Room == room.RoomNumber) + { + roomsList.RemoveAt(i); + } + }); + } + + roomsList.ForEach(room => + { + listBox1.Items.Add(room.RoomNumber); + }); + } + + dataGridView1.DataSource = roomsWithLecResult.Data; + dataGridView1.Columns[1].HeaderCell.Value = "Lecturer"; + dataGridView1.Columns[2].HeaderCell.Value = "Room"; + dataGridView1.Columns[0].Visible = false; + dataGridView1.RowHeadersVisible = false; + + } + } + + private void btnInsert_Click(object sender, EventArgs e) + { + var selected = listBox1.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Lecturer", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + ActionResult saveResult = formCtrl._saveFormData(new RoomsforSessionModel() + { + Room = (string)selected, + SessionId = Int32.Parse(comboBox1.SelectedItem.ToString()), + + }); + + if (saveResult.State) + { + RoomsforSessionModel saveObj = saveResult.Data; + MessageBox.Show("Rooms With Lecturer : " + saveObj.Room + "-" + saveObj.SessionId + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + /*var selected = listBox2.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + int id = 0; + + ActionResult roomsWithLecResult = formCtrl._getFormData(typeof(RoomsforSessionModel), "RoomsforaLecturer"); + if (roomsWithLecResult.State) + { + + foreach (RoomsforSessionModel room in roomsWithLecResult.Data) + { + if (room.Room == (string)selected && room.Lecturer == comboBox1.SelectedItem.ToString()) + { + id = room.RoomWithLectureID; + } + } + + } + + + ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforSessionModel() { RoomWithLectureID = id }); + + if (deleteResult.State) + { + RoomsforSessionModel deleteObj = deleteResult.Data; + MessageBox.Show("Room " + (string)selected + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + }*/ + } + + + 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) + { + + } + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.resx b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforSessionSubForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.Designer.cs new file mode 100644 index 0000000..eea336f --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.Designer.cs @@ -0,0 +1,201 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class RoomsforTimeNotReservedSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnInsert = new System.Windows.Forms.Button(); + this.btnUpdate = new System.Windows.Forms.Button(); + this.btnDelete = new System.Windows.Forms.Button(); + this.btnCansel = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.txtTo = new System.Windows.Forms.TextBox(); + this.txtFrom = new System.Windows.Forms.TextBox(); + this.comboRoom = new System.Windows.Forms.ComboBox(); + this.comboBuilding = new System.Windows.Forms.ComboBox(); + this.gridRoomDetails = new System.Windows.Forms.DataGridView(); + this.comboDay = new System.Windows.Forms.ComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.gridRoomDetails)).BeginInit(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(763, 79); + this.btnInsert.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(105, 26); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = "Insert"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // btnUpdate + // + this.btnUpdate.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnUpdate.Location = new System.Drawing.Point(763, 118); + this.btnUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnUpdate.Name = "btnUpdate"; + this.btnUpdate.Size = new System.Drawing.Size(105, 26); + this.btnUpdate.TabIndex = 0; + this.btnUpdate.Text = "Update"; + this.btnUpdate.UseVisualStyleBackColor = true; + this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(763, 158); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(105, 26); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "Delete"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // btnCansel + // + this.btnCansel.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnCansel.Location = new System.Drawing.Point(763, 198); + this.btnCansel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnCansel.Name = "btnCansel"; + this.btnCansel.Size = new System.Drawing.Size(105, 26); + this.btnCansel.TabIndex = 0; + this.btnCansel.Text = "Cancel"; + this.btnCansel.UseVisualStyleBackColor = true; + this.btnCansel.Click += new System.EventHandler(this.btnCansel_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(381, 11); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(88, 30); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Rooms"; + // + // txtTo + // + this.txtTo.Location = new System.Drawing.Point(60, 162); + this.txtTo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.txtTo.Name = "txtTo"; + this.txtTo.PlaceholderText = "To"; + this.txtTo.Size = new System.Drawing.Size(307, 23); + this.txtTo.TabIndex = 1; + // + // txtFrom + // + this.txtFrom.Location = new System.Drawing.Point(415, 118); + this.txtFrom.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.txtFrom.Name = "txtFrom"; + this.txtFrom.PlaceholderText = "From"; + this.txtFrom.Size = new System.Drawing.Size(307, 23); + this.txtFrom.TabIndex = 12; + // + // comboRoom + // + this.comboRoom.FormattingEnabled = true; + this.comboRoom.Location = new System.Drawing.Point(415, 79); + this.comboRoom.Name = "comboRoom"; + this.comboRoom.Size = new System.Drawing.Size(307, 23); + this.comboRoom.TabIndex = 10; + // + // comboBuilding + // + this.comboBuilding.FormattingEnabled = true; + this.comboBuilding.Location = new System.Drawing.Point(60, 79); + this.comboBuilding.Name = "comboBuilding"; + this.comboBuilding.Size = new System.Drawing.Size(307, 23); + this.comboBuilding.TabIndex = 11; + // + // gridRoomDetails + // + this.gridRoomDetails.AllowUserToAddRows = false; + this.gridRoomDetails.AllowUserToDeleteRows = false; + this.gridRoomDetails.AllowUserToResizeColumns = false; + this.gridRoomDetails.AllowUserToResizeRows = false; + this.gridRoomDetails.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.gridRoomDetails.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.gridRoomDetails.Location = new System.Drawing.Point(60, 270); + this.gridRoomDetails.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.gridRoomDetails.Name = "gridRoomDetails"; + this.gridRoomDetails.ReadOnly = true; + this.gridRoomDetails.RowHeadersWidth = 51; + this.gridRoomDetails.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.gridRoomDetails.Size = new System.Drawing.Size(808, 141); + this.gridRoomDetails.TabIndex = 9; + this.gridRoomDetails.Text = "dataGridView1"; + this.gridRoomDetails.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridRoomDetails_CellDoubleClick); + // + // comboDay + // + this.comboDay.FormattingEnabled = true; + this.comboDay.Location = new System.Drawing.Point(60, 121); + this.comboDay.Name = "comboDay"; + this.comboDay.Size = new System.Drawing.Size(307, 23); + this.comboDay.TabIndex = 10; + // + // RoomsforTimeNotReservedSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.comboDay); + this.Controls.Add(this.gridRoomDetails); + this.Controls.Add(this.txtTo); + this.Controls.Add(this.txtFrom); + this.Controls.Add(this.comboRoom); + this.Controls.Add(this.comboBuilding); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnCansel); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.btnUpdate); + this.Controls.Add(this.btnInsert); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "RoomsforTimeNotReservedSubForm"; + this.Size = new System.Drawing.Size(890, 450); + ((System.ComponentModel.ISupportInitialize)(this.gridRoomDetails)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Button btnUpdate; + private System.Windows.Forms.Button btnCansel; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.TextBox txtTo; + private System.Windows.Forms.TextBox txtFrom; + private System.Windows.Forms.ComboBox comboRoom; + private System.Windows.Forms.ComboBox comboBuilding; + private System.Windows.Forms.DataGridView gridRoomDetails; + private System.Windows.Forms.ComboBox comboDay; + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.cs new file mode 100644 index 0000000..d6dfef6 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.cs @@ -0,0 +1,273 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using TimeTable_App.Global; +using TimeTable_App.Models; + +namespace TimeTable_App.Forms.SubForms +{ + public partial class RoomsforTimeNotReservedSubForm : UserControl + { + private static RoomsforTimeNotReservedSubForm _instance; + private FormCtrl formCtrl; + private int Id = 0; + + public static RoomsforTimeNotReservedSubForm Instance + { + get + { + if (_instance == null) _instance = new RoomsforTimeNotReservedSubForm(); + return _instance; + } + } + public RoomsforTimeNotReservedSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + + + private void initForm() + { + + Id = 0; + txtTo.Text = string.Empty; + txtFrom.Text = string.Empty; + comboRoom.Items.Clear(); + comboBuilding.Items.Clear(); + comboDay.Items.Clear(); + + comboRoom.Items.Insert(0, "Select Room"); + comboBuilding.Items.Insert(0, "Select Building"); + comboDay.Items.Insert(0, "Select Day"); + + int count = 1; + ActionResult buildingResult = formCtrl._getFormData(typeof(BuildingModel), "Buildings"); + if (buildingResult.State) + { + + List buildingList = buildingResult.Data; + buildingList.ForEach(bulding => comboBuilding.Items.Insert(count, bulding.BuildingName)); + ++count; + } + + count = 1; + ActionResult RoomsResult = formCtrl._getFormData(typeof(RoomsModel), "Rooms"); + if (RoomsResult.State) + { + List RoomsList = RoomsResult.Data; + RoomsList.ForEach(room => comboRoom.Items.Insert(count, room.RoomNumber)); + } + + comboDay.Items.Insert(1, "Monday"); + comboDay.Items.Insert(2, "Tuesday"); + comboDay.Items.Insert(3, "Wednesday"); + comboDay.Items.Insert(4, "Thursday"); + comboDay.Items.Insert(5, "Friday"); + comboDay.Items.Insert(6, "Saturday"); + comboDay.Items.Insert(7, "Sunday"); + + comboRoom.SelectedIndex = 0; + comboBuilding.SelectedIndex = 0; + comboDay.SelectedIndex = 0; + + btnInsert.Enabled = true; + btnCansel.Enabled = true; + btnUpdate.Enabled = false; + btnDelete.Enabled = false; + + + + ActionResult TimeResult = formCtrl._getFormData(typeof(RoomsforTimeNotReservedModel), "RoomsforTimeNotReserved"); + if (TimeResult.State) + { + + + gridRoomDetails.DataSource = TimeResult.Data; + + gridRoomDetails.Columns[1].HeaderCell.Value = "Building"; + gridRoomDetails.Columns[2].HeaderCell.Value = "Room Number"; + gridRoomDetails.Columns[3].HeaderCell.Value = "Day"; + gridRoomDetails.Columns[4].HeaderCell.Value = "From"; + gridRoomDetails.Columns[5].HeaderCell.Value = "To"; + + gridRoomDetails.Columns[0].Visible = false; + + gridRoomDetails.RowHeadersVisible = false; + + } + } + + private void gridRoomDetails_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + DataGridViewRow selectedRow = this.gridRoomDetails.SelectedRows[0]; + if (selectedRow != null) + { + Id = Int32.Parse(selectedRow.Cells[0].Value.ToString()); + comboBuilding.SelectedIndex = comboBuilding.FindStringExact(selectedRow.Cells[1].Value.ToString()); + comboRoom.SelectedIndex = comboRoom.FindStringExact(selectedRow.Cells[2].Value.ToString()); + comboDay.SelectedIndex = comboDay.FindStringExact(selectedRow.Cells[3].Value.ToString()); + txtFrom.Text = selectedRow.Cells[4].Value.ToString(); + txtTo.Text = selectedRow.Cells[5].Value.ToString(); + + + btnInsert.Enabled = false; + btnUpdate.Enabled = true; + btnDelete.Enabled = true; + + } + } + + private void btnCansel_Click(object sender, EventArgs e) + { + initForm(); + } + + private void btnInsert_Click(object sender, EventArgs e) + { + if (comboBuilding.SelectedIndex == 0) + { + MessageBox.Show("Please Select Building!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboBuilding.Focus(); + } + else if (comboRoom.SelectedIndex == 0) + { + MessageBox.Show("Please Select Room!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboRoom.Focus(); + } + else if (comboDay.SelectedIndex == 0) + { + MessageBox.Show("Please Select Day!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboDay.Focus(); + } + + else if (string.IsNullOrEmpty(txtFrom.Text)) + { + MessageBox.Show("Please Enter From!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + txtFrom.Focus(); + } + else if (string.IsNullOrEmpty(txtTo.Text)) + { + MessageBox.Show("Please Enter To", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + txtTo.Focus(); + } + else + { + ActionResult saveResult = formCtrl._saveFormData(new RoomsforTimeNotReservedModel() + { + + Building = comboBuilding.SelectedItem.ToString(), + Room = comboRoom.SelectedItem.ToString(), + Day = comboDay.SelectedItem.ToString(), + From = txtFrom.Text.Trim(), + To = txtTo.Text.Trim(), + + }); + + if (saveResult.State) + { + RoomsforTimeNotReservedModel saveObj = saveResult.Data; + MessageBox.Show("Room Not Allocate Time adde " + saveObj.Room + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + if (Id == 0) + { + MessageBox.Show("Please select Non Allocate time first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + initForm(); + } + else + { + ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforTimeNotReservedModel() { Id = Id }); + + if (deleteResult.State) + { + RoomsforTimeNotReservedModel deleteObj = deleteResult.Data; + MessageBox.Show("Room " + deleteObj.Room + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + + + + + private void btnUpdate_Click(object sender, EventArgs e) + { + if (comboBuilding.SelectedIndex == 0) + { + MessageBox.Show("Please Select Building!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboBuilding.Focus(); + } + else if (comboRoom.SelectedIndex == 0) + { + MessageBox.Show("Please Select Room!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboRoom.Focus(); + } + else if (comboDay.SelectedIndex == 0) + { + MessageBox.Show("Please Select Day!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboDay.Focus(); + } + + else if (string.IsNullOrEmpty(txtFrom.Text)) + { + MessageBox.Show("Please Enter From!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + txtFrom.Focus(); + } + else if (string.IsNullOrEmpty(txtTo.Text)) + { + MessageBox.Show("Please Enter To", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + txtTo.Focus(); + } + else + { + + ActionResult updateResult = formCtrl._updateFormData(new RoomsforTimeNotReservedModel() + { + Id = Id, + Building = comboBuilding.SelectedItem.ToString(), + Room = comboRoom.SelectedItem.ToString(), + Day = comboDay.SelectedItem.ToString(), + From = txtFrom.Text.Trim(), + To = txtTo.Text.Trim(), + }); + + if (updateResult.State) + { + RoomsforTimeNotReservedModel updateObj = updateResult.Data; + MessageBox.Show("Room " + updateObj.Id + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.resx b/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforTimeNotReservedSubForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.Designer.cs new file mode 100644 index 0000000..3301d48 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.Designer.cs @@ -0,0 +1,195 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class RoomsforaLecturerSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnInsert = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.btnDelete = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(397, 149); + this.btnInsert.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(105, 26); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = ">>"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(346, 10); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(254, 30); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Rooms With Lecturers"; + this.lblCaption.Click += new System.EventHandler(this.lblCaption_Click); + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 15; + this.listBox1.Location = new System.Drawing.Point(46, 131); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(313, 139); + this.listBox1.TabIndex = 3; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(46, 57); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(313, 23); + this.comboBox1.TabIndex = 10; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // listBox2 + // + this.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 15; + this.listBox2.Location = new System.Drawing.Point(535, 131); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(313, 139); + this.listBox2.TabIndex = 3; + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(397, 192); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(105, 26); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "<<"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + this.dataGridView1.AllowUserToResizeRows = false; + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle4; + this.dataGridView1.Location = new System.Drawing.Point(46, 293); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(802, 141); + this.dataGridView1.TabIndex = 9; + this.dataGridView1.Text = "dataGridView1"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(141, 96); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 21); + this.label1.TabIndex = 2; + this.label1.Text = "All Rooms"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(639, 96); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(143, 21); + this.label2.TabIndex = 2; + this.label2.Text = "Allocated Rooms"; + // + // RoomsforaLecturerSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.listBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnInsert); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "RoomsforaLecturerSubForm"; + this.Size = new System.Drawing.Size(890, 450); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ListBox listBox2; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + } +} diff --git a/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.cs new file mode 100644 index 0000000..a99030a --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using TimeTable_App.Global; +using TimeTable_App.Models; +using System.Linq; + +namespace TimeTable_App.Forms.SubForms +{ + public partial class RoomsforaLecturerSubForm : UserControl + { + private static RoomsforaLecturerSubForm _instance; + private FormCtrl formCtrl; + private int selectedLec = 0; + + public static RoomsforaLecturerSubForm Instance + { + get + { + if (_instance == null) _instance = new RoomsforaLecturerSubForm(); + return _instance; + } + } + + public RoomsforaLecturerSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + + + private void initForm() + { + + int count = 0; + listBox1.Items.Clear(); + listBox2.Items.Clear(); + comboBox1.Items.Clear(); + ActionResult lecResult = formCtrl._getFormData(typeof(LecturersFormModel), "Lecturers"); + if (lecResult.State) + { + List lecList = lecResult.Data; + lecList.ForEach(lec => comboBox1.Items.Insert(count, lec.EmployeeName)); + count++; + } + comboBox1.SelectedIndex = selectedLec; + + } + + private void updateLecturer() + { + listBox1.Items.Clear(); + listBox2.Items.Clear(); + + ActionResult roomsWithLecResult = formCtrl._getFormData(typeof(RoomsforaLecturerModel), "RoomsforaLecturer"); + if (roomsWithLecResult.State) + { + + List RoomsWithLecModalList = roomsWithLecResult.Data; + var SelectedRWTList = RoomsWithLecModalList.Where(RWT => RWT.Lecturer == comboBox1.SelectedItem.ToString()).ToList(); + SelectedRWTList.ForEach(RWT => + listBox2.Items.Add(RWT.Room) + ); + + ActionResult roomsResult = formCtrl._getFormData(typeof(RoomsModel), "Rooms"); + if (roomsResult.State) + { + + List roomsList = roomsResult.Data; + + + for (int i = roomsList.Count - 1; i >= 0; --i) + { + + RoomsModel room = roomsList[i]; + SelectedRWTList.ForEach(selected => + { + if (selected.Room == room.RoomNumber) + { + roomsList.RemoveAt(i); + } + }); + } + + roomsList.ForEach(room => + { + listBox1.Items.Add(room.RoomNumber); + }); + } + + dataGridView1.DataSource = roomsWithLecResult.Data; + dataGridView1.Columns[1].HeaderCell.Value = "Lecturer"; + dataGridView1.Columns[2].HeaderCell.Value = "Room"; + dataGridView1.Columns[0].Visible = false; + dataGridView1.RowHeadersVisible = false; + + } + } + + private void btnInsert_Click(object sender, EventArgs e) + { + var selected = listBox1.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Lecturer", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + ActionResult saveResult = formCtrl._saveFormData(new RoomsforaLecturerModel() + { + Room = (string)selected, + Lecturer = comboBox1.SelectedItem.ToString(), + + }); + + if (saveResult.State) + { + RoomsforaLecturerModel saveObj = saveResult.Data; + MessageBox.Show("Rooms With Lecturer : " + saveObj.Room + "-" + saveObj.Lecturer + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + var selected = listBox2.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + int id = 0; + + ActionResult roomsWithLecResult = formCtrl._getFormData(typeof(RoomsforaLecturerModel), "RoomsforaLecturer"); + if (roomsWithLecResult.State) + { + + foreach (RoomsforaLecturerModel room in roomsWithLecResult.Data) + { + if (room.Room == (string)selected && room.Lecturer == comboBox1.SelectedItem.ToString()) + { + id = room.RoomWithLectureID; + } + } + + } + + + ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforaLecturerModel() { RoomWithLectureID = id }); + + if (deleteResult.State) + { + RoomsforaLecturerModel deleteObj = deleteResult.Data; + MessageBox.Show("Room " + (string)selected + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + selectedLec = comboBox1.SelectedIndex; + updateLecturer(); + } + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void lblCaption_Click(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.resx b/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforaLecturerSubForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.Designer.cs new file mode 100644 index 0000000..7a29941 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.Designer.cs @@ -0,0 +1,194 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class RoomsforaSubGroupSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnInsert = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.btnDelete = new System.Windows.Forms.Button(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(397, 149); + this.btnInsert.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(105, 26); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = ">>"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(346, 10); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(273, 30); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Rooms With SubGroups"; + + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 15; + this.listBox1.Location = new System.Drawing.Point(46, 131); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(313, 139); + this.listBox1.TabIndex = 3; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(46, 57); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(313, 23); + this.comboBox1.TabIndex = 10; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // listBox2 + // + this.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 15; + this.listBox2.Location = new System.Drawing.Point(535, 131); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(313, 139); + this.listBox2.TabIndex = 3; + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(397, 192); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(105, 26); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "<<"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + this.dataGridView1.AllowUserToResizeRows = false; + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle2.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.Location = new System.Drawing.Point(46, 293); + this.dataGridView1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersWidth = 51; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(802, 141); + this.dataGridView1.TabIndex = 9; + this.dataGridView1.Text = "dataGridView1"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(141, 96); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(90, 21); + this.label1.TabIndex = 2; + this.label1.Text = "All Rooms"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Segoe UI Black", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(639, 96); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(143, 21); + this.label2.TabIndex = 2; + this.label2.Text = "Allocated Rooms"; + // + // RoomsforaSubGroupSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.listBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnInsert); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "RoomsforaSubGroupSubForm"; + this.Size = new System.Drawing.Size(890, 450); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ListBox listBox2; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + } +} diff --git a/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.cs b/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.cs new file mode 100644 index 0000000..cd5bf17 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.cs @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using TimeTable_App.Global; +using TimeTable_App.Models; +using System.Linq; + +namespace TimeTable_App.Forms.SubForms +{ + public partial class RoomsforaSubGroupSubForm : UserControl + { + private static RoomsforaSubGroupSubForm _instance; + private FormCtrl formCtrl; + private int selectedLec = 0; + + public static RoomsforaSubGroupSubForm Instance + { + get + { + if (_instance == null) _instance = new RoomsforaSubGroupSubForm(); + return _instance; + } + } + + public RoomsforaSubGroupSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + + + private void initForm() + { + + int count = 0; + listBox1.Items.Clear(); + listBox2.Items.Clear(); + comboBox1.Items.Clear(); + ActionResult subgroupResult = formCtrl._getFormData(typeof(SubGroupIDModel), "SubGroupID"); + if (subgroupResult.State) + { + List subgroupList = subgroupResult.Data; + subgroupList.ForEach(subgrp => comboBox1.Items.Insert(count, subgrp.SubGroupID)); + count++; + } + comboBox1.SelectedIndex = selectedLec; + + } + + private void updateLecturer() + { + listBox1.Items.Clear(); + listBox2.Items.Clear(); + + ActionResult subgroupResult = formCtrl._getFormData(typeof(RoomsforaSubGroupModel), "RoomsforaSubGroup"); + if (subgroupResult.State) + { + + List RoomsWithLecModalList = subgroupResult.Data; + var SelectedRWTList = RoomsWithLecModalList.Where(RWT => RWT.SubGroup == comboBox1.SelectedItem.ToString()).ToList(); + SelectedRWTList.ForEach(RWT => + listBox2.Items.Add(RWT.Room) + ); + + + ActionResult roomsResult = formCtrl._getFormData(typeof(RoomsModel), "Rooms"); + if (roomsResult.State) + { + + List roomsList = roomsResult.Data; + + + for (int i = roomsList.Count - 1; i >= 0; --i) + { + + RoomsModel room = roomsList[i]; + SelectedRWTList.ForEach(selected => + { + if (selected.Room == room.RoomNumber) + { + roomsList.RemoveAt(i); + } + }); + } + + roomsList.ForEach(room => + { + listBox1.Items.Add(room.RoomNumber); + }); + } + + dataGridView1.DataSource = subgroupResult.Data; + dataGridView1.Columns[1].HeaderCell.Value = "SubGroup"; + dataGridView1.Columns[2].HeaderCell.Value = "Room"; + dataGridView1.Columns[0].Visible = false; + dataGridView1.RowHeadersVisible = false; + + } + } + + private void btnInsert_Click(object sender, EventArgs e) + { + var selected = listBox1.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select SubGroup", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + ActionResult saveResult = formCtrl._saveFormData(new RoomsforaSubGroupModel() + { + Room = (string)selected, + SubGroup = comboBox1.SelectedItem.ToString(), + + }); + + if (saveResult.State) + { + RoomsforaSubGroupModel saveObj = saveResult.Data; + MessageBox.Show("Rooms With SubGroup : " + saveObj.Room + "-" + saveObj.SubGroup + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + var selected = listBox2.SelectedItem; + + + if (selected is null) + { + MessageBox.Show("Please Select Room", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + int id = 0; + + ActionResult roomsWitSubGroupResult = formCtrl._getFormData(typeof(RoomsforaSubGroupModel), "RoomsforaSubGroup"); + if (roomsWitSubGroupResult.State) + { + + foreach (RoomsforaSubGroupModel room in roomsWitSubGroupResult.Data) + { + if (room.Room == (string)selected && room.SubGroup == comboBox1.SelectedItem.ToString()) + { + id = room.RoomWithSubGroupID; + } + } + + } + + + ActionResult deleteResult = formCtrl._deleteFormData(new RoomsforaSubGroupModel() { RoomWithSubGroupID = id }); + + if (deleteResult.State) + { + RoomsforaSubGroupModel deleteObj = deleteResult.Data; + MessageBox.Show("Room " + (string)selected + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + selectedLec = comboBox1.SelectedIndex; + updateLecturer(); + } + + + } +} \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.resx b/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/RoomsforaSubGroupSubForm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TimeTable_App/Forms/SubForms/SessionsSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/SessionsSubForm.Designer.cs new file mode 100644 index 0000000..786ca6e --- /dev/null +++ b/TimeTable_App/Forms/SubForms/SessionsSubForm.Designer.cs @@ -0,0 +1,272 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class SessionsSubForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnInsert = new System.Windows.Forms.Button(); + this.btnUpdate = new System.Windows.Forms.Button(); + this.btnDelete = new System.Windows.Forms.Button(); + this.btnCansel = new System.Windows.Forms.Button(); + this.lblCaption = new System.Windows.Forms.Label(); + this.txtSessionCode = new System.Windows.Forms.TextBox(); + this.comboTags = new System.Windows.Forms.ComboBox(); + this.comboGroup = new System.Windows.Forms.ComboBox(); + this.comboSubjects = new System.Windows.Forms.ComboBox(); + this.txtDurations = new System.Windows.Forms.TextBox(); + this.gridSessionDetails = new System.Windows.Forms.DataGridView(); + this.txtNoOfStudents = new System.Windows.Forms.TextBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btnSearch = new System.Windows.Forms.Button(); + this.txtSearch = new System.Windows.Forms.TextBox(); + this.comboSearchType = new System.Windows.Forms.ComboBox(); + this.chkListLecturers = new System.Windows.Forms.CheckedListBox(); + ((System.ComponentModel.ISupportInitialize)(this.gridSessionDetails)).BeginInit(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // btnInsert + // + this.btnInsert.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnInsert.Location = new System.Drawing.Point(872, 105); + this.btnInsert.Name = "btnInsert"; + this.btnInsert.Size = new System.Drawing.Size(120, 35); + this.btnInsert.TabIndex = 0; + this.btnInsert.Text = "Insert"; + this.btnInsert.UseVisualStyleBackColor = true; + this.btnInsert.Click += new System.EventHandler(this.btnInsert_Click); + // + // btnUpdate + // + this.btnUpdate.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnUpdate.Location = new System.Drawing.Point(872, 158); + this.btnUpdate.Name = "btnUpdate"; + this.btnUpdate.Size = new System.Drawing.Size(120, 35); + this.btnUpdate.TabIndex = 0; + this.btnUpdate.Text = "Update"; + this.btnUpdate.UseVisualStyleBackColor = true; + this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); + // + // btnDelete + // + this.btnDelete.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnDelete.Location = new System.Drawing.Point(872, 211); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(120, 35); + this.btnDelete.TabIndex = 0; + this.btnDelete.Text = "Delete"; + this.btnDelete.UseVisualStyleBackColor = true; + this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); + // + // btnCansel + // + this.btnCansel.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnCansel.Location = new System.Drawing.Point(872, 264); + this.btnCansel.Name = "btnCansel"; + this.btnCansel.Size = new System.Drawing.Size(120, 35); + this.btnCansel.TabIndex = 0; + this.btnCansel.Text = "Cansel"; + this.btnCansel.UseVisualStyleBackColor = true; + this.btnCansel.Click += new System.EventHandler(this.btnCansel_Click); + // + // lblCaption + // + this.lblCaption.AutoSize = true; + this.lblCaption.Font = new System.Drawing.Font("Segoe UI Black", 16.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.lblCaption.Location = new System.Drawing.Point(435, 15); + this.lblCaption.Name = "lblCaption"; + this.lblCaption.Size = new System.Drawing.Size(136, 38); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Sessions"; + // + // txtSessionCode + // + this.txtSessionCode.Location = new System.Drawing.Point(69, 90); + this.txtSessionCode.Name = "txtSessionCode"; + this.txtSessionCode.PlaceholderText = "Session Code"; + this.txtSessionCode.Size = new System.Drawing.Size(350, 27); + this.txtSessionCode.TabIndex = 1; + // + // comboTags + // + this.comboTags.FormattingEnabled = true; + this.comboTags.Location = new System.Drawing.Point(449, 138); + this.comboTags.Name = "comboTags"; + this.comboTags.Size = new System.Drawing.Size(350, 28); + this.comboTags.TabIndex = 4; + this.comboTags.SelectedIndexChanged += new System.EventHandler(this.comboTags_SelectedIndexChanged); + // + // comboGroup + // + this.comboGroup.FormattingEnabled = true; + this.comboGroup.Location = new System.Drawing.Point(69, 201); + this.comboGroup.Name = "comboGroup"; + this.comboGroup.Size = new System.Drawing.Size(350, 28); + this.comboGroup.TabIndex = 5; + this.comboGroup.SelectedIndexChanged += new System.EventHandler(this.comboGroup_SelectedIndexChanged); + // + // comboSubjects + // + this.comboSubjects.FormattingEnabled = true; + this.comboSubjects.Location = new System.Drawing.Point(449, 203); + this.comboSubjects.Name = "comboSubjects"; + this.comboSubjects.Size = new System.Drawing.Size(350, 28); + this.comboSubjects.TabIndex = 6; + // + // txtDurations + // + this.txtDurations.Location = new System.Drawing.Point(449, 256); + this.txtDurations.Name = "txtDurations"; + this.txtDurations.PlaceholderText = "Durations"; + this.txtDurations.Size = new System.Drawing.Size(350, 27); + this.txtDurations.TabIndex = 8; + // + // gridSessionDetails + // + this.gridSessionDetails.AllowUserToAddRows = false; + this.gridSessionDetails.AllowUserToDeleteRows = false; + this.gridSessionDetails.AllowUserToResizeColumns = false; + this.gridSessionDetails.AllowUserToResizeRows = false; + this.gridSessionDetails.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.gridSessionDetails.Location = new System.Drawing.Point(14, 58); + this.gridSessionDetails.Name = "gridSessionDetails"; + this.gridSessionDetails.ReadOnly = true; + this.gridSessionDetails.RowHeadersWidth = 51; + this.gridSessionDetails.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.gridSessionDetails.Size = new System.Drawing.Size(899, 197); + this.gridSessionDetails.TabIndex = 9; + this.gridSessionDetails.Text = "dataGridView1"; + this.gridSessionDetails.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridLecturersDetails_CellDoubleClick); + // + // txtNoOfStudents + // + this.txtNoOfStudents.Location = new System.Drawing.Point(69, 256); + this.txtNoOfStudents.Name = "txtNoOfStudents"; + this.txtNoOfStudents.PlaceholderText = "No Of Students"; + this.txtNoOfStudents.Size = new System.Drawing.Size(350, 27); + this.txtNoOfStudents.TabIndex = 8; + // + // panel1 + // + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Controls.Add(this.btnSearch); + this.panel1.Controls.Add(this.gridSessionDetails); + this.panel1.Controls.Add(this.txtSearch); + this.panel1.Controls.Add(this.comboSearchType); + this.panel1.Location = new System.Drawing.Point(54, 322); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(935, 265); + this.panel1.TabIndex = 10; + // + // btnSearch + // + this.btnSearch.Font = new System.Drawing.Font("Segoe UI Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.btnSearch.Location = new System.Drawing.Point(653, 12); + this.btnSearch.Name = "btnSearch"; + this.btnSearch.Size = new System.Drawing.Size(117, 35); + this.btnSearch.TabIndex = 0; + this.btnSearch.Text = "Search"; + this.btnSearch.UseVisualStyleBackColor = true; + this.btnSearch.Click += new System.EventHandler(this.btnCansel_Click); + // + // txtSearch + // + this.txtSearch.Location = new System.Drawing.Point(339, 17); + this.txtSearch.Name = "txtSearch"; + this.txtSearch.PlaceholderText = "Search ..."; + this.txtSearch.Size = new System.Drawing.Size(290, 27); + this.txtSearch.TabIndex = 1; + // + // comboSearchType + // + this.comboSearchType.FormattingEnabled = true; + this.comboSearchType.Location = new System.Drawing.Point(15, 16); + this.comboSearchType.Name = "comboSearchType"; + this.comboSearchType.Size = new System.Drawing.Size(290, 28); + this.comboSearchType.TabIndex = 5; + // + // chkListLecturers + // + this.chkListLecturers.FormattingEnabled = true; + this.chkListLecturers.Location = new System.Drawing.Point(69, 136); + this.chkListLecturers.Name = "chkListLecturers"; + this.chkListLecturers.Size = new System.Drawing.Size(350, 48); + this.chkListLecturers.TabIndex = 11; + // + // SessionsSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.chkListLecturers); + this.Controls.Add(this.panel1); + this.Controls.Add(this.comboSubjects); + this.Controls.Add(this.comboTags); + this.Controls.Add(this.comboGroup); + this.Controls.Add(this.txtNoOfStudents); + this.Controls.Add(this.txtDurations); + this.Controls.Add(this.txtSessionCode); + this.Controls.Add(this.lblCaption); + this.Controls.Add(this.btnCansel); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.btnUpdate); + this.Controls.Add(this.btnInsert); + this.Name = "SessionsSubForm"; + this.Size = new System.Drawing.Size(1017, 600); + ((System.ComponentModel.ISupportInitialize)(this.gridSessionDetails)).EndInit(); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Button btnUpdate; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button btnCansel; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.TextBox txtSessionCode; + private System.Windows.Forms.ComboBox comboDept; + private System.Windows.Forms.ComboBox comboCenter; + private System.Windows.Forms.ComboBox comboBulding; + private System.Windows.Forms.TextBox txtRank; + private System.Windows.Forms.DataGridView gridSessionDetails; + private System.Windows.Forms.ComboBox comboTags; + private System.Windows.Forms.ComboBox comboGroup; + private System.Windows.Forms.ComboBox comboSubjects; + private System.Windows.Forms.TextBox txtNoOfStudents; + private System.Windows.Forms.TextBox txtDurations; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button btnSearch; + private System.Windows.Forms.TextBox txtSearch; + private System.Windows.Forms.ComboBox comboSearchType; + private System.Windows.Forms.CheckedListBox chkListLecturers; + } +} diff --git a/TimeTable_App/Forms/SubForms/SessionsSubForm.cs b/TimeTable_App/Forms/SubForms/SessionsSubForm.cs new file mode 100644 index 0000000..2f210f5 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/SessionsSubForm.cs @@ -0,0 +1,350 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using TimeTable_App.Global; +using TimeTable_App.Models; +using System.Linq; +using System.Windows.Forms; + +/* + * Class Name - SessionsSubForm + * Author - Kusal Perera + * Date - 14/08/2020 + * Description - Sessions Form + * + * Version Control + * * [Kusal Perera] + * Implement the Sessions Form and configure singleton pattern. + * + */ + +namespace TimeTable_App.Forms.SubForms +{ + public partial class SessionsSubForm : UserControl + { + private static SessionsSubForm _instance; + private FormCtrl formCtrl; + private List lecturerList; + private List subList; + + public static SessionsSubForm Instance + { + get + { + if (_instance == null) _instance = new SessionsSubForm(); + return _instance; + } + } + + public SessionsSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + private void initForm() + { + chkListLecturers.Items.Clear(); + comboTags.Items.Clear(); + comboGroup.Items.Clear(); + comboSubjects.Items.Clear(); + comboSearchType.Items.Clear(); + txtSessionCode.Text = string.Empty; + txtNoOfStudents.Text = string.Empty; + txtDurations.Text = string.Empty; + txtSearch.Text = string.Empty; + + txtSessionCode.Enabled = false; + btnInsert.Enabled = true; + btnCansel.Enabled = true; + btnUpdate.Enabled = false; + btnDelete.Enabled = false; + + comboTags.Items.Insert(0, "Select the tag"); + comboGroup.Items.Insert(0, "Select the group or subgroup"); + comboSubjects.Items.Insert(0, "Select the subject"); + comboSearchType.Items.Insert(0, "Select the search type"); + + ActionResult lecturersResult = formCtrl._getFormData(typeof(SessionsSubFormModel), "Lecturers"); + if (lecturersResult.State) + { + lecturerList = lecturersResult.Data; + lecturerList.ForEach(lecturer => chkListLecturers.Items.Add(lecturer.EmployeeName)); + } + + ActionResult tagResult = formCtrl._getFormData(typeof(SessionsSubFormModel), "Tags"); + if (tagResult.State) + { + List tagList = tagResult.Data; + tagList.ForEach(tag => comboTags.Items.Insert(tag.TagId, tag.Tag)); + } + + comboTags.SelectedIndex = 0; + comboGroup.SelectedIndex = 0; + comboSubjects.SelectedIndex = 0; + comboSearchType.SelectedIndex = 0; + + ActionResult sessionResult = formCtrl._getFormData(typeof(SessionsSubFormModel), "Session"); + if (sessionResult.State) + { + gridSessionDetails.DataSource = sessionResult.Data; + + gridSessionDetails.Columns[0].HeaderCell.Value = "Session Code"; + gridSessionDetails.Columns[1].HeaderCell.Value = "Lecturers Code"; + gridSessionDetails.Columns[2].HeaderCell.Value = "Lecturers"; + gridSessionDetails.Columns[3].HeaderCell.Value = "Tag"; + gridSessionDetails.Columns[4].HeaderCell.Value = "Group Id"; + gridSessionDetails.Columns[5].HeaderCell.Value = "Subject Code"; + gridSessionDetails.Columns[6].HeaderCell.Value = "Subject Name"; + gridSessionDetails.Columns[7].HeaderCell.Value = "No Of Students"; + gridSessionDetails.Columns[8].HeaderCell.Value = "Hours"; + + gridSessionDetails.Columns[1].Visible = false; + gridSessionDetails.RowHeadersVisible = false; + } + } + + private void comboTags_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboTags.SelectedIndex != 0) + { + string type = (comboTags.SelectedItem.ToString().ToLower() == "lecture" || + comboTags.SelectedItem.ToString().ToLower() == "tutorial") ? "Group" : "SubGroup"; + + comboGroup.Items.Clear(); + comboGroup.Items.Insert(0, "Select the group or subgroup"); + + ActionResult groupOrSubResult = formCtrl._getFormData(typeof(SessionsSubFormModel), type); + if (groupOrSubResult.State) + { + if (type == "Group") + { + List groupList = groupOrSubResult.Data; + groupList.ForEach(group => comboGroup.Items.Insert(group.Id, group.GroupID)); + } + else if (type == "SubGroup") + { + List subgroupList = groupOrSubResult.Data; + subgroupList.ForEach(subGroup => comboGroup.Items.Insert(subGroup.Id, subGroup.SubGroupID)); + } + } + } + } + + private void comboGroup_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboGroup.SelectedIndex != 0) + { + comboSubjects.Items.Clear(); + comboSubjects.Items.Insert(0, "Select the subject"); + + string year = comboGroup.SelectedItem.ToString().Substring(0, 2); + string semester = comboGroup.SelectedItem.ToString().Substring(3, 2); + + ActionResult subjectResult = formCtrl._getFormData(typeof(SessionsSubFormModel), "Subject"); + if (subjectResult.State) + { + int count = 1; + subList = subjectResult.Data; + subList.ForEach(sub => + { + if (sub.Year == year && sub.Semester == semester) + { + comboSubjects.Items.Insert(count, sub.SubjectName); + count++; + } + }); + } + } + } + + private void gridLecturersDetails_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + DataGridViewRow selectedRow = this.gridSessionDetails.SelectedRows[0]; + if (selectedRow != null) + { + List selectedLecturers = selectedRow.Cells[1].Value.ToString().Split(",").ToList(); + List LecturerList = new List(); + + foreach (var lecName in selectedLecturers) + { + LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeId == lecName.ToString()).FirstOrDefault(); + LecturerList.Add(lecObj); + } + + for (int count = 0; count < chkListLecturers.Items.Count; count++) + { + LecturersFormModel emp = LecturerList.Where(lec => lec.EmployeeName == chkListLecturers.Items[count].ToString()).FirstOrDefault(); + + if (selectedLecturers.Contains(emp.EmployeeId)) + { + chkListLecturers.SetItemChecked(count, true); + } + } + + txtSessionCode.Text = selectedRow.Cells[0].Value.ToString(); + comboTags.SelectedIndex = comboTags.FindStringExact(selectedRow.Cells[3].Value.ToString()); + comboGroup.SelectedIndex = comboGroup.FindStringExact(selectedRow.Cells[4].Value.ToString()); + comboSubjects.SelectedIndex = comboSubjects.FindStringExact(selectedRow.Cells[6].Value.ToString()); + txtNoOfStudents.Text = selectedRow.Cells[7].Value.ToString(); + txtDurations.Text = selectedRow.Cells[8].Value.ToString(); + + btnInsert.Enabled = false; + btnUpdate.Enabled = true; + btnDelete.Enabled = true; + } + } + + private void btnInsert_Click(object sender, EventArgs e) + { + if (chkListLecturers.CheckedItems.Count == 0) + { + MessageBox.Show("Please Select The Lecturers!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else if (comboTags.SelectedIndex == 0) + { + MessageBox.Show("Please Select Tag!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboTags.Focus(); + } + else if (comboGroup.SelectedIndex == 0) + { + MessageBox.Show("Please Select Group Or Subgroup!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboGroup.Focus(); + } + else if (comboSubjects.SelectedIndex == 0) + { + MessageBox.Show("Please Select Subject!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + comboSubjects.Focus(); + } + else if (string.IsNullOrEmpty(txtNoOfStudents.Text)) + { + MessageBox.Show("Please Enter No Of Students!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + txtNoOfStudents.Focus(); + } + else if (string.IsNullOrEmpty(txtDurations.Text)) + { + MessageBox.Show("Please Enter Duration!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + txtDurations.Focus(); + } + else + { + string Lecturers = "", LecturersList = ""; + foreach (var lecturer in chkListLecturers.CheckedItems) + { + if (Lecturers != "" && LecturersList != "") + { + Lecturers += ","; + LecturersList += ","; + } + LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeName == lecturer.ToString()).FirstOrDefault(); + Lecturers += lecObj.EmployeeId; + LecturersList += lecObj.EmployeeName; + } + + SubjectsFormModel subModel = subList.Where(sub => sub.SubjectName == comboSubjects.SelectedItem.ToString().Trim()).FirstOrDefault(); + + ActionResult saveResult = formCtrl._saveFormData(new SessionsSubFormModel() + { + Lecturers = Lecturers, + LecturersList = LecturersList, + Tags = comboTags.SelectedItem.ToString(), + GroupId = comboGroup.SelectedItem.ToString(), + SubjectCode = subModel.SubjectCode, + SubjectName = subModel.SubjectName, + NoOfStudent = Convert.ToInt32(txtNoOfStudents.Text), + Duration = Convert.ToInt32(txtDurations.Text) + }); + + if (saveResult.State) + { + SessionsSubFormModel saveObj = saveResult.Data; + MessageBox.Show("Session " + saveObj.SessionCode + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void btnUpdate_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(txtSessionCode.Text)) + { + MessageBox.Show("Please select session first!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + string Lecturers = "", LecturersList = ""; + foreach (var lecturer in chkListLecturers.CheckedItems) + { + if (Lecturers != "" && LecturersList != "") + { + Lecturers += ","; + LecturersList += ","; + } + LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeName == lecturer.ToString()).FirstOrDefault(); + Lecturers += lecObj.EmployeeId; + LecturersList += lecObj.EmployeeName; + } + + SubjectsFormModel subModel = subList.Where(sub => sub.SubjectName == comboSubjects.SelectedItem.ToString().Trim()).FirstOrDefault(); + + ActionResult updateResult = formCtrl._updateFormData(new SessionsSubFormModel() + { + SessionCode = Convert.ToInt32(txtSessionCode.Text), + Lecturers = Lecturers, + LecturersList = LecturersList, + Tags = comboTags.SelectedItem.ToString(), + GroupId = comboGroup.SelectedItem.ToString(), + SubjectCode = subModel.SubjectCode, + SubjectName = subModel.SubjectName, + NoOfStudent = Convert.ToInt32(txtNoOfStudents.Text), + Duration = Convert.ToInt32(txtDurations.Text) + }); + + if (updateResult.State) + { + SessionsSubFormModel updateObj = updateResult.Data; + MessageBox.Show("Session " + updateObj.SessionCode + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void btnDelete_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(txtSessionCode.Text)) + { + MessageBox.Show("Please select session first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + ActionResult deleteResult = formCtrl._deleteFormData(new SessionsSubFormModel() { SessionCode = Convert.ToInt32(txtSessionCode.Text.Trim()) }); + + if (deleteResult.State) + { + SessionsSubFormModel deleteObj = deleteResult.Data; + MessageBox.Show("Session " + deleteObj.SessionCode + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void btnCansel_Click(object sender, EventArgs e) + { + initForm(); + } + + } +} diff --git a/TimeTable_App/Global/TimeTableDbContext.cs b/TimeTable_App/Global/TimeTableDbContext.cs index 24a5f30..ecf03df 100644 --- a/TimeTable_App/Global/TimeTableDbContext.cs +++ b/TimeTable_App/Global/TimeTableDbContext.cs @@ -49,5 +49,14 @@ public TimeTableDbContext() : base("DBCON") public DbSet ConsectiveSessions { get; set; } public DbSet Sessions { get; set; } public DbSet NOS { get; set; } + public DbSet RoomsWithTags { get; set; } + public DbSet RoomsForASubject { get; set; } + public DbSet RoomsforaLecturer { get; set; } + public DbSet RoomsforaSubGroup { get; set; } + public DbSet RoomsforTimeNotReserved { get; set; } + public DbSet ConsectiveSessions { get; set; } + public DbSet RoomsforConsectiveSession { get; set; } + public DbSet RoomsforSession { get; set; } + public DbSet Sessions { get; set; } } } diff --git a/TimeTable_App/Migrations/Configuration.cs b/TimeTable_App/Migrations/Configuration.cs index 307cb9e..4df2001 100644 --- a/TimeTable_App/Migrations/Configuration.cs +++ b/TimeTable_App/Migrations/Configuration.cs @@ -9,7 +9,6 @@ public class Configuration : DropCreateDatabaseIfModelChanges { - protected override void Seed(TimeTable_App.Global.TimeTableDbContext context) { // Adding Forms @@ -29,6 +28,14 @@ protected override void Seed(TimeTable_App.Global.TimeTableDbContext context) context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Group ID", SubFormDesc = "Manage Group ID", SubFormController = "GroupIDSubForm", Status = "A", FormId = 3 }); context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Sub Group ID", SubFormDesc = "Manage Sub Group ID", SubFormController = "SubGroupIDSubForm", Status = "A", FormId = 3 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms With Tags", SubFormDesc = "Rooms With Tags", SubFormController = "RoomsWithTagsSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms for a Subject", SubFormDesc = "Rooms for a Subject", SubFormController = "RoomsForASubjectSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms for a Lecturer", SubFormDesc = "Rooms for a Lecturer", SubFormController = "RoomsforaLecturerSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms for a SubGroup", SubFormDesc = "Rooms for a SubGroup", SubFormController = "RoomsforaSubGroupSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms for a Time Not Reserved", SubFormDesc = "Rooms for a Time Not Reserved", SubFormController = "RoomsforTimeNotReservedSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms for Consective Session", SubFormDesc = "Rooms for Consective Session", SubFormController = "RoomsforConsectiveSessionSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms for Session", SubFormDesc = "RoomsforSession", SubFormController = "RoomsforSessionSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Buildings", SubFormDesc = "Manage Buildings", SubFormController = "BuildingsSubForm", Status = "A", FormId = 5 }); context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Rooms", SubFormDesc = "Manage Rooms", SubFormController = "RoomsSubForm", Status = "A", FormId = 5 }); @@ -38,11 +45,12 @@ protected override void Seed(TimeTable_App.Global.TimeTableDbContext context) context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Working Days", SubFormDesc = "Working Days", SubFormController = "WorkingDaySubForm", Status = "A", FormId = 7 }); context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Time Slots", SubFormDesc = "Time Slots", SubFormController = "TimeSlotSubForm", Status = "A", FormId = 7 }); - + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Not Available Time Of Lecturer", SubFormDesc = "Not Available Time Of Lecturer", SubFormController = "NATLectureSubForm", Status = "A", FormId = 8 }); context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Consective Sessions", SubFormDesc = "Consective Sessions", SubFormController = "ConsectiveSessionsSubForm", Status = "A", FormId = 8 }); context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Not Overlap Sessions", SubFormDesc = "Not Overlap Sessions", SubFormController = "NOSSubForm", Status = "A", FormId = 8 }); context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Parallel Sessions", SubFormDesc = "Parallel Sessions", SubFormController = "ParallelSessionsSubForm", Status = "A", FormId = 8 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Sessions", SubFormDesc = "Sessions", SubFormController = "SessionsSubForm", Status = "A", FormId = 8 }); // Adding Faculties [Kusal Perera] context.Faculties.Add(new FacultyModel() { FacultyName = "Computing", FacultyDesc = "Computing Faculty" }); @@ -82,13 +90,12 @@ protected override void Seed(TimeTable_App.Global.TimeTableDbContext context) context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Friday", WorkHourPerDay = 0, status = "I" }); context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Saturday", WorkHourPerDay = 0, status = "I" }); + // Adding Subjects context.Subjects.Add(new SubjectsFormModel() { SubjectCode = "IT1010", SubjectName = "IP", Year = "Y1", Semester = "S1", LectureHours = 2, LabHours = 0, TuteHours = 2, EvaluationHours = 0 }); - context.Subjects.Add(new SubjectsFormModel() { SubjectCode = "IT1020", SubjectName = "SPM", Year = "Y1", Semester = "S2", LectureHours = 2, LabHours = 0, TuteHours = 2, EvaluationHours = 2 }); - - - + context.Subjects.Add(new SubjectsFormModel() { SubjectCode = "IT1020", SubjectName = "SPM", Year = "Y1", Semester = "S2", LectureHours = 2, LabHours = 0, TuteHours = 2, EvaluationHours = 2 }); - + // Adding Consective Sessions + context.ConsectiveSessions.Add(new ConsectiveSessionsModel() { Year = "Y1", Semester = "S1", Subject="OOP",Lecture= "YES", Tutorial="YES", Lab ="NO" }); } } } diff --git a/TimeTable_App/Models/AppSubFormsModel.cs b/TimeTable_App/Models/AppSubFormsModel.cs index 8544aa2..2b11f58 100644 --- a/TimeTable_App/Models/AppSubFormsModel.cs +++ b/TimeTable_App/Models/AppSubFormsModel.cs @@ -22,13 +22,13 @@ public class AppSubFormsModel [Key] public int SubFormId { get; set; } [Required] - [MaxLength(100)] + [MaxLength(200)] public string SubFormName { get; set; } [Required] - [MaxLength(100)] + [MaxLength(200)] public string SubFormDesc { get; set; } [Required] - [MaxLength(100)] + [MaxLength(200)] public string SubFormController { get; set; } [Required] [MaxLength(1)] diff --git a/TimeTable_App/Models/ConsectiveSessionsModel.cs b/TimeTable_App/Models/ConsectiveSessionsModel.cs index 5a84e0c..c501ef0 100644 --- a/TimeTable_App/Models/ConsectiveSessionsModel.cs +++ b/TimeTable_App/Models/ConsectiveSessionsModel.cs @@ -30,7 +30,6 @@ public class ConsectiveSessionsModel [MaxLength(50)] public string Lab { get; set; } - public dynamic GetFormData(TimeTableDbContext _dbContext, string type) { diff --git a/TimeTable_App/Models/RoomsForASubjectModel.cs b/TimeTable_App/Models/RoomsForASubjectModel.cs new file mode 100644 index 0000000..a6c1467 --- /dev/null +++ b/TimeTable_App/Models/RoomsForASubjectModel.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using TimeTable_App.Global; + +namespace TimeTable_App.Models +{ + public class RoomsForASubjectModel + { + [Key] + public int RoomsForASubjectModelID { get; set; } + [Required] + [MaxLength(50)] + public string Tag { get; set; } + [Required] + [MaxLength(50)] + public string Subject { get; set; } + [Required] + [MaxLength(50)] + public string Room { get; set; } + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + + if (type == "Tags") + { + return _dbContext.Tags.AsNoTracking().ToList(); + } + if (type == "Rooms") + { + return _dbContext.Rooms.AsNoTracking().ToList(); + } + if (type == "Subjects") + { + return _dbContext.Subjects.AsNoTracking().ToList(); + } + if (type == "RoomsForASubject") + { + return _dbContext.RoomsForASubject.AsNoTracking().ToList(); + } + + return null; + } + } + + +} \ No newline at end of file diff --git a/TimeTable_App/Models/RoomsWithTagsModal.cs b/TimeTable_App/Models/RoomsWithTagsModal.cs new file mode 100644 index 0000000..08c4bd3 --- /dev/null +++ b/TimeTable_App/Models/RoomsWithTagsModal.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using TimeTable_App.Global; + +namespace TimeTable_App.Models +{ + public class RoomsWithTagsModal + { + [Key] + public int RoomsWithTagsID { get; set; } + [Required] + [MaxLength(50)] + public string Tag { get; set; } + [Required] + [MaxLength(50)] + public string Room { get; set; } + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + + if (type == "Tags") + { + return _dbContext.Tags.AsNoTracking().ToList(); + } + if (type == "Rooms") + { + return _dbContext.Rooms.AsNoTracking().ToList(); + } + if(type == "RoomsWithTags") + { + return _dbContext.RoomsWithTags.AsNoTracking().ToList(); + } + + return null; + } + } + + +} diff --git a/TimeTable_App/Models/RoomsforConsectiveSessionModel.cs b/TimeTable_App/Models/RoomsforConsectiveSessionModel.cs new file mode 100644 index 0000000..df1f20f --- /dev/null +++ b/TimeTable_App/Models/RoomsforConsectiveSessionModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using TimeTable_App.Global; + +namespace TimeTable_App.Models +{ + public class RoomsforConsectiveSessionModel + { + [Key] + public int Id { get; set; } + [Required] + [MaxLength(50)] + public string Year { get; set; } + [Required] + [MaxLength(50)] + public string Semester { get; set; } + [Required] + public int ConsectiveSessionId { get; set; } + [Required] + [MaxLength(50)] + public string Room { get; set; } + + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + if (type == "Groups") + { + return _dbContext.Groups.AsNoTracking().ToList(); + } + else if (type == "ASY") + { + return _dbContext.ASY.AsNoTracking().ToList(); + } + else if (type == "GroupID") + { + return _dbContext.GroupID.AsNoTracking().ToList(); + } + + else if (type == "Rooms") + { + return _dbContext.Rooms.AsNoTracking().ToList(); + } + else if (type == "RoomsforConsectiveSession") + { + return _dbContext.RoomsforConsectiveSession.AsNoTracking().ToList(); + } + return null; + } + } +} diff --git a/TimeTable_App/Models/RoomsforSessionModel.cs b/TimeTable_App/Models/RoomsforSessionModel.cs new file mode 100644 index 0000000..097e208 --- /dev/null +++ b/TimeTable_App/Models/RoomsforSessionModel.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using TimeTable_App.Global; + +namespace TimeTable_App.Models +{ + public class RoomsforSessionModel + { + [Key] + public int RoomWithSessionID { get; set; } + [Required] + public int SessionId { get; set; } + [Required] + [MaxLength(50)] + public string Room { get; set; } + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + + if (type == "Sessions") + { + return _dbContext.Sessions.AsNoTracking().ToList(); + } + if (type == "Rooms") + { + return _dbContext.Rooms.AsNoTracking().ToList(); + } + //db context name + if (type == "RoomsforSession") + { + return _dbContext.RoomsforSession.AsNoTracking().ToList(); + + } + + return null; + } + } + + +} + diff --git a/TimeTable_App/Models/RoomsforaLecturerModel.cs b/TimeTable_App/Models/RoomsforaLecturerModel.cs new file mode 100644 index 0000000..abd3e65 --- /dev/null +++ b/TimeTable_App/Models/RoomsforaLecturerModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using TimeTable_App.Global; + +namespace TimeTable_App.Models +{ + public class RoomsforaLecturerModel + { + [Key] + public int RoomWithLectureID { get; set; } + [Required] + [MaxLength(50)] + public string Lecturer { get; set; } + [Required] + [MaxLength(50)] + public string Room {get; set; } + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + + if (type == "Lecturer") + { + return _dbContext.Tags.AsNoTracking().ToList(); + } + if (type == "Rooms") + { + return _dbContext.Rooms.AsNoTracking().ToList(); + } + //db context name + if (type == "RoomsforaLecturer") + { + return _dbContext.RoomsforaLecturer.AsNoTracking().ToList(); + + } + + return null; + } + } + + +} + diff --git a/TimeTable_App/Models/RoomsforaSubGroupModel.cs b/TimeTable_App/Models/RoomsforaSubGroupModel.cs new file mode 100644 index 0000000..a817786 --- /dev/null +++ b/TimeTable_App/Models/RoomsforaSubGroupModel.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using TimeTable_App.Global; + +namespace TimeTable_App.Models +{ + public class RoomsforaSubGroupModel + { + [Key] + public int RoomWithSubGroupID { get; set; } + [Required] + [MaxLength(50)] + public string SubGroup { get; set; } + [Required] + [MaxLength(50)] + public string Room { get; set; } + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + + if (type == "SubGroupID") + { + return _dbContext.SubGroupID.AsNoTracking().ToList(); + } + if (type == "Rooms") + { + return _dbContext.Rooms.AsNoTracking().ToList(); + } + //db context name + if (type == "RoomsforaSubGroup") + { + return _dbContext.RoomsforaSubGroup.AsNoTracking().ToList(); + + } + + return null; + } + } + + +} + +