diff --git a/AppointmentsManager/AppointmentsUi/MainForm.Designer.cs b/AppointmentsManager/AppointmentsUi/MainForm.Designer.cs index 2e44e34..7c8c9ae 100644 --- a/AppointmentsManager/AppointmentsUi/MainForm.Designer.cs +++ b/AppointmentsManager/AppointmentsUi/MainForm.Designer.cs @@ -117,8 +117,9 @@ namespace AppointmentsUi // toolstripCompaniesAddNewButton // this.toolstripCompaniesAddNewButton.Name = "toolstripCompaniesAddNewButton"; - this.toolstripCompaniesAddNewButton.Size = new System.Drawing.Size(180, 22); + this.toolstripCompaniesAddNewButton.Size = new System.Drawing.Size(121, 22); this.toolstripCompaniesAddNewButton.Text = "Add new"; + this.toolstripCompaniesAddNewButton.Click += new System.EventHandler(this.toolstripCompaniesAddNewButton_Click); // // toolStripSplitButton1 // @@ -130,12 +131,14 @@ namespace AppointmentsUi this.toolStripSplitButton1.Name = "toolStripSplitButton1"; this.toolStripSplitButton1.Size = new System.Drawing.Size(86, 22); this.toolStripSplitButton1.Text = "PhoneTypes"; + this.toolStripSplitButton1.ButtonClick += new System.EventHandler(this.toolStripSplitButton1_ButtonClick); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Size = new System.Drawing.Size(121, 22); this.toolStripMenuItem1.Text = "Add new"; + this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click); // // toolstripSalutationsButton // @@ -147,12 +150,14 @@ namespace AppointmentsUi this.toolstripSalutationsButton.Name = "toolstripSalutationsButton"; this.toolstripSalutationsButton.Size = new System.Drawing.Size(81, 22); this.toolstripSalutationsButton.Text = "Salutations"; + this.toolstripSalutationsButton.ButtonClick += new System.EventHandler(this.toolstripSalutationsButton_ButtonClick); // // toolstripSalutationsAddNewButton // this.toolstripSalutationsAddNewButton.Name = "toolstripSalutationsAddNewButton"; - this.toolstripSalutationsAddNewButton.Size = new System.Drawing.Size(121, 22); + this.toolstripSalutationsAddNewButton.Size = new System.Drawing.Size(180, 22); this.toolstripSalutationsAddNewButton.Text = "Add new"; + this.toolstripSalutationsAddNewButton.Click += new System.EventHandler(this.toolstripSalutationsAddNewButton_Click); // // toolstripPostalsButton // @@ -164,12 +169,14 @@ namespace AppointmentsUi this.toolstripPostalsButton.Name = "toolstripPostalsButton"; this.toolstripPostalsButton.Size = new System.Drawing.Size(60, 22); this.toolstripPostalsButton.Text = "Postals"; + this.toolstripPostalsButton.ButtonClick += new System.EventHandler(this.toolstripPostalsButton_ButtonClick); // // toolstripPostalsAddNewButton // this.toolstripPostalsAddNewButton.Name = "toolstripPostalsAddNewButton"; - this.toolstripPostalsAddNewButton.Size = new System.Drawing.Size(121, 22); + this.toolstripPostalsAddNewButton.Size = new System.Drawing.Size(180, 22); this.toolstripPostalsAddNewButton.Text = "Add new"; + this.toolstripPostalsAddNewButton.Click += new System.EventHandler(this.toolstripPostalsAddNewButton_Click); // // toolstripAboutButton // diff --git a/AppointmentsManager/AppointmentsUi/MainForm.cs b/AppointmentsManager/AppointmentsUi/MainForm.cs index 0435833..4c62fcb 100644 --- a/AppointmentsManager/AppointmentsUi/MainForm.cs +++ b/AppointmentsManager/AppointmentsUi/MainForm.cs @@ -19,12 +19,14 @@ namespace AppointmentsUi EmbedForm(); } - internal void EmbedForm() where T : Form, new() + internal T EmbedForm() where T : Form, new() { T embedded = new T() { TopLevel = false, TopMost = true, FormBorderStyle = FormBorderStyle.None, Dock = DockStyle.Fill, AutoSize = false, Parent = this }; embeddingContainer.Controls.Clear(); embeddingContainer.Controls.Add(embedded); embedded.Show(); + + return embedded; } private void toolstripAboutButton_Click(object sender, EventArgs e) @@ -56,5 +58,40 @@ namespace AppointmentsUi { EmbedForm(); } + + private void toolstripCompaniesAddNewButton_Click(object sender, EventArgs e) + { + EmbedForm().addCompany(); + } + + private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e) + { + EmbedForm(); + } + + private void toolStripMenuItem1_Click(object sender, EventArgs e) + { + EmbedForm().addPhoneType(); + } + + private void toolstripSalutationsButton_ButtonClick(object sender, EventArgs e) + { + EmbedForm(); + } + + private void toolstripSalutationsAddNewButton_Click(object sender, EventArgs e) + { + EmbedForm().addSalutation(); + } + + private void toolstripPostalsButton_ButtonClick(object sender, EventArgs e) + { + EmbedForm(); + } + + private void toolstripPostalsAddNewButton_Click(object sender, EventArgs e) + { + EmbedForm().addPostal(); + } } } diff --git a/AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs b/AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs index c414bfe..af956e6 100644 --- a/AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs +++ b/AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs @@ -36,7 +36,10 @@ namespace AppointmentsUi.Views // // tableLayoutPanelCompanies // - this.tableLayoutPanelCompanies.BackColor = System.Drawing.SystemColors.ControlDark; + this.tableLayoutPanelCompanies.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanelCompanies.BackColor = System.Drawing.SystemColors.Control; this.tableLayoutPanelCompanies.ColumnCount = 4; this.tableLayoutPanelCompanies.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanelCompanies.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); diff --git a/AppointmentsManager/AppointmentsUi/Views/CompanyList.cs b/AppointmentsManager/AppointmentsUi/Views/CompanyList.cs index 62c7117..f65369c 100644 --- a/AppointmentsManager/AppointmentsUi/Views/CompanyList.cs +++ b/AppointmentsManager/AppointmentsUi/Views/CompanyList.cs @@ -50,10 +50,15 @@ namespace AppointmentsUi.Views } } - private void buttonAddNewCompany_Click(object sender, EventArgs e) + internal void addCompany() { AppointmentsLib.Models.Company.Create("New company"); Program.mainForm.EmbedForm(); } + + private void buttonAddNewCompany_Click(object sender, EventArgs e) + { + addCompany(); + } } } diff --git a/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.Designer.cs b/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.Designer.cs new file mode 100644 index 0000000..b44d2d2 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.Designer.cs @@ -0,0 +1,95 @@ +namespace AppointmentsUi.Views +{ + partial class PhoneTypesList + { + /// + /// 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.buttonAddNewPhoneTypes = new System.Windows.Forms.Button(); + this.labelPhoneTypesHeader = new System.Windows.Forms.Label(); + this.tableLayoutPanelPhoneTypes = new System.Windows.Forms.TableLayoutPanel(); + this.SuspendLayout(); + // + // buttonAddNewPhoneTypes + // + this.buttonAddNewPhoneTypes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAddNewPhoneTypes.Location = new System.Drawing.Point(725, -1); + this.buttonAddNewPhoneTypes.Name = "buttonAddNewPhoneTypes"; + this.buttonAddNewPhoneTypes.Size = new System.Drawing.Size(75, 23); + this.buttonAddNewPhoneTypes.TabIndex = 5; + this.buttonAddNewPhoneTypes.Text = "Add new"; + this.buttonAddNewPhoneTypes.UseVisualStyleBackColor = true; + this.buttonAddNewPhoneTypes.Click += new System.EventHandler(this.buttonAddNewPhoneTypes_Click); + // + // labelPhoneTypesHeader + // + this.labelPhoneTypesHeader.AutoSize = true; + this.labelPhoneTypesHeader.Location = new System.Drawing.Point(-1, 3); + this.labelPhoneTypesHeader.Name = "labelPhoneTypesHeader"; + this.labelPhoneTypesHeader.Size = new System.Drawing.Size(70, 15); + this.labelPhoneTypesHeader.TabIndex = 4; + this.labelPhoneTypesHeader.Text = "PhoneTypes"; + // + // tableLayoutPanelPhoneTypes + // + this.tableLayoutPanelPhoneTypes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanelPhoneTypes.BackColor = System.Drawing.SystemColors.Control; + this.tableLayoutPanelPhoneTypes.ColumnCount = 4; + this.tableLayoutPanelPhoneTypes.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPhoneTypes.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPhoneTypes.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPhoneTypes.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPhoneTypes.Location = new System.Drawing.Point(-1, 28); + this.tableLayoutPanelPhoneTypes.Name = "tableLayoutPanelPhoneTypes"; + this.tableLayoutPanelPhoneTypes.RowCount = 1; + this.tableLayoutPanelPhoneTypes.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanelPhoneTypes.Size = new System.Drawing.Size(802, 423); + this.tableLayoutPanelPhoneTypes.TabIndex = 3; + // + // PhoneTypesList + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonAddNewPhoneTypes); + this.Controls.Add(this.labelPhoneTypesHeader); + this.Controls.Add(this.tableLayoutPanelPhoneTypes); + this.Name = "PhoneTypesList"; + this.Text = "PhoneTypesList"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonAddNewPhoneTypes; + private System.Windows.Forms.Label labelPhoneTypesHeader; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanelPhoneTypes; + } +} \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.cs b/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.cs new file mode 100644 index 0000000..953a75f --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AppointmentsUi.Views +{ + public partial class PhoneTypesList : Form + { + public PhoneTypesList() + { + InitializeComponent(); + + var phoneTypes = AppointmentsLib.Models.PhoneType.GetPhoneTypes(); + + for (int i = 0; i < phoneTypes.Count(); i++) + { + var phoneType = phoneTypes.ElementAt(i); + + var labelPhoneTypeId = new Label() { Text = phoneType.PhoneTypeId.ToString(), AutoSize = true, TextAlign = ContentAlignment.MiddleCenter }; + var textboxPhoneTypeName = new TextBox() { Text = phoneType.Label, AutoSize = true }; + var buttonApplyChanges = new Button() { Text = "Apply" }; + var buttonDelete = new Button() { Text = "Delete" }; + + buttonApplyChanges.Click += new EventHandler(delegate (object sender, EventArgs e) { + phoneType.Save(); + Program.mainForm.EmbedForm(); + }); + buttonDelete.Click += new EventHandler(delegate (object sender, EventArgs e) { + var res = MessageBox.Show($"Are you sure to delete the phone type\n{phoneType.Label}\n?", "Delete phone type?", MessageBoxButtons.YesNo); + if (res == DialogResult.Yes) + { + phoneType.Delete(); + Program.mainForm.EmbedForm(); + } + }); + textboxPhoneTypeName.TextChanged += new EventHandler(delegate (object sender, EventArgs e) { + phoneType.Label = textboxPhoneTypeName.Text; + }); + + tableLayoutPanelPhoneTypes.Controls.Add(labelPhoneTypeId, 0, 1 + i); + tableLayoutPanelPhoneTypes.Controls.Add(textboxPhoneTypeName, 1, 1 + i); + tableLayoutPanelPhoneTypes.Controls.Add(buttonApplyChanges, 2, 1 + i); + tableLayoutPanelPhoneTypes.Controls.Add(buttonDelete, 3, 1 + i); + } + } + + internal void addPhoneType() + { + AppointmentsLib.Models.PhoneType.Create("New phone type"); + Program.mainForm.EmbedForm(); + } + + private void buttonAddNewPhoneTypes_Click(object sender, EventArgs e) + { + addPhoneType(); + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.resx b/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/PhoneTypesList.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/AppointmentsManager/AppointmentsUi/Views/PostalsList.Designer.cs b/AppointmentsManager/AppointmentsUi/Views/PostalsList.Designer.cs new file mode 100644 index 0000000..4f89a56 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/PostalsList.Designer.cs @@ -0,0 +1,95 @@ +namespace AppointmentsUi.Views +{ + partial class PostalsList + { + /// + /// 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.buttonAddNewPostals = new System.Windows.Forms.Button(); + this.labelPostalsHeader = new System.Windows.Forms.Label(); + this.tableLayoutPanelPostals = new System.Windows.Forms.TableLayoutPanel(); + this.SuspendLayout(); + // + // buttonAddNewPostals + // + this.buttonAddNewPostals.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAddNewPostals.Location = new System.Drawing.Point(725, -1); + this.buttonAddNewPostals.Name = "buttonAddNewPostals"; + this.buttonAddNewPostals.Size = new System.Drawing.Size(75, 23); + this.buttonAddNewPostals.TabIndex = 8; + this.buttonAddNewPostals.Text = "Add new"; + this.buttonAddNewPostals.UseVisualStyleBackColor = true; + this.buttonAddNewPostals.Click += new System.EventHandler(this.buttonAddNewPostals_Click); + // + // labelPostalsHeader + // + this.labelPostalsHeader.AutoSize = true; + this.labelPostalsHeader.Location = new System.Drawing.Point(-1, 3); + this.labelPostalsHeader.Name = "labelPostalsHeader"; + this.labelPostalsHeader.Size = new System.Drawing.Size(44, 15); + this.labelPostalsHeader.TabIndex = 7; + this.labelPostalsHeader.Text = "Postals"; + // + // tableLayoutPanelPostals + // + this.tableLayoutPanelPostals.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanelPostals.BackColor = System.Drawing.SystemColors.Control; + this.tableLayoutPanelPostals.ColumnCount = 4; + this.tableLayoutPanelPostals.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPostals.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPostals.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPostals.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelPostals.Location = new System.Drawing.Point(-1, 28); + this.tableLayoutPanelPostals.Name = "tableLayoutPanelPostals"; + this.tableLayoutPanelPostals.RowCount = 1; + this.tableLayoutPanelPostals.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanelPostals.Size = new System.Drawing.Size(802, 423); + this.tableLayoutPanelPostals.TabIndex = 6; + // + // PostalsList + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonAddNewPostals); + this.Controls.Add(this.labelPostalsHeader); + this.Controls.Add(this.tableLayoutPanelPostals); + this.Name = "PostalsList"; + this.Text = "PostalsList"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonAddNewPostals; + private System.Windows.Forms.Label labelPostalsHeader; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanelPostals; + } +} \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsUi/Views/PostalsList.cs b/AppointmentsManager/AppointmentsUi/Views/PostalsList.cs new file mode 100644 index 0000000..ce6b87d --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/PostalsList.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AppointmentsUi.Views +{ + public partial class PostalsList : Form + { + public PostalsList() + { + InitializeComponent(); + + var postals = AppointmentsLib.Models.Postal.GetPostals(); + + for (int i = 0; i < postals.Count(); i++) + { + var postal = postals.ElementAt(i); + + var labelPostalId = new Label() { Text = postal.PostalId.ToString(), AutoSize = true, TextAlign = ContentAlignment.MiddleCenter }; + var textboxPostalLabel = new TextBox() { Text = postal.Label, AutoSize = true }; + var buttonApplyChanges = new Button() { Text = "Apply" }; + var buttonDelete = new Button() { Text = "Delete" }; + + buttonApplyChanges.Click += new EventHandler(delegate (object sender, EventArgs e) { + postal.Save(); + Program.mainForm.EmbedForm(); + }); + buttonDelete.Click += new EventHandler(delegate (object sender, EventArgs e) { + var res = MessageBox.Show($"Are you sure to delete the postal\n{postal.Label}\n?", "Delete postal?", MessageBoxButtons.YesNo); + if (res == DialogResult.Yes) + { + postal.Delete(); + Program.mainForm.EmbedForm(); + } + }); + textboxPostalLabel.TextChanged += new EventHandler(delegate (object sender, EventArgs e) { + postal.Label = textboxPostalLabel.Text; + }); + + tableLayoutPanelPostals.Controls.Add(labelPostalId, 0, 1 + i); + tableLayoutPanelPostals.Controls.Add(textboxPostalLabel, 1, 1 + i); + tableLayoutPanelPostals.Controls.Add(buttonApplyChanges, 2, 1 + i); + tableLayoutPanelPostals.Controls.Add(buttonDelete, 3, 1 + i); + } + } + + internal void addPostal() + { + AppointmentsLib.Models.Postal.Create("New postal"); + Program.mainForm.EmbedForm(); + } + + private void buttonAddNewPostals_Click(object sender, EventArgs e) + { + addPostal(); + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/Views/PostalsList.resx b/AppointmentsManager/AppointmentsUi/Views/PostalsList.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/PostalsList.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/AppointmentsManager/AppointmentsUi/Views/SalutationsList.Designer.cs b/AppointmentsManager/AppointmentsUi/Views/SalutationsList.Designer.cs new file mode 100644 index 0000000..411cf31 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/SalutationsList.Designer.cs @@ -0,0 +1,95 @@ +namespace AppointmentsUi.Views +{ + partial class SalutationsList + { + /// + /// 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.buttonAddNewSalutation = new System.Windows.Forms.Button(); + this.labelSalutationsHeader = new System.Windows.Forms.Label(); + this.tableLayoutPanelSalutations = new System.Windows.Forms.TableLayoutPanel(); + this.SuspendLayout(); + // + // buttonAddNewSalutation + // + this.buttonAddNewSalutation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAddNewSalutation.Location = new System.Drawing.Point(725, -1); + this.buttonAddNewSalutation.Name = "buttonAddNewSalutation"; + this.buttonAddNewSalutation.Size = new System.Drawing.Size(75, 23); + this.buttonAddNewSalutation.TabIndex = 5; + this.buttonAddNewSalutation.Text = "Add new"; + this.buttonAddNewSalutation.UseVisualStyleBackColor = true; + this.buttonAddNewSalutation.Click += new System.EventHandler(this.buttonAddNewSalutation_Click); + // + // labelSalutationsHeader + // + this.labelSalutationsHeader.AutoSize = true; + this.labelSalutationsHeader.Location = new System.Drawing.Point(-1, 3); + this.labelSalutationsHeader.Name = "labelSalutationsHeader"; + this.labelSalutationsHeader.Size = new System.Drawing.Size(65, 15); + this.labelSalutationsHeader.TabIndex = 4; + this.labelSalutationsHeader.Text = "Salutations"; + // + // tableLayoutPanelSalutations + // + this.tableLayoutPanelSalutations.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanelSalutations.BackColor = System.Drawing.SystemColors.Control; + this.tableLayoutPanelSalutations.ColumnCount = 4; + this.tableLayoutPanelSalutations.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelSalutations.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelSalutations.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelSalutations.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelSalutations.Location = new System.Drawing.Point(-1, 28); + this.tableLayoutPanelSalutations.Name = "tableLayoutPanelSalutations"; + this.tableLayoutPanelSalutations.RowCount = 1; + this.tableLayoutPanelSalutations.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanelSalutations.Size = new System.Drawing.Size(802, 423); + this.tableLayoutPanelSalutations.TabIndex = 3; + // + // SalutationsList + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonAddNewSalutation); + this.Controls.Add(this.labelSalutationsHeader); + this.Controls.Add(this.tableLayoutPanelSalutations); + this.Name = "SalutationsList"; + this.Text = "SalutationsList"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonAddNewSalutation; + private System.Windows.Forms.Label labelSalutationsHeader; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanelSalutations; + } +} \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsUi/Views/SalutationsList.cs b/AppointmentsManager/AppointmentsUi/Views/SalutationsList.cs new file mode 100644 index 0000000..a4dfb6b --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/SalutationsList.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AppointmentsUi.Views +{ + public partial class SalutationsList : Form + { + public SalutationsList() + { + InitializeComponent(); + + var salutations = AppointmentsLib.Models.Salutation.GetSalutations(); + + for (int i = 0; i < salutations.Count(); i++) + { + var salutation = salutations.ElementAt(i); + + var labelSalutationId = new Label() { Text = salutation.SalutationId.ToString(), AutoSize = true, TextAlign = ContentAlignment.MiddleCenter }; + var textboxSalutationLabel = new TextBox() { Text = salutation.Label, AutoSize = true }; + var buttonApplyChanges = new Button() { Text = "Apply" }; + var buttonDelete = new Button() { Text = "Delete" }; + + buttonApplyChanges.Click += new EventHandler(delegate (object sender, EventArgs e) { + salutation.Save(); + Program.mainForm.EmbedForm(); + }); + buttonDelete.Click += new EventHandler(delegate (object sender, EventArgs e) { + var res = MessageBox.Show($"Are you sure to delete the salutation\n{salutation.Label}\n?", "Delete salutation?", MessageBoxButtons.YesNo); + if (res == DialogResult.Yes) + { + salutation.Delete(); + Program.mainForm.EmbedForm(); + } + }); + textboxSalutationLabel.TextChanged += new EventHandler(delegate (object sender, EventArgs e) { + salutation.Label = textboxSalutationLabel.Text; + }); + + tableLayoutPanelSalutations.Controls.Add(labelSalutationId, 0, 1 + i); + tableLayoutPanelSalutations.Controls.Add(textboxSalutationLabel, 1, 1 + i); + tableLayoutPanelSalutations.Controls.Add(buttonApplyChanges, 2, 1 + i); + tableLayoutPanelSalutations.Controls.Add(buttonDelete, 3, 1 + i); + } + } + + internal void addSalutation() + { + AppointmentsLib.Models.Salutation.Create("New salutation"); + Program.mainForm.EmbedForm(); + } + + private void buttonAddNewSalutation_Click(object sender, EventArgs e) + { + addSalutation(); + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/Views/SalutationsList.resx b/AppointmentsManager/AppointmentsUi/Views/SalutationsList.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/SalutationsList.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