From d3189b9ce31673499cf7f0362f0e45fa8b8d65da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=9F=D0=B5=D1=80=D0=BC=D1=8F?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2?= Date: Fri, 22 Nov 2024 14:45:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RealEstateTransactions/Entities/Deal.cs | 8 +- .../FormGeneral.Designer.cs | 35 ++-- .../RealEstateTransactions/FormGeneral.cs | 12 -- .../Forms/FormDeal.Designer.cs | 68 +++++++- .../RealEstateTransactions/Forms/FormDeal.cs | 67 +++----- .../Forms/FormDeal.resx | 6 + .../Forms/FormDeals.Designer.cs | 16 +- .../RealEstateTransactions/Forms/FormDeals.cs | 17 -- .../Forms/FormServicesDeal.Designer.cs | 158 ------------------ .../Forms/FormServicesDeal.cs | 47 ------ .../Forms/FormServicesDeal.resx | 120 ------------- .../Forms/FormServicesDeals.Designer.cs | 100 ----------- .../Forms/FormServicesDeals.cs | 46 ----- .../Forms/FormServicesDeals.resx | 120 ------------- .../Implementations/DealRepository.cs | 7 +- 15 files changed, 114 insertions(+), 713 deletions(-) delete mode 100644 RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.Designer.cs delete mode 100644 RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.cs delete mode 100644 RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.resx delete mode 100644 RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.Designer.cs delete mode 100644 RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.cs delete mode 100644 RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.resx diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/Deal.cs b/RealEstateTransactions/RealEstateTransactions/Entities/Deal.cs index e72cdf4..b634918 100644 --- a/RealEstateTransactions/RealEstateTransactions/Entities/Deal.cs +++ b/RealEstateTransactions/RealEstateTransactions/Entities/Deal.cs @@ -12,7 +12,10 @@ public DateTime DealDate { get; private set; } - public static Deal CreateDeal(int id, int apartmentId, int buyerId, float dealPrice, DateTime dealDate) + public IEnumerable DealServices { get; private set; } = []; + + public static Deal CreateDeal(int id, int apartmentId, int buyerId, float dealPrice, + DateTime dealDate, IEnumerable dealServices) { return new Deal { @@ -20,7 +23,8 @@ ApartmentId = apartmentId, BuyerId = buyerId, DealPrice = dealPrice, - DealDate = dealDate + DealDate = dealDate, + DealServices = dealServices }; } } diff --git a/RealEstateTransactions/RealEstateTransactions/FormGeneral.Designer.cs b/RealEstateTransactions/RealEstateTransactions/FormGeneral.Designer.cs index af5ae6e..b21203d 100644 --- a/RealEstateTransactions/RealEstateTransactions/FormGeneral.Designer.cs +++ b/RealEstateTransactions/RealEstateTransactions/FormGeneral.Designer.cs @@ -32,11 +32,10 @@ справочникиToolStripMenuItem = new ToolStripMenuItem(); квартирыToolStripMenuItem = new ToolStripMenuItem(); покупателиToolStripMenuItem = new ToolStripMenuItem(); - сделкиToolStripMenuItem = new ToolStripMenuItem(); услугиToolStripMenuItem = new ToolStripMenuItem(); операцииToolStripMenuItem = new ToolStripMenuItem(); допродажныеУслугиToolStripMenuItem = new ToolStripMenuItem(); - услугиПродажиToolStripMenuItem = new ToolStripMenuItem(); + сделкиToolStripMenuItem = new ToolStripMenuItem(); отчётToolStripMenuItem = new ToolStripMenuItem(); menuStrip1.SuspendLayout(); SuspendLayout(); @@ -53,7 +52,7 @@ // // справочникиToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { квартирыToolStripMenuItem, покупателиToolStripMenuItem, сделкиToolStripMenuItem, услугиToolStripMenuItem }); + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { квартирыToolStripMenuItem, покупателиToolStripMenuItem, услугиToolStripMenuItem }); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Text = "Справочники"; @@ -61,34 +60,27 @@ // квартирыToolStripMenuItem // квартирыToolStripMenuItem.Name = "квартирыToolStripMenuItem"; - квартирыToolStripMenuItem.Size = new Size(174, 26); + квартирыToolStripMenuItem.Size = new Size(224, 26); квартирыToolStripMenuItem.Text = "Квартиры"; квартирыToolStripMenuItem.Click += КвартирыToolStripMenuItem_Click; // // покупателиToolStripMenuItem // покупателиToolStripMenuItem.Name = "покупателиToolStripMenuItem"; - покупателиToolStripMenuItem.Size = new Size(174, 26); + покупателиToolStripMenuItem.Size = new Size(224, 26); покупателиToolStripMenuItem.Text = "Покупатели"; покупателиToolStripMenuItem.Click += ПокупателиToolStripMenuItem_Click; // - // сделкиToolStripMenuItem - // - сделкиToolStripMenuItem.Name = "сделкиToolStripMenuItem"; - сделкиToolStripMenuItem.Size = new Size(174, 26); - сделкиToolStripMenuItem.Text = "Сделки"; - сделкиToolStripMenuItem.Click += СделкиToolStripMenuItem_Click; - // // услугиToolStripMenuItem // услугиToolStripMenuItem.Name = "услугиToolStripMenuItem"; - услугиToolStripMenuItem.Size = new Size(174, 26); + услугиToolStripMenuItem.Size = new Size(224, 26); услугиToolStripMenuItem.Text = "Услуги"; услугиToolStripMenuItem.Click += УслугиToolStripMenuItem_Click; // // операцииToolStripMenuItem // - операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { допродажныеУслугиToolStripMenuItem, услугиПродажиToolStripMenuItem }); + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { допродажныеУслугиToolStripMenuItem, сделкиToolStripMenuItem }); операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; операцииToolStripMenuItem.Size = new Size(95, 24); операцииToolStripMenuItem.Text = "Операции"; @@ -100,12 +92,12 @@ допродажныеУслугиToolStripMenuItem.Text = "Допродажные услуги"; допродажныеУслугиToolStripMenuItem.Click += ДопродажныеУслугиToolStripMenuItem_Click; // - // услугиПродажиToolStripMenuItem + // сделкиToolStripMenuItem // - услугиПродажиToolStripMenuItem.Name = "услугиПродажиToolStripMenuItem"; - услугиПродажиToolStripMenuItem.Size = new Size(241, 26); - услугиПродажиToolStripMenuItem.Text = "Услуги продажи"; - услугиПродажиToolStripMenuItem.Click += УслугиПродажиToolStripMenuItem_Click; + сделкиToolStripMenuItem.Name = "сделкиToolStripMenuItem"; + сделкиToolStripMenuItem.Size = new Size(241, 26); + сделкиToolStripMenuItem.Text = "Сделки"; + сделкиToolStripMenuItem.Click += СделкиToolStripMenuItem_Click; // // отчётToolStripMenuItem // @@ -138,11 +130,10 @@ private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem квартирыToolStripMenuItem; private ToolStripMenuItem покупателиToolStripMenuItem; - private ToolStripMenuItem сделкиToolStripMenuItem; - private ToolStripMenuItem услугиToolStripMenuItem; private ToolStripMenuItem операцииToolStripMenuItem; private ToolStripMenuItem допродажныеУслугиToolStripMenuItem; - private ToolStripMenuItem услугиПродажиToolStripMenuItem; private ToolStripMenuItem отчётToolStripMenuItem; + private ToolStripMenuItem услугиToolStripMenuItem; + private ToolStripMenuItem сделкиToolStripMenuItem; } } diff --git a/RealEstateTransactions/RealEstateTransactions/FormGeneral.cs b/RealEstateTransactions/RealEstateTransactions/FormGeneral.cs index 8ab09b3..ba33777 100644 --- a/RealEstateTransactions/RealEstateTransactions/FormGeneral.cs +++ b/RealEstateTransactions/RealEstateTransactions/FormGeneral.cs @@ -73,17 +73,5 @@ namespace RealEstateTransactions MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - - private void ToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } } } \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.Designer.cs index 88047d1..f7b3cf2 100644 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.Designer.cs +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.Designer.cs @@ -38,7 +38,13 @@ dateTimePickerDealDate = new DateTimePicker(); buttonSave = new Button(); buttonCancel = new Button(); + groupBoxDataGrid = new GroupBox(); + dataGridView = new DataGridView(); + ColumnService = new DataGridViewComboBoxColumn(); + ColumnTimeSpan = new DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)numericUpDownDealPrice).BeginInit(); + groupBoxDataGrid.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // // labelApartmentId @@ -47,9 +53,9 @@ labelApartmentId.Font = new Font("Segoe UI", 14F); labelApartmentId.Location = new Point(12, 9); labelApartmentId.Name = "labelApartmentId"; - labelApartmentId.Size = new Size(345, 32); + labelApartmentId.Size = new Size(349, 32); labelApartmentId.TabIndex = 0; - labelApartmentId.Text = "ID квартиты - - - - - - - -"; + labelApartmentId.Text = "ID квартиры - - - - - - - -"; // // comboBoxApartmentId // @@ -73,6 +79,7 @@ // // comboBoxFullName // + comboBoxFullName.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxFullName.Font = new Font("Segoe UI", 14F); comboBoxFullName.FormattingEnabled = true; comboBoxFullName.Location = new Point(218, 73); @@ -127,8 +134,9 @@ // // buttonSave // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonSave.Font = new Font("Segoe UI", 14F); - buttonSave.Location = new Point(66, 281); + buttonSave.Location = new Point(66, 579); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(146, 63); buttonSave.TabIndex = 3; @@ -138,8 +146,9 @@ // // buttonCancel // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.Font = new Font("Segoe UI", 14F); - buttonCancel.Location = new Point(328, 281); + buttonCancel.Location = new Point(328, 579); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(146, 63); buttonCancel.TabIndex = 4; @@ -147,11 +156,54 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; // + // groupBoxDataGrid + // + groupBoxDataGrid.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxDataGrid.Controls.Add(dataGridView); + groupBoxDataGrid.Font = new Font("Segoe UI", 14F); + groupBoxDataGrid.Location = new Point(66, 283); + groupBoxDataGrid.Name = "groupBoxDataGrid"; + groupBoxDataGrid.Size = new Size(408, 269); + groupBoxDataGrid.TabIndex = 6; + groupBoxDataGrid.TabStop = false; + groupBoxDataGrid.Text = "Услуги"; + // + // dataGridView + // + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnService, ColumnTimeSpan }); + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(3, 35); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(402, 231); + dataGridView.TabIndex = 0; + dataGridView.TabStop = false; + // + // ColumnService + // + ColumnService.HeaderText = "Услуга"; + ColumnService.MinimumWidth = 6; + ColumnService.Name = "ColumnService"; + // + // ColumnTimeSpan + // + ColumnTimeSpan.HeaderText = "Время выполнения (ч)"; + ColumnTimeSpan.MinimumWidth = 6; + ColumnTimeSpan.Name = "ColumnTimeSpan"; + // // FormDeal // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(534, 356); + ClientSize = new Size(534, 654); + Controls.Add(groupBoxDataGrid); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(dateTimePickerDealDate); @@ -166,6 +218,8 @@ StartPosition = FormStartPosition.CenterParent; Text = "Сделка"; ((System.ComponentModel.ISupportInitialize)numericUpDownDealPrice).EndInit(); + groupBoxDataGrid.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -182,5 +236,9 @@ private DateTimePicker dateTimePickerDealDate; private Button buttonSave; private Button buttonCancel; + private GroupBox groupBoxDataGrid; + private DataGridView dataGridView; + private DataGridViewComboBoxColumn ColumnService; + private DataGridViewTextBoxColumn ColumnTimeSpan; } } \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.cs index fbb8890..63122bf 100644 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.cs +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.cs @@ -6,43 +6,12 @@ namespace RealEstateTransactions.Forms public partial class FormDeal : Form { private readonly IDealRepository _repository; - private readonly IApartmentRepository _apartmentRepository; - private readonly IBuyerRepository _buyerRepository; - - private int? _dealId; - - public int Id - { - set - { - try - { - var deal = _repository.ReadDeal(value); - - if (deal == null) throw new InvalidDataException(nameof(deal)); - - comboBoxApartmentId.SelectedItem = _apartmentRepository.ReadApartment(deal.ApartmentId); - comboBoxFullName.SelectedItem = _buyerRepository.ReadBuyer(deal.BuyerId); - numericUpDownDealPrice.Value = (decimal)deal.DealPrice; - dateTimePickerDealDate.Value = deal.DealDate; - - _dealId = value; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } public FormDeal(IDealRepository repository, IApartmentRepository apartmentRepository, - IBuyerRepository buyerRepository) + IBuyerRepository buyerRepository, IServicesRepository servicesRepository) { InitializeComponent(); _repository = repository ?? throw new ArgumentNullException(nameof(repository)); - _apartmentRepository = apartmentRepository ?? throw new ArgumentNullException(nameof(apartmentRepository)); - _buyerRepository = buyerRepository ?? throw new ArgumentNullException(nameof(buyerRepository)); comboBoxApartmentId.DataSource = apartmentRepository.ReadApartments(); comboBoxApartmentId.DisplayMember = "Id"; @@ -52,6 +21,10 @@ namespace RealEstateTransactions.Forms comboBoxFullName.DisplayMember = "FullName"; comboBoxFullName.ValueMember = "Id"; + ColumnService.DataSource = servicesRepository.ReadServices(); + ColumnService.DisplayMember = "Name"; + ColumnService.ValueMember = "Id"; + dateTimePickerDealDate.Value = DateTime.Now; } @@ -59,17 +32,13 @@ namespace RealEstateTransactions.Forms { try { - if (comboBoxApartmentId.SelectedItem == null || comboBoxFullName.SelectedItem == null) + if (comboBoxApartmentId.SelectedItem == null || comboBoxFullName.SelectedItem == null + || dataGridView.RowCount < 1) throw new Exception("Имеются не заполненные поля"); - if (_dealId.HasValue) - { - _repository.UpdateDeal(CreateDeal(_dealId.Value)); - } - else - { - _repository.CreateDeal(CreateDeal(0)); - } + _repository.CreateDeal(Deal.CreateDeal(0, (int)comboBoxApartmentId.SelectedValue!, + (int)comboBoxFullName.SelectedValue!, (float)numericUpDownDealPrice.Value, + dateTimePickerDealDate.Value, CreateListFromDataGridView())); Close(); } @@ -81,7 +50,19 @@ namespace RealEstateTransactions.Forms private void ButtonCancel_Click(object sender, EventArgs e) => Close(); - private Deal CreateDeal(int id) => Deal.CreateDeal(id, (int)comboBoxApartmentId.SelectedValue!, - (int)comboBoxFullName.SelectedValue!, (float)numericUpDownDealPrice.Value, dateTimePickerDealDate.Value); + private List CreateListFromDataGridView() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridView.Rows) + { + if (row.Cells["ColumnService"].Value == null || + row.Cells["ColumnTimeSpan"].Value == null) + { + continue; + } + list.Add(ServicesDeal.CreateServicesDeal((int)row.Cells["ColumnService"].Value, 0, (float)row.Cells["ColumnTimeSpan"].Value)); + } + return list; + } } } \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.resx index 8b2ff64..0ccc94e 100644 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.resx +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.Designer.cs index 41f9393..e74eccc 100644 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.Designer.cs +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.Designer.cs @@ -30,7 +30,6 @@ { panelTools = new Panel(); buttonDelete = new Button(); - buttonUpdate = new Button(); buttonAdd = new Button(); dataGridView = new DataGridView(); panelTools.SuspendLayout(); @@ -40,7 +39,6 @@ // panelTools // panelTools.Controls.Add(buttonDelete); - panelTools.Controls.Add(buttonUpdate); panelTools.Controls.Add(buttonAdd); panelTools.Dock = DockStyle.Right; panelTools.Location = new Point(851, 0); @@ -55,21 +53,10 @@ buttonDelete.Location = new Point(28, 333); buttonDelete.Name = "buttonDelete"; buttonDelete.Size = new Size(80, 80); - buttonDelete.TabIndex = 2; + buttonDelete.TabIndex = 1; buttonDelete.UseVisualStyleBackColor = true; buttonDelete.Click += ButtonDelete_Click; // - // buttonUpdate - // - buttonUpdate.BackgroundImage = Properties.Resources.Update; - buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; - buttonUpdate.Location = new Point(28, 204); - buttonUpdate.Name = "buttonUpdate"; - buttonUpdate.Size = new Size(80, 80); - buttonUpdate.TabIndex = 1; - buttonUpdate.UseVisualStyleBackColor = true; - buttonUpdate.Click += ButtonUpdate_Click; - // // buttonAdd // buttonAdd.BackgroundImage = Properties.Resources.Add; @@ -121,7 +108,6 @@ private Panel panelTools; private Button buttonDelete; - private Button buttonUpdate; private Button buttonAdd; private DataGridView dataGridView; } diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.cs index 082cac5..9cc0622 100644 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.cs +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.cs @@ -42,23 +42,6 @@ namespace RealEstateTransactions.Entities } } - private void ButtonUpdate_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFormSelectedRow(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 ButtonDelete_Click(object sender, EventArgs e) { if (!TryGetIdentifierFormSelectedRow(out var findId)) return; diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.Designer.cs deleted file mode 100644 index 0054667..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.Designer.cs +++ /dev/null @@ -1,158 +0,0 @@ -namespace RealEstateTransactions.Forms -{ - partial class FormServicesDeal - { - /// - /// 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() - { - labelServicesId = new Label(); - comboBoxServicesId = new ComboBox(); - labelApartmentId = new Label(); - comboBoxDealId = new ComboBox(); - labelTimeSpan = new Label(); - numericUpDownTimeSpan = new NumericUpDown(); - buttonSave = new Button(); - buttonCancel = new Button(); - ((System.ComponentModel.ISupportInitialize)numericUpDownTimeSpan).BeginInit(); - SuspendLayout(); - // - // labelServicesId - // - labelServicesId.AutoSize = true; - labelServicesId.Font = new Font("Segoe UI", 14F); - labelServicesId.Location = new Point(12, 9); - labelServicesId.Name = "labelServicesId"; - labelServicesId.Size = new Size(212, 32); - labelServicesId.TabIndex = 0; - labelServicesId.Text = "Услуга - - - - -"; - // - // comboBoxServicesId - // - comboBoxServicesId.DropDownStyle = ComboBoxStyle.DropDownList; - comboBoxServicesId.Font = new Font("Segoe UI", 14F); - comboBoxServicesId.FormattingEnabled = true; - comboBoxServicesId.Location = new Point(237, 6); - comboBoxServicesId.Name = "comboBoxServicesId"; - comboBoxServicesId.Size = new Size(192, 39); - comboBoxServicesId.TabIndex = 0; - // - // labelApartmentId - // - labelApartmentId.AutoSize = true; - labelApartmentId.Font = new Font("Segoe UI", 14F); - labelApartmentId.Location = new Point(12, 70); - labelApartmentId.Name = "labelApartmentId"; - labelApartmentId.Size = new Size(271, 32); - labelApartmentId.TabIndex = 1; - labelApartmentId.Text = "ID сделки - - - - - -"; - // - // comboBoxDealId - // - comboBoxDealId.DropDownStyle = ComboBoxStyle.DropDownList; - comboBoxDealId.Font = new Font("Segoe UI", 14F); - comboBoxDealId.FormattingEnabled = true; - comboBoxDealId.Location = new Point(301, 70); - comboBoxDealId.Name = "comboBoxDealId"; - comboBoxDealId.Size = new Size(128, 39); - comboBoxDealId.TabIndex = 1; - // - // labelTimeSpan - // - labelTimeSpan.AutoSize = true; - labelTimeSpan.Font = new Font("Segoe UI", 14F); - labelTimeSpan.Location = new Point(12, 141); - labelTimeSpan.Name = "labelTimeSpan"; - labelTimeSpan.Size = new Size(268, 32); - labelTimeSpan.TabIndex = 2; - labelTimeSpan.Text = "Затраченное время (ч)"; - // - // numericUpDownTimeSpan - // - numericUpDownTimeSpan.BorderStyle = BorderStyle.FixedSingle; - numericUpDownTimeSpan.DecimalPlaces = 1; - numericUpDownTimeSpan.Font = new Font("Segoe UI", 14F); - numericUpDownTimeSpan.Location = new Point(301, 139); - numericUpDownTimeSpan.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); - numericUpDownTimeSpan.Name = "numericUpDownTimeSpan"; - numericUpDownTimeSpan.Size = new Size(128, 39); - numericUpDownTimeSpan.TabIndex = 2; - numericUpDownTimeSpan.TextAlign = HorizontalAlignment.Center; - // - // buttonSave - // - buttonSave.Font = new Font("Segoe UI", 14F); - buttonSave.Location = new Point(38, 205); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(141, 56); - buttonSave.TabIndex = 3; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += ButtonSave_Click; - // - // buttonCancel - // - buttonCancel.Font = new Font("Segoe UI", 14F); - buttonCancel.Location = new Point(237, 205); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(141, 56); - buttonCancel.TabIndex = 4; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += ButtonCancel_Click; - // - // FormServicesDeal - // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(440, 269); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(numericUpDownTimeSpan); - Controls.Add(labelTimeSpan); - Controls.Add(comboBoxDealId); - Controls.Add(labelApartmentId); - Controls.Add(comboBoxServicesId); - Controls.Add(labelServicesId); - Name = "FormServicesDeal"; - StartPosition = FormStartPosition.CenterParent; - Text = "Услуга в сделке"; - ((System.ComponentModel.ISupportInitialize)numericUpDownTimeSpan).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label labelServicesId; - private ComboBox comboBoxServicesId; - private Label labelApartmentId; - private ComboBox comboBoxDealId; - private Label labelTimeSpan; - private NumericUpDown numericUpDownTimeSpan; - private Button buttonSave; - private Button buttonCancel; - } -} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.cs deleted file mode 100644 index 900ae82..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.cs +++ /dev/null @@ -1,47 +0,0 @@ -using RealEstateTransactions.Entities; -using RealEstateTransactions.Repositories; - -namespace RealEstateTransactions.Forms -{ - public partial class FormServicesDeal : Form - { - private readonly IServicesDealRepository _repository; - - public FormServicesDeal(IServicesDealRepository repository, - IDealRepository dealRepository, IServicesRepository servicesRepository) - { - InitializeComponent(); - _repository = repository ?? throw new ArgumentNullException(nameof(repository)); - - comboBoxDealId.DataSource = dealRepository.ReadDeals(); - comboBoxDealId.DisplayMember = "Id"; - comboBoxDealId.ValueMember = "Id"; - - comboBoxServicesId.DataSource = servicesRepository.ReadServices(); - comboBoxServicesId.DisplayMember = "Name"; - comboBoxServicesId.ValueMember = "Id"; - } - - private void ButtonSave_Click(object sender, EventArgs e) - { - try - { - if (comboBoxDealId.SelectedItem == null || comboBoxServicesId.SelectedItem == null) - { - throw new Exception("Имеются незаполненные поля"); - } - - _repository.CreateServicesDeal(ServicesDeal.CreateServicesDeal((int)comboBoxServicesId.SelectedValue!, - (int)comboBoxDealId.SelectedValue!, (float)numericUpDownTimeSpan.Value)); - - Close(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void ButtonCancel_Click(object sender, EventArgs e) => Close(); - } -} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeal.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.Designer.cs deleted file mode 100644 index 9e3ce6f..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.Designer.cs +++ /dev/null @@ -1,100 +0,0 @@ -namespace RealEstateTransactions.Forms -{ - partial class FormServicesDeals - { - /// - /// 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() - { - panelTools = new Panel(); - buttonAdd = new Button(); - dataGridView = new DataGridView(); - panelTools.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // panelTools - // - panelTools.Controls.Add(buttonAdd); - panelTools.Dock = DockStyle.Right; - panelTools.Location = new Point(851, 0); - panelTools.Name = "panelTools"; - panelTools.Size = new Size(131, 553); - panelTools.TabIndex = 2; - // - // buttonAdd - // - buttonAdd.BackgroundImage = Properties.Resources.Add; - buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; - buttonAdd.Location = new Point(28, 226); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(80, 80); - buttonAdd.TabIndex = 0; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += ButtonAdd_Click; - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.RowHeadersWidth = 51; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(851, 553); - dataGridView.TabIndex = 3; - dataGridView.TabStop = false; - // - // FormServicesDeals - // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(982, 553); - Controls.Add(dataGridView); - Controls.Add(panelTools); - Name = "FormServicesDeals"; - StartPosition = FormStartPosition.CenterParent; - Text = "Услуги в сделках"; - Load += FormServicesDeals_Load; - panelTools.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - } - - #endregion - - private Panel panelTools; - private Button buttonAdd; - private DataGridView dataGridView; - } -} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.cs deleted file mode 100644 index 5339479..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.cs +++ /dev/null @@ -1,46 +0,0 @@ -using RealEstateTransactions.Repositories; -using Unity; - -namespace RealEstateTransactions.Forms -{ - public partial class FormServicesDeals : Form - { - private readonly IUnityContainer _container; - - private readonly IServicesDealRepository _repository; - - public FormServicesDeals(IUnityContainer container, IServicesDealRepository repository) - { - InitializeComponent(); - _container = container ?? throw new ArgumentNullException(nameof(container)); - _repository = repository ?? throw new ArgumentNullException(nameof(repository)); - } - - private void FormServicesDeals_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() => dataGridView.DataSource = _repository.ReadServicesDeal(); - } -} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Forms/FormServicesDeals.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/DealRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/DealRepository.cs index c98d0c5..3eaf7b2 100644 --- a/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/DealRepository.cs +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/DealRepository.cs @@ -1,9 +1,4 @@ using RealEstateTransactions.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace RealEstateTransactions.Repositories.Implementations { @@ -21,7 +16,7 @@ namespace RealEstateTransactions.Repositories.Implementations public Deal ReadDeal(int id) { - return Deal.CreateDeal(0, 0, 0, 0, DateTime.Now); + return Deal.CreateDeal(0, 0, 0, 0, DateTime.Now, []); } public IEnumerable ReadDeals()