From 780993b244f4ac6ba7f92f464d386546da415c55 Mon Sep 17 00:00:00 2001 From: vasmaae Date: Mon, 11 Nov 2024 02:53:10 -0800 Subject: [PATCH] add all forms, fixed issues --- .../FormItCompany.Designer.cs | 86 ++++---- .../FormItCompany.cs | 81 +++++++- .../Forms/FormContract.Designer.cs | 38 +++- .../Forms/FormContract.cs | 26 ++- .../Forms/FormContracts.Designer.cs | 112 ++++++++++ .../Forms/FormContracts.cs | 78 +++++++ .../Forms/FormContracts.resx | 120 +++++++++++ .../Forms/FormCustomer.cs | 2 + .../FormCustomerContractReview.Designer.cs | 180 ++++++++++++++++ .../Forms/FormCustomerContractReview.cs | 49 +++++ .../Forms/FormCustomerContractReview.resx | 120 +++++++++++ .../FormCustomerContractReviews.Designer.cs | 98 +++++++++ .../Forms/FormCustomerContractReviews.cs | 47 +++++ .../Forms/FormCustomerContractReviews.resx | 120 +++++++++++ .../Forms/FormExecutor.Designer.cs | 3 +- .../Forms/FormExecutor.cs | 2 + .../Forms/FormExecutors.Designer.cs | 3 +- .../Forms/FormExecutors.cs | 11 - .../Forms/FormService.Designer.cs | 121 +++++++++++ .../Forms/FormService.cs | 75 +++++++ .../Forms/FormService.resx | 120 +++++++++++ .../Forms/FormServiceExecution.Designer.cs | 194 ++++++++++++++++++ .../Forms/FormServiceExecution.cs | 63 ++++++ .../Forms/FormServiceExecution.resx | 120 +++++++++++ .../Forms/FormServiceExecutions.Designer.cs | 112 ++++++++++ .../Forms/FormServiceExecutions.cs | 77 +++++++ .../Forms/FormServiceExecutions.resx | 120 +++++++++++ .../Forms/FormServices.Designer.cs | 126 ++++++++++++ .../Forms/FormServices.cs | 97 +++++++++ .../Forms/FormServices.resx | 120 +++++++++++ .../Repositories/IContractRepository.cs | 2 - .../Implementations/ContractRepository.cs | 4 - 32 files changed, 2456 insertions(+), 71 deletions(-) create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.Designer.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.resx create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.Designer.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.resx create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.Designer.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.resx create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.Designer.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.resx create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.Designer.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.resx create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.Designer.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.resx create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.Designer.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.cs create mode 100644 PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.resx diff --git a/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.Designer.cs index a63cf5c..b5a55e6 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.Designer.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.Designer.cs @@ -30,14 +30,14 @@ { menuStrip = new MenuStrip(); справочникиToolStripMenuItem = new ToolStripMenuItem(); - заказчикиToolStripMenuItem = new ToolStripMenuItem(); - исполнителиToolStripMenuItem = new ToolStripMenuItem(); - услугиToolStripMenuItem = new ToolStripMenuItem(); - контрактыToolStripMenuItem = new ToolStripMenuItem(); + CustomersToolStripMenuItem = new ToolStripMenuItem(); + ExecutorsToolStripMenuItem = new ToolStripMenuItem(); + ServicesToolStripMenuItem = new ToolStripMenuItem(); операцииToolStripMenuItem = new ToolStripMenuItem(); - выполнениеУслугиToolStripMenuItem = new ToolStripMenuItem(); - отзывыКлиентовToolStripMenuItem = new ToolStripMenuItem(); + CustomerContractReviewsToolStripMenuItem = new ToolStripMenuItem(); + контрактыToolStripMenuItem = new ToolStripMenuItem(); отчетыToolStripMenuItem = new ToolStripMenuItem(); + выполнениеУслугToolStripMenuItem = new ToolStripMenuItem(); menuStrip.SuspendLayout(); SuspendLayout(); // @@ -52,53 +52,52 @@ // // справочникиToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказчикиToolStripMenuItem, исполнителиToolStripMenuItem, услугиToolStripMenuItem, контрактыToolStripMenuItem }); + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { CustomersToolStripMenuItem, ExecutorsToolStripMenuItem, ServicesToolStripMenuItem }); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Size = new Size(94, 20); справочникиToolStripMenuItem.Text = "Справочники"; // - // заказчикиToolStripMenuItem + // CustomersToolStripMenuItem // - заказчикиToolStripMenuItem.Name = "заказчикиToolStripMenuItem"; - заказчикиToolStripMenuItem.Size = new Size(149, 22); - заказчикиToolStripMenuItem.Text = "Заказчики"; + CustomersToolStripMenuItem.Name = "CustomersToolStripMenuItem"; + CustomersToolStripMenuItem.Size = new Size(149, 22); + CustomersToolStripMenuItem.Text = "Заказчики"; + CustomersToolStripMenuItem.Click += CustomersToolStripMenuItem_Click; // - // исполнителиToolStripMenuItem + // ExecutorsToolStripMenuItem // - исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; - исполнителиToolStripMenuItem.Size = new Size(149, 22); - исполнителиToolStripMenuItem.Text = "Исполнители"; + ExecutorsToolStripMenuItem.Name = "ExecutorsToolStripMenuItem"; + ExecutorsToolStripMenuItem.Size = new Size(149, 22); + ExecutorsToolStripMenuItem.Text = "Исполнители"; + ExecutorsToolStripMenuItem.Click += ExecutorsToolStripMenuItem_Click; // - // услугиToolStripMenuItem + // ServicesToolStripMenuItem // - услугиToolStripMenuItem.Name = "услугиToolStripMenuItem"; - услугиToolStripMenuItem.Size = new Size(149, 22); - услугиToolStripMenuItem.Text = "Услуги"; - // - // контрактыToolStripMenuItem - // - контрактыToolStripMenuItem.Name = "контрактыToolStripMenuItem"; - контрактыToolStripMenuItem.Size = new Size(149, 22); - контрактыToolStripMenuItem.Text = "Контракты"; + ServicesToolStripMenuItem.Name = "ServicesToolStripMenuItem"; + ServicesToolStripMenuItem.Size = new Size(149, 22); + ServicesToolStripMenuItem.Text = "Услуги"; + ServicesToolStripMenuItem.Click += ServicesToolStripMenuItem_Click; // // операцииToolStripMenuItem // - операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { выполнениеУслугиToolStripMenuItem, отзывыКлиентовToolStripMenuItem }); + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { CustomerContractReviewsToolStripMenuItem, контрактыToolStripMenuItem, выполнениеУслугToolStripMenuItem }); операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; операцииToolStripMenuItem.Size = new Size(75, 20); операцииToolStripMenuItem.Text = "Операции"; // - // выполнениеУслугиToolStripMenuItem + // CustomerContractReviewsToolStripMenuItem // - выполнениеУслугиToolStripMenuItem.Name = "выполнениеУслугиToolStripMenuItem"; - выполнениеУслугиToolStripMenuItem.Size = new Size(184, 22); - выполнениеУслугиToolStripMenuItem.Text = "Выполнение услуги"; + CustomerContractReviewsToolStripMenuItem.Name = "CustomerContractReviewsToolStripMenuItem"; + CustomerContractReviewsToolStripMenuItem.Size = new Size(181, 22); + CustomerContractReviewsToolStripMenuItem.Text = "Отзывы заказчиков"; + CustomerContractReviewsToolStripMenuItem.Click += CustomerContractReviewsToolStripMenuItem_Click; // - // отзывыКлиентовToolStripMenuItem + // контрактыToolStripMenuItem // - отзывыКлиентовToolStripMenuItem.Name = "отзывыКлиентовToolStripMenuItem"; - отзывыКлиентовToolStripMenuItem.Size = new Size(184, 22); - отзывыКлиентовToolStripMenuItem.Text = "Отзывы заказчиков"; + контрактыToolStripMenuItem.Name = "контрактыToolStripMenuItem"; + контрактыToolStripMenuItem.Size = new Size(181, 22); + контрактыToolStripMenuItem.Text = "Контракты"; + контрактыToolStripMenuItem.Click += ContractsToolStripMenuItem_Click; // // отчетыToolStripMenuItem // @@ -106,6 +105,13 @@ отчетыToolStripMenuItem.Size = new Size(60, 20); отчетыToolStripMenuItem.Text = "Отчеты"; // + // выполнениеУслугToolStripMenuItem + // + выполнениеУслугToolStripMenuItem.Name = "выполнениеУслугToolStripMenuItem"; + выполнениеУслугToolStripMenuItem.Size = new Size(181, 22); + выполнениеУслугToolStripMenuItem.Text = "Выполнение услуг"; + выполнениеУслугToolStripMenuItem.Click += ServiceExecutionsToolStripMenuItem_Click; + // // FormItCompany // AutoScaleDimensions = new SizeF(7F, 15F); @@ -128,13 +134,13 @@ private MenuStrip menuStrip; private ToolStripMenuItem справочникиToolStripMenuItem; - private ToolStripMenuItem заказчикиToolStripMenuItem; - private ToolStripMenuItem исполнителиToolStripMenuItem; - private ToolStripMenuItem услугиToolStripMenuItem; - private ToolStripMenuItem контрактыToolStripMenuItem; + private ToolStripMenuItem CustomersToolStripMenuItem; + private ToolStripMenuItem ExecutorsToolStripMenuItem; + private ToolStripMenuItem ServicesToolStripMenuItem; private ToolStripMenuItem операцииToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem; - private ToolStripMenuItem выполнениеУслугиToolStripMenuItem; - private ToolStripMenuItem отзывыКлиентовToolStripMenuItem; + private ToolStripMenuItem CustomerContractReviewsToolStripMenuItem; + private ToolStripMenuItem контрактыToolStripMenuItem; + private ToolStripMenuItem выполнениеУслугToolStripMenuItem; } } diff --git a/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.cs b/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.cs index 9b2720f..e53911b 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/FormItCompany.cs @@ -1,10 +1,89 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Forms; +using System.Runtime.Serialization; +using Unity; + namespace PIbd_23_Gutorov_I.A._IT_Company { public partial class FormItCompany : Form { - public FormItCompany() + private readonly IUnityContainer _container; + + public FormItCompany(IUnityContainer container) { InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void CustomersToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ExecutorsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ServicesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ContractsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void CustomerContractReviewsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ServiceExecutionsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } } diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.Designer.cs index 64591d2..148c1b8 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.Designer.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.Designer.cs @@ -40,7 +40,11 @@ comboBoxContractExecutorId = new ComboBox(); labelContractDeadline = new Label(); labelContractPaymentAmount = new Label(); + dataGridViewServices = new DataGridView(); + groupBox = new GroupBox(); ((System.ComponentModel.ISupportInitialize)numericUpDownContractPaymentAmount).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewServices).BeginInit(); + groupBox.SuspendLayout(); SuspendLayout(); // // checkedListBoxContractCategory @@ -60,14 +64,16 @@ // // numericUpDownContractPaymentAmount // + numericUpDownContractPaymentAmount.Increment = new decimal(new int[] { 100000, 0, 0, 0 }); numericUpDownContractPaymentAmount.Location = new Point(169, 139); + numericUpDownContractPaymentAmount.Maximum = new decimal(new int[] { 1000000000, 0, 0, 0 }); numericUpDownContractPaymentAmount.Name = "numericUpDownContractPaymentAmount"; numericUpDownContractPaymentAmount.Size = new Size(202, 23); numericUpDownContractPaymentAmount.TabIndex = 2; // // buttonCancel // - buttonCancel.Location = new Point(12, 197); + buttonCancel.Location = new Point(12, 469); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(358, 23); buttonCancel.TabIndex = 9; @@ -77,7 +83,7 @@ // // buttonSave // - buttonSave.Location = new Point(12, 168); + buttonSave.Location = new Point(12, 440); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(358, 23); buttonSave.TabIndex = 8; @@ -148,11 +154,32 @@ labelContractPaymentAmount.TabIndex = 16; labelContractPaymentAmount.Text = "Сумма платежа:"; // + // dataGridViewServices + // + dataGridViewServices.AllowUserToDeleteRows = false; + dataGridViewServices.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewServices.Dock = DockStyle.Fill; + dataGridViewServices.Location = new Point(3, 19); + dataGridViewServices.Name = "dataGridViewServices"; + dataGridViewServices.Size = new Size(352, 244); + dataGridViewServices.TabIndex = 17; + // + // groupBox + // + groupBox.Controls.Add(dataGridViewServices); + groupBox.Location = new Point(12, 168); + groupBox.Name = "groupBox"; + groupBox.Size = new Size(358, 266); + groupBox.TabIndex = 18; + groupBox.TabStop = false; + groupBox.Text = "Услуги:"; + // // FormContract // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(382, 231); + ClientSize = new Size(382, 502); + Controls.Add(groupBox); Controls.Add(labelContractPaymentAmount); Controls.Add(labelContractDeadline); Controls.Add(comboBoxContractExecutorId); @@ -166,8 +193,11 @@ Controls.Add(dateTimePickerContractDeadline); Controls.Add(checkedListBoxContractCategory); Name = "FormContract"; + StartPosition = FormStartPosition.CenterParent; Text = "Контракт"; ((System.ComponentModel.ISupportInitialize)numericUpDownContractPaymentAmount).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewServices).EndInit(); + groupBox.ResumeLayout(false); ResumeLayout(false); PerformLayout(); } @@ -186,5 +216,7 @@ private ComboBox comboBoxContractExecutorId; private Label labelContractDeadline; private Label labelContractPaymentAmount; + private DataGridView dataGridViewServices; + private GroupBox groupBox; } } \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.cs index f853138..769d8b3 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContract.cs @@ -27,10 +27,11 @@ namespace PIbd_23_Gutorov_I.A._IT_Company.Forms } } - dateTimePickerContractDeadline.Value = contract.Deadline; numericUpDownContractPaymentAmount.Value = contract.PaymentAmount; _contractId = value; + + } catch (Exception ex) { @@ -40,11 +41,18 @@ namespace PIbd_23_Gutorov_I.A._IT_Company.Forms } } - public FormContract(IContractRepository contractRepository) + public FormContract(IContractRepository contractRepository, ICustomerRepository customerRepository, IExecutorRepository executorRepository) { InitializeComponent(); _contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository)); + comboBoxContractCustomerId.DataSource = customerRepository.ReadCustomers(); + comboBoxContractCustomerId.DisplayMember = "Id"; + + comboBoxContractExecutorId.DataSource = executorRepository.ReadExecutors(); + comboBoxContractExecutorId.DisplayMember = "Name"; + comboBoxContractExecutorId.DisplayMember = "Id"; + foreach (var elem in Enum.GetValues(typeof(ContractCategory))) { checkedListBoxContractCategory.Items.Add(elem); @@ -55,15 +63,16 @@ namespace PIbd_23_Gutorov_I.A._IT_Company.Forms { try { - if (string.IsNullOrEmpty(textBoxCustomerName.Text) || - string.IsNullOrEmpty(textBoxCustomerContact.Text) || - string.IsNullOrEmpty(textBoxCustomerAddress.Text)) + if (checkedListBoxContractCategory.CheckedItems.Count == 0 || + comboBoxContractCustomerId.SelectedIndex < 0 || + comboBoxContractExecutorId.SelectedIndex < 0) { throw new Exception("Имеются незаполненные поля"); } - if (_contractId.HasValue) _contractRepository.UpdateContract(CreateContract(_contractId.Value)); - else _contractRepository.UpdateContract(CreateContract(0)); + _contractRepository.CreateContract(CreateContract(0)); + + Close(); } catch (Exception ex) { @@ -81,7 +90,8 @@ namespace PIbd_23_Gutorov_I.A._IT_Company.Forms contractCategory |= (ContractCategory)elem; } - return Contract.CreateEntity(id) + return Contract.CreateEntity(id, (int)comboBoxContractCustomerId.SelectedValue!, (int)comboBoxContractExecutorId.SelectedValue!, + contractCategory, dateTimePickerContractDeadline.Value, Convert.ToInt32(numericUpDownContractPaymentAmount.Value)); } } } diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.Designer.cs new file mode 100644 index 0000000..71e53a8 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.Designer.cs @@ -0,0 +1,112 @@ +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + partial class FormContracts + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonDel = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(677, 450); + dataGridViewData.TabIndex = 5; + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(677, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 450); + panel.TabIndex = 4; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.icon_remove_button; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(16, 108); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(90, 90); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add_button; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormContracts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormContracts"; + StartPosition = FormStartPosition.CenterParent; + Text = "Контракты"; + Load += FormContracts_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonDel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.cs new file mode 100644 index 0000000..abce63a --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.cs @@ -0,0 +1,78 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Repositories; +using Unity; + +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + public partial class FormContracts : Form + { + private readonly IUnityContainer _container; + + private readonly IContractRepository _contractRepository; + + public FormContracts(IUnityContainer container, IContractRepository contractRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _contractRepository = contractRepository ?? throw new ArgumentException(nameof(contractRepository)); + } + + private void FormContracts_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; + + try + { + _contractRepository.DeleteContract(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _contractRepository.ReadContracts(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.resx b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormContracts.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/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomer.cs index d61b4c6..b763e2f 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomer.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomer.cs @@ -50,6 +50,8 @@ namespace PIbd_23_Gutorov_I.A._IT_Company.Forms if (_customerId.HasValue) _customerRepository.UpdateCustomer(CreateCustomer(_customerId.Value)); else _customerRepository.UpdateCustomer(CreateCustomer(0)); + + Close(); } catch (Exception ex) { diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.Designer.cs new file mode 100644 index 0000000..58acf10 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.Designer.cs @@ -0,0 +1,180 @@ +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + partial class FormCustomerContractReview + { + /// + /// 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() + { + labelCustomerContractReviewCustomerId = new Label(); + buttonCancel = new Button(); + buttonSave = new Button(); + richTextBoxCustomerContractReviewReview = new RichTextBox(); + labelCustomerContractReviewReview = new Label(); + numericUpDownCustomerContractReviewGrade = new NumericUpDown(); + comboBoxCustomerContractReviewCustomerId = new ComboBox(); + comboBoxCustomerContractReviewContractId = new ComboBox(); + labelCustomerContractReviewContractId = new Label(); + labelCustomerContractReviewGrade = new Label(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCustomerContractReviewGrade).BeginInit(); + SuspendLayout(); + // + // labelCustomerContractReviewCustomerId + // + labelCustomerContractReviewCustomerId.AutoSize = true; + labelCustomerContractReviewCustomerId.Location = new Point(12, 9); + labelCustomerContractReviewCustomerId.Name = "labelCustomerContractReviewCustomerId"; + labelCustomerContractReviewCustomerId.Size = new Size(60, 15); + labelCustomerContractReviewCustomerId.TabIndex = 22; + labelCustomerContractReviewCustomerId.Text = "Заказчик:"; + // + // buttonCancel + // + buttonCancel.Location = new Point(12, 224); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(358, 23); + buttonCancel.TabIndex = 21; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 195); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(358, 23); + buttonSave.TabIndex = 20; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // richTextBoxCustomerContractReviewReview + // + richTextBoxCustomerContractReviewReview.Location = new Point(169, 64); + richTextBoxCustomerContractReviewReview.Name = "richTextBoxCustomerContractReviewReview"; + richTextBoxCustomerContractReviewReview.Size = new Size(202, 96); + richTextBoxCustomerContractReviewReview.TabIndex = 27; + richTextBoxCustomerContractReviewReview.Text = ""; + // + // labelCustomerContractReviewReview + // + labelCustomerContractReviewReview.AutoSize = true; + labelCustomerContractReviewReview.Location = new Point(12, 67); + labelCustomerContractReviewReview.Name = "labelCustomerContractReviewReview"; + labelCustomerContractReviewReview.Size = new Size(44, 15); + labelCustomerContractReviewReview.TabIndex = 28; + labelCustomerContractReviewReview.Text = "Отзыв:"; + // + // numericUpDownCustomerContractReviewGrade + // + numericUpDownCustomerContractReviewGrade.Location = new Point(169, 166); + numericUpDownCustomerContractReviewGrade.Maximum = new decimal(new int[] { 5, 0, 0, 0 }); + numericUpDownCustomerContractReviewGrade.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownCustomerContractReviewGrade.Name = "numericUpDownCustomerContractReviewGrade"; + numericUpDownCustomerContractReviewGrade.Size = new Size(201, 23); + numericUpDownCustomerContractReviewGrade.TabIndex = 29; + numericUpDownCustomerContractReviewGrade.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // comboBoxCustomerContractReviewCustomerId + // + comboBoxCustomerContractReviewCustomerId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCustomerContractReviewCustomerId.FormattingEnabled = true; + comboBoxCustomerContractReviewCustomerId.Location = new Point(169, 6); + comboBoxCustomerContractReviewCustomerId.Name = "comboBoxCustomerContractReviewCustomerId"; + comboBoxCustomerContractReviewCustomerId.Size = new Size(202, 23); + comboBoxCustomerContractReviewCustomerId.TabIndex = 30; + // + // comboBoxCustomerContractReviewContractId + // + comboBoxCustomerContractReviewContractId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCustomerContractReviewContractId.FormattingEnabled = true; + comboBoxCustomerContractReviewContractId.Location = new Point(169, 35); + comboBoxCustomerContractReviewContractId.Name = "comboBoxCustomerContractReviewContractId"; + comboBoxCustomerContractReviewContractId.Size = new Size(202, 23); + comboBoxCustomerContractReviewContractId.TabIndex = 31; + // + // labelCustomerContractReviewContractId + // + labelCustomerContractReviewContractId.AutoSize = true; + labelCustomerContractReviewContractId.Location = new Point(12, 38); + labelCustomerContractReviewContractId.Name = "labelCustomerContractReviewContractId"; + labelCustomerContractReviewContractId.Size = new Size(60, 15); + labelCustomerContractReviewContractId.TabIndex = 32; + labelCustomerContractReviewContractId.Text = "Контракт:"; + // + // labelCustomerContractReviewGrade + // + labelCustomerContractReviewGrade.AutoSize = true; + labelCustomerContractReviewGrade.Location = new Point(12, 168); + labelCustomerContractReviewGrade.Name = "labelCustomerContractReviewGrade"; + labelCustomerContractReviewGrade.Size = new Size(51, 15); + labelCustomerContractReviewGrade.TabIndex = 33; + labelCustomerContractReviewGrade.Text = "Оценка:"; + // + // FormCustomerContractReview + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(381, 260); + Controls.Add(labelCustomerContractReviewGrade); + Controls.Add(labelCustomerContractReviewContractId); + Controls.Add(comboBoxCustomerContractReviewContractId); + Controls.Add(comboBoxCustomerContractReviewCustomerId); + Controls.Add(numericUpDownCustomerContractReviewGrade); + Controls.Add(labelCustomerContractReviewReview); + Controls.Add(richTextBoxCustomerContractReviewReview); + Controls.Add(labelCustomerContractReviewCustomerId); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Name = "FormCustomerContractReview"; + StartPosition = FormStartPosition.CenterParent; + Text = "Отзыв заказчика"; + ((System.ComponentModel.ISupportInitialize)numericUpDownCustomerContractReviewGrade).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelContractPaymentAmount; + private Label labelContractDeadline; + private ComboBox comboBoxCustomerContractReviewCustomerId; + private ComboBox comboBoxContractCustomerId; + private Label labelContractCategory; + private Label labelContractExecutorId; + private Label labelCustomerContractReviewCustomerId; + private Button buttonCancel; + private Button buttonSave; + private RichTextBox richTextBoxCustomerContractReviewReview; + private Label labelCustomerContractReviewReview; + private NumericUpDown numericUpDownCustomerContractReviewGrade; + private NumericUpDown numericUpDownContractPaymentAmount; + private DateTimePicker dateTimePickerContractDeadline; + private CheckedListBox checkedListBoxContractCategory; + private ComboBox comboBoxCustomerContractReviewContractId; + private Label labelCustomerContractReviewContractId; + private Label labelCustomerContractReviewGrade; + } +} \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.cs new file mode 100644 index 0000000..cceece4 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.cs @@ -0,0 +1,49 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Repositories; +using PIbd_23_Gutorov_I.A._IT_Company.Entities; + +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + public partial class FormCustomerContractReview : Form + { + private readonly ICustomerContractReviewRepository _customerContractReviewRepository; + + public FormCustomerContractReview(ICustomerContractReviewRepository customerContractReviewRepository, + ICustomerRepository customerRepository, IContractRepository contractRepository) + { + InitializeComponent(); + _customerContractReviewRepository = customerContractReviewRepository ?? throw new ArgumentNullException(nameof(customerContractReviewRepository)); + + comboBoxCustomerContractReviewCustomerId.DataSource = customerRepository.ReadCustomers(); + comboBoxCustomerContractReviewCustomerId.DisplayMember = "Name"; + comboBoxCustomerContractReviewCustomerId.DisplayMember = "Id"; + + comboBoxCustomerContractReviewContractId.DataSource = contractRepository.ReadContracts(); + comboBoxCustomerContractReviewCustomerId.DisplayMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxCustomerContractReviewContractId.SelectedIndex < 0 || + comboBoxCustomerContractReviewCustomerId.SelectedIndex < 0 || + string.IsNullOrEmpty(richTextBoxCustomerContractReviewReview.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + _customerContractReviewRepository.CreateCustomerContractReview(CustomerContractReview.CreateElement( + 0, (int)comboBoxCustomerContractReviewCustomerId.SelectedValue!, (int)comboBoxCustomerContractReviewContractId.SelectedValue!, + richTextBoxCustomerContractReviewReview.Text, Convert.ToInt32(numericUpDownContractPaymentAmount.Value))); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.resx b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReview.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/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.Designer.cs new file mode 100644 index 0000000..756dbe0 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.Designer.cs @@ -0,0 +1,98 @@ +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + partial class FormCustomerContractReviews + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(677, 450); + dataGridViewData.TabIndex = 5; + // + // panel + // + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(677, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 450); + panel.TabIndex = 4; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add_button; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormCustomerContractReviews + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormCustomerContractReviews"; + StartPosition = FormStartPosition.CenterParent; + Text = "Отзывы заказчиков"; + Load += FormCustomerContractReviews_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.cs new file mode 100644 index 0000000..e6453df --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.cs @@ -0,0 +1,47 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Repositories; +using PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations; +using Unity; + +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + public partial class FormCustomerContractReviews : Form + { + private readonly IUnityContainer _container; + + private readonly ICustomerContractReviewRepository _customerContractReviewRepository; + + public FormCustomerContractReviews(IUnityContainer container, ICustomerContractReviewRepository customerContractReviewRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _customerContractReviewRepository = customerContractReviewRepository ?? throw new ArgumentException(nameof(customerContractReviewRepository)); + } + + private void FormCustomerContractReviews_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _customerContractReviewRepository.ReadCustomerContractReviews(); + } +} diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.resx b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormCustomerContractReviews.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/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.Designer.cs index d165291..648db50 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.Designer.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.Designer.cs @@ -102,7 +102,8 @@ Controls.Add(LabelExecutorName); Controls.Add(comboBoxExecutorPost); Name = "FormExecutor"; - Text = "FormExecutor"; + StartPosition = FormStartPosition.CenterParent; + Text = "Исполнитель"; ResumeLayout(false); PerformLayout(); } diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.cs index f5c9666..5945fe2 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutor.cs @@ -51,6 +51,8 @@ namespace PIbd_23_Gutorov_I.A._IT_Company.Forms if (_executorId.HasValue) _executorRepository.UpdateExecutor(CreateExecutor(_executorId.Value)); else _executorRepository.UpdateExecutor(CreateExecutor(0)); + + Close(); } catch (Exception ex) { diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.Designer.cs index b67755c..5a6fca5 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.Designer.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.Designer.cs @@ -107,7 +107,8 @@ Controls.Add(dataGridViewData); Controls.Add(panel); Name = "FormExecutors"; - Text = "FormExecutors"; + StartPosition = FormStartPosition.CenterParent; + Text = "Исполнители"; Load += FormExecutors_Load; ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); panel.ResumeLayout(false); diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.cs index 8c99e4b..f4b93ba 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormExecutors.cs @@ -1,15 +1,4 @@ using PIbd_23_Gutorov_I.A._IT_Company.Repositories; -using PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations; -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; -using System.Xml.Linq; using Unity; namespace PIbd_23_Gutorov_I.A._IT_Company.Forms diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.Designer.cs new file mode 100644 index 0000000..08125c8 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.Designer.cs @@ -0,0 +1,121 @@ +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + partial class FormService + { + /// + /// 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() + { + comboBoxServiceContractId = new ComboBox(); + labelServiceContractId = new Label(); + labelServiceDescription = new Label(); + richTextBoxServiceDescription = new RichTextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // comboBoxServiceContractId + // + comboBoxServiceContractId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxServiceContractId.FormattingEnabled = true; + comboBoxServiceContractId.Location = new Point(169, 6); + comboBoxServiceContractId.Name = "comboBoxServiceContractId"; + comboBoxServiceContractId.Size = new Size(202, 23); + comboBoxServiceContractId.TabIndex = 15; + // + // labelServiceContractId + // + labelServiceContractId.AutoSize = true; + labelServiceContractId.Location = new Point(12, 9); + labelServiceContractId.Name = "labelServiceContractId"; + labelServiceContractId.Size = new Size(60, 15); + labelServiceContractId.TabIndex = 14; + labelServiceContractId.Text = "Контракт:"; + // + // labelServiceDescription + // + labelServiceDescription.AutoSize = true; + labelServiceDescription.Location = new Point(12, 38); + labelServiceDescription.Name = "labelServiceDescription"; + labelServiceDescription.Size = new Size(65, 15); + labelServiceDescription.TabIndex = 30; + labelServiceDescription.Text = "Описание:"; + // + // richTextBoxServiceDescription + // + richTextBoxServiceDescription.Location = new Point(169, 35); + richTextBoxServiceDescription.Name = "richTextBoxServiceDescription"; + richTextBoxServiceDescription.Size = new Size(202, 96); + richTextBoxServiceDescription.TabIndex = 29; + richTextBoxServiceDescription.Text = ""; + // + // buttonCancel + // + buttonCancel.Location = new Point(12, 166); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(359, 23); + buttonCancel.TabIndex = 32; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 137); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(359, 23); + buttonSave.TabIndex = 31; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormService + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(387, 208); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelServiceDescription); + Controls.Add(richTextBoxServiceDescription); + Controls.Add(comboBoxServiceContractId); + Controls.Add(labelServiceContractId); + Name = "FormService"; + StartPosition = FormStartPosition.CenterParent; + Text = "Услуга"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxServiceContractId; + private Label labelServiceContractId; + private Label labelServiceDescription; + private RichTextBox richTextBoxServiceDescription; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.cs new file mode 100644 index 0000000..b5429c0 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.cs @@ -0,0 +1,75 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Entities; +using PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums; +using PIbd_23_Gutorov_I.A._IT_Company.Repositories; +using PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations; +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 PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + public partial class FormService : Form + { + private readonly IServiceRepository _serviceRepository; + + private int? _serviceId; + + public int Id + { + set + { + try + { + var contract = _serviceRepository.ReadServiceById(value); + if (contract == null) throw new InvalidDataException(nameof(contract)); + + richTextBoxServiceDescription.Text = contract.Description; + _serviceId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormService(IServiceRepository serviceRepository, IContractRepository contractRepository) + { + InitializeComponent(); + _serviceRepository = serviceRepository ?? throw new ArgumentNullException(nameof(serviceRepository)); + + comboBoxServiceContractId.DataSource = contractRepository.ReadContracts(); + comboBoxServiceContractId.DisplayMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxServiceContractId.SelectedIndex < 0 || + string.IsNullOrEmpty(richTextBoxServiceDescription.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + _serviceRepository.CreateService(Service.CreateEntity(0, + richTextBoxServiceDescription.Text, (int)comboBoxServiceContractId.SelectedValue!)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.resx b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormService.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/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.Designer.cs new file mode 100644 index 0000000..f8332dd --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.Designer.cs @@ -0,0 +1,194 @@ +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + partial class FormServiceExecution + { + /// + /// 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() + { + labelContractDeadline = new Label(); + comboBoxServiceExecutionExecutorId = new ComboBox(); + labelServiceExecutionExecutorId = new Label(); + dateTimePickerContractDeadline = new DateTimePicker(); + comboBoxServiceExecutionContractId = new ComboBox(); + labelServiceExecutionContractId = new Label(); + comboBoxServiceExecutionServiceId = new ComboBox(); + labelServiceExecutionServiceId = new Label(); + labelServiceExecutionCompleteion = new Label(); + numericUpDownContractPaymentAmount = new NumericUpDown(); + buttonCancel = new Button(); + buttonSave = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownContractPaymentAmount).BeginInit(); + SuspendLayout(); + // + // labelContractDeadline + // + labelContractDeadline.AutoSize = true; + labelContractDeadline.Location = new Point(12, 128); + labelContractDeadline.Name = "labelContractDeadline"; + labelContractDeadline.Size = new Size(110, 15); + labelContractDeadline.TabIndex = 21; + labelContractDeadline.Text = "Срок выполнения:"; + // + // comboBoxServiceExecutionExecutorId + // + comboBoxServiceExecutionExecutorId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxServiceExecutionExecutorId.FormattingEnabled = true; + comboBoxServiceExecutionExecutorId.Location = new Point(169, 64); + comboBoxServiceExecutionExecutorId.Name = "comboBoxServiceExecutionExecutorId"; + comboBoxServiceExecutionExecutorId.Size = new Size(202, 23); + comboBoxServiceExecutionExecutorId.TabIndex = 20; + // + // labelServiceExecutionExecutorId + // + labelServiceExecutionExecutorId.AutoSize = true; + labelServiceExecutionExecutorId.Location = new Point(12, 67); + labelServiceExecutionExecutorId.Name = "labelServiceExecutionExecutorId"; + labelServiceExecutionExecutorId.Size = new Size(84, 15); + labelServiceExecutionExecutorId.TabIndex = 18; + labelServiceExecutionExecutorId.Text = "Исполнитель:"; + // + // dateTimePickerContractDeadline + // + dateTimePickerContractDeadline.Location = new Point(169, 122); + dateTimePickerContractDeadline.Name = "dateTimePickerContractDeadline"; + dateTimePickerContractDeadline.Size = new Size(202, 23); + dateTimePickerContractDeadline.TabIndex = 16; + // + // comboBoxServiceExecutionContractId + // + comboBoxServiceExecutionContractId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxServiceExecutionContractId.FormattingEnabled = true; + comboBoxServiceExecutionContractId.Location = new Point(169, 6); + comboBoxServiceExecutionContractId.Name = "comboBoxServiceExecutionContractId"; + comboBoxServiceExecutionContractId.Size = new Size(202, 23); + comboBoxServiceExecutionContractId.TabIndex = 23; + // + // labelServiceExecutionContractId + // + labelServiceExecutionContractId.AutoSize = true; + labelServiceExecutionContractId.Location = new Point(12, 9); + labelServiceExecutionContractId.Name = "labelServiceExecutionContractId"; + labelServiceExecutionContractId.Size = new Size(60, 15); + labelServiceExecutionContractId.TabIndex = 22; + labelServiceExecutionContractId.Text = "Контракт:"; + // + // comboBoxServiceExecutionServiceId + // + comboBoxServiceExecutionServiceId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxServiceExecutionServiceId.FormattingEnabled = true; + comboBoxServiceExecutionServiceId.Location = new Point(169, 35); + comboBoxServiceExecutionServiceId.Name = "comboBoxServiceExecutionServiceId"; + comboBoxServiceExecutionServiceId.Size = new Size(202, 23); + comboBoxServiceExecutionServiceId.TabIndex = 25; + // + // labelServiceExecutionServiceId + // + labelServiceExecutionServiceId.AutoSize = true; + labelServiceExecutionServiceId.Location = new Point(12, 38); + labelServiceExecutionServiceId.Name = "labelServiceExecutionServiceId"; + labelServiceExecutionServiceId.Size = new Size(47, 15); + labelServiceExecutionServiceId.TabIndex = 24; + labelServiceExecutionServiceId.Text = "Услуга:"; + // + // labelServiceExecutionCompleteion + // + labelServiceExecutionCompleteion.AutoSize = true; + labelServiceExecutionCompleteion.Location = new Point(12, 95); + labelServiceExecutionCompleteion.Name = "labelServiceExecutionCompleteion"; + labelServiceExecutionCompleteion.Size = new Size(94, 15); + labelServiceExecutionCompleteion.TabIndex = 27; + labelServiceExecutionCompleteion.Text = "Готовность в %:"; + // + // numericUpDownContractPaymentAmount + // + numericUpDownContractPaymentAmount.Increment = new decimal(new int[] { 100000, 0, 0, 0 }); + numericUpDownContractPaymentAmount.Location = new Point(169, 93); + numericUpDownContractPaymentAmount.Maximum = new decimal(new int[] { 1000000000, 0, 0, 0 }); + numericUpDownContractPaymentAmount.Name = "numericUpDownContractPaymentAmount"; + numericUpDownContractPaymentAmount.Size = new Size(202, 23); + numericUpDownContractPaymentAmount.TabIndex = 26; + // + // buttonCancel + // + buttonCancel.Location = new Point(12, 180); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(359, 23); + buttonCancel.TabIndex = 29; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 151); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(359, 23); + buttonSave.TabIndex = 28; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormServiceExecution + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(387, 214); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelServiceExecutionCompleteion); + Controls.Add(numericUpDownContractPaymentAmount); + Controls.Add(comboBoxServiceExecutionServiceId); + Controls.Add(labelServiceExecutionServiceId); + Controls.Add(comboBoxServiceExecutionContractId); + Controls.Add(labelServiceExecutionContractId); + Controls.Add(labelContractDeadline); + Controls.Add(comboBoxServiceExecutionExecutorId); + Controls.Add(labelServiceExecutionExecutorId); + Controls.Add(dateTimePickerContractDeadline); + Name = "FormServiceExecution"; + StartPosition = FormStartPosition.CenterParent; + Text = "Выполнение услуги"; + ((System.ComponentModel.ISupportInitialize)numericUpDownContractPaymentAmount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelContractDeadline; + private ComboBox comboBoxServiceExecutionExecutorId; + private Label labelServiceExecutionExecutorId; + private DateTimePicker dateTimePickerContractDeadline; + private ComboBox comboBoxServiceExecutionContractId; + private Label labelServiceExecutionContractId; + private ComboBox comboBoxServiceExecutionServiceId; + private Label labelServiceExecutionServiceId; + private Label labelServiceExecutionCompleteion; + private NumericUpDown numericUpDownContractPaymentAmount; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.cs new file mode 100644 index 0000000..07498f3 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.cs @@ -0,0 +1,63 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums; +using PIbd_23_Gutorov_I.A._IT_Company.Repositories; +using PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations; +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 PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + public partial class FormServiceExecution : Form + { + private readonly IServiceExecutionRepository _serviceExecutionRepository; + + private int? _serviceExecutionId; + + public int Id + { + set + { + try + { + var executor = _serviceExecutionRepository.ReadServiceExecutionById(value); + if (executor == null) throw new InvalidDataException(nameof(executor)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormServiceExecution(IServiceExecutionRepository serviceExecutionRepository, IContractRepository contractRepository, + IServiceRepository serviceRepository, IExecutorRepository executorRepository) + { + InitializeComponent(); + _serviceExecutionRepository = serviceExecutionRepository ?? throw new ArgumentNullException(nameof(serviceExecutionRepository)); + + comboBoxServiceExecutionContractId.DataSource = contractRepository.ReadContracts(); + comboBoxServiceExecutionContractId.DisplayMember = "Id"; + + comboBoxServiceExecutionServiceId.DataSource = serviceRepository.ReadServices(); + comboBoxServiceExecutionServiceId.DisplayMember = "Id"; + + comboBoxServiceExecutionExecutorId.DataSource = executorRepository.ReadExecutors(); + comboBoxServiceExecutionExecutorId.DisplayMember = "Name"; + comboBoxServiceExecutionExecutorId.DisplayMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + Close(); + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.resx b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecution.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/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.Designer.cs new file mode 100644 index 0000000..13ead64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.Designer.cs @@ -0,0 +1,112 @@ +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + partial class FormServiceExecutions + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(677, 450); + dataGridViewData.TabIndex = 5; + // + // panel + // + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(677, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 450); + panel.TabIndex = 4; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.icon_edit_button; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(16, 108); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 90); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add_button; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormServiceExecutions + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormServiceExecutions"; + StartPosition = FormStartPosition.CenterParent; + Text = "Выполнение услуг"; + Load += FormServiceExecutions_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.cs new file mode 100644 index 0000000..cd3fdaf --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.cs @@ -0,0 +1,77 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Repositories; +using Unity; + +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + public partial class FormServiceExecutions : Form + { + private readonly IUnityContainer _container; + + private readonly IServiceExecutionRepository _serviceExecutionRepository; + + public FormServiceExecutions(IUnityContainer container, IServiceExecutionRepository serviceExecutionRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _serviceExecutionRepository = serviceExecutionRepository ?? throw new ArgumentException(nameof(serviceExecutionRepository)); + } + + private void FormServiceExecutions_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _serviceExecutionRepository.ReadServiceExecutions(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.resx b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServiceExecutions.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/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.Designer.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.Designer.cs new file mode 100644 index 0000000..dafc7f2 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.Designer.cs @@ -0,0 +1,126 @@ +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + partial class FormServices + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(677, 450); + dataGridViewData.TabIndex = 5; + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(677, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 450); + panel.TabIndex = 4; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.icon_remove_button; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(16, 204); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(90, 90); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.icon_edit_button; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(16, 108); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 90); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add_button; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormServices + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormServices"; + StartPosition = FormStartPosition.CenterParent; + Text = "Услуги"; + Load += FormServices_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.cs b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.cs new file mode 100644 index 0000000..50d6fd4 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.cs @@ -0,0 +1,97 @@ +using PIbd_23_Gutorov_I.A._IT_Company.Repositories; +using PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations; +using Unity; + +namespace PIbd_23_Gutorov_I.A._IT_Company.Forms +{ + public partial class FormServices : Form + { + private readonly IUnityContainer _container; + + private readonly IServiceRepository _serviceRepository; + + public FormServices(IUnityContainer container, IServiceRepository serviceRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _serviceRepository = serviceRepository ?? throw new ArgumentException(nameof(serviceRepository)); + } + + private void FormServices_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; + + try + { + _serviceRepository.DeleteService(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _serviceRepository.ReadServices(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.resx b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PIbd-23_Gutorov_I.A._IT-Company/Forms/FormServices.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/PIbd-23_Gutorov_I.A._IT-Company/Repositories/IContractRepository.cs b/PIbd-23_Gutorov_I.A._IT-Company/Repositories/IContractRepository.cs index d22894e..5dbfb59 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Repositories/IContractRepository.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Repositories/IContractRepository.cs @@ -10,7 +10,5 @@ public interface IContractRepository void CreateContract(Contract Contract); - void UpdateContract(Contract Contract); - void DeleteContract(int id); } diff --git a/PIbd-23_Gutorov_I.A._IT-Company/Repositories/Implementations/ContractRepository.cs b/PIbd-23_Gutorov_I.A._IT-Company/Repositories/Implementations/ContractRepository.cs index 255904a..3afd64f 100644 --- a/PIbd-23_Gutorov_I.A._IT-Company/Repositories/Implementations/ContractRepository.cs +++ b/PIbd-23_Gutorov_I.A._IT-Company/Repositories/Implementations/ContractRepository.cs @@ -21,8 +21,4 @@ public class ContractRepository : IContractRepository { return []; } - - public void UpdateContract(Contract Contract) - { - } }