Исправления

This commit is contained in:
Роман Пермяков 2024-11-22 14:45:33 +04:00
parent e78a74d712
commit d3189b9ce3
15 changed files with 114 additions and 713 deletions

View File

@ -12,7 +12,10 @@
public DateTime DealDate { get; private set; } public DateTime DealDate { get; private set; }
public static Deal CreateDeal(int id, int apartmentId, int buyerId, float dealPrice, DateTime dealDate) public IEnumerable<ServicesDeal> DealServices { get; private set; } = [];
public static Deal CreateDeal(int id, int apartmentId, int buyerId, float dealPrice,
DateTime dealDate, IEnumerable<ServicesDeal> dealServices)
{ {
return new Deal return new Deal
{ {
@ -20,7 +23,8 @@
ApartmentId = apartmentId, ApartmentId = apartmentId,
BuyerId = buyerId, BuyerId = buyerId,
DealPrice = dealPrice, DealPrice = dealPrice,
DealDate = dealDate DealDate = dealDate,
DealServices = dealServices
}; };
} }
} }

View File

@ -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(); операцииToolStripMenuItem = new ToolStripMenuItem();
допродажныеУслугиToolStripMenuItem = new ToolStripMenuItem(); допродажныеУслугиToolStripMenuItem = new ToolStripMenuItem();
услугиПродажиToolStripMenuItem = new ToolStripMenuItem(); сделкиToolStripMenuItem = new ToolStripMenuItem();
отчётToolStripMenuItem = new ToolStripMenuItem(); отчётToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout(); menuStrip1.SuspendLayout();
SuspendLayout(); SuspendLayout();
@ -53,7 +52,7 @@
// //
// справочникиToolStripMenuItem // справочникиToolStripMenuItem
// //
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { квартирыToolStripMenuItem, покупателиToolStripMenuItem, сделкиToolStripMenuItem, услугиToolStripMenuItem }); справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { квартирыToolStripMenuItem, покупателиToolStripMenuItem, услугиToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники"; справочникиToolStripMenuItem.Text = "Справочники";
@ -61,34 +60,27 @@
// квартирыToolStripMenuItem // квартирыToolStripMenuItem
// //
квартирыToolStripMenuItem.Name = "квартирыToolStripMenuItem"; квартирыToolStripMenuItem.Name = "квартирыToolStripMenuItem";
квартирыToolStripMenuItem.Size = new Size(174, 26); квартирыToolStripMenuItem.Size = new Size(224, 26);
квартирыToolStripMenuItem.Text = "Квартиры"; квартирыToolStripMenuItem.Text = "Квартиры";
квартирыToolStripMenuItem.Click += КвартирыToolStripMenuItem_Click; квартирыToolStripMenuItem.Click += КвартирыToolStripMenuItem_Click;
// //
// покупателиToolStripMenuItem // покупателиToolStripMenuItem
// //
покупателиToolStripMenuItem.Name = "покупателиToolStripMenuItem"; покупателиToolStripMenuItem.Name = "покупателиToolStripMenuItem";
покупателиToolStripMenuItem.Size = new Size(174, 26); покупателиToolStripMenuItem.Size = new Size(224, 26);
покупателиToolStripMenuItem.Text = "Покупатели"; покупателиToolStripMenuItem.Text = "Покупатели";
покупателиToolStripMenuItem.Click += ПокупателиToolStripMenuItem_Click; покупателиToolStripMenuItem.Click += ПокупателиToolStripMenuItem_Click;
// //
// сделкиToolStripMenuItem
//
сделкиToolStripMenuItem.Name = "сделкиToolStripMenuItem";
сделкиToolStripMenuItem.Size = new Size(174, 26);
сделкиToolStripMenuItem.Text = "Сделки";
сделкиToolStripMenuItem.Click += СделкиToolStripMenuItem_Click;
//
// услугиToolStripMenuItem // услугиToolStripMenuItem
// //
услугиToolStripMenuItem.Name = "услугиToolStripMenuItem"; услугиToolStripMenuItem.Name = "услугиToolStripMenuItem";
услугиToolStripMenuItem.Size = new Size(174, 26); услугиToolStripMenuItem.Size = new Size(224, 26);
услугиToolStripMenuItem.Text = "Услуги"; услугиToolStripMenuItem.Text = "Услуги";
услугиToolStripMenuItem.Click += УслугиToolStripMenuItem_Click; услугиToolStripMenuItem.Click += УслугиToolStripMenuItem_Click;
// //
// операцииToolStripMenuItem // операцииToolStripMenuItem
// //
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { допродажныеУслугиToolStripMenuItem, услугиПродажиToolStripMenuItem }); операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { допродажныеУслугиToolStripMenuItem, сделкиToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24); операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции"; операцииToolStripMenuItem.Text = "Операции";
@ -100,12 +92,12 @@
допродажныеУслугиToolStripMenuItem.Text = "Допродажные услуги"; допродажныеУслугиToolStripMenuItem.Text = "Допродажные услуги";
допродажныеУслугиToolStripMenuItem.Click += ДопродажныеУслугиToolStripMenuItem_Click; допродажныеУслугиToolStripMenuItem.Click += ДопродажныеУслугиToolStripMenuItem_Click;
// //
// услугиПродажиToolStripMenuItem // сделкиToolStripMenuItem
// //
услугиПродажиToolStripMenuItem.Name = "услугиПродажиToolStripMenuItem"; сделкиToolStripMenuItem.Name = "сделкиToolStripMenuItem";
услугиПродажиToolStripMenuItem.Size = new Size(241, 26); сделкиToolStripMenuItem.Size = new Size(241, 26);
услугиПродажиToolStripMenuItem.Text = "Услуги продажи"; сделкиToolStripMenuItem.Text = "Сделки";
услугиПродажиToolStripMenuItem.Click += УслугиПродажиToolStripMenuItem_Click; сделкиToolStripMenuItem.Click += СделкиToolStripMenuItem_Click;
// //
// отчётToolStripMenuItem // отчёт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; private ToolStripMenuItem допродажныеУслугиToolStripMenuItem;
private ToolStripMenuItem услугиПродажиToolStripMenuItem;
private ToolStripMenuItem отчётToolStripMenuItem; private ToolStripMenuItem отчётToolStripMenuItem;
private ToolStripMenuItem услугиToolStripMenuItem;
private ToolStripMenuItem сделкиToolStripMenuItem;
} }
} }

