diff --git a/C969Project/AddUpdateCustomerForm.Designer.cs b/C969Project/AddUpdateCustomerForm.Designer.cs new file mode 100644 index 0000000..e641696 --- /dev/null +++ b/C969Project/AddUpdateCustomerForm.Designer.cs @@ -0,0 +1,172 @@ +using System.ComponentModel; + +namespace C969Project; + +partial class AddUpdateCustomerForm +{ + /// + /// Required designer variable. + /// + private 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() + { + label1 = new System.Windows.Forms.Label(); + saveButton = new System.Windows.Forms.Button(); + cancelButton = new System.Windows.Forms.Button(); + label2 = new System.Windows.Forms.Label(); + textBox1 = new System.Windows.Forms.TextBox(); + textBox2 = new System.Windows.Forms.TextBox(); + label3 = new System.Windows.Forms.Label(); + textBox3 = new System.Windows.Forms.TextBox(); + label4 = new System.Windows.Forms.Label(); + label5 = new System.Windows.Forms.Label(); + SuspendLayout(); + // + // label1 + // + label1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)0)); + label1.Location = new System.Drawing.Point(12, 9); + label1.Name = "label1"; + label1.Size = new System.Drawing.Size(776, 23); + label1.TabIndex = 0; + label1.Text = "Add Customer"; + label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // saveButton + // + saveButton.Location = new System.Drawing.Point(632, 415); + saveButton.Name = "saveButton"; + saveButton.Size = new System.Drawing.Size(75, 23); + saveButton.TabIndex = 1; + saveButton.Text = "Save"; + saveButton.UseVisualStyleBackColor = true; + // + // cancelButton + // + cancelButton.Location = new System.Drawing.Point(713, 415); + cancelButton.Name = "cancelButton"; + cancelButton.Size = new System.Drawing.Size(75, 23); + cancelButton.TabIndex = 2; + cancelButton.Text = "Cancel"; + cancelButton.UseVisualStyleBackColor = true; + // + // label2 + // + label2.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); + label2.Location = new System.Drawing.Point(12, 61); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(332, 23); + label2.TabIndex = 3; + label2.Text = "Name"; + label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBox1 + // + textBox1.Location = new System.Drawing.Point(12, 87); + textBox1.Name = "textBox1"; + textBox1.Size = new System.Drawing.Size(332, 23); + textBox1.TabIndex = 4; + // + // textBox2 + // + textBox2.Location = new System.Drawing.Point(12, 144); + textBox2.Name = "textBox2"; + textBox2.Size = new System.Drawing.Size(332, 23); + textBox2.TabIndex = 6; + // + // label3 + // + label3.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); + label3.Location = new System.Drawing.Point(12, 118); + label3.Name = "label3"; + label3.Size = new System.Drawing.Size(332, 23); + label3.TabIndex = 5; + label3.Text = "Phone"; + label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBox3 + // + textBox3.Location = new System.Drawing.Point(12, 212); + textBox3.Name = "textBox3"; + textBox3.Size = new System.Drawing.Size(218, 23); + textBox3.TabIndex = 8; + // + // label4 + // + label4.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((byte)0)); + label4.Location = new System.Drawing.Point(12, 186); + label4.Name = "label4"; + label4.Size = new System.Drawing.Size(332, 23); + label4.TabIndex = 7; + label4.Text = "Address"; + label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label5 + // + label5.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)0)); + label5.Location = new System.Drawing.Point(248, 212); + label5.Name = "label5"; + label5.Size = new System.Drawing.Size(63, 23); + label5.TabIndex = 9; + label5.Text = "Address"; + label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // AddUpdateCustomerForm + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + BackColor = System.Drawing.SystemColors.Control; + ClientSize = new System.Drawing.Size(800, 450); + Controls.Add(label5); + Controls.Add(textBox3); + Controls.Add(label4); + Controls.Add(textBox2); + Controls.Add(label3); + Controls.Add(textBox1); + Controls.Add(label2); + Controls.Add(cancelButton); + Controls.Add(saveButton); + Controls.Add(label1); + Location = new System.Drawing.Point(15, 15); + Text = "Add Customer"; + ResumeLayout(false); + PerformLayout(); + } + + private System.Windows.Forms.Label label5; + + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.Label label4; + + private System.Windows.Forms.Button saveButton; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Label label2; + + private System.Windows.Forms.Label label1; + + #endregion +} \ No newline at end of file diff --git a/C969Project/AddUpdateCustomerForm.cs b/C969Project/AddUpdateCustomerForm.cs new file mode 100644 index 0000000..45b0dc6 --- /dev/null +++ b/C969Project/AddUpdateCustomerForm.cs @@ -0,0 +1,27 @@ +namespace C969Project; + +public partial class AddUpdateCustomerForm : Form +{ + public enum OperationType { Add, Update } + public AddUpdateCustomerForm(OperationType operationType) + { + InitializeComponent(); + + if (operationType == OperationType.Add) InitAdd(); + else if (operationType == OperationType.Update) InitUpdate(); + } + + private void InitAdd() + { + Text = "Add Customer"; + label1.Text = "Add Customer"; + } + + private void InitUpdate() + { + Text = "Update Customer"; + label1.Text = "Update Customer"; + } + + // name, {address, phone} +} \ No newline at end of file diff --git a/C969Project/C969Project.csproj b/C969Project/C969Project.csproj index 947595d..5ba583b 100644 --- a/C969Project/C969Project.csproj +++ b/C969Project/C969Project.csproj @@ -17,6 +17,12 @@ Form + + Form + + + Form + diff --git a/C969Project/DashboardForm.Designer.cs b/C969Project/DashboardForm.Designer.cs index 814f01a..1453484 100644 --- a/C969Project/DashboardForm.Designer.cs +++ b/C969Project/DashboardForm.Designer.cs @@ -31,79 +31,67 @@ partial class DashboardForm /// private void InitializeComponent() { - customersButton = new System.Windows.Forms.Button(); - appointmentsButton = new System.Windows.Forms.Button(); - calendarButton = new System.Windows.Forms.Button(); - button4 = new System.Windows.Forms.Button(); + CustomersButton = new System.Windows.Forms.Button(); + AppointmentsButton = new System.Windows.Forms.Button(); label1 = new System.Windows.Forms.Label(); + ReportsButton = new System.Windows.Forms.Button(); SuspendLayout(); // - // customersButton + // CustomersButton // - customersButton.Location = new System.Drawing.Point(258, 151); - customersButton.Name = "customersButton"; - customersButton.Size = new System.Drawing.Size(100, 100); - customersButton.TabIndex = 0; - customersButton.Text = "Customers"; - customersButton.UseVisualStyleBackColor = true; + CustomersButton.Location = new System.Drawing.Point(339, 185); + CustomersButton.Name = "CustomersButton"; + CustomersButton.Size = new System.Drawing.Size(100, 100); + CustomersButton.TabIndex = 0; + CustomersButton.Text = "Customers"; + CustomersButton.UseVisualStyleBackColor = true; // - // appointmentsButton + // AppointmentsButton // - appointmentsButton.Location = new System.Drawing.Point(406, 151); - appointmentsButton.Name = "appointmentsButton"; - appointmentsButton.Size = new System.Drawing.Size(100, 100); - appointmentsButton.TabIndex = 1; - appointmentsButton.Text = "Appointments"; - appointmentsButton.UseVisualStyleBackColor = true; - // - // calendarButton - // - calendarButton.Location = new System.Drawing.Point(258, 269); - calendarButton.Name = "calendarButton"; - calendarButton.Size = new System.Drawing.Size(100, 100); - calendarButton.TabIndex = 2; - calendarButton.Text = "Calendar"; - calendarButton.UseVisualStyleBackColor = true; - // - // button4 - // - button4.Location = new System.Drawing.Point(406, 269); - button4.Name = "button4"; - button4.Size = new System.Drawing.Size(100, 100); - button4.TabIndex = 3; - button4.Text = "button4"; - button4.UseVisualStyleBackColor = true; + AppointmentsButton.Location = new System.Drawing.Point(445, 185); + AppointmentsButton.Name = "AppointmentsButton"; + AppointmentsButton.Size = new System.Drawing.Size(100, 100); + AppointmentsButton.TabIndex = 1; + AppointmentsButton.Text = "Appointments"; + AppointmentsButton.UseVisualStyleBackColor = true; // // label1 // label1.Font = new System.Drawing.Font("Segoe UI", 15F); - label1.Location = new System.Drawing.Point(330, 65); + label1.Location = new System.Drawing.Point(332, 116); label1.Name = "label1"; label1.Size = new System.Drawing.Size(113, 40); label1.TabIndex = 4; label1.Text = "Dashboard"; label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // ReportsButton + // + ReportsButton.Location = new System.Drawing.Point(233, 185); + ReportsButton.Name = "ReportsButton"; + ReportsButton.Size = new System.Drawing.Size(100, 100); + ReportsButton.TabIndex = 2; + ReportsButton.Text = "Reports"; + ReportsButton.UseVisualStyleBackColor = true; + // // DashboardForm // AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ClientSize = new System.Drawing.Size(800, 450); Controls.Add(label1); - Controls.Add(customersButton); - Controls.Add(appointmentsButton); - Controls.Add(calendarButton); - Controls.Add(button4); + Controls.Add(CustomersButton); + Controls.Add(AppointmentsButton); + Controls.Add(ReportsButton); Text = "DashboardForm"; ResumeLayout(false); } private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button customersButton; - private System.Windows.Forms.Button appointmentsButton; - private System.Windows.Forms.Button calendarButton; - private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button CustomersButton; + private System.Windows.Forms.Button AppointmentsButton; + private System.Windows.Forms.Button ReportsButton; #endregion } \ No newline at end of file diff --git a/C969Project/DashboardForm.cs b/C969Project/DashboardForm.cs index 47d5fd5..21a3e5e 100644 --- a/C969Project/DashboardForm.cs +++ b/C969Project/DashboardForm.cs @@ -2,8 +2,20 @@ namespace C969Project; public partial class DashboardForm : Form { + private RecordsForm _recordsForm; + public DashboardForm() { InitializeComponent(); + + _recordsForm = new RecordsForm(); + + CustomersButton.Click += (sender, args) => + { + _recordsForm.ShowDialog(); + _recordsForm.UpdateCustomersList(); + }; + + } } \ No newline at end of file diff --git a/C969Project/Data/DatabaseHelper.cs b/C969Project/Data/DatabaseHelper.cs index 600a150..e0f4e74 100644 --- a/C969Project/Data/DatabaseHelper.cs +++ b/C969Project/Data/DatabaseHelper.cs @@ -103,8 +103,6 @@ public static class DatabaseHelper command.Parameters.AddWithValue("@lastUpdateBy", AppState.CurrentUser.Username); int rowsAffected = command.ExecuteNonQuery(); - - } catch (MySqlException e) { diff --git a/C969Project/LoginForm.cs b/C969Project/LoginForm.cs index 5945a7a..45e3499 100644 --- a/C969Project/LoginForm.cs +++ b/C969Project/LoginForm.cs @@ -35,6 +35,7 @@ namespace C969Project AppState.CurrentUser = usr; var dash = new DashboardForm(); + dash.FormClosing += (o, args) => { this.Show(); }; dash.Show(); Hide(); } diff --git a/C969Project/RecordsForm.Designer.cs b/C969Project/RecordsForm.Designer.cs new file mode 100644 index 0000000..b714e3e --- /dev/null +++ b/C969Project/RecordsForm.Designer.cs @@ -0,0 +1,101 @@ +using System.ComponentModel; + +namespace C969Project; + +partial class RecordsForm +{ + /// + /// Required designer variable. + /// + private 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() + { + CustomersDataGrid = new System.Windows.Forms.DataGridView(); + AddButton = new System.Windows.Forms.Button(); + ModifyButton = new System.Windows.Forms.Button(); + DeleteButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)CustomersDataGrid).BeginInit(); + SuspendLayout(); + // + // CustomersDataGrid + // + CustomersDataGrid.AllowUserToAddRows = false; + CustomersDataGrid.AllowUserToDeleteRows = false; + CustomersDataGrid.AllowUserToOrderColumns = true; + CustomersDataGrid.Location = new System.Drawing.Point(12, 12); + CustomersDataGrid.Name = "CustomersDataGrid"; + CustomersDataGrid.ReadOnly = true; + CustomersDataGrid.Size = new System.Drawing.Size(873, 430); + CustomersDataGrid.TabIndex = 0; + // + // AddButton + // + AddButton.Location = new System.Drawing.Point(12, 448); + AddButton.Name = "AddButton"; + AddButton.Size = new System.Drawing.Size(75, 23); + AddButton.TabIndex = 1; + AddButton.Text = "Add"; + AddButton.UseVisualStyleBackColor = true; + // + // ModifyButton + // + ModifyButton.Location = new System.Drawing.Point(93, 448); + ModifyButton.Name = "ModifyButton"; + ModifyButton.Size = new System.Drawing.Size(75, 23); + ModifyButton.TabIndex = 2; + ModifyButton.Text = "Modify"; + ModifyButton.UseVisualStyleBackColor = true; + // + // DeleteButton + // + DeleteButton.Location = new System.Drawing.Point(810, 448); + DeleteButton.Name = "DeleteButton"; + DeleteButton.Size = new System.Drawing.Size(75, 23); + DeleteButton.TabIndex = 3; + DeleteButton.Text = "Delete"; + DeleteButton.UseVisualStyleBackColor = true; + // + // RecordsForm + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(897, 569); + Controls.Add(DeleteButton); + Controls.Add(ModifyButton); + Controls.Add(AddButton); + Controls.Add(CustomersDataGrid); + Text = "Records"; + ((System.ComponentModel.ISupportInitialize)CustomersDataGrid).EndInit(); + ResumeLayout(false); + } + + private System.Windows.Forms.Button ModifyButton; + private System.Windows.Forms.Button DeleteButton; + + private System.Windows.Forms.Button AddButton; + + private System.Windows.Forms.DataGridView CustomersDataGrid; + + #endregion +} \ No newline at end of file diff --git a/C969Project/RecordsForm.cs b/C969Project/RecordsForm.cs new file mode 100644 index 0000000..fee2d15 --- /dev/null +++ b/C969Project/RecordsForm.cs @@ -0,0 +1,24 @@ +using C969Project.Data; +using C969Project.Data.Models; + +namespace C969Project; + +public partial class RecordsForm : Form +{ + private List? _customers; + + public RecordsForm() + { + InitializeComponent(); + UpdateCustomersList(); + + AddButton.Click += (sender, args) => { ShowDialog(new AddUpdateCustomerForm(AddUpdateCustomerForm.OperationType.Add)); }; + } + + public void UpdateCustomersList() + { + if (_customers != null && _customers.Count > 0) _customers.Clear(); + _customers = DatabaseHelper.RetrieveCustomers(); + CustomersDataGrid.DataSource = _customers; + } +} \ No newline at end of file