diff --git a/.vs/PayrollSystem/FileContentIndex/102ea028-e367-4fa1-b7be-6b710587cf83.vsidx b/.vs/PayrollSystem/FileContentIndex/102ea028-e367-4fa1-b7be-6b710587cf83.vsidx
new file mode 100644
index 0000000..92b6ea1
Binary files /dev/null and b/.vs/PayrollSystem/FileContentIndex/102ea028-e367-4fa1-b7be-6b710587cf83.vsidx differ
diff --git a/.vs/PayrollSystem/FileContentIndex/1af5216d-2cc8-44cf-aaa7-65657e6a929e.vsidx b/.vs/PayrollSystem/FileContentIndex/1af5216d-2cc8-44cf-aaa7-65657e6a929e.vsidx
new file mode 100644
index 0000000..1fea084
Binary files /dev/null and b/.vs/PayrollSystem/FileContentIndex/1af5216d-2cc8-44cf-aaa7-65657e6a929e.vsidx differ
diff --git a/.vs/PayrollSystem/FileContentIndex/1e1e6c95-f43f-4a7d-a9de-4df138af59eb.vsidx b/.vs/PayrollSystem/FileContentIndex/1e1e6c95-f43f-4a7d-a9de-4df138af59eb.vsidx
new file mode 100644
index 0000000..9ddfbd5
Binary files /dev/null and b/.vs/PayrollSystem/FileContentIndex/1e1e6c95-f43f-4a7d-a9de-4df138af59eb.vsidx differ
diff --git a/.vs/PayrollSystem/FileContentIndex/6971894b-3abe-4e64-9779-c1d5c8a0a542.vsidx b/.vs/PayrollSystem/FileContentIndex/6971894b-3abe-4e64-9779-c1d5c8a0a542.vsidx
deleted file mode 100644
index 300c28b..0000000
Binary files a/.vs/PayrollSystem/FileContentIndex/6971894b-3abe-4e64-9779-c1d5c8a0a542.vsidx and /dev/null differ
diff --git a/.vs/PayrollSystem/FileContentIndex/7bcce091-433e-460f-9231-9ef278a4ac66.vsidx b/.vs/PayrollSystem/FileContentIndex/7bcce091-433e-460f-9231-9ef278a4ac66.vsidx
deleted file mode 100644
index b4248f3..0000000
Binary files a/.vs/PayrollSystem/FileContentIndex/7bcce091-433e-460f-9231-9ef278a4ac66.vsidx and /dev/null differ
diff --git a/.vs/PayrollSystem/FileContentIndex/daf9380f-7999-48e8-a2a1-fdd0e5d57a7b.vsidx b/.vs/PayrollSystem/FileContentIndex/daf9380f-7999-48e8-a2a1-fdd0e5d57a7b.vsidx
deleted file mode 100644
index deea61b..0000000
Binary files a/.vs/PayrollSystem/FileContentIndex/daf9380f-7999-48e8-a2a1-fdd0e5d57a7b.vsidx and /dev/null differ
diff --git a/.vs/PayrollSystem/v17/.suo b/.vs/PayrollSystem/v17/.suo
index 89f067a..ed83784 100644
Binary files a/.vs/PayrollSystem/v17/.suo and b/.vs/PayrollSystem/v17/.suo differ
diff --git a/.vs/PayrollSystem/v17/DocumentLayout.json b/.vs/PayrollSystem/v17/DocumentLayout.json
index 61950bd..8d32531 100644
--- a/.vs/PayrollSystem/v17/DocumentLayout.json
+++ b/.vs/PayrollSystem/v17/DocumentLayout.json
@@ -7,15 +7,15 @@
"RelativeMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|solutionrelative:payrollsystem\\form_modify_employee.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
- "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|c:\\users\\warlock\\source\\repos\\payrollsystem\\payrollsystem\\form_employees.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|C:\\Users\\warlock\\source\\repos\\PayrollSystem\\payrollsystem\\form_employees.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|solutionrelative:payrollsystem\\form_employees.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
- "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|c:\\users\\warlock\\source\\repos\\payrollsystem\\payrollsystem\\form_modify_employee.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
+ "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|C:\\Users\\warlock\\source\\repos\\PayrollSystem\\payrollsystem\\form_modify_employee.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
"RelativeMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|solutionrelative:payrollsystem\\form_modify_employee.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
},
{
- "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|c:\\users\\warlock\\source\\repos\\payrollsystem\\payrollsystem\\form_dashboard.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|C:\\Users\\warlock\\source\\repos\\PayrollSystem\\payrollsystem\\form_dashboard.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|solutionrelative:payrollsystem\\form_dashboard.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
@@ -23,11 +23,11 @@
"RelativeMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|solutionrelative:payrollsystem\\form_main.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
- "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|c:\\users\\warlock\\source\\repos\\payrollsystem\\payrollsystem\\helpers.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|C:\\Users\\warlock\\source\\repos\\PayrollSystem\\payrollsystem\\helpers.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|solutionrelative:payrollsystem\\helpers.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
- "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|c:\\users\\warlock\\source\\repos\\payrollsystem\\payrollsystem\\form_employees.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
+ "AbsoluteMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|C:\\Users\\warlock\\source\\repos\\PayrollSystem\\payrollsystem\\form_employees.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
"RelativeMoniker": "D:0:0:{F11EDBAB-9CD5-45D6-A949-595713DC63E2}|PayrollSystem\\PayrollSystem.csproj|solutionrelative:payrollsystem\\form_employees.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
},
{
@@ -74,8 +74,7 @@
"RelativeToolTip": "PayrollSystem\\Helpers.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAoAAAApAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T17:37:30.193Z",
- "EditorCaption": ""
+ "WhenOpened": "2024-08-25T17:37:30.193Z"
},
{
"$type": "Document",
@@ -85,7 +84,7 @@
"RelativeDocumentMoniker": "PayrollSystem\\form_modify_employee.cs",
"ToolTip": "C:\\Users\\warlock\\source\\repos\\PayrollSystem\\PayrollSystem\\form_modify_employee.cs",
"RelativeToolTip": "PayrollSystem\\form_modify_employee.cs",
- "ViewState": "AQIAABEAAAAAAAAAAAAQwCUAAABGAAAA",
+ "ViewState": "AQIAABEAAAAAAAAAAAAxwCUAAABGAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-08-25T17:31:29.274Z",
"EditorCaption": ""
@@ -99,8 +98,7 @@
"ToolTip": "C:\\Users\\warlock\\source\\repos\\PayrollSystem\\PayrollSystem\\form_modify_employee.cs [Design]",
"RelativeToolTip": "PayrollSystem\\form_modify_employee.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T17:28:33.607Z",
- "EditorCaption": " [Design]"
+ "WhenOpened": "2024-08-25T17:28:33.607Z"
},
{
"$type": "Document",
@@ -112,8 +110,7 @@
"RelativeToolTip": "PayrollSystem\\form_employees.cs",
"ViewState": "AQIAAEIAAAAAAAAAAAAmwEcAAABKAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T17:03:13.406Z",
- "EditorCaption": ""
+ "WhenOpened": "2024-08-25T17:03:13.406Z"
},
{
"$type": "Document",
@@ -124,8 +121,7 @@
"ToolTip": "C:\\Users\\warlock\\source\\repos\\PayrollSystem\\PayrollSystem\\form_employees.cs [Design]",
"RelativeToolTip": "PayrollSystem\\form_employees.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T17:03:11.483Z",
- "EditorCaption": " [Design]"
+ "WhenOpened": "2024-08-25T17:03:11.483Z"
},
{
"$type": "Document",
@@ -137,8 +133,7 @@
"RelativeToolTip": "PayrollSystem\\form_dashboard.cs",
"ViewState": "AQIAAAYAAAAAAAAAAAAIwBsAAABKAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T11:01:49.474Z",
- "EditorCaption": ""
+ "WhenOpened": "2024-08-25T11:01:49.474Z"
},
{
"$type": "Document",
@@ -149,8 +144,7 @@
"ToolTip": "C:\\Users\\warlock\\source\\repos\\PayrollSystem\\PayrollSystem\\payrolldbDataSet.xsd",
"RelativeToolTip": "PayrollSystem\\payrolldbDataSet.xsd",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003579|",
- "WhenOpened": "2024-08-25T10:05:24.481Z",
- "EditorCaption": ""
+ "WhenOpened": "2024-08-25T10:05:24.481Z"
},
{
"$type": "Document",
@@ -162,8 +156,7 @@
"RelativeToolTip": "PayrollSystem\\Program.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAgAAAAEAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T10:05:19.141Z",
- "EditorCaption": ""
+ "WhenOpened": "2024-08-25T10:05:19.141Z"
},
{
"$type": "Document",
@@ -175,8 +168,7 @@
"RelativeToolTip": "PayrollSystem\\Form1.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABwAAABTAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T06:05:16.764Z",
- "EditorCaption": ""
+ "WhenOpened": "2024-08-25T06:05:16.764Z"
},
{
"$type": "Document",
@@ -188,8 +180,7 @@
"RelativeToolTip": "PayrollSystem\\form_main.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABgAAAAkAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T06:04:04.236Z",
- "EditorCaption": ""
+ "WhenOpened": "2024-08-25T06:04:04.236Z"
},
{
"$type": "Document",
@@ -200,8 +191,7 @@
"ToolTip": "C:\\Users\\warlock\\source\\repos\\PayrollSystem\\PayrollSystem\\form_dashboard.cs [Design]",
"RelativeToolTip": "PayrollSystem\\form_dashboard.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T05:38:00.048Z",
- "EditorCaption": " [Design]"
+ "WhenOpened": "2024-08-25T05:38:00.048Z"
},
{
"$type": "Document",
@@ -212,8 +202,7 @@
"ToolTip": "C:\\Users\\warlock\\source\\repos\\PayrollSystem\\PayrollSystem\\form_main.cs [Design]",
"RelativeToolTip": "PayrollSystem\\form_main.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T05:32:49.675Z",
- "EditorCaption": " [Design]"
+ "WhenOpened": "2024-08-25T05:32:49.675Z"
},
{
"$type": "Document",
@@ -224,8 +213,7 @@
"ToolTip": "C:\\Users\\warlock\\source\\repos\\PayrollSystem\\PayrollSystem\\Form1.cs [Design]",
"RelativeToolTip": "PayrollSystem\\Form1.cs [Design]",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
- "WhenOpened": "2024-08-25T05:21:39.964Z",
- "EditorCaption": " [Design]"
+ "WhenOpened": "2024-08-25T05:21:39.964Z"
}
]
}
diff --git a/PayrollSystem/PayrollSystem.csproj b/PayrollSystem/PayrollSystem.csproj
index dd614fe..85da69e 100644
--- a/PayrollSystem/PayrollSystem.csproj
+++ b/PayrollSystem/PayrollSystem.csproj
@@ -73,6 +73,12 @@
form_dashboard.cs
+
+ Form
+
+
+ form_departments.cs
+
Form
@@ -85,6 +91,12 @@
form_main.cs
+
+ Form
+
+
+ form_modify_department.cs
+
Form
@@ -110,12 +122,18 @@
form_dashboard.cs
+
+ form_departments.cs
+
form_employees.cs
form_main.cs
+
+ form_modify_department.cs
+
form_modify_employee.cs
diff --git a/PayrollSystem/bin/Debug/PayrollSystem.exe b/PayrollSystem/bin/Debug/PayrollSystem.exe
index ea10584..b82d451 100644
Binary files a/PayrollSystem/bin/Debug/PayrollSystem.exe and b/PayrollSystem/bin/Debug/PayrollSystem.exe differ
diff --git a/PayrollSystem/bin/Debug/PayrollSystem.pdb b/PayrollSystem/bin/Debug/PayrollSystem.pdb
index 82d7b2c..c5f3f03 100644
Binary files a/PayrollSystem/bin/Debug/PayrollSystem.pdb and b/PayrollSystem/bin/Debug/PayrollSystem.pdb differ
diff --git a/PayrollSystem/bin/Debug/payrolldb.mdf b/PayrollSystem/bin/Debug/payrolldb.mdf
index 8aa2fc9..e4c4758 100644
Binary files a/PayrollSystem/bin/Debug/payrolldb.mdf and b/PayrollSystem/bin/Debug/payrolldb.mdf differ
diff --git a/PayrollSystem/bin/Debug/payrolldb_log.ldf b/PayrollSystem/bin/Debug/payrolldb_log.ldf
index 2b3627e..d0eae8a 100644
Binary files a/PayrollSystem/bin/Debug/payrolldb_log.ldf and b/PayrollSystem/bin/Debug/payrolldb_log.ldf differ
diff --git a/PayrollSystem/form_departments.Designer.cs b/PayrollSystem/form_departments.Designer.cs
new file mode 100644
index 0000000..8aab32b
--- /dev/null
+++ b/PayrollSystem/form_departments.Designer.cs
@@ -0,0 +1,148 @@
+namespace PayrollSystem
+{
+ partial class form_departments
+ {
+ ///
+ /// 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 Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.list_departments = new System.Windows.Forms.ListView();
+ this.btnAdd = new System.Windows.Forms.Button();
+ this.btnEdit = new System.Windows.Forms.Button();
+ this.btnRemove = new System.Windows.Forms.Button();
+ this.btnShowEmployees = new System.Windows.Forms.Button();
+ this.col_ID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.col_Name = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.col_basic = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.col_employees = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.SuspendLayout();
+ //
+ // list_departments
+ //
+ this.list_departments.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.col_ID,
+ this.col_Name,
+ this.col_basic,
+ this.col_employees});
+ this.list_departments.FullRowSelect = true;
+ this.list_departments.HideSelection = false;
+ this.list_departments.Location = new System.Drawing.Point(12, 12);
+ this.list_departments.MultiSelect = false;
+ this.list_departments.Name = "list_departments";
+ this.list_departments.Size = new System.Drawing.Size(911, 633);
+ this.list_departments.TabIndex = 0;
+ this.list_departments.UseCompatibleStateImageBehavior = false;
+ this.list_departments.View = System.Windows.Forms.View.Details;
+ //
+ // btnAdd
+ //
+ this.btnAdd.Location = new System.Drawing.Point(929, 12);
+ this.btnAdd.Name = "btnAdd";
+ this.btnAdd.Size = new System.Drawing.Size(106, 62);
+ this.btnAdd.TabIndex = 1;
+ this.btnAdd.Text = "Add New Department";
+ this.btnAdd.UseVisualStyleBackColor = true;
+ this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
+ //
+ // btnEdit
+ //
+ this.btnEdit.Enabled = false;
+ this.btnEdit.Location = new System.Drawing.Point(929, 80);
+ this.btnEdit.Name = "btnEdit";
+ this.btnEdit.Size = new System.Drawing.Size(106, 62);
+ this.btnEdit.TabIndex = 2;
+ this.btnEdit.Text = "Edit selected Department";
+ this.btnEdit.UseVisualStyleBackColor = true;
+ //
+ // btnRemove
+ //
+ this.btnRemove.Enabled = false;
+ this.btnRemove.Location = new System.Drawing.Point(929, 148);
+ this.btnRemove.Name = "btnRemove";
+ this.btnRemove.Size = new System.Drawing.Size(106, 62);
+ this.btnRemove.TabIndex = 3;
+ this.btnRemove.Text = "Remove selected Department";
+ this.btnRemove.UseVisualStyleBackColor = true;
+ //
+ // btnShowEmployees
+ //
+ this.btnShowEmployees.Location = new System.Drawing.Point(929, 583);
+ this.btnShowEmployees.Name = "btnShowEmployees";
+ this.btnShowEmployees.Size = new System.Drawing.Size(106, 62);
+ this.btnShowEmployees.TabIndex = 4;
+ this.btnShowEmployees.Text = "Show Employees in Selected";
+ this.btnShowEmployees.UseVisualStyleBackColor = true;
+ this.btnShowEmployees.Click += new System.EventHandler(this.btnShowEmployees_Click);
+ //
+ // col_ID
+ //
+ this.col_ID.Text = "ID";
+ //
+ // col_Name
+ //
+ this.col_Name.Text = "Name";
+ this.col_Name.Width = 284;
+ //
+ // col_basic
+ //
+ this.col_basic.Text = "Basic";
+ this.col_basic.Width = 194;
+ //
+ // col_employees
+ //
+ this.col_employees.Text = "Employee Count";
+ this.col_employees.Width = 135;
+ //
+ // form_departments
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1047, 657);
+ this.Controls.Add(this.btnShowEmployees);
+ this.Controls.Add(this.btnRemove);
+ this.Controls.Add(this.btnEdit);
+ this.Controls.Add(this.btnAdd);
+ this.Controls.Add(this.list_departments);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.Name = "form_departments";
+ this.Text = "form_departments";
+ this.Load += new System.EventHandler(this.form_departments_Load);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ListView list_departments;
+ private System.Windows.Forms.Button btnAdd;
+ private System.Windows.Forms.Button btnEdit;
+ private System.Windows.Forms.Button btnRemove;
+ private System.Windows.Forms.Button btnShowEmployees;
+ private System.Windows.Forms.ColumnHeader col_ID;
+ private System.Windows.Forms.ColumnHeader col_Name;
+ private System.Windows.Forms.ColumnHeader col_basic;
+ private System.Windows.Forms.ColumnHeader col_employees;
+ }
+}
\ No newline at end of file
diff --git a/PayrollSystem/form_departments.cs b/PayrollSystem/form_departments.cs
new file mode 100644
index 0000000..a38f777
--- /dev/null
+++ b/PayrollSystem/form_departments.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Data.SqlClient;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PayrollSystem
+{
+ public partial class form_departments : Form
+ {
+ public form_departments()
+ {
+ InitializeComponent();
+ }
+
+ private void form_departments_Load(object sender, EventArgs e)
+ {
+ Search();
+ }
+
+
+ void Search()
+ {
+ string query = @"
+ SELECT
+ Departments.ID,
+ Departments.Name,
+ Departments.Basic,
+ COUNT(Employees.ID) AS EmployeeCount
+ FROM
+ Departments
+ LEFT JOIN
+ Employees ON Departments.ID = Employees.Department_ID
+ GROUP BY
+ Departments.ID, Departments.Name, Departments.Basic;
+ ";
+
+ using (SqlConnection con = new SqlConnection(Helpers.conString))
+ {
+ con.Open();
+ using (SqlCommand cmd = new SqlCommand(query, con)) {
+ using (SqlDataReader reader = cmd.ExecuteReader())
+ {
+ list_departments.Items.Clear();
+ while (reader.Read()) {
+ ListViewItem newItem = new ListViewItem(reader["ID"].ToString());
+ newItem.SubItems.Add(reader["Name"].ToString());
+ newItem.SubItems.Add(reader["Basic"].ToString());
+ newItem.SubItems.Add(reader["EmployeeCount"].ToString());
+
+ list_departments.Items.Add(newItem);
+ }
+ }
+
+ }
+ con.Close();
+ }
+ }
+
+ private void btnAdd_Click(object sender, EventArgs e)
+ {
+ form_modify_department addForm = new form_modify_department();
+ addForm.ShowDialog();
+
+ Search();
+ }
+
+ private void btnShowEmployees_Click(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/PayrollSystem/form_departments.resx b/PayrollSystem/form_departments.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/PayrollSystem/form_departments.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/PayrollSystem/form_employees.Designer.cs b/PayrollSystem/form_employees.Designer.cs
index f179150..2cc772e 100644
--- a/PayrollSystem/form_employees.Designer.cs
+++ b/PayrollSystem/form_employees.Designer.cs
@@ -47,8 +47,8 @@
this.combo_date_type = new System.Windows.Forms.ComboBox();
this.joined_date_picker = new System.Windows.Forms.DateTimePicker();
this.btnAdd = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
+ this.btnEdit = new System.Windows.Forms.Button();
+ this.btnRemove = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// list_employees
@@ -60,13 +60,16 @@
this.col_basic,
this.col_allowance,
this.col_joined});
+ this.list_employees.FullRowSelect = true;
this.list_employees.HideSelection = false;
this.list_employees.Location = new System.Drawing.Point(12, 72);
+ this.list_employees.MultiSelect = false;
this.list_employees.Name = "list_employees";
this.list_employees.Size = new System.Drawing.Size(941, 573);
this.list_employees.TabIndex = 0;
this.list_employees.UseCompatibleStateImageBehavior = false;
this.list_employees.View = System.Windows.Forms.View.Details;
+ this.list_employees.SelectedIndexChanged += new System.EventHandler(this.list_employees_SelectedIndexChanged);
//
// col_id
//
@@ -212,31 +215,35 @@
this.btnAdd.UseVisualStyleBackColor = true;
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
- // button1
+ // btnEdit
//
- this.button1.Location = new System.Drawing.Point(960, 130);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 52);
- this.button1.TabIndex = 13;
- this.button1.Text = "Edit Employee";
- this.button1.UseVisualStyleBackColor = true;
+ this.btnEdit.Enabled = false;
+ this.btnEdit.Location = new System.Drawing.Point(960, 130);
+ this.btnEdit.Name = "btnEdit";
+ this.btnEdit.Size = new System.Drawing.Size(75, 52);
+ this.btnEdit.TabIndex = 13;
+ this.btnEdit.Text = "Edit Employee";
+ this.btnEdit.UseVisualStyleBackColor = true;
+ this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
//
- // button2
+ // btnRemove
//
- this.button2.Location = new System.Drawing.Point(959, 188);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 52);
- this.button2.TabIndex = 14;
- this.button2.Text = "Remove Employee";
- this.button2.UseVisualStyleBackColor = true;
+ this.btnRemove.Enabled = false;
+ this.btnRemove.Location = new System.Drawing.Point(959, 188);
+ this.btnRemove.Name = "btnRemove";
+ this.btnRemove.Size = new System.Drawing.Size(75, 52);
+ this.btnRemove.TabIndex = 14;
+ this.btnRemove.Text = "Remove Employee";
+ this.btnRemove.UseVisualStyleBackColor = true;
+ this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
//
// form_employees
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1047, 657);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.button1);
+ this.Controls.Add(this.btnRemove);
+ this.Controls.Add(this.btnEdit);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.joined_date_picker);
this.Controls.Add(this.combo_date_type);
@@ -280,7 +287,7 @@
private System.Windows.Forms.ColumnHeader col_allowance;
private System.Windows.Forms.ColumnHeader col_joined;
private System.Windows.Forms.Button btnAdd;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.Button btnEdit;
+ private System.Windows.Forms.Button btnRemove;
}
}
\ No newline at end of file
diff --git a/PayrollSystem/form_employees.cs b/PayrollSystem/form_employees.cs
index 32a1a35..5dfd0bd 100644
--- a/PayrollSystem/form_employees.cs
+++ b/PayrollSystem/form_employees.cs
@@ -74,23 +74,23 @@ namespace PayrollSystem
con.Open();
//Prepare the WHERE Clauses
List clauses = new List();
- if(txtID.Text.Length > 0) { clauses.Add($"Employees.ID='%{txtID.Text}%'"); }
- if (txtName.Text.Length > 0) { clauses.Add($"Employees.Name='%{txtID.Text}%'"); }
+ if(txtID.Text.Length > 0) { clauses.Add($"Employees.ID={txtID.Text}"); }
+ if (txtName.Text.Length > 0) { clauses.Add($"Employees.Name='%{txtName.Text}%'"); }
if(combo_date_type.SelectedItem.ToString() != "Anytime") {
string condition = "=";
if (combo_date_type.SelectedItem.ToString() == "After")
{
- condition = "<";
+ condition = ">";
}else if(combo_date_type.SelectedItem.ToString() == "Before")
{
- condition = ">";
+ condition = "<";
}
- clauses.Add($"Employees.Joined_Date{condition}{joined_date_picker.Value}");
+ clauses.Add($"Employees.Joined_Date{condition}'{joined_date_picker.Value}'");
}
if(combo_department.SelectedItem.ToString() != "Any")
{
- clauses.Add($"Departments.Name={combo_department.SelectedItem.ToString()}");
+ clauses.Add($"Departments.Name='{combo_department.SelectedItem.ToString()}'");
}
//Calculate the final WHERE statement
@@ -101,7 +101,7 @@ namespace PayrollSystem
}
string baseQuery = "SELECT Employees.ID, Employees.Name, Departments.Name as DepartmentName, Departments.Basic, Employees.Allowance, Employees.Joined_Date FROM Employees JOIN Departments ON Employees.Department_ID=Departments.ID";
- MessageBox.Show(baseQuery + querySuffix);
+ // MessageBox.Show(baseQuery + querySuffix);
using (SqlCommand cmd = new SqlCommand(baseQuery + querySuffix, con))
{
@@ -132,5 +132,56 @@ namespace PayrollSystem
Search();
}
+
+ private void list_employees_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ RefreshUI();
+ }
+
+ void RefreshUI()
+ {
+ btnEdit.Enabled = list_employees.SelectedItems.Count > 0;
+ btnRemove.Enabled = list_employees.SelectedItems.Count > 0;
+ }
+
+ private void btnEdit_Click(object sender, EventArgs e)
+ {
+ RefreshUI();
+ if (!btnEdit.Enabled) { return; }
+
+ form_modify_employee modifyForm = new form_modify_employee(int.Parse(list_employees.SelectedItems[0].Text));
+ modifyForm.ShowDialog();
+
+ Search();
+ }
+
+ private void btnRemove_Click(object sender, EventArgs e)
+ {
+ RefreshUI();
+ if (!btnRemove.Enabled) { return; }
+
+ DialogResult confirmation = MessageBox.Show($"Are you sure to remove this Employee?\n\n{list_employees.SelectedItems[0].SubItems[1].Text}", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ if (confirmation == DialogResult.Yes)
+ {
+ using (SqlConnection conn = new SqlConnection(Helpers.conString))
+ {
+ conn.Open();
+ using (SqlCommand cmd = new SqlCommand("DELETE FROM Employees WHERE ID=@id", conn))
+ {
+ cmd.Parameters.AddWithValue("@id", list_employees.SelectedItems[0].Text);
+
+ int result = cmd.ExecuteNonQuery();
+
+ if (result < 0)
+ {
+ MessageBox.Show($"There was an error removing employee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ conn.Close();
+ }
+ }
+
+ Search();
+ }
}
}
diff --git a/PayrollSystem/form_main.Designer.cs b/PayrollSystem/form_main.Designer.cs
index 9bec90a..3f19d09 100644
--- a/PayrollSystem/form_main.Designer.cs
+++ b/PayrollSystem/form_main.Designer.cs
@@ -66,6 +66,7 @@
this.btn_departments.TabIndex = 2;
this.btn_departments.Text = "Departments";
this.btn_departments.UseVisualStyleBackColor = true;
+ this.btn_departments.Click += new System.EventHandler(this.btn_departments_Click);
//
// btnExit
//
@@ -76,6 +77,7 @@
this.btnExit.TabIndex = 3;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
+ this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// panel1
//
@@ -96,6 +98,8 @@
this.Controls.Add(this.btn_dash);
this.Name = "form_main";
this.Text = "Payroll Management System - Dashboard";
+ this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.form_main_FormClosed);
+ this.Load += new System.EventHandler(this.form_main_Load);
this.ResumeLayout(false);
}
diff --git a/PayrollSystem/form_main.cs b/PayrollSystem/form_main.cs
index 65093a3..e8cd392 100644
--- a/PayrollSystem/form_main.cs
+++ b/PayrollSystem/form_main.cs
@@ -18,6 +18,11 @@ namespace PayrollSystem
}
private void button1_Click(object sender, EventArgs e)
+ {
+ ShowDash();
+ }
+
+ void ShowDash()
{
form_dashboard dashboard = new form_dashboard();
dashboard.TopLevel = false;
@@ -36,5 +41,31 @@ namespace PayrollSystem
panel1.Controls.Add(employees);
employees.Show();
}
+
+ private void btn_departments_Click(object sender, EventArgs e)
+ {
+ form_departments deparments = new form_departments();
+ deparments.TopLevel = false;
+ deparments.AutoScroll = true;
+ panel1.Controls.Clear();
+ panel1.Controls.Add(deparments);
+ deparments.Show();
+
+ }
+
+ private void form_main_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ Application.Exit();
+ }
+
+ private void btnExit_Click(object sender, EventArgs e)
+ {
+ Application.Exit();
+ }
+
+ private void form_main_Load(object sender, EventArgs e)
+ {
+ ShowDash();
+ }
}
}
diff --git a/PayrollSystem/form_modify_department.Designer.cs b/PayrollSystem/form_modify_department.Designer.cs
new file mode 100644
index 0000000..8e59195
--- /dev/null
+++ b/PayrollSystem/form_modify_department.Designer.cs
@@ -0,0 +1,136 @@
+namespace PayrollSystem
+{
+ partial class form_modify_department
+ {
+ ///
+ /// 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 Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.txtName = new System.Windows.Forms.TextBox();
+ this.txtBasic = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.btnAdd = new System.Windows.Forms.Button();
+ this.btn_cancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(32, 34);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(99, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Department Name :";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(92, 65);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(39, 13);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Basic :";
+ //
+ // txtName
+ //
+ this.txtName.Location = new System.Drawing.Point(137, 31);
+ this.txtName.Name = "txtName";
+ this.txtName.Size = new System.Drawing.Size(302, 20);
+ this.txtName.TabIndex = 2;
+ //
+ // txtBasic
+ //
+ this.txtBasic.Location = new System.Drawing.Point(137, 62);
+ this.txtBasic.Name = "txtBasic";
+ this.txtBasic.Size = new System.Drawing.Size(188, 20);
+ this.txtBasic.TabIndex = 3;
+ this.txtBasic.Text = "0";
+ this.txtBasic.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(331, 65);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(20, 13);
+ this.label3.TabIndex = 4;
+ this.label3.Text = "Rs";
+ //
+ // btnAdd
+ //
+ this.btnAdd.Location = new System.Drawing.Point(318, 105);
+ this.btnAdd.Name = "btnAdd";
+ this.btnAdd.Size = new System.Drawing.Size(75, 23);
+ this.btnAdd.TabIndex = 5;
+ this.btnAdd.Text = "Add";
+ this.btnAdd.UseVisualStyleBackColor = true;
+ this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
+ //
+ // btn_cancel
+ //
+ this.btn_cancel.Location = new System.Drawing.Point(399, 105);
+ this.btn_cancel.Name = "btn_cancel";
+ this.btn_cancel.Size = new System.Drawing.Size(75, 23);
+ this.btn_cancel.TabIndex = 6;
+ this.btn_cancel.Text = "Cancel";
+ this.btn_cancel.UseVisualStyleBackColor = true;
+ this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);
+ //
+ // form_modify_department
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(486, 140);
+ this.Controls.Add(this.btn_cancel);
+ this.Controls.Add(this.btnAdd);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.txtBasic);
+ this.Controls.Add(this.txtName);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "form_modify_department";
+ this.Text = "form_modify_department";
+ this.Load += new System.EventHandler(this.form_modify_department_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox txtName;
+ private System.Windows.Forms.TextBox txtBasic;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Button btnAdd;
+ private System.Windows.Forms.Button btn_cancel;
+ }
+}
\ No newline at end of file
diff --git a/PayrollSystem/form_modify_department.cs b/PayrollSystem/form_modify_department.cs
new file mode 100644
index 0000000..dd621df
--- /dev/null
+++ b/PayrollSystem/form_modify_department.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Data.SqlClient;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PayrollSystem
+{
+ public partial class form_modify_department : Form
+ {
+ int editingId=-1;
+ bool isEditing => editingId >= 0;
+ public form_modify_department(int editId=-1)
+ {
+ InitializeComponent();
+ editingId = editId;
+ }
+
+ private void form_modify_department_Load(object sender, EventArgs e)
+ {
+ Text = isEditing ? "Edit Department" : "Add new Department";
+ btnAdd.Text = isEditing ? "Edit" : "Add";
+ }
+
+ private void btnAdd_Click(object sender, EventArgs e)
+ {
+ //Validate inputs
+ if(txtName.Text.Length <= 1) { MessageBox.Show("Please enter a name longer than 1 letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
+ int basic = 0;
+ try
+ {
+ basic = Convert.ToInt32(txtBasic.Text);
+ if(basic <= 0)
+ {
+ MessageBox.Show("Enter a valid basic pay amount, Employees must be paid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
+ }
+ }
+ catch
+ {
+ MessageBox.Show("Enter a number on the basic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
+ }
+
+
+ if (isEditing)
+ {
+
+ }
+ else
+ {
+ Insert();
+ }
+ }
+
+ void Insert()
+ {
+ using (SqlConnection con = new SqlConnection(Helpers.conString))
+ {
+ con.Open();
+ using (SqlCommand cmd = new SqlCommand("INSERT INTO Departments (Name, Basic) VALUES(@name,@basic)", con))
+ {
+ cmd.Parameters.AddWithValue("@name", txtName.Text);
+ cmd.Parameters.AddWithValue("@basic", txtBasic.Text);
+
+ int result = cmd.ExecuteNonQuery();
+ if (result < 0)
+ {
+ MessageBox.Show("There was an error adding new department", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ con.Close();
+ }
+ this.Close();
+ }
+
+ private void btn_cancel_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
diff --git a/PayrollSystem/form_modify_department.resx b/PayrollSystem/form_modify_department.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/PayrollSystem/form_modify_department.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/PayrollSystem/form_modify_employee.cs b/PayrollSystem/form_modify_employee.cs
index 709cf77..9131bb5 100644
--- a/PayrollSystem/form_modify_employee.cs
+++ b/PayrollSystem/form_modify_employee.cs
@@ -41,6 +41,42 @@ namespace PayrollSystem
if (combo_department.Items.Count > 0) { combo_department.SelectedIndex = 0; }
}
}
+
+ if (isEditing)
+ {
+ using(SqlCommand cmd = new SqlCommand("SELECT * FROM Employees WHERE ID=@id",con))
+ {
+ cmd.Parameters.AddWithValue("@id", editingId);
+
+ using(SqlDataReader reader = cmd.ExecuteReader())
+ {
+ while (reader.Read())
+ {
+ txtName.Text = reader["Name"].ToString();
+ txtAllowance.Text = reader["Allowance"].ToString();
+
+ string depId = reader["Department_ID"].ToString();
+ foreach(KeyValuePair department in departmentIdDic)
+ {
+ if(department.Value == depId)
+ {
+ for(int i=0; i < combo_department.Items.Count; i++)
+ {
+ if(combo_department.Items[i].ToString() == depId)
+ {
+ combo_department.SelectedIndex =i;
+ }
+ }
+ break;
+ }
+ }
+
+ date_joined.Value = DateTime.Parse(reader["Joined_Date"].ToString());
+ }
+ }
+ }
+ }
+
con.Close();
}
@@ -55,11 +91,31 @@ namespace PayrollSystem
private void btnAdd_Click(object sender, EventArgs e)
{
- using(SqlConnection connection = new SqlConnection(Helpers.conString))
+ //Validate the inputs
+ if(txtName.Text.Length <= 2) { MessageBox.Show("Please enter a name longer than 2 letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
+ try
+ {
+ int allowance = Convert.ToInt32(txtAllowance.Text);
+ }
+ catch
+ {
+ MessageBox.Show("Enter a valid input on the allowance", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
+ }
+
+
+ using (SqlConnection connection = new SqlConnection(Helpers.conString))
{
string query = "INSERT INTO Employees (Name, Department_ID, Allowance, Joined_Date) VALUES(@name, @depId, @allowance, @joinedDate)";
+ if (isEditing)
+ {
+ query = "UPDATE Employees SET Name=@name, Department_ID=@depId, Allowance=@allowance, Joined_Date=@joinedDate WHERE ID=@id";
+ }
using (SqlCommand command = new SqlCommand(query, connection))
{
+ if (isEditing)
+ {
+ command.Parameters.AddWithValue("@id", editingId);
+ }
command.Parameters.AddWithValue("@name", txtName.Text);
command.Parameters.AddWithValue("@depId", departmentIdDic[combo_department.SelectedItem.ToString()]);
command.Parameters.AddWithValue("@allowance", txtAllowance.Text);
@@ -71,10 +127,12 @@ namespace PayrollSystem
if (result < 0)
{
- MessageBox.Show("There was an error adding new employee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show($"There was an error {(isEditing ? "editing" : "adding new")} employee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
+
+ this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
diff --git a/PayrollSystem/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/PayrollSystem/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 2dd1442..470505b 100644
Binary files a/PayrollSystem/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/PayrollSystem/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/PayrollSystem/obj/Debug/PayrollSystem.csproj.CoreCompileInputs.cache b/PayrollSystem/obj/Debug/PayrollSystem.csproj.CoreCompileInputs.cache
index 7bbf483..6686235 100644
--- a/PayrollSystem/obj/Debug/PayrollSystem.csproj.CoreCompileInputs.cache
+++ b/PayrollSystem/obj/Debug/PayrollSystem.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-f0475c0bcd5a36c968bb1dae4fa9ab9f3ebd0b02be5078e6215513bfbd4b243e
+13d37ad0a7cb2bc32946ea1a632a9a66c057688644a20571be28f2c378649b21
diff --git a/PayrollSystem/obj/Debug/PayrollSystem.csproj.FileListAbsolute.txt b/PayrollSystem/obj/Debug/PayrollSystem.csproj.FileListAbsolute.txt
index 9342cc6..7c711ac 100644
--- a/PayrollSystem/obj/Debug/PayrollSystem.csproj.FileListAbsolute.txt
+++ b/PayrollSystem/obj/Debug/PayrollSystem.csproj.FileListAbsolute.txt
@@ -14,3 +14,5 @@ C:\Users\warlock\source\repos\PayrollSystem\PayrollSystem\bin\Debug\payrolldb.md
C:\Users\warlock\source\repos\PayrollSystem\PayrollSystem\bin\Debug\payrolldb_log.ldf
C:\Users\warlock\source\repos\PayrollSystem\PayrollSystem\obj\Debug\PayrollSystem.form_employees.resources
C:\Users\warlock\source\repos\PayrollSystem\PayrollSystem\obj\Debug\PayrollSystem.form_modify_employee.resources
+C:\Users\warlock\source\repos\PayrollSystem\PayrollSystem\obj\Debug\PayrollSystem.form_departments.resources
+C:\Users\warlock\source\repos\PayrollSystem\PayrollSystem\obj\Debug\PayrollSystem.form_modify_department.resources
diff --git a/PayrollSystem/obj/Debug/PayrollSystem.csproj.GenerateResource.cache b/PayrollSystem/obj/Debug/PayrollSystem.csproj.GenerateResource.cache
index e09789e..61bb826 100644
Binary files a/PayrollSystem/obj/Debug/PayrollSystem.csproj.GenerateResource.cache and b/PayrollSystem/obj/Debug/PayrollSystem.csproj.GenerateResource.cache differ
diff --git a/PayrollSystem/obj/Debug/PayrollSystem.exe b/PayrollSystem/obj/Debug/PayrollSystem.exe
index ea10584..b82d451 100644
Binary files a/PayrollSystem/obj/Debug/PayrollSystem.exe and b/PayrollSystem/obj/Debug/PayrollSystem.exe differ
diff --git a/PayrollSystem/obj/Debug/PayrollSystem.form_departments.resources b/PayrollSystem/obj/Debug/PayrollSystem.form_departments.resources
new file mode 100644
index 0000000..6c05a97
Binary files /dev/null and b/PayrollSystem/obj/Debug/PayrollSystem.form_departments.resources differ
diff --git a/PayrollSystem/obj/Debug/PayrollSystem.form_modify_department.resources b/PayrollSystem/obj/Debug/PayrollSystem.form_modify_department.resources
new file mode 100644
index 0000000..6c05a97
Binary files /dev/null and b/PayrollSystem/obj/Debug/PayrollSystem.form_modify_department.resources differ
diff --git a/PayrollSystem/obj/Debug/PayrollSystem.pdb b/PayrollSystem/obj/Debug/PayrollSystem.pdb
index 82d7b2c..c5f3f03 100644
Binary files a/PayrollSystem/obj/Debug/PayrollSystem.pdb and b/PayrollSystem/obj/Debug/PayrollSystem.pdb differ
diff --git a/PayrollSystem/payrolldb.mdf b/PayrollSystem/payrolldb.mdf
index db68f87..1130400 100644
Binary files a/PayrollSystem/payrolldb.mdf and b/PayrollSystem/payrolldb.mdf differ
diff --git a/PayrollSystem/payrolldb_log.ldf b/PayrollSystem/payrolldb_log.ldf
index f656dc0..021904a 100644
Binary files a/PayrollSystem/payrolldb_log.ldf and b/PayrollSystem/payrolldb_log.ldf differ