View File

@ -73,17 +73,5 @@ namespace RealEstateTransactions
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ÓñëóãèÏðîäàæèToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormServicesDeals>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
} }

View File

@ -38,7 +38,13 @@
dateTimePickerDealDate = new DateTimePicker(); dateTimePickerDealDate = new DateTimePicker();
buttonSave = new Button(); buttonSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
groupBoxDataGrid = new GroupBox();
dataGridView = new DataGridView();
ColumnService = new DataGridViewComboBoxColumn();
ColumnTimeSpan = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)numericUpDownDealPrice).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownDealPrice).BeginInit();
groupBoxDataGrid.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// labelApartmentId // labelApartmentId
@ -47,9 +53,9 @@
labelApartmentId.Font = new Font("Segoe UI", 14F); labelApartmentId.Font = new Font("Segoe UI", 14F);
labelApartmentId.Location = new Point(12, 9); labelApartmentId.Location = new Point(12, 9);
labelApartmentId.Name = "labelApartmentId"; labelApartmentId.Name = "labelApartmentId";
labelApartmentId.Size = new Size(345, 32); labelApartmentId.Size = new Size(349, 32);
labelApartmentId.TabIndex = 0; labelApartmentId.TabIndex = 0;
labelApartmentId.Text = "ID квартиты - - - - - - - -"; labelApartmentId.Text = "ID квартиры - - - - - - - -";
// //
// comboBoxApartmentId // comboBoxApartmentId
// //
@ -73,6 +79,7 @@
// //
// comboBoxFullName // comboBoxFullName
// //
comboBoxFullName.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxFullName.Font = new Font("Segoe UI", 14F); comboBoxFullName.Font = new Font("Segoe UI", 14F);
comboBoxFullName.FormattingEnabled = true; comboBoxFullName.FormattingEnabled = true;
comboBoxFullName.Location = new Point(218, 73); comboBoxFullName.Location = new Point(218, 73);
@ -127,8 +134,9 @@
// //
// buttonSave // buttonSave
// //
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Font = new Font("Segoe UI", 14F); buttonSave.Font = new Font("Segoe UI", 14F);
buttonSave.Location = new Point(66, 281); buttonSave.Location = new Point(66, 579);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(146, 63); buttonSave.Size = new Size(146, 63);
buttonSave.TabIndex = 3; buttonSave.TabIndex = 3;
@ -138,8 +146,9 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Font = new Font("Segoe UI", 14F); buttonCancel.Font = new Font("Segoe UI", 14F);
buttonCancel.Location = new Point(328, 281); buttonCancel.Location = new Point(328, 579);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(146, 63); buttonCancel.Size = new Size(146, 63);
buttonCancel.TabIndex = 4; buttonCancel.TabIndex = 4;
@ -147,11 +156,54 @@
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click; 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 // FormDeal
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(534, 356); ClientSize = new Size(534, 654);
Controls.Add(groupBoxDataGrid);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(dateTimePickerDealDate); Controls.Add(dateTimePickerDealDate);
@ -166,6 +218,8 @@
StartPosition = FormStartPosition.CenterParent; StartPosition = FormStartPosition.CenterParent;
Text = "Сделка"; Text = "Сделка";
((System.ComponentModel.ISupportInitialize)numericUpDownDealPrice).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownDealPrice).EndInit();
groupBoxDataGrid.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
@ -182,5 +236,9 @@
private DateTimePicker dateTimePickerDealDate; private DateTimePicker dateTimePickerDealDate;
private Button buttonSave; private Button buttonSave;
private Button buttonCancel; private Button buttonCancel;
private GroupBox groupBoxDataGrid;
private DataGridView dataGridView;
private DataGridViewComboBoxColumn ColumnService;
private DataGridViewTextBoxColumn ColumnTimeSpan;
} }
} }

