From 77077a6b7c8157707a5bae3f5aa862a711951a57 Mon Sep 17 00:00:00 2001 From: Dimuthu Date: Thu, 3 Sep 2020 20:51:06 +0530 Subject: [PATCH] sprint - 1 --- .../SubForms/TimeSlotSubForm.Designer.cs | 192 ++++++ .../Forms/SubForms/TimeSlotSubForm.cs | 176 ++++++ .../Forms/SubForms/TimeSlotSubForm.resx | 60 ++ .../SubForms/WorkingDaySubForm.Designer.cs | 334 +++++++++++ .../Forms/SubForms/WorkingDaySubForm.cs | 548 ++++++++++++++++++ .../Forms/SubForms/WorkingDaySubForm.resx | 60 ++ TimeTable_App/Global/TimeTableDbContext.cs | 3 + TimeTable_App/Migrations/Configuration.cs | 19 + TimeTable_App/Models/TimeSlotSubFormModel.cs | 42 ++ .../Models/WorkingDaySubFormModel.cs | 46 ++ TimeTable_App/TimeTable_App.csproj | 4 - 11 files changed, 1480 insertions(+), 4 deletions(-) create mode 100644 TimeTable_App/Forms/SubForms/TimeSlotSubForm.Designer.cs create mode 100644 TimeTable_App/Forms/SubForms/TimeSlotSubForm.cs create mode 100644 TimeTable_App/Forms/SubForms/TimeSlotSubForm.resx create mode 100644 TimeTable_App/Forms/SubForms/WorkingDaySubForm.Designer.cs create mode 100644 TimeTable_App/Forms/SubForms/WorkingDaySubForm.cs create mode 100644 TimeTable_App/Forms/SubForms/WorkingDaySubForm.resx create mode 100644 TimeTable_App/Models/TimeSlotSubFormModel.cs create mode 100644 TimeTable_App/Models/WorkingDaySubFormModel.cs diff --git a/TimeTable_App/Forms/SubForms/TimeSlotSubForm.Designer.cs b/TimeTable_App/Forms/SubForms/TimeSlotSubForm.Designer.cs new file mode 100644 index 0000000..514d999 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/TimeSlotSubForm.Designer.cs @@ -0,0 +1,192 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class TimeSlotSubForm + { + /// + /// 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.lblCaption = new System.Windows.Forms.Label(); + 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.textStartTime = new System.Windows.Forms.TextBox(); + this.textEndTime = new System.Windows.Forms.TextBox(); + this.gridTimeSlot = new System.Windows.Forms.DataGridView(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.gridTimeSlot)).BeginInit(); + this.SuspendLayout(); + // + // 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(164, 38); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Time Slots"; + // + // 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); + // + // textStartTime + // + this.textStartTime.Enabled = false; + this.textStartTime.Location = new System.Drawing.Point(195, 158); + this.textStartTime.Name = "textStartTime"; + this.textStartTime.PlaceholderText = "HH : MM"; + this.textStartTime.Size = new System.Drawing.Size(75, 27); + this.textStartTime.TabIndex = 25; + this.textStartTime.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // textEndTime + // + this.textEndTime.Location = new System.Drawing.Point(475, 158); + this.textEndTime.Name = "textEndTime"; + this.textEndTime.PlaceholderText = "HH : MM"; + this.textEndTime.Size = new System.Drawing.Size(75, 27); + this.textEndTime.TabIndex = 25; + this.textEndTime.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // gridTimeSlot + // + this.gridTimeSlot.AllowUserToAddRows = false; + this.gridTimeSlot.AllowUserToDeleteRows = false; + this.gridTimeSlot.AllowUserToResizeColumns = false; + this.gridTimeSlot.AllowUserToResizeRows = false; + this.gridTimeSlot.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; + this.gridTimeSlot.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.gridTimeSlot.Cursor = System.Windows.Forms.Cursors.Default; + this.gridTimeSlot.Location = new System.Drawing.Point(69, 360); + this.gridTimeSlot.Name = "gridTimeSlot"; + this.gridTimeSlot.ReadOnly = true; + this.gridTimeSlot.RowHeadersWidth = 51; + this.gridTimeSlot.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.gridTimeSlot.Size = new System.Drawing.Size(923, 188); + this.gridTimeSlot.TabIndex = 9; + this.gridTimeSlot.Text = "dataGridView1"; + this.gridTimeSlot.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridTimeSlots_CellDoubleClick); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(69, 158); + this.textBox1.Name = "textBox1"; + this.textBox1.ReadOnly = true; + this.textBox1.Size = new System.Drawing.Size(103, 27); + this.textBox1.TabIndex = 26; + this.textBox1.Text = "Start Time"; + this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(349, 158); + this.textBox2.Name = "textBox2"; + this.textBox2.ReadOnly = true; + this.textBox2.Size = new System.Drawing.Size(103, 27); + this.textBox2.TabIndex = 27; + this.textBox2.Text = "End Time"; + this.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // TimeSlotSubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox2); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.gridTimeSlot); + this.Controls.Add(this.textEndTime); + this.Controls.Add(this.textStartTime); + this.Controls.Add(this.btnCansel); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.btnUpdate); + this.Controls.Add(this.btnInsert); + this.Controls.Add(this.lblCaption); + this.Name = "TimeSlotSubForm"; + this.Size = new System.Drawing.Size(1017, 600); + ((System.ComponentModel.ISupportInitialize)(this.gridTimeSlot)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.Button btnUpdate; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.Button btnCansel; + private System.Windows.Forms.TextBox textStartTime; + private System.Windows.Forms.TextBox textEndTime; + private System.Windows.Forms.DataGridView gridTimeSlot; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + } +} diff --git a/TimeTable_App/Forms/SubForms/TimeSlotSubForm.cs b/TimeTable_App/Forms/SubForms/TimeSlotSubForm.cs new file mode 100644 index 0000000..24c0868 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/TimeSlotSubForm.cs @@ -0,0 +1,176 @@ +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; + +/* + * Class Name - TimeSlotSubForm + * Author - Dimuthu Abeysinghe + * Date - 17/08/2020 + * Description - Time Slots + * + * Version Control + * * [Dimuthu Abeysinghe] + * Implement the Working days Form and configure singleton pattern. + * + */ + +namespace TimeTable_App.Forms.SubForms +{ + public partial class TimeSlotSubForm : UserControl + { + private static TimeSlotSubForm _instance; + private FormCtrl formCtrl; + + public static TimeSlotSubForm Instance + { + get + { + if (_instance == null) _instance = new TimeSlotSubForm(); + return _instance; + } + } + + public TimeSlotSubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + private void initForm() + { + + textStartTime.Text = ""; + textEndTime.Text = ""; + textStartTime.Focus(); + + btnInsert.Enabled = true; + btnCansel.Enabled = true; + btnUpdate.Enabled = false; + btnDelete.Enabled = false; + + + //ActionResult timeSlotResult = formCtrl._getFormData(typeof(TimeSlotSubFormModel), "TimeSlots"); + + ActionResult timeSlotResult = formCtrl._getFormData(typeof(TimeSlotSubFormModel), "TimeSlots"); + List depList = timeSlotResult.Data; + + String result = ""; + if (depList.Count != 0) { + result = depList.OrderByDescending(y => y.id).First().endTime; + textStartTime.Text = result; + } + else{ + textStartTime.Text = "8:30"; + } + gridTimeSlot.DataSource = depList; + + gridTimeSlot.Columns[0].HeaderCell.Value = "#"; + gridTimeSlot.Columns[1].HeaderCell.Value = "Start time"; + gridTimeSlot.Columns[2].HeaderCell.Value = "End time"; + gridTimeSlot.RowHeadersVisible = false; + + this.gridTimeSlot.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; + this.gridTimeSlot.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; + this.gridTimeSlot.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + + + private void gridTimeSlots_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + + } + + + private void btnInsert_Click(object sender, EventArgs e) + { + if (textEndTime.Text == "") + { + MessageBox.Show("Please enter end time!. It should be a 30 min or 1 hour", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + textEndTime.Focus(); + } + else + { + double startTime = 0.0, endTime = 0.0, timeDiff = 0.0; + //startTime = double.Parse(textStartTime.Text); + //endTime = double.Parse(textEndTime.Text); + try + { + TimeSpan duration = DateTime.Parse(textEndTime.Text).Subtract(DateTime.Parse(textStartTime.Text)); + if (duration.TotalMinutes != 30 && duration.TotalMinutes != 60) + { + MessageBox.Show("End time should be a 30 min or 1 hour!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + textEndTime.Focus(); + } + else + { + ActionResult saveResult = formCtrl._saveFormData(new TimeSlotSubFormModel() + { + startTime = textStartTime.Text, + endTime = textEndTime.Text + }); + + if (saveResult.State) + { + TimeSlotSubFormModel saveObj = saveResult.Data; + MessageBox.Show("Start time: " + saveObj.startTime + " End time: " + saveObj.endTime + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + catch (FormatException) { + MessageBox.Show("Invalid Time format!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + textEndTime.Focus(); + } + + } + + } + + + private void btnUpdate_Click(object sender, EventArgs e) + { + + } + + private void btnDelete_Click(object sender, EventArgs e) + { + + } + + private void btnCansel_Click(object sender, EventArgs e) + { + textEndTime.Text = ""; + textEndTime.Focus(); + } + + private void fnOnlyDecimal_KeyPress(object sender, KeyPressEventArgs e) + { + if (char.IsNumber(e.KeyChar) || e.KeyChar == ':') + { + + } + else + { + e.Handled = e.KeyChar != (char)Keys.Back; + } + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + + } + } +} diff --git a/TimeTable_App/Forms/SubForms/TimeSlotSubForm.resx b/TimeTable_App/Forms/SubForms/TimeSlotSubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/TimeSlotSubForm.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/WorkingDaySubForm.Designer.cs b/TimeTable_App/Forms/SubForms/WorkingDaySubForm.Designer.cs new file mode 100644 index 0000000..e1d2052 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/WorkingDaySubForm.Designer.cs @@ -0,0 +1,334 @@ +namespace TimeTable_App.Forms.SubForms +{ + partial class WorkingDaySubForm + { + /// + /// 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.lblCaption = new System.Windows.Forms.Label(); + this.chkSaturday = new System.Windows.Forms.CheckBox(); + this.chkFriday = new System.Windows.Forms.CheckBox(); + this.chkThursday = new System.Windows.Forms.CheckBox(); + this.chkWednesday = new System.Windows.Forms.CheckBox(); + this.chkTuesday = new System.Windows.Forms.CheckBox(); + this.chkMonday = new System.Windows.Forms.CheckBox(); + this.chkSunday = new System.Windows.Forms.CheckBox(); + this.gridWorkingDays = new System.Windows.Forms.DataGridView(); + this.btnCansel = new System.Windows.Forms.Button(); + this.btnDelete = new System.Windows.Forms.Button(); + this.btnUpdate = new System.Windows.Forms.Button(); + this.btnInsert = new System.Windows.Forms.Button(); + this.numWorkingDay = new System.Windows.Forms.TextBox(); + this.numWHSunday = new System.Windows.Forms.TextBox(); + this.numWHMonday = new System.Windows.Forms.TextBox(); + this.numWHTuesday = new System.Windows.Forms.TextBox(); + this.numWHWednesday = new System.Windows.Forms.TextBox(); + this.numWHThursday = new System.Windows.Forms.TextBox(); + this.numWHFriday = new System.Windows.Forms.TextBox(); + this.numWHSaturday = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.gridWorkingDays)).BeginInit(); + this.SuspendLayout(); + // + // 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(213, 38); + this.lblCaption.TabIndex = 2; + this.lblCaption.Text = "Working Days"; + // + // chkSaturday + // + this.chkSaturday.AutoSize = true; + this.chkSaturday.Location = new System.Drawing.Point(400, 255); + this.chkSaturday.Name = "chkSaturday"; + this.chkSaturday.Size = new System.Drawing.Size(89, 24); + this.chkSaturday.TabIndex = 16; + this.chkSaturday.Text = "Saturday"; + this.chkSaturday.UseVisualStyleBackColor = true; + this.chkSaturday.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // chkFriday + // + this.chkFriday.AutoSize = true; + this.chkFriday.Location = new System.Drawing.Point(400, 205); + this.chkFriday.Name = "chkFriday"; + this.chkFriday.Size = new System.Drawing.Size(71, 24); + this.chkFriday.TabIndex = 15; + this.chkFriday.Text = "Friday"; + this.chkFriday.UseVisualStyleBackColor = true; + this.chkFriday.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // chkThursday + // + this.chkThursday.AutoSize = true; + this.chkThursday.Location = new System.Drawing.Point(400, 155); + this.chkThursday.Name = "chkThursday"; + this.chkThursday.Size = new System.Drawing.Size(90, 24); + this.chkThursday.TabIndex = 14; + this.chkThursday.Text = "Thursday"; + this.chkThursday.UseVisualStyleBackColor = true; + this.chkThursday.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // chkWednesday + // + this.chkWednesday.AutoSize = true; + this.chkWednesday.Location = new System.Drawing.Point(69, 305); + this.chkWednesday.Name = "chkWednesday"; + this.chkWednesday.Size = new System.Drawing.Size(107, 24); + this.chkWednesday.TabIndex = 13; + this.chkWednesday.Text = "Wednesday"; + this.chkWednesday.UseVisualStyleBackColor = true; + this.chkWednesday.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // chkTuesday + // + this.chkTuesday.AutoSize = true; + this.chkTuesday.Location = new System.Drawing.Point(69, 255); + this.chkTuesday.Name = "chkTuesday"; + this.chkTuesday.Size = new System.Drawing.Size(85, 24); + this.chkTuesday.TabIndex = 12; + this.chkTuesday.Text = "Tuesday"; + this.chkTuesday.UseVisualStyleBackColor = true; + this.chkTuesday.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // chkMonday + // + this.chkMonday.AutoSize = true; + this.chkMonday.Location = new System.Drawing.Point(69, 205); + this.chkMonday.Name = "chkMonday"; + this.chkMonday.Size = new System.Drawing.Size(85, 24); + this.chkMonday.TabIndex = 11; + this.chkMonday.Text = "Monday"; + this.chkMonday.UseVisualStyleBackColor = true; + this.chkMonday.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // chkSunday + // + this.chkSunday.AutoSize = true; + this.chkSunday.Location = new System.Drawing.Point(69, 155); + this.chkSunday.Name = "chkSunday"; + this.chkSunday.Size = new System.Drawing.Size(79, 24); + this.chkSunday.TabIndex = 10; + this.chkSunday.Text = "Sunday"; + this.chkSunday.UseVisualStyleBackColor = true; + this.chkSunday.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // gridWorkingDays + // + this.gridWorkingDays.AllowUserToAddRows = false; + this.gridWorkingDays.AllowUserToDeleteRows = false; + this.gridWorkingDays.AllowUserToResizeColumns = false; + this.gridWorkingDays.AllowUserToResizeRows = false; + this.gridWorkingDays.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; + this.gridWorkingDays.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.gridWorkingDays.Cursor = System.Windows.Forms.Cursors.Default; + this.gridWorkingDays.Location = new System.Drawing.Point(69, 360); + this.gridWorkingDays.Name = "gridWorkingDays"; + this.gridWorkingDays.ReadOnly = true; + this.gridWorkingDays.RowHeadersWidth = 51; + this.gridWorkingDays.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.gridWorkingDays.Size = new System.Drawing.Size(923, 188); + this.gridWorkingDays.TabIndex = 9; + this.gridWorkingDays.Text = "dataGridView1"; + this.gridWorkingDays.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridWorkingDays_CellDoubleClick); + // + // 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); + // + // 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); + // + // 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); + // + // 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); + // + // numWorkingDay + // + this.numWorkingDay.Location = new System.Drawing.Point(69, 105); + this.numWorkingDay.Name = "numWorkingDay"; + this.numWorkingDay.PlaceholderText = "No. of working day"; + this.numWorkingDay.Size = new System.Drawing.Size(150, 27); + this.numWorkingDay.TabIndex = 25; + this.numWorkingDay.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // numWHSunday + // + this.numWHSunday.Location = new System.Drawing.Point(200, 155); + this.numWHSunday.Name = "numWHSunday"; + this.numWHSunday.PlaceholderText = "Working hour"; + this.numWHSunday.Size = new System.Drawing.Size(98, 27); + this.numWHSunday.TabIndex = 26; + this.numWHSunday.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // numWHMonday + // + this.numWHMonday.Location = new System.Drawing.Point(200, 205); + this.numWHMonday.Name = "numWHMonday"; + this.numWHMonday.PlaceholderText = "Working hour"; + this.numWHMonday.Size = new System.Drawing.Size(98, 27); + this.numWHMonday.TabIndex = 27; + this.numWHMonday.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // numWHTuesday + // + this.numWHTuesday.Location = new System.Drawing.Point(200, 255); + this.numWHTuesday.Name = "numWHTuesday"; + this.numWHTuesday.PlaceholderText = "Working hour"; + this.numWHTuesday.Size = new System.Drawing.Size(98, 27); + this.numWHTuesday.TabIndex = 28; + this.numWHTuesday.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // numWHWednesday + // + this.numWHWednesday.Location = new System.Drawing.Point(200, 305); + this.numWHWednesday.Name = "numWHWednesday"; + this.numWHWednesday.PlaceholderText = "Working hour"; + this.numWHWednesday.Size = new System.Drawing.Size(98, 27); + this.numWHWednesday.TabIndex = 29; + this.numWHWednesday.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // numWHThursday + // + this.numWHThursday.Location = new System.Drawing.Point(531, 155); + this.numWHThursday.Name = "numWHThursday"; + this.numWHThursday.PlaceholderText = "Working hour"; + this.numWHThursday.Size = new System.Drawing.Size(98, 27); + this.numWHThursday.TabIndex = 30; + this.numWHThursday.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // numWHFriday + // + this.numWHFriday.Location = new System.Drawing.Point(531, 205); + this.numWHFriday.Name = "numWHFriday"; + this.numWHFriday.PlaceholderText = "Working hour"; + this.numWHFriday.Size = new System.Drawing.Size(98, 27); + this.numWHFriday.TabIndex = 31; + this.numWHFriday.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // numWHSaturday + // + this.numWHSaturday.Location = new System.Drawing.Point(531, 255); + this.numWHSaturday.Name = "numWHSaturday"; + this.numWHSaturday.PlaceholderText = "Working hour"; + this.numWHSaturday.Size = new System.Drawing.Size(98, 27); + this.numWHSaturday.TabIndex = 32; + this.numWHSaturday.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fnOnlyDecimal_KeyPress); + // + // WorkingDaySubForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.numWHSaturday); + this.Controls.Add(this.numWHFriday); + this.Controls.Add(this.numWHThursday); + this.Controls.Add(this.numWHWednesday); + this.Controls.Add(this.numWHTuesday); + this.Controls.Add(this.numWHMonday); + this.Controls.Add(this.numWHSunday); + this.Controls.Add(this.numWorkingDay); + this.Controls.Add(this.btnInsert); + this.Controls.Add(this.btnUpdate); + this.Controls.Add(this.btnDelete); + this.Controls.Add(this.btnCansel); + this.Controls.Add(this.gridWorkingDays); + this.Controls.Add(this.chkSunday); + this.Controls.Add(this.chkMonday); + this.Controls.Add(this.chkTuesday); + this.Controls.Add(this.chkWednesday); + this.Controls.Add(this.chkThursday); + this.Controls.Add(this.chkFriday); + this.Controls.Add(this.chkSaturday); + this.Controls.Add(this.lblCaption); + this.Name = "WorkingDaySubForm"; + this.Size = new System.Drawing.Size(1017, 600); + ((System.ComponentModel.ISupportInitialize)(this.gridWorkingDays)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblCaption; + private System.Windows.Forms.CheckBox chkSaturday; + private System.Windows.Forms.CheckBox chkFriday; + private System.Windows.Forms.CheckBox chkThursday; + private System.Windows.Forms.CheckBox chkWednesday; + private System.Windows.Forms.CheckBox chkTuesday; + private System.Windows.Forms.CheckBox chkMonday; + private System.Windows.Forms.CheckBox chkSunday; + private System.Windows.Forms.DataGridView gridWorkingDays; + private System.Windows.Forms.Button btnCansel; + private System.Windows.Forms.Button btnDelete; + private System.Windows.Forms.Button btnUpdate; + private System.Windows.Forms.Button btnInsert; + private System.Windows.Forms.TextBox numWorkingDay; + private System.Windows.Forms.TextBox numWHSunday; + private System.Windows.Forms.TextBox numWHMonday; + private System.Windows.Forms.TextBox numWHTuesday; + private System.Windows.Forms.TextBox numWHWednesday; + private System.Windows.Forms.TextBox numWHThursday; + private System.Windows.Forms.TextBox numWHFriday; + private System.Windows.Forms.TextBox numWHSaturday; + } +} diff --git a/TimeTable_App/Forms/SubForms/WorkingDaySubForm.cs b/TimeTable_App/Forms/SubForms/WorkingDaySubForm.cs new file mode 100644 index 0000000..c317f48 --- /dev/null +++ b/TimeTable_App/Forms/SubForms/WorkingDaySubForm.cs @@ -0,0 +1,548 @@ +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; + +/* + * Class Name - WorkingDaySubForm + * Author - Dimuthu Abeysinghe + * Date - 17/08/2020 + * Description - Working Days + * + * Version Control + * * [Dimuthu Abeysinghe] + * Implement the Working days Form and configure singleton pattern. + * + */ + +namespace TimeTable_App.Forms.SubForms +{ + public partial class WorkingDaySubForm : UserControl + { + private static WorkingDaySubForm _instance; + private FormCtrl formCtrl; + + public static WorkingDaySubForm Instance + { + get + { + if (_instance == null) _instance = new WorkingDaySubForm(); + return _instance; + } + } + + public WorkingDaySubForm() + { + InitializeComponent(); + formCtrl = new FormCtrl(); + initForm(); + } + + private void initForm() + { + isModify = false; + isShowSunday = false; + isShowMonday = false; + isShowTuesday = false; + isShowWednesday = false; + isShowThursday = false; + isShowFriday = false; + isShowSaturday = false; + + numWorkingDay.Text = ""; + chkSunday.Checked = false; + chkMonday.Checked = false; + chkTuesday.Checked = false; + chkWednesday.Checked = false; + chkThursday.Checked = false; + chkFriday.Checked = false; + chkSaturday.Checked = false; + + numWorkingDay.Focus(); + numWorkingDay.Enabled = true; + btnInsert.Enabled = true; + btnCansel.Enabled = true; + btnUpdate.Enabled = false; + btnDelete.Enabled = false; + + numWHSunday.Hide(); + numWHMonday.Hide(); + numWHTuesday.Hide(); + numWHWednesday.Hide(); + numWHThursday.Hide(); + numWHFriday.Hide(); + numWHSaturday.Hide(); + + + ActionResult workingDayResult = formCtrl._getFormData(typeof(WorkingDaySubFormModel), "WorkingDays"); + List depList = workingDayResult.Data; + + var selectList = depList.Where(dep => dep.status == "A").ToList(); + //var result = depList.OrderByDescending(y => y.WorkHourPerDay).First(); + + gridWorkingDays.DataSource = selectList; + gridWorkingDays.Columns[0].HeaderCell.Value = "#"; + gridWorkingDays.Columns[1].HeaderCell.Value = "Working days"; + gridWorkingDays.Columns[2].HeaderCell.Value = "Working hours per day"; + gridWorkingDays.Columns[3].HeaderCell.Value = "Status"; + gridWorkingDays.RowHeadersVisible = false; + this.gridWorkingDays.Columns["Status"].Visible = false; + + this.gridWorkingDays.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; + this.gridWorkingDays.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; + this.gridWorkingDays.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + //this.gridWorkingDays.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + + } + + private void btnInsert_Click(object sender, EventArgs e) + { + string statusSunday = "I", statusMonday = "I", statusTuesday = "I", statusWednesday = "I"; + string statusThursday = "I", statusFriday = "I", statusSaturday = "I"; + int intCount = 0; + if (chkSunday.Checked) + { + statusSunday = "A"; + intCount++; + } + if (chkMonday.Checked) + { + statusMonday = "A"; + intCount++; + } + if (chkTuesday.Checked) + { + statusTuesday = "A"; + intCount++; + } + if (chkWednesday.Checked) + { + statusWednesday = "A"; + intCount++; + } + if (chkThursday.Checked) + { + statusThursday = "A"; + intCount++; + } + if (chkFriday.Checked) + { + statusFriday = "A"; + intCount++; + } + if (chkSaturday.Checked) + { + statusSaturday = "A"; + intCount++; + } + + if (!isModify && numWorkingDay.Text == "") + { + MessageBox.Show("Please enter number of working days!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + numWorkingDay.Focus(); + } + else if (!isModify && Int32.Parse(numWorkingDay.Text) != intCount) + { + MessageBox.Show("Number of working days miss match. Please check again!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + numWorkingDay.Focus(); + } + else + { + bool booValidSunday = true, booValidMonday = true, booValidTuesday = true, booValidWednesday = true, booValidThursday = true, booValidFriday = true, booValidSaturday = true; + if (isShowSunday) { + ActionResult updateResultSunday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 1, + StrWorkingDays = "Sunday", + WorkHourPerDay = float.Parse(numWHSunday.Text), + status = statusSunday + }); + if (updateResultSunday.State) { booValidSunday = true; } + else booValidSunday = false; + } + if (isShowMonday) { + ActionResult updateResultMonday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 2, + StrWorkingDays = "Monday", + WorkHourPerDay = float.Parse(numWHMonday.Text), + status = statusMonday + }); + if (updateResultMonday.State) { booValidMonday = true; } + else booValidMonday = false; + } + + if (isShowTuesday) { + ActionResult updateResultTuesday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 3, + StrWorkingDays = "Tuesday", + WorkHourPerDay = float.Parse(numWHTuesday.Text), + status = statusTuesday + }); + if (updateResultTuesday.State) { booValidTuesday = true; } + else booValidTuesday = false; + } + + if (isShowWednesday) { + ActionResult updateResultWednesday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 4, + StrWorkingDays = "Wednesday", + WorkHourPerDay = float.Parse(numWHWednesday.Text.Trim()), + status = statusWednesday + }); + if (updateResultWednesday.State) { booValidWednesday = true; } + else booValidWednesday = false; + } + + if (isShowThursday) { + ActionResult updateResultThursday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 5, + StrWorkingDays = "Thursday", + WorkHourPerDay = float.Parse(numWHThursday.Text.Trim()), + status = statusThursday + }); + if (updateResultThursday.State) { booValidThursday = true; } + else booValidThursday = false; + } + + if (isShowFriday) + { + ActionResult updateResultFriday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 6, + StrWorkingDays = "Friday", + WorkHourPerDay = float.Parse(numWHFriday.Text.Trim()), + status = statusFriday + }); + if (updateResultFriday.State) { booValidFriday = true; } + else booValidFriday = false; + } + + if (isShowSaturday) + { + ActionResult updateResultSaturday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 7, + StrWorkingDays = "Saturday", + WorkHourPerDay = float.Parse(numWHSaturday.Text.Trim()), + status = statusSaturday + }); + if (updateResultSaturday.State) { booValidSaturday = true; } + else booValidSaturday = false; + } + + + if (booValidSunday && booValidMonday && booValidTuesday && booValidWednesday && booValidThursday && booValidFriday && booValidSaturday) + { + if(isModify == false) + MessageBox.Show("Sucessfully Saved!", "Saved Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MessageBox.Show("Sucessfully Updated!", "Saved Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + + initForm(); + } + else + { + MessageBox.Show("Something went wrong. Please try again!", "Saved Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + bool isModify = false; + private void btnUpdate_Click(object sender, EventArgs e) + { + isModify = true; + btnInsert_Click(sender, e); + } + + private void btnDelete_Click(object sender, EventArgs e) + { + bool booValidSunday = true, booValidMonday = true, booValidTuesday = true, booValidWednesday = true, booValidThursday = true, booValidFriday = true, booValidSaturday = true; + if (isShowSunday) + { + ActionResult updateResultSunday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 1, + StrWorkingDays = "Sunday", + WorkHourPerDay = float.Parse(numWHSunday.Text), + status = "I" + }); + if (updateResultSunday.State) { booValidSunday = true; } + else booValidSunday = false; + } + if (isShowMonday) + { + ActionResult updateResultMonday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 2, + StrWorkingDays = "Monday", + WorkHourPerDay = float.Parse(numWHMonday.Text), + status = "I" + }); + if (updateResultMonday.State) { booValidMonday = true; } + else booValidMonday = false; + } + + if (isShowTuesday) + { + ActionResult updateResultTuesday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 3, + StrWorkingDays = "Tuesday", + WorkHourPerDay = float.Parse(numWHTuesday.Text), + status = "I" + }); + if (updateResultTuesday.State) { booValidTuesday = true; } + else booValidTuesday = false; + } + + if (isShowWednesday) + { + ActionResult updateResultWednesday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 4, + StrWorkingDays = "Wednesday", + WorkHourPerDay = float.Parse(numWHWednesday.Text.Trim()), + status = "I" + }); + if (updateResultWednesday.State) { booValidWednesday = true; } + else booValidWednesday = false; + } + + if (isShowThursday) + { + ActionResult updateResultThursday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 5, + StrWorkingDays = "Thursday", + WorkHourPerDay = float.Parse(numWHThursday.Text.Trim()), + status = "I" + }); + if (updateResultThursday.State) { booValidThursday = true; } + else booValidThursday = false; + } + + if (isShowFriday) + { + ActionResult updateResultFriday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 6, + StrWorkingDays = "Friday", + WorkHourPerDay = float.Parse(numWHFriday.Text.Trim()), + status = "I" + }); + if (updateResultFriday.State) { booValidFriday = true; } + else booValidFriday = false; + } + + if (isShowSaturday) + { + ActionResult updateResultSaturday = formCtrl._updateFormData(new WorkingDaySubFormModel() + { + id = 7, + StrWorkingDays = "Saturday", + WorkHourPerDay = float.Parse(numWHSaturday.Text.Trim()), + status = "I" + }); + if (updateResultSaturday.State) { booValidSaturday = true; } + else booValidSaturday = false; + } + + + if (booValidSunday && booValidMonday && booValidTuesday && booValidWednesday && booValidThursday && booValidFriday && booValidSaturday) + { + MessageBox.Show("Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); + initForm(); + } + else + { + MessageBox.Show("Something went wrong. Please try again!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void btnCansel_Click(object sender, EventArgs e) + { + initForm(); + } + + private void gridWorkingDays_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + //initForm(); + DataGridViewRow selectedRow = this.gridWorkingDays.SelectedRows[0]; + if (selectedRow != null) + { + if (selectedRow.Cells[1].Value.ToString() == "Sunday") { + numWHSunday.Show(); + numWHSunday.Text = selectedRow.Cells[2].Value.ToString(); + if (selectedRow.Cells[3].Value.ToString() == "A") { + chkSunday.Checked = true; + } + } + if (selectedRow.Cells[1].Value.ToString() == "Monday") + { + numWHMonday.Show(); + numWHMonday.Text = selectedRow.Cells[2].Value.ToString(); + if (selectedRow.Cells[3].Value.ToString() == "A") + { + chkMonday.Checked = true; + } + } + if (selectedRow.Cells[1].Value.ToString() == "Tuesday") + { + numWHTuesday.Show(); + numWHTuesday.Text = selectedRow.Cells[2].Value.ToString(); + if (selectedRow.Cells[3].Value.ToString() == "A") + { + chkTuesday.Checked = true; + } + } + if (selectedRow.Cells[1].Value.ToString() == "Wednesday") + { + numWHWednesday.Show(); + numWHWednesday.Text = selectedRow.Cells[2].Value.ToString(); + if (selectedRow.Cells[3].Value.ToString() == "A") + { + chkWednesday.Checked = true; + } + } + if (selectedRow.Cells[1].Value.ToString() == "Thursday") + { + numWHThursday.Show(); + numWHThursday.Text = selectedRow.Cells[2].Value.ToString(); + if (selectedRow.Cells[3].Value.ToString() == "A") + { + chkThursday.Checked = true; + } + } + if (selectedRow.Cells[1].Value.ToString() == "Friday") + { + numWHFriday.Show(); + numWHFriday.Text = selectedRow.Cells[2].Value.ToString(); + if (selectedRow.Cells[3].Value.ToString() == "A") + { + chkFriday.Checked = true; + } + } + if (selectedRow.Cells[1].Value.ToString() == "Saturday") + { + numWHSaturday.Show(); + numWHSaturday.Text = selectedRow.Cells[2].Value.ToString(); + if (selectedRow.Cells[3].Value.ToString() == "A") + { + chkSaturday.Checked = true; + } + } + + numWorkingDay.Enabled = false; + btnUpdate.Enabled = true; + btnInsert.Enabled = false; + btnDelete.Enabled = true; + } + } + + bool isShowSunday = false, isShowMonday = false, isShowTuesday = false, isShowWednesday = false, isShowThursday = false, isShowFriday = false, isShowSaturday = false; + private void checkBox_CheckedChanged(object sender, EventArgs e) + { + if (chkSunday.Checked) + { + numWHSunday.Show(); + isShowSunday = true; + } + else + { + numWHSunday.Hide(); + isShowSunday = false; + } + + if (chkMonday.Checked) + { + numWHMonday.Show(); + isShowMonday = true; + } + else + { + numWHMonday.Hide(); + isShowMonday = false; + } + + if (chkTuesday.Checked) + { + numWHTuesday.Show(); + isShowTuesday = true; + } + else + { + numWHTuesday.Hide(); + isShowTuesday = false; + } + + if (chkWednesday.Checked) + { + numWHWednesday.Show(); + isShowWednesday = true; + } + else + { + numWHWednesday.Hide(); + isShowWednesday = false; + } + + if (chkThursday.Checked) + { + numWHThursday.Show(); + isShowThursday = true; + } + else + { + numWHThursday.Hide(); + isShowThursday = false; + } + + if (chkFriday.Checked) + { + numWHFriday.Show(); + isShowFriday = true; + } + else + { + numWHFriday.Hide(); + isShowFriday = false; + } + + if (chkSaturday.Checked) + { + numWHSaturday.Show(); + isShowSaturday = true; + } + else + { + numWHSaturday.Hide(); + isShowSaturday = false; + } + } + + + private void fnOnlyDecimal_KeyPress(object sender, KeyPressEventArgs e) + { + if (char.IsNumber(e.KeyChar) || e.KeyChar == '.') + { + + } + else + { + e.Handled = e.KeyChar != (char)Keys.Back; + } + } + } +} + diff --git a/TimeTable_App/Forms/SubForms/WorkingDaySubForm.resx b/TimeTable_App/Forms/SubForms/WorkingDaySubForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/TimeTable_App/Forms/SubForms/WorkingDaySubForm.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/Global/TimeTableDbContext.cs b/TimeTable_App/Global/TimeTableDbContext.cs index bdc9d9e..be641e2 100644 --- a/TimeTable_App/Global/TimeTableDbContext.cs +++ b/TimeTable_App/Global/TimeTableDbContext.cs @@ -34,5 +34,8 @@ public TimeTableDbContext() : base("DBCON") public DbSet Buildings { get; set; } public DbSet EmployeeLevels { get; set; } public DbSet AppSubForms { get; set; } + public DbSet WorkingDays { get; set; } + public DbSet TimeSlots { get; set; } + } } diff --git a/TimeTable_App/Migrations/Configuration.cs b/TimeTable_App/Migrations/Configuration.cs index 1abdf77..b3e4e9d 100644 --- a/TimeTable_App/Migrations/Configuration.cs +++ b/TimeTable_App/Migrations/Configuration.cs @@ -14,6 +14,12 @@ protected override void Seed(TimeTable_App.Global.TimeTableDbContext context) { // Adding Forms context.AppForms.Add(new AppFormsModel() { FormName = "Lecturers", FormDesc = "Manage Lecturers", FormController = "LecturersForm", Status = "A"}); + context.AppForms.Add(new AppFormsModel() { FormName = "Working D and H", FormDesc = "Working Days and Time", FormController = "WorkingDayTimeForm", Status = "A" }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Working Days", SubFormDesc = "Working Days", SubFormController = "WorkingDaySubForm", Status = "A", FormId = 2 }); + context.AppSubForms.Add(new AppSubFormsModel() { SubFormName = "Time Slots", SubFormDesc = "Time Slots", SubFormController = "TimeSlotSubForm", Status = "A", FormId = 2 }); + context.AppForms.Add(new AppFormsModel() { FormName = "Subjects", FormDesc = "Manage Lecturers", FormController = "SubjectsForm", Status = "A" }); + context.AppForms.Add(new AppFormsModel() { FormName = "Students", FormDesc = "Manage Lecturers", FormController = "StudentsForm", Status = "A" }); + context.AppForms.Add(new AppFormsModel() { FormName = "Locations", FormDesc = "Manage Lecturers", FormController = "LocationsForm", Status = "A" }); // Adding Faculties [Kusal Perera] context.Faculties.Add(new FacultyModel() { FacultyName = "Computing", FacultyDesc = "Computing Faculty" }); @@ -43,6 +49,19 @@ protected override void Seed(TimeTable_App.Global.TimeTableDbContext context) context.EmployeeLevels.Add(new EmployeeLevelModel() { EmployeeLevelName = "Lecturer", EmployeeLevelDesc = "Lecturer" }); context.EmployeeLevels.Add(new EmployeeLevelModel() { EmployeeLevelName = "Assistant Lecturer", EmployeeLevelDesc = "Assistant Lecturer" }); context.EmployeeLevels.Add(new EmployeeLevelModel() { EmployeeLevelName = "Instructors", EmployeeLevelDesc = "Instructors" }); + + // Adding Working Days & Hours [Dimuthu Abeysinghe] + context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Sunday", WorkHourPerDay = 0, status = "I" }); + context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Monday", WorkHourPerDay = 0, status = "I" }); + context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Tuesday", WorkHourPerDay = 0, status = "I" }); + context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Wednesday", WorkHourPerDay = 0, status = "I" }); + context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Thursday", WorkHourPerDay = 0, status = "I" }); + context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Friday", WorkHourPerDay = 0, status = "I" }); + context.WorkingDays.Add(new WorkingDaySubFormModel() { StrWorkingDays = "Saturday", WorkHourPerDay = 0, status = "I" }); + + // Adding Time Slots [Dimuthu Abeysinghe] + //context.TimeSlots.Add(new TimeSlotSubFormModel() { startTime = "8:30", endTime = "8:30" }); + } } } diff --git a/TimeTable_App/Models/TimeSlotSubFormModel.cs b/TimeTable_App/Models/TimeSlotSubFormModel.cs new file mode 100644 index 0000000..e6a892b --- /dev/null +++ b/TimeTable_App/Models/TimeSlotSubFormModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using TimeTable_App.Global; + +/* + * Class Name - TimeSlotSubFormModel + * Author - Dimuthu Abeysinghe + * Date - 20/08/2020 + * Description - Handle the details about the Time slots. + * + * Version Control + * * [Dimuthu Abeysinghe] + * Implement the class to handle Time slots. + * + */ + +namespace TimeTable_App.Models +{ + public class TimeSlotSubFormModel + { + [Key] + public int id { get; set; } + [Required] + public string startTime { get; set; } + [Required] + public string endTime { get; set; } + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + if (type == "TimeSlots") + { + return _dbContext.TimeSlots.AsNoTracking().ToList(); + } + + return null; + } + } +} diff --git a/TimeTable_App/Models/WorkingDaySubFormModel.cs b/TimeTable_App/Models/WorkingDaySubFormModel.cs new file mode 100644 index 0000000..f39c28a --- /dev/null +++ b/TimeTable_App/Models/WorkingDaySubFormModel.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using TimeTable_App.Global; + +/* + * Class Name - WorkingDaySubFormModel + * Author - Dimuthu Abeysinghe + * Date - 20/08/2020 + * Description - Handle the details about the Working Days. + * + * Version Control + * * [Dimuthu Abeysinghe] + * Implement the class to handle Working Days details. + * + */ + +namespace TimeTable_App.Models +{ + public class WorkingDaySubFormModel + { + [Key] + public int id { get; set; } + [Required] + [MaxLength(50)] + public string StrWorkingDays { get; set; } + [Required] + public float WorkHourPerDay { get; set; } + [Required] + public string status { get; set; } + + public dynamic GetFormData(TimeTableDbContext _dbContext, string type) + { + if (type == "WorkingDays") + { + return _dbContext.WorkingDays.AsNoTracking().ToList(); + } + + return null; + } + + } +} diff --git a/TimeTable_App/TimeTable_App.csproj b/TimeTable_App/TimeTable_App.csproj index bef2ad9..76c6bfe 100644 --- a/TimeTable_App/TimeTable_App.csproj +++ b/TimeTable_App/TimeTable_App.csproj @@ -25,8 +25,4 @@ - - - - \ No newline at end of file