View File

@ -6,43 +6,12 @@ namespace RealEstateTransactions.Forms
public partial class FormDeal : Form public partial class FormDeal : Form
{ {
private readonly IDealRepository _repository; 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, public FormDeal(IDealRepository repository, IApartmentRepository apartmentRepository,
IBuyerRepository buyerRepository) IBuyerRepository buyerRepository, IServicesRepository servicesRepository)
{ {
InitializeComponent(); InitializeComponent();
_repository = repository ?? throw new ArgumentNullException(nameof(repository)); _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.DataSource = apartmentRepository.ReadApartments();
comboBoxApartmentId.DisplayMember = "Id"; comboBoxApartmentId.DisplayMember = "Id";
@ -52,6 +21,10 @@ namespace RealEstateTransactions.Forms
comboBoxFullName.DisplayMember = "FullName"; comboBoxFullName.DisplayMember = "FullName";
comboBoxFullName.ValueMember = "Id"; comboBoxFullName.ValueMember = "Id";
ColumnService.DataSource = servicesRepository.ReadServices();
ColumnService.DisplayMember = "Name";
ColumnService.ValueMember = "Id";
dateTimePickerDealDate.Value = DateTime.Now; dateTimePickerDealDate.Value = DateTime.Now;
} }
@ -59,17 +32,13 @@ namespace RealEstateTransactions.Forms
{ {
try try
{ {
if (comboBoxApartmentId.SelectedItem == null || comboBoxFullName.SelectedItem == null) if (comboBoxApartmentId.SelectedItem == null || comboBoxFullName.SelectedItem == null
|| dataGridView.RowCount < 1)
throw new Exception("Имеются не заполненные поля"); throw new Exception("Имеются не заполненные поля");
if (_dealId.HasValue) _repository.CreateDeal(Deal.CreateDeal(0, (int)comboBoxApartmentId.SelectedValue!,
{ (int)comboBoxFullName.SelectedValue!, (float)numericUpDownDealPrice.Value,
_repository.UpdateDeal(CreateDeal(_dealId.Value)); dateTimePickerDealDate.Value, CreateListFromDataGridView()));
}
else
{
_repository.CreateDeal(CreateDeal(0));
}
Close(); Close();
} }
@ -81,7 +50,19 @@ namespace RealEstateTransactions.Forms
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Deal CreateDeal(int id) => Deal.CreateDeal(id, (int)comboBoxApartmentId.SelectedValue!, private List<ServicesDeal> CreateListFromDataGridView()
(int)comboBoxFullName.SelectedValue!, (float)numericUpDownDealPrice.Value, dateTimePickerDealDate.Value); {
var list = new List<ServicesDeal>();
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;
}
} }
} }

View File

@ -117,4 +117,10 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="ColumnService.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnTimeSpan.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -30,7 +30,6 @@
{ {
panelTools = new Panel(); panelTools = new Panel();
buttonDelete = new Button(); buttonDelete = new Button();
buttonUpdate = new Button();
buttonAdd = new Button(); buttonAdd = new Button();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
panelTools.SuspendLayout(); panelTools.SuspendLayout();
@ -40,7 +39,6 @@
// panelTools // panelTools
// //
panelTools.Controls.Add(buttonDelete); panelTools.Controls.Add(buttonDelete);
panelTools.Controls.Add(buttonUpdate);
panelTools.Controls.Add(buttonAdd); panelTools.Controls.Add(buttonAdd);
panelTools.Dock = DockStyle.Right; panelTools.Dock = DockStyle.Right;
panelTools.Location = new Point(851, 0); panelTools.Location = new Point(851, 0);
@ -55,21 +53,10 @@
buttonDelete.Location = new Point(28, 333); buttonDelete.Location = new Point(28, 333);
buttonDelete.Name = "buttonDelete"; buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(80, 80); buttonDelete.Size = new Size(80, 80);
buttonDelete.TabIndex = 2; buttonDelete.TabIndex = 1;
buttonDelete.UseVisualStyleBackColor = true; buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click; 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
// //
buttonAdd.BackgroundImage = Properties.Resources.Add; buttonAdd.BackgroundImage = Properties.Resources.Add;
@ -121,7 +108,6 @@
private Panel panelTools; private Panel panelTools;
private Button buttonDelete; private Button buttonDelete;
private Button buttonUpdate;
private Button buttonAdd; private Button buttonAdd;
private DataGridView dataGridView; private DataGridView dataGridView;
} }

View File

@ -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<FormDeal>();
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) private void ButtonDelete_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFormSelectedRow(out var findId)) return; if (!TryGetIdentifierFormSelectedRow(out var findId)) return;

View File

@ -1,158 +0,0 @@
namespace RealEstateTransactions.Forms
{
partial class FormServicesDeal
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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();
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,100 +0,0 @@
namespace RealEstateTransactions.Forms
{
partial class FormServicesDeals
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<FormServicesDeal>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _repository.ReadServicesDeal();
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,9 +1,4 @@
using RealEstateTransactions.Entities; using RealEstateTransactions.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RealEstateTransactions.Repositories.Implementations namespace RealEstateTransactions.Repositories.Implementations
{ {
@ -21,7 +16,7 @@ namespace RealEstateTransactions.Repositories.Implementations
public Deal ReadDeal(int id) 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<Deal> ReadDeals() public IEnumerable<Deal> ReadDeals()