diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/Apartment.cs b/RealEstateTransactions/RealEstateTransactions/Entities/Apartment.cs new file mode 100644 index 0000000..4046422 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/Apartment.cs @@ -0,0 +1,36 @@ +using RealEstateTransactions.Entities.Enums; + +namespace RealEstateTransactions.Entities +{ + public class Apartment + { + public int Id { get; private set; } + + public AgencyType AgencyId { get; private set; } + + public FormFactorType FormFactorId { get; private set; } + + public float Area { get; private set; } + + public float PricePerSM { get; private set; } + + public float BasePrice { get; private set; } + + public float DesiredPrice { get; private set; } + + public static Apartment CreateApartment(int id, AgencyType agencyId, FormFactorType formFactorId, float area, + float pricePerSM, float basePrice, float desiredPrice) + { + return new Apartment + { + Id = id, + AgencyId = agencyId, + FormFactorId = formFactorId, + Area = area, + PricePerSM = pricePerSM, + BasePrice = basePrice, + DesiredPrice = desiredPrice + }; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/Buyer.cs b/RealEstateTransactions/RealEstateTransactions/Entities/Buyer.cs new file mode 100644 index 0000000..567ef9b --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/Buyer.cs @@ -0,0 +1,24 @@ +namespace RealEstateTransactions.Entities +{ + public class Buyer + { + public int Id { get; private set; } + + public string FullName { get; private set; } = string.Empty; + + public int PassportSeries { get; private set; } + + public int PassportNumber { get; private set; } + + public static Buyer CreateBuyer(int id, string fullName, int passportSeries, int passportNumber) + { + return new Buyer + { + Id = id, + FullName = fullName, + PassportSeries = passportSeries, + PassportNumber = passportNumber + }; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/Deal.cs b/RealEstateTransactions/RealEstateTransactions/Entities/Deal.cs new file mode 100644 index 0000000..b634918 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/Deal.cs @@ -0,0 +1,31 @@ +namespace RealEstateTransactions.Entities +{ + public class Deal + { + public int Id { get; private set; } + + public int ApartmentId { get; private set; } + + public int BuyerId { get; private set; } + + public float DealPrice { get; private set; } + + public DateTime DealDate { get; private set; } + + 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 + { + Id = id, + ApartmentId = apartmentId, + BuyerId = buyerId, + DealPrice = dealPrice, + DealDate = dealDate, + DealServices = dealServices + }; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/Enums/AgencyType.cs b/RealEstateTransactions/RealEstateTransactions/Entities/Enums/AgencyType.cs new file mode 100644 index 0000000..1e1263c --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/Enums/AgencyType.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RealEstateTransactions.Entities.Enums +{ + public enum AgencyType + { + None = 0, + + Sniper = 1, + + Shark = 2, + + Hammer = 3 + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/Enums/FormFactorType.cs b/RealEstateTransactions/RealEstateTransactions/Entities/Enums/FormFactorType.cs new file mode 100644 index 0000000..b923b01 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/Enums/FormFactorType.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RealEstateTransactions.Entities.Enums +{ + [Flags] + public enum FormFactorType + { + None = 0, + + Kitchen = 1, + + Hall = 2, + + BedRoom = 4, + + Lounge = 8 + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/PreSalesServices.cs b/RealEstateTransactions/RealEstateTransactions/Entities/PreSalesServices.cs new file mode 100644 index 0000000..12b1549 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/PreSalesServices.cs @@ -0,0 +1,24 @@ +namespace RealEstateTransactions.Entities +{ + public class PreSalesServices + { + public int Id { get; private set; } + + public int ApartmentId { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public float Cost { get; private set; } + + public static PreSalesServices CreatePreSalesServices(int id, int apartmentId, string name, float cost) + { + return new PreSalesServices + { + Id = id, + ApartmentId = apartmentId, + Name = name, + Cost = cost + }; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/Services.cs b/RealEstateTransactions/RealEstateTransactions/Entities/Services.cs new file mode 100644 index 0000000..134631b --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/Services.cs @@ -0,0 +1,21 @@ +namespace RealEstateTransactions.Entities +{ + public class Services + { + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public float Price { get; private set; } + + public static Services CreateService(int id, string name, float price) + { + return new Services + { + Id = id, + Name = name, + Price = price + }; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Entities/ServicesDeal.cs b/RealEstateTransactions/RealEstateTransactions/Entities/ServicesDeal.cs new file mode 100644 index 0000000..950156c --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Entities/ServicesDeal.cs @@ -0,0 +1,21 @@ +namespace RealEstateTransactions.Entities +{ + public class ServicesDeal + { + public int ServicesId { get; private set; } + + public int DealId { get; private set; } + + public float ExecutionTime { get; private set; } + + public static ServicesDeal CreateServicesDeal(int servicesId, int dealId, float executionTime) + { + return new ServicesDeal + { + ServicesId = servicesId, + DealId = dealId, + ExecutionTime = executionTime + }; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Form1.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Form1.Designer.cs deleted file mode 100644 index fe4f9d4..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace RealEstateTransactions -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/RealEstateTransactions/RealEstateTransactions/Form1.cs b/RealEstateTransactions/RealEstateTransactions/Form1.cs deleted file mode 100644 index a177668..0000000 --- a/RealEstateTransactions/RealEstateTransactions/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace RealEstateTransactions -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/RealEstateTransactions/RealEstateTransactions/FormGeneral.Designer.cs b/RealEstateTransactions/RealEstateTransactions/FormGeneral.Designer.cs new file mode 100644 index 0000000..b21203d --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/FormGeneral.Designer.cs @@ -0,0 +1,139 @@ +namespace RealEstateTransactions +{ + partial class FormGeneral + { + /// + /// 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() + { + menuStrip1 = new MenuStrip(); + справочники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(); + // + // menuStrip1 + // + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(800, 28); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { квартирыToolStripMenuItem, покупателиToolStripMenuItem, услугиToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(117, 24); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // квартирыToolStripMenuItem + // + квартирыToolStripMenuItem.Name = "квартирыToolStripMenuItem"; + квартирыToolStripMenuItem.Size = new Size(224, 26); + квартирыToolStripMenuItem.Text = "Квартиры"; + квартирыToolStripMenuItem.Click += КвартирыToolStripMenuItem_Click; + // + // покупателиToolStripMenuItem + // + покупателиToolStripMenuItem.Name = "покупателиToolStripMenuItem"; + покупателиToolStripMenuItem.Size = new Size(224, 26); + покупателиToolStripMenuItem.Text = "Покупатели"; + покупателиToolStripMenuItem.Click += ПокупателиToolStripMenuItem_Click; + // + // услугиToolStripMenuItem + // + услугиToolStripMenuItem.Name = "услугиToolStripMenuItem"; + услугиToolStripMenuItem.Size = new Size(224, 26); + услугиToolStripMenuItem.Text = "Услуги"; + услугиToolStripMenuItem.Click += УслугиToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { допродажныеУслугиToolStripMenuItem, сделкиToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(95, 24); + операцииToolStripMenuItem.Text = "Операции"; + // + // допродажныеУслугиToolStripMenuItem + // + допродажныеУслугиToolStripMenuItem.Name = "допродажныеУслугиToolStripMenuItem"; + допродажныеУслугиToolStripMenuItem.Size = new Size(241, 26); + допродажныеУслугиToolStripMenuItem.Text = "Допродажные услуги"; + допродажныеУслугиToolStripMenuItem.Click += ДопродажныеУслугиToolStripMenuItem_Click; + // + // сделкиToolStripMenuItem + // + сделкиToolStripMenuItem.Name = "сделкиToolStripMenuItem"; + сделкиToolStripMenuItem.Size = new Size(241, 26); + сделкиToolStripMenuItem.Text = "Сделки"; + сделкиToolStripMenuItem.Click += СделкиToolStripMenuItem_Click; + // + // отчётToolStripMenuItem + // + отчётToolStripMenuItem.Name = "отчётToolStripMenuItem"; + отчётToolStripMenuItem.Size = new Size(73, 24); + отчётToolStripMenuItem.Text = "Отчёты"; + // + // FormGeneral + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.фон; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(800, 450); + Controls.Add(menuStrip1); + DoubleBuffered = true; + MainMenuStrip = menuStrip1; + Name = "FormGeneral"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Недвижимость"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + 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 new file mode 100644 index 0000000..ba33777 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/FormGeneral.cs @@ -0,0 +1,77 @@ +using Unity; +using RealEstateTransactions.Forms; +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions +{ + public partial class FormGeneral : Form + { + private readonly IUnityContainer _container; + + public FormGeneral(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + 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); + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + 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); + } + } + + 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/FormGeneral.resx b/RealEstateTransactions/RealEstateTransactions/FormGeneral.resx new file mode 100644 index 0000000..b48baf1 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/FormGeneral.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.Designer.cs new file mode 100644 index 0000000..74c26f3 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.Designer.cs @@ -0,0 +1,268 @@ +namespace RealEstateTransactions.Forms +{ + partial class FormApartment + { + /// + /// 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() + { + comboBoxAgency = new ComboBox(); + labelAgency = new Label(); + labelformFactor = new Label(); + labelArea = new Label(); + labelPricePerSM = new Label(); + labelBasePrice = new Label(); + labelDesiredPrice = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + numericUpDownArea = new NumericUpDown(); + numericUpDownPricePerSM = new NumericUpDown(); + numericUpDownDesiredPrice = new NumericUpDown(); + numericUpDownBasePrice = new NumericUpDown(); + checkedListBoxFormFactor = new CheckedListBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownArea).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPricePerSM).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownDesiredPrice).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownBasePrice).BeginInit(); + SuspendLayout(); + // + // comboBoxAgency + // + comboBoxAgency.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxAgency.Font = new Font("Segoe UI", 14F); + comboBoxAgency.FormattingEnabled = true; + comboBoxAgency.Location = new Point(336, 6); + comboBoxAgency.Name = "comboBoxAgency"; + comboBoxAgency.Size = new Size(217, 39); + comboBoxAgency.TabIndex = 0; + // + // labelAgency + // + labelAgency.AutoSize = true; + labelAgency.Font = new Font("Segoe UI", 14F); + labelAgency.Location = new Point(12, 9); + labelAgency.Name = "labelAgency"; + labelAgency.Size = new Size(312, 32); + labelAgency.TabIndex = 10; + labelAgency.Text = "Агенство - - - - - - - -"; + // + // labelformFactor + // + labelformFactor.AutoSize = true; + labelformFactor.Font = new Font("Segoe UI", 14F); + labelformFactor.Location = new Point(12, 73); + labelformFactor.Name = "labelformFactor"; + labelformFactor.Size = new Size(271, 32); + labelformFactor.TabIndex = 2; + labelformFactor.Text = "Вид квартиры - - - -"; + // + // labelArea + // + labelArea.AutoSize = true; + labelArea.Font = new Font("Segoe UI", 14F); + labelArea.Location = new Point(12, 265); + labelArea.Name = "labelArea"; + labelArea.Size = new Size(382, 32); + labelArea.TabIndex = 4; + labelArea.Text = "Площадь квартиры (м2) - - - -"; + // + // labelPricePerSM + // + labelPricePerSM.AutoSize = true; + labelPricePerSM.Font = new Font("Segoe UI", 14F); + labelPricePerSM.Location = new Point(12, 332); + labelPricePerSM.Name = "labelPricePerSM"; + labelPricePerSM.Size = new Size(380, 32); + labelPricePerSM.TabIndex = 11; + labelPricePerSM.Text = "Цена квадратного метра (руб) -"; + // + // labelBasePrice + // + labelBasePrice.AutoSize = true; + labelBasePrice.Font = new Font("Segoe UI", 14F); + labelBasePrice.Location = new Point(12, 397); + labelBasePrice.Name = "labelBasePrice"; + labelBasePrice.Size = new Size(278, 32); + labelBasePrice.TabIndex = 12; + labelBasePrice.Text = "Базовая цена (руб) - -"; + // + // labelDesiredPrice + // + labelDesiredPrice.AutoSize = true; + labelDesiredPrice.Font = new Font("Segoe UI", 14F); + labelDesiredPrice.Location = new Point(12, 451); + labelDesiredPrice.Name = "labelDesiredPrice"; + labelDesiredPrice.Size = new Size(281, 32); + labelDesiredPrice.TabIndex = 13; + labelDesiredPrice.Text = "Цена от агенства (руб) -"; + // + // buttonSave + // + buttonSave.Font = new Font("Segoe UI", 14F); + buttonSave.Location = new Point(77, 517); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 41); + buttonSave.TabIndex = 5; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Font = new Font("Segoe UI", 14F); + buttonCancel.Location = new Point(336, 517); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 41); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // numericUpDownArea + // + numericUpDownArea.BorderStyle = BorderStyle.FixedSingle; + numericUpDownArea.DecimalPlaces = 1; + numericUpDownArea.Font = new Font("Segoe UI", 14F); + numericUpDownArea.Increment = new decimal(new int[] { 5, 0, 0, 0 }); + numericUpDownArea.Location = new Point(403, 272); + numericUpDownArea.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownArea.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownArea.Name = "numericUpDownArea"; + numericUpDownArea.Size = new Size(150, 39); + numericUpDownArea.TabIndex = 2; + numericUpDownArea.TextAlign = HorizontalAlignment.Center; + numericUpDownArea.Value = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownArea.ValueChanged += NumericUpDownArea_ValueChanged; + // + // numericUpDownPricePerSM + // + numericUpDownPricePerSM.BorderStyle = BorderStyle.FixedSingle; + numericUpDownPricePerSM.DecimalPlaces = 2; + numericUpDownPricePerSM.Font = new Font("Segoe UI", 14F); + numericUpDownPricePerSM.Increment = new decimal(new int[] { 5, 0, 0, 0 }); + numericUpDownPricePerSM.Location = new Point(403, 330); + numericUpDownPricePerSM.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownPricePerSM.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownPricePerSM.Name = "numericUpDownPricePerSM"; + numericUpDownPricePerSM.Size = new Size(150, 39); + numericUpDownPricePerSM.TabIndex = 3; + numericUpDownPricePerSM.TextAlign = HorizontalAlignment.Center; + numericUpDownPricePerSM.ThousandsSeparator = true; + numericUpDownPricePerSM.Value = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownPricePerSM.ValueChanged += NumericUpDownPricePerSM_ValueChanged; + // + // numericUpDownDesiredPrice + // + numericUpDownDesiredPrice.BorderStyle = BorderStyle.FixedSingle; + numericUpDownDesiredPrice.DecimalPlaces = 2; + numericUpDownDesiredPrice.Font = new Font("Segoe UI", 14F); + numericUpDownDesiredPrice.Increment = new decimal(new int[] { 5, 0, 0, 0 }); + numericUpDownDesiredPrice.Location = new Point(294, 449); + numericUpDownDesiredPrice.Maximum = new decimal(new int[] { 1000000000, 0, 0, 0 }); + numericUpDownDesiredPrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownDesiredPrice.Name = "numericUpDownDesiredPrice"; + numericUpDownDesiredPrice.Size = new Size(259, 39); + numericUpDownDesiredPrice.TabIndex = 4; + numericUpDownDesiredPrice.TextAlign = HorizontalAlignment.Center; + numericUpDownDesiredPrice.ThousandsSeparator = true; + numericUpDownDesiredPrice.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // numericUpDownBasePrice + // + numericUpDownBasePrice.BorderStyle = BorderStyle.FixedSingle; + numericUpDownBasePrice.DecimalPlaces = 2; + numericUpDownBasePrice.Font = new Font("Segoe UI", 14F); + numericUpDownBasePrice.Increment = new decimal(new int[] { 5, 0, 0, 0 }); + numericUpDownBasePrice.InterceptArrowKeys = false; + numericUpDownBasePrice.Location = new Point(294, 395); + numericUpDownBasePrice.Maximum = new decimal(new int[] { 1000000000, 0, 0, 0 }); + numericUpDownBasePrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownBasePrice.Name = "numericUpDownBasePrice"; + numericUpDownBasePrice.ReadOnly = true; + numericUpDownBasePrice.Size = new Size(259, 39); + numericUpDownBasePrice.TabIndex = 14; + numericUpDownBasePrice.TabStop = false; + numericUpDownBasePrice.TextAlign = HorizontalAlignment.Center; + numericUpDownBasePrice.ThousandsSeparator = true; + numericUpDownBasePrice.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // checkedListBoxFormFactor + // + checkedListBoxFormFactor.BorderStyle = BorderStyle.FixedSingle; + checkedListBoxFormFactor.Font = new Font("Segoe UI", 14F); + checkedListBoxFormFactor.FormattingEnabled = true; + checkedListBoxFormFactor.Location = new Point(289, 73); + checkedListBoxFormFactor.Name = "checkedListBoxFormFactor"; + checkedListBoxFormFactor.Size = new Size(264, 172); + checkedListBoxFormFactor.TabIndex = 1; + // + // FormApartment + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(577, 575); + Controls.Add(checkedListBoxFormFactor); + Controls.Add(numericUpDownBasePrice); + Controls.Add(numericUpDownDesiredPrice); + Controls.Add(numericUpDownPricePerSM); + Controls.Add(numericUpDownArea); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelDesiredPrice); + Controls.Add(labelBasePrice); + Controls.Add(labelPricePerSM); + Controls.Add(labelArea); + Controls.Add(labelformFactor); + Controls.Add(labelAgency); + Controls.Add(comboBoxAgency); + Name = "FormApartment"; + StartPosition = FormStartPosition.CenterParent; + Text = "Квартира"; + ((System.ComponentModel.ISupportInitialize)numericUpDownArea).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPricePerSM).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownDesiredPrice).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownBasePrice).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxAgency; + private Label labelAgency; + private Label labelformFactor; + private Label labelArea; + private Label labelPricePerSM; + private Label labelBasePrice; + private Label labelDesiredPrice; + private Button buttonSave; + private Button buttonCancel; + private NumericUpDown numericUpDownArea; + private NumericUpDown numericUpDownPricePerSM; + private NumericUpDown numericUpDownDesiredPrice; + private NumericUpDown numericUpDownBasePrice; + private CheckedListBox checkedListBoxFormFactor; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.cs new file mode 100644 index 0000000..b00f3b7 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.cs @@ -0,0 +1,101 @@ +using RealEstateTransactions.Entities; +using RealEstateTransactions.Repositories; +using RealEstateTransactions.Entities.Enums; + +namespace RealEstateTransactions.Forms +{ + public partial class FormApartment : Form + { + private readonly IApartmentRepository _repository; + + private int? _apartmentId; + + public int Id + { + set + { + try + { + var apartment = _repository.ReadApartment(value); + + if (apartment == null) throw new InvalidDataException(nameof(apartment)); + + foreach (FormFactorType elem in Enum.GetValues(typeof(FormFactorType))) + { + if ((elem & apartment.FormFactorId) != 0) + checkedListBoxFormFactor.SetItemChecked(checkedListBoxFormFactor.Items.IndexOf(elem), true); + } + + comboBoxAgency.SelectedIndex = (int)apartment.AgencyId; + numericUpDownArea.Value = (decimal)apartment.Area; + numericUpDownPricePerSM.Value = (decimal)apartment.PricePerSM; + numericUpDownBasePrice.Value = (decimal)apartment.BasePrice; + numericUpDownDesiredPrice.Value = (decimal)apartment.DesiredPrice; + + _apartmentId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormApartment(IApartmentRepository repository) + { + InitializeComponent(); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + comboBoxAgency.DataSource = Enum.GetValues(typeof(AgencyType)); + + foreach (var elem in Enum.GetValues(typeof(FormFactorType))) checkedListBoxFormFactor.Items.Add(elem); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxAgency.SelectedIndex == -1 || checkedListBoxFormFactor.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_apartmentId.HasValue) + { + _repository.UpdateApartment(CreateApartment(_apartmentId.Value)); + } + else + { + _repository.CreateApartment(CreateApartment(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Apartment CreateApartment(int Id) + { + FormFactorType formFactorType = FormFactorType.None; + foreach (FormFactorType elem in checkedListBoxFormFactor.CheckedItems) formFactorType |= elem; + + return Apartment.CreateApartment(Id, + (AgencyType)comboBoxAgency.SelectedIndex, formFactorType, + (float)numericUpDownArea.Value, (float)numericUpDownPricePerSM.Value, + (float)numericUpDownBasePrice.Value, (float)numericUpDownDesiredPrice.Value); + } + + private void NumericUpDownArea_ValueChanged(object sender, EventArgs e) => + numericUpDownBasePrice.Value = numericUpDownArea.Value * numericUpDownPricePerSM.Value; + + private void NumericUpDownPricePerSM_ValueChanged(object sender, EventArgs e) => + numericUpDownBasePrice.Value = numericUpDownArea.Value * numericUpDownPricePerSM.Value; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Form1.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.resx similarity index 92% rename from RealEstateTransactions/RealEstateTransactions/Form1.resx rename to RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.resx index 1af7de1..8b2ff64 100644 --- a/RealEstateTransactions/RealEstateTransactions/Form1.resx +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartment.resx @@ -1,17 +1,17 @@  - diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.Designer.cs new file mode 100644 index 0000000..a56daba --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.Designer.cs @@ -0,0 +1,128 @@ +namespace RealEstateTransactions.Forms +{ + partial class FormApartments + { + /// + /// 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(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panelTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panelTools + // + panelTools.Controls.Add(buttonDelete); + panelTools.Controls.Add(buttonUpdate); + 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 = 0; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.Delete; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(28, 333); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(80, 80); + buttonDelete.TabIndex = 2; + 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; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 73); + 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 = 1; + dataGridView.TabStop = false; + // + // FormApartments + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(982, 553); + Controls.Add(dataGridView); + Controls.Add(panelTools); + Name = "FormApartments"; + StartPosition = FormStartPosition.CenterParent; + Text = "Квартиры"; + Load += FormApartments_Load; + panelTools.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panelTools; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.cs new file mode 100644 index 0000000..6910d40 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.cs @@ -0,0 +1,95 @@ +using Unity; +using RealEstateTransactions.Repositories; + +namespace RealEstateTransactions.Forms +{ + public partial class FormApartments : Form + { + private readonly IUnityContainer _container; + + private readonly IApartmentRepository _repository; + + public FormApartments(IUnityContainer container, IApartmentRepository repository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + } + + private void FormApartments_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 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; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) + != DialogResult.Yes) return; + + try + { + _repository.DeleteApartment(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _repository.ReadApartments(); + + private bool TryGetIdentifierFormSelectedRow(out int id) + { + id = 0; + + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormApartments.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/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.Designer.cs new file mode 100644 index 0000000..f76b17c --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.Designer.cs @@ -0,0 +1,164 @@ +namespace RealEstateTransactions.Forms +{ + partial class FormBuyer + { + /// + /// 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() + { + labelFullName = new Label(); + textBoxFullName = new TextBox(); + labelPassportSeries = new Label(); + numericUpDownPassportSeries = new NumericUpDown(); + labelPassportNumber = new Label(); + numericUpDownPassportNumber = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPassportSeries).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPassportNumber).BeginInit(); + SuspendLayout(); + // + // labelFullName + // + labelFullName.AutoSize = true; + labelFullName.Font = new Font("Segoe UI", 14F); + labelFullName.Location = new Point(12, 9); + labelFullName.Name = "labelFullName"; + labelFullName.Size = new Size(67, 32); + labelFullName.TabIndex = 0; + labelFullName.Text = "ФИО"; + // + // textBoxFullName + // + textBoxFullName.BorderStyle = BorderStyle.FixedSingle; + textBoxFullName.Font = new Font("Segoe UI", 14F); + textBoxFullName.Location = new Point(85, 7); + textBoxFullName.Name = "textBoxFullName"; + textBoxFullName.Size = new Size(357, 39); + textBoxFullName.TabIndex = 0; + textBoxFullName.TextAlign = HorizontalAlignment.Center; + // + // labelPassportSeries + // + labelPassportSeries.AutoSize = true; + labelPassportSeries.Font = new Font("Segoe UI", 14F); + labelPassportSeries.Location = new Point(12, 68); + labelPassportSeries.Name = "labelPassportSeries"; + labelPassportSeries.Size = new Size(317, 32); + labelPassportSeries.TabIndex = 1; + labelPassportSeries.Text = "Серия паспорта - - - - -"; + // + // numericUpDownPassportSeries + // + numericUpDownPassportSeries.BorderStyle = BorderStyle.FixedSingle; + numericUpDownPassportSeries.Font = new Font("Segoe UI", 14F); + numericUpDownPassportSeries.Location = new Point(345, 66); + numericUpDownPassportSeries.Maximum = new decimal(new int[] { 9999, 0, 0, 0 }); + numericUpDownPassportSeries.Minimum = new decimal(new int[] { 1111, 0, 0, 0 }); + numericUpDownPassportSeries.Name = "numericUpDownPassportSeries"; + numericUpDownPassportSeries.Size = new Size(97, 39); + numericUpDownPassportSeries.TabIndex = 1; + numericUpDownPassportSeries.TextAlign = HorizontalAlignment.Center; + numericUpDownPassportSeries.Value = new decimal(new int[] { 1111, 0, 0, 0 }); + // + // labelPassportNumber + // + labelPassportNumber.AutoSize = true; + labelPassportNumber.Font = new Font("Segoe UI", 14F); + labelPassportNumber.Location = new Point(12, 130); + labelPassportNumber.Name = "labelPassportNumber"; + labelPassportNumber.Size = new Size(300, 32); + labelPassportNumber.TabIndex = 2; + labelPassportNumber.Text = "Номер паспорта - - - -"; + // + // numericUpDownPassportNumber + // + numericUpDownPassportNumber.BorderStyle = BorderStyle.FixedSingle; + numericUpDownPassportNumber.Font = new Font("Segoe UI", 14F); + numericUpDownPassportNumber.Location = new Point(318, 128); + numericUpDownPassportNumber.Maximum = new decimal(new int[] { 999999, 0, 0, 0 }); + numericUpDownPassportNumber.Minimum = new decimal(new int[] { 111111, 0, 0, 0 }); + numericUpDownPassportNumber.Name = "numericUpDownPassportNumber"; + numericUpDownPassportNumber.Size = new Size(124, 39); + numericUpDownPassportNumber.TabIndex = 2; + numericUpDownPassportNumber.TextAlign = HorizontalAlignment.Center; + numericUpDownPassportNumber.Value = new decimal(new int[] { 111111, 0, 0, 0 }); + // + // buttonSave + // + buttonSave.Font = new Font("Segoe UI", 14F); + buttonSave.Location = new Point(49, 176); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(147, 50); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Font = new Font("Segoe UI", 14F); + buttonCancel.Location = new Point(258, 176); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(147, 50); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormBuyer + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(455, 238); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownPassportNumber); + Controls.Add(labelPassportNumber); + Controls.Add(numericUpDownPassportSeries); + Controls.Add(labelPassportSeries); + Controls.Add(textBoxFullName); + Controls.Add(labelFullName); + Name = "FormBuyer"; + StartPosition = FormStartPosition.CenterParent; + Text = "Покупатель"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPassportSeries).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPassportNumber).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelFullName; + private TextBox textBoxFullName; + private Label labelPassportSeries; + private NumericUpDown numericUpDownPassportSeries; + private Label labelPassportNumber; + private NumericUpDown numericUpDownPassportNumber; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.cs new file mode 100644 index 0000000..985fa56 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.cs @@ -0,0 +1,71 @@ +using RealEstateTransactions.Entities; +using RealEstateTransactions.Repositories; + +namespace RealEstateTransactions.Forms +{ + public partial class FormBuyer : Form + { + private readonly IBuyerRepository _repository; + + private int? _buyerId; + + public int Id + { + set + { + try + { + var buyer = _repository.ReadBuyer(value); + + if (buyer == null) throw new InvalidDataException(nameof(buyer)); + + textBoxFullName.Text = buyer.FullName; + numericUpDownPassportSeries.Value = buyer.PassportSeries; + numericUpDownPassportNumber.Value = buyer.PassportNumber; + + _buyerId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormBuyer(IBuyerRepository repository) + { + InitializeComponent(); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxFullName.Text)) + throw new Exception("Имеются не заполненные поля"); + + if (_buyerId.HasValue) + { + _repository.UpdateBuyer(CreateBuyer(_buyerId.Value)); + } + else + { + _repository.CreateBuyer(CreateBuyer(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Buyer CreateBuyer(int id) => Buyer.CreateBuyer(id, textBoxFullName.Text, + (int)numericUpDownPassportSeries.Value, (int)numericUpDownPassportNumber.Value); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyer.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/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.Designer.cs new file mode 100644 index 0000000..b2c13c4 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.Designer.cs @@ -0,0 +1,128 @@ +namespace RealEstateTransactions.Forms +{ + partial class FormBuyers + { + /// + /// 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(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panelTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panelTools + // + panelTools.Controls.Add(buttonDelete); + panelTools.Controls.Add(buttonUpdate); + panelTools.Controls.Add(buttonAdd); + panelTools.Dock = DockStyle.Right; + panelTools.Location = new Point(850, 0); + panelTools.Name = "panelTools"; + panelTools.Size = new Size(132, 553); + panelTools.TabIndex = 0; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.Delete; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(27, 358); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(80, 80); + buttonDelete.TabIndex = 2; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.Update; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(27, 223); + 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; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(27, 88); + 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(850, 553); + dataGridView.TabIndex = 1; + dataGridView.TabStop = false; + // + // FormBuyers + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(982, 553); + Controls.Add(dataGridView); + Controls.Add(panelTools); + Name = "FormBuyers"; + StartPosition = FormStartPosition.CenterParent; + Text = "Покупатели"; + Load += FormBuyers_Load; + panelTools.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panelTools; + private Button buttonAdd; + private Button buttonDelete; + private Button buttonUpdate; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.cs new file mode 100644 index 0000000..393dc1b --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.cs @@ -0,0 +1,96 @@ +using RealEstateTransactions.Repositories; +using Unity; + +namespace RealEstateTransactions.Forms +{ + public partial class FormBuyers : Form + { + private readonly IUnityContainer _container; + + private readonly IBuyerRepository _repository; + + public FormBuyers(IUnityContainer container, IBuyerRepository repository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + } + + private void FormBuyers_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 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; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo, + MessageBoxIcon.Question) == DialogResult.No) return; + + try + { + _repository.DeleteBuyer(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _repository.ReadBuyers(); + + private bool TryGetIdentifierFormSelectedRow(out int id) + { + id = 0; + + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + + return true; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormBuyers.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/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.Designer.cs new file mode 100644 index 0000000..f7b3cf2 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.Designer.cs @@ -0,0 +1,244 @@ +namespace RealEstateTransactions.Forms +{ + partial class FormDeal + { + /// + /// 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() + { + labelApartmentId = new Label(); + comboBoxApartmentId = new ComboBox(); + labelFullName = new Label(); + comboBoxFullName = new ComboBox(); + labelDealPrice = new Label(); + numericUpDownDealPrice = new NumericUpDown(); + labelDealDate = new Label(); + 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 + // + labelApartmentId.AutoSize = true; + labelApartmentId.Font = new Font("Segoe UI", 14F); + labelApartmentId.Location = new Point(12, 9); + labelApartmentId.Name = "labelApartmentId"; + labelApartmentId.Size = new Size(349, 32); + labelApartmentId.TabIndex = 0; + labelApartmentId.Text = "ID квартиры - - - - - - - -"; + // + // comboBoxApartmentId + // + comboBoxApartmentId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxApartmentId.Font = new Font("Segoe UI", 14F); + comboBoxApartmentId.FormattingEnabled = true; + comboBoxApartmentId.Location = new Point(370, 6); + comboBoxApartmentId.Name = "comboBoxApartmentId"; + comboBoxApartmentId.Size = new Size(151, 39); + comboBoxApartmentId.TabIndex = 0; + // + // labelFullName + // + labelFullName.AutoSize = true; + labelFullName.Font = new Font("Segoe UI", 14F); + labelFullName.Location = new Point(12, 76); + labelFullName.Name = "labelFullName"; + labelFullName.Size = new Size(200, 32); + labelFullName.TabIndex = 1; + labelFullName.Text = "ФИО покупателя"; + // + // comboBoxFullName + // + comboBoxFullName.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxFullName.Font = new Font("Segoe UI", 14F); + comboBoxFullName.FormattingEnabled = true; + comboBoxFullName.Location = new Point(218, 73); + comboBoxFullName.Name = "comboBoxFullName"; + comboBoxFullName.Size = new Size(303, 39); + comboBoxFullName.TabIndex = 1; + // + // labelDealPrice + // + labelDealPrice.AutoSize = true; + labelDealPrice.Font = new Font("Segoe UI", 14F); + labelDealPrice.Location = new Point(12, 152); + labelDealPrice.Name = "labelDealPrice"; + labelDealPrice.Size = new Size(214, 32); + labelDealPrice.TabIndex = 3; + labelDealPrice.Text = "Стоимость сделки"; + // + // numericUpDownDealPrice + // + numericUpDownDealPrice.BorderStyle = BorderStyle.FixedSingle; + numericUpDownDealPrice.DecimalPlaces = 2; + numericUpDownDealPrice.Font = new Font("Segoe UI", 14F); + numericUpDownDealPrice.Location = new Point(232, 150); + numericUpDownDealPrice.Maximum = new decimal(new int[] { 1410065408, 2, 0, 0 }); + numericUpDownDealPrice.Name = "numericUpDownDealPrice"; + numericUpDownDealPrice.Size = new Size(289, 39); + numericUpDownDealPrice.TabIndex = 2; + numericUpDownDealPrice.TextAlign = HorizontalAlignment.Center; + numericUpDownDealPrice.ThousandsSeparator = true; + // + // labelDealDate + // + labelDealDate.AutoSize = true; + labelDealDate.Font = new Font("Segoe UI", 14F); + labelDealDate.Location = new Point(12, 219); + labelDealDate.Name = "labelDealDate"; + labelDealDate.Size = new Size(251, 32); + labelDealDate.TabIndex = 4; + labelDealDate.Text = "Дата сделки - - - -"; + // + // dateTimePickerDealDate + // + dateTimePickerDealDate.CalendarFont = new Font("Segoe UI", 14F); + dateTimePickerDealDate.Enabled = false; + dateTimePickerDealDate.Font = new Font("Segoe UI", 14F); + dateTimePickerDealDate.Location = new Point(271, 213); + dateTimePickerDealDate.Name = "dateTimePickerDealDate"; + dateTimePickerDealDate.Size = new Size(250, 39); + dateTimePickerDealDate.TabIndex = 5; + dateTimePickerDealDate.TabStop = false; + dateTimePickerDealDate.Value = new DateTime(2024, 11, 22, 10, 0, 0, 0); + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Font = new Font("Segoe UI", 14F); + buttonSave.Location = new Point(66, 579); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(146, 63); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Font = new Font("Segoe UI", 14F); + buttonCancel.Location = new Point(328, 579); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(146, 63); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + 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, 654); + Controls.Add(groupBoxDataGrid); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerDealDate); + Controls.Add(labelDealDate); + Controls.Add(numericUpDownDealPrice); + Controls.Add(labelDealPrice); + Controls.Add(comboBoxFullName); + Controls.Add(labelFullName); + Controls.Add(comboBoxApartmentId); + Controls.Add(labelApartmentId); + Name = "FormDeal"; + StartPosition = FormStartPosition.CenterParent; + Text = "Сделка"; + ((System.ComponentModel.ISupportInitialize)numericUpDownDealPrice).EndInit(); + groupBoxDataGrid.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelApartmentId; + private ComboBox comboBoxApartmentId; + private Label labelFullName; + private ComboBox comboBoxFullName; + private Label labelDealPrice; + private NumericUpDown numericUpDownDealPrice; + private Label labelDealDate; + 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 new file mode 100644 index 0000000..63122bf --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.cs @@ -0,0 +1,68 @@ +using RealEstateTransactions.Entities; +using RealEstateTransactions.Repositories; + +namespace RealEstateTransactions.Forms +{ + public partial class FormDeal : Form + { + private readonly IDealRepository _repository; + + public FormDeal(IDealRepository repository, IApartmentRepository apartmentRepository, + IBuyerRepository buyerRepository, IServicesRepository servicesRepository) + { + InitializeComponent(); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + + comboBoxApartmentId.DataSource = apartmentRepository.ReadApartments(); + comboBoxApartmentId.DisplayMember = "Id"; + comboBoxApartmentId.ValueMember = "Id"; + + comboBoxFullName.DataSource = buyerRepository.ReadBuyers(); + comboBoxFullName.DisplayMember = "FullName"; + comboBoxFullName.ValueMember = "Id"; + + ColumnService.DataSource = servicesRepository.ReadServices(); + ColumnService.DisplayMember = "Name"; + ColumnService.ValueMember = "Id"; + + dateTimePickerDealDate.Value = DateTime.Now; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxApartmentId.SelectedItem == null || comboBoxFullName.SelectedItem == null + || dataGridView.RowCount < 1) + throw new Exception("Имеются не заполненные поля"); + + _repository.CreateDeal(Deal.CreateDeal(0, (int)comboBoxApartmentId.SelectedValue!, + (int)comboBoxFullName.SelectedValue!, (float)numericUpDownDealPrice.Value, + dateTimePickerDealDate.Value, CreateListFromDataGridView())); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + 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 new file mode 100644 index 0000000..0ccc94e --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeal.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.Designer.cs new file mode 100644 index 0000000..e74eccc --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.Designer.cs @@ -0,0 +1,114 @@ +namespace RealEstateTransactions.Entities +{ + partial class FormDeals + { + /// + /// 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(); + buttonDelete = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panelTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panelTools + // + panelTools.Controls.Add(buttonDelete); + 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 = 1; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.Delete; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(28, 333); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(80, 80); + buttonDelete.TabIndex = 1; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 73); + 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 = 2; + dataGridView.TabStop = false; + // + // FormDeals + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(982, 553); + Controls.Add(dataGridView); + Controls.Add(panelTools); + Name = "FormDeals"; + StartPosition = FormStartPosition.CenterParent; + Text = "Сделки"; + Load += FormDeals_Load; + panelTools.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panelTools; + private Button buttonDelete; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.cs new file mode 100644 index 0000000..9cc0622 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.cs @@ -0,0 +1,79 @@ +using RealEstateTransactions.Forms; +using RealEstateTransactions.Repositories; +using Unity; + +namespace RealEstateTransactions.Entities +{ + public partial class FormDeals : Form + { + private readonly IUnityContainer _container; + + private readonly IDealRepository _repository; + + public FormDeals(IUnityContainer container, IDealRepository repository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + } + + private void FormDeals_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 ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFormSelectedRow(out var findId)) return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) + != DialogResult.Yes) return; + + try + { + _repository.DeleteDeal(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _repository.ReadDeals(); + + private bool TryGetIdentifierFormSelectedRow(out int id) + { + id = 0; + + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormDeals.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/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.Designer.cs new file mode 100644 index 0000000..857f047 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.Designer.cs @@ -0,0 +1,159 @@ +namespace RealEstateTransactions.Forms +{ + partial class FormPreSalesService + { + /// + /// 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() + { + labelApartmentId = new Label(); + comboBoxApartmentId = new ComboBox(); + labelName = new Label(); + textBoxName = new TextBox(); + labelCost = new Label(); + numericUpDownCost = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit(); + SuspendLayout(); + // + // labelApartmentId + // + labelApartmentId.AutoSize = true; + labelApartmentId.Font = new Font("Segoe UI", 14F); + labelApartmentId.Location = new Point(12, 9); + labelApartmentId.Name = "labelApartmentId"; + labelApartmentId.Size = new Size(270, 32); + labelApartmentId.TabIndex = 0; + labelApartmentId.Text = "ID квартиры - - - - -"; + // + // comboBoxApartmentId + // + comboBoxApartmentId.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxApartmentId.Font = new Font("Segoe UI", 14F); + comboBoxApartmentId.FormattingEnabled = true; + comboBoxApartmentId.Location = new Point(292, 6); + comboBoxApartmentId.Name = "comboBoxApartmentId"; + comboBoxApartmentId.Size = new Size(151, 39); + comboBoxApartmentId.TabIndex = 0; + // + // labelName + // + labelName.AutoSize = true; + labelName.Font = new Font("Segoe UI", 14F); + labelName.Location = new Point(12, 83); + labelName.Name = "labelName"; + labelName.Size = new Size(198, 32); + labelName.TabIndex = 1; + labelName.Text = "Название услуги"; + // + // textBoxName + // + textBoxName.BorderStyle = BorderStyle.FixedSingle; + textBoxName.Font = new Font("Segoe UI", 14F); + textBoxName.Location = new Point(216, 81); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(227, 39); + textBoxName.TabIndex = 1; + textBoxName.TextAlign = HorizontalAlignment.Center; + // + // labelCost + // + labelCost.AutoSize = true; + labelCost.Font = new Font("Segoe UI", 14F); + labelCost.Location = new Point(12, 169); + labelCost.Name = "labelCost"; + labelCost.Size = new Size(264, 32); + labelCost.TabIndex = 2; + labelCost.Text = "Стоимость услуги - -"; + // + // numericUpDownCost + // + numericUpDownCost.BorderStyle = BorderStyle.FixedSingle; + numericUpDownCost.DecimalPlaces = 2; + numericUpDownCost.Font = new Font("Segoe UI", 14F); + numericUpDownCost.Location = new Point(272, 167); + numericUpDownCost.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownCost.Name = "numericUpDownCost"; + numericUpDownCost.Size = new Size(171, 39); + numericUpDownCost.TabIndex = 2; + numericUpDownCost.TextAlign = HorizontalAlignment.Center; + numericUpDownCost.ThousandsSeparator = true; + // + // buttonSave + // + buttonSave.Font = new Font("Segoe UI", 14F); + buttonSave.Location = new Point(48, 228); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(144, 57); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Font = new Font("Segoe UI", 14F); + buttonCancel.Location = new Point(254, 228); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(144, 57); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormPreSalesService + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(455, 294); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownCost); + Controls.Add(labelCost); + Controls.Add(textBoxName); + Controls.Add(labelName); + Controls.Add(comboBoxApartmentId); + Controls.Add(labelApartmentId); + Name = "FormPreSalesService"; + StartPosition = FormStartPosition.CenterParent; + Text = "Допродажная услуга"; + ((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelApartmentId; + private ComboBox comboBoxApartmentId; + private Label labelName; + private TextBox textBoxName; + private Label labelCost; + private NumericUpDown numericUpDownCost; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.cs new file mode 100644 index 0000000..46bcf47 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.cs @@ -0,0 +1,42 @@ +using RealEstateTransactions.Entities; +using RealEstateTransactions.Repositories; + +namespace RealEstateTransactions.Forms +{ + public partial class FormPreSalesService : Form + { + private readonly IPreSalesServicesRepository _repository; + + public FormPreSalesService(IPreSalesServicesRepository repository, IApartmentRepository apartmentRepository) + { + InitializeComponent(); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + + comboBoxApartmentId.DataSource = apartmentRepository.ReadApartments(); + comboBoxApartmentId.DisplayMember = "Id"; + comboBoxApartmentId.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxApartmentId.SelectedItem == null || string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + _repository.CreatePreSalesService(PreSalesServices.CreatePreSalesServices(0, (int)comboBoxApartmentId.SelectedValue!, + textBoxName.Text, (float)numericUpDownCost.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/FormPreSalesService.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesService.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/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.Designer.cs new file mode 100644 index 0000000..1d41783 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.Designer.cs @@ -0,0 +1,114 @@ +namespace RealEstateTransactions.Forms +{ + partial class FormPreSalesServices + { + /// + /// 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(); + buttonDelete = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panelTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panelTools + // + panelTools.Controls.Add(buttonDelete); + 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 = 1; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.Delete; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(28, 307); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(80, 80); + buttonDelete.TabIndex = 1; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 139); + 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 = 2; + dataGridView.TabStop = false; + // + // FormPreSalesServices + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(982, 553); + Controls.Add(dataGridView); + Controls.Add(panelTools); + Name = "FormPreSalesServices"; + StartPosition = FormStartPosition.CenterParent; + Text = "Допродажные услуги"; + Load += FormPreSalesServices_Load; + panelTools.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panelTools; + private Button buttonDelete; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.cs new file mode 100644 index 0000000..a6e8cf4 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.cs @@ -0,0 +1,78 @@ +using RealEstateTransactions.Repositories; +using Unity; + +namespace RealEstateTransactions.Forms +{ + public partial class FormPreSalesServices : Form + { + private readonly IUnityContainer _container; + + private readonly IPreSalesServicesRepository _repository; + + public FormPreSalesServices(IUnityContainer container, IPreSalesServicesRepository repository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + } + + private void FormPreSalesServices_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 ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFormSelectedRow(out var findId)) return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) + != DialogResult.Yes) return; + + try + { + _repository.DeletePreSalesService(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _repository.ReadPreSalesServices(); + + private bool TryGetIdentifierFormSelectedRow(out int id) + { + id = 0; + + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormPreSalesServices.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/RealEstateTransactions/RealEstateTransactions/Forms/FormService.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormService.Designer.cs new file mode 100644 index 0000000..4d7f8c1 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormService.Designer.cs @@ -0,0 +1,133 @@ +namespace RealEstateTransactions.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() + { + labelName = new Label(); + labelPrice = new Label(); + textBoxName = new TextBox(); + numericUpDownPrice = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Font = new Font("Segoe UI", 14F); + labelName.Location = new Point(12, 9); + labelName.Name = "labelName"; + labelName.Size = new Size(198, 32); + labelName.TabIndex = 0; + labelName.Text = "Название услуги"; + // + // labelPrice + // + labelPrice.AutoSize = true; + labelPrice.Font = new Font("Segoe UI", 14F); + labelPrice.Location = new Point(12, 80); + labelPrice.Name = "labelPrice"; + labelPrice.Size = new Size(209, 32); + labelPrice.TabIndex = 1; + labelPrice.Text = "Стоимость услуги"; + // + // textBoxName + // + textBoxName.BorderStyle = BorderStyle.FixedSingle; + textBoxName.Font = new Font("Segoe UI", 14F); + textBoxName.Location = new Point(232, 7); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(186, 39); + textBoxName.TabIndex = 0; + textBoxName.TextAlign = HorizontalAlignment.Center; + // + // numericUpDownPrice + // + numericUpDownPrice.BorderStyle = BorderStyle.FixedSingle; + numericUpDownPrice.DecimalPlaces = 2; + numericUpDownPrice.Font = new Font("Segoe UI", 14F); + numericUpDownPrice.Location = new Point(232, 73); + numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(186, 39); + numericUpDownPrice.TabIndex = 1; + numericUpDownPrice.TextAlign = HorizontalAlignment.Center; + numericUpDownPrice.ThousandsSeparator = true; + // + // buttonSave + // + buttonSave.Font = new Font("Segoe UI", 14F); + buttonSave.Location = new Point(32, 137); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(148, 49); + buttonSave.TabIndex = 2; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Font = new Font("Segoe UI", 14F); + buttonCancel.Location = new Point(232, 137); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(148, 49); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormService + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(429, 194); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownPrice); + Controls.Add(textBoxName); + Controls.Add(labelPrice); + Controls.Add(labelName); + Name = "FormService"; + StartPosition = FormStartPosition.CenterParent; + Text = "Услуга"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelPrice; + private TextBox textBoxName; + private NumericUpDown numericUpDownPrice; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormService.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormService.cs new file mode 100644 index 0000000..b733d25 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormService.cs @@ -0,0 +1,73 @@ +using RealEstateTransactions.Entities; +using RealEstateTransactions.Repositories; + +namespace RealEstateTransactions.Forms +{ + public partial class FormService : Form + { + private readonly IServicesRepository _repository; + + private int? _serviceId; + + public int Id + { + set + { + try + { + var service = _repository.ReadService(value); + + if (service == null) throw new InvalidDataException(nameof(service)); + + textBoxName.Text = service.Name; + numericUpDownPrice.Value = (decimal)service.Price; + + _serviceId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormService(IServicesRepository repository) + { + InitializeComponent(); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_serviceId.HasValue) + { + _repository.UpdateService(CreateService(_serviceId.Value)); + } + else + { + _repository.CreateService(CreateService(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Services CreateService(int id) => Services.CreateService(id, textBoxName.Text, (float)numericUpDownPrice.Value); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormService.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormService.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/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/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.Designer.cs new file mode 100644 index 0000000..9aa5101 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.Designer.cs @@ -0,0 +1,128 @@ +namespace RealEstateTransactions.Entities +{ + 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() + { + panelTools = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panelTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panelTools + // + panelTools.Controls.Add(buttonDelete); + panelTools.Controls.Add(buttonUpdate); + 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 = 1; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.Delete; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(28, 333); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(80, 80); + buttonDelete.TabIndex = 2; + 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; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 73); + 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 = 2; + dataGridView.TabStop = false; + // + // FormServices + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(982, 553); + Controls.Add(dataGridView); + Controls.Add(panelTools); + Name = "FormServices"; + StartPosition = FormStartPosition.CenterParent; + Text = "Услуги"; + Load += FormServices_Load; + panelTools.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panelTools; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.cs b/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.cs new file mode 100644 index 0000000..b80d5d0 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.cs @@ -0,0 +1,96 @@ +using RealEstateTransactions.Forms; +using RealEstateTransactions.Repositories; +using Unity; + +namespace RealEstateTransactions.Entities +{ + public partial class FormServices : Form + { + private readonly IUnityContainer _container; + + private readonly IServicesRepository _repository; + + public FormServices(IUnityContainer container, IServicesRepository repository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _repository = repository ?? throw new ArgumentNullException(nameof(_repository)); + } + + 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 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; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) + != DialogResult.Yes) return; + + try + { + _repository.DeleteService(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _repository.ReadServices(); + + private bool TryGetIdentifierFormSelectedRow(out int id) + { + id = 0; + + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.resx b/RealEstateTransactions/RealEstateTransactions/Forms/FormServices.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/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/RealEstateTransactions/RealEstateTransactions/Program.cs b/RealEstateTransactions/RealEstateTransactions/Program.cs index 9fc45d0..cef90b1 100644 --- a/RealEstateTransactions/RealEstateTransactions/Program.cs +++ b/RealEstateTransactions/RealEstateTransactions/Program.cs @@ -1,3 +1,7 @@ +using RealEstateTransactions.Repositories; +using RealEstateTransactions.Repositories.Implementations; +using Unity; + namespace RealEstateTransactions { internal static class Program @@ -11,7 +15,21 @@ namespace RealEstateTransactions // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Properties/Resources.Designer.cs b/RealEstateTransactions/RealEstateTransactions/Properties/Resources.Designer.cs new file mode 100644 index 0000000..3179bd4 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace RealEstateTransactions.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RealEstateTransactions.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Add { + get { + object obj = ResourceManager.GetObject("Add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Delete { + get { + object obj = ResourceManager.GetObject("Delete", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ERka { + get { + object obj = ResourceManager.GetObject("ERka", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Update { + get { + object obj = ResourceManager.GetObject("Update", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap фон { + get { + object obj = ResourceManager.GetObject("фон", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Properties/Resources.resx b/RealEstateTransactions/RealEstateTransactions/Properties/Resources.resx new file mode 100644 index 0000000..3adb1ee --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\фон.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ERka.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/RealEstateTransactions.csproj b/RealEstateTransactions/RealEstateTransactions/RealEstateTransactions.csproj index 663fdb8..accbdf0 100644 --- a/RealEstateTransactions/RealEstateTransactions/RealEstateTransactions.csproj +++ b/RealEstateTransactions/RealEstateTransactions/RealEstateTransactions.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/IApartmentRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/IApartmentRepository.cs new file mode 100644 index 0000000..1a77ebf --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/IApartmentRepository.cs @@ -0,0 +1,17 @@ +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions.Repositories +{ + public interface IApartmentRepository + { + IEnumerable ReadApartments(); + + Apartment ReadApartment(int id); + + void CreateApartment(Apartment apartment); + + void UpdateApartment(Apartment apartment); + + void DeleteApartment(int id); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/IBuyerRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/IBuyerRepository.cs new file mode 100644 index 0000000..4510691 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/IBuyerRepository.cs @@ -0,0 +1,17 @@ +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions.Repositories +{ + public interface IBuyerRepository + { + IEnumerable ReadBuyers(); + + Buyer ReadBuyer(int id); + + void CreateBuyer(Buyer buyer); + + void UpdateBuyer(Buyer buyer); + + void DeleteBuyer(int id); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/IDealRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/IDealRepository.cs new file mode 100644 index 0000000..7d37e4c --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/IDealRepository.cs @@ -0,0 +1,17 @@ +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions.Repositories +{ + public interface IDealRepository + { + IEnumerable ReadDeals(); + + Deal ReadDeal(int id); + + void CreateDeal(Deal deal); + + void UpdateDeal(Deal deal); + + void DeleteDeal(int id); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/IPreSalesServicesRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/IPreSalesServicesRepository.cs new file mode 100644 index 0000000..05bb6ae --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/IPreSalesServicesRepository.cs @@ -0,0 +1,13 @@ +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions.Repositories +{ + public interface IPreSalesServicesRepository + { + IEnumerable ReadPreSalesServices(); + + void CreatePreSalesService(PreSalesServices preSalesServices); + + void DeletePreSalesService(int id); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/IServicesDealRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/IServicesDealRepository.cs new file mode 100644 index 0000000..204f8cd --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/IServicesDealRepository.cs @@ -0,0 +1,11 @@ +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions.Repositories +{ + public interface IServicesDealRepository + { + IEnumerable ReadServicesDeal(); + + void CreateServicesDeal(ServicesDeal servicesDeal); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/IServicesRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/IServicesRepository.cs new file mode 100644 index 0000000..413c287 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/IServicesRepository.cs @@ -0,0 +1,17 @@ +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions.Repositories +{ + public interface IServicesRepository + { + IEnumerable ReadServices(); + + Services ReadService(int id); + + void CreateService(Services service); + + void UpdateService(Services service); + + void DeleteService(int id); + } +} \ No newline at end of file diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ApartmentRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ApartmentRepository.cs new file mode 100644 index 0000000..9ee9018 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ApartmentRepository.cs @@ -0,0 +1,38 @@ +using RealEstateTransactions.Entities; +using RealEstateTransactions.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RealEstateTransactions.Repositories.Implementations +{ + public class ApartmentRepository : IApartmentRepository + { + public Apartment ReadApartment(int id) + { + return Apartment.CreateApartment(0, AgencyType.None, FormFactorType.None, 0, 0, 0, 0); + } + + public IEnumerable ReadApartments() + { + return []; + } + + public void CreateApartment(Apartment apartment) + { + + } + + public void DeleteApartment(int id) + { + + } + + public void UpdateApartment(Apartment apartment) + { + + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/BuyerRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/BuyerRepository.cs new file mode 100644 index 0000000..f67c262 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/BuyerRepository.cs @@ -0,0 +1,38 @@ +using RealEstateTransactions.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Metadata.Ecma335; +using System.Text; +using System.Threading.Tasks; + +namespace RealEstateTransactions.Repositories.Implementations +{ + public class BuyerRepository : IBuyerRepository + { + public void CreateBuyer(Buyer buyer) + { + + } + + public void DeleteBuyer(int id) + { + + } + + public Buyer ReadBuyer(int id) + { + return Buyer.CreateBuyer(0, "", 0, 0); + } + + public IEnumerable ReadBuyers() + { + return []; + } + + public void UpdateBuyer(Buyer buyer) + { + + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/DealRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/DealRepository.cs new file mode 100644 index 0000000..3eaf7b2 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/DealRepository.cs @@ -0,0 +1,32 @@ +using RealEstateTransactions.Entities; + +namespace RealEstateTransactions.Repositories.Implementations +{ + public class DealRepository : IDealRepository + { + public void CreateDeal(Deal deal) + { + + } + + public void DeleteDeal(int id) + { + + } + + public Deal ReadDeal(int id) + { + return Deal.CreateDeal(0, 0, 0, 0, DateTime.Now, []); + } + + public IEnumerable ReadDeals() + { + return []; + } + + public void UpdateDeal(Deal deal) + { + + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/PreSalesServicesRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/PreSalesServicesRepository.cs new file mode 100644 index 0000000..17e590d --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/PreSalesServicesRepository.cs @@ -0,0 +1,28 @@ +using RealEstateTransactions.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RealEstateTransactions.Repositories.Implementations +{ + public class PreSalesServicesRepository : IPreSalesServicesRepository + { + public void CreatePreSalesService(PreSalesServices preSalesServices) + { + + + } + + public void DeletePreSalesService(int id) + { + + } + + public IEnumerable ReadPreSalesServices() + { + return []; + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ServicesDealRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ServicesDealRepository.cs new file mode 100644 index 0000000..ab2dfc1 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ServicesDealRepository.cs @@ -0,0 +1,27 @@ +using RealEstateTransactions.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RealEstateTransactions.Repositories.Implementations +{ + public class ServicesDealRepository : IServicesDealRepository + { + public void CreateServicesDeal(ServicesDeal servicesDeal) + { + + } + + public void DeleteServicesDeal(int id) + { + + } + + public IEnumerable ReadServicesDeal() + { + return []; + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ServicesRepository.cs b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ServicesRepository.cs new file mode 100644 index 0000000..f6c8bb9 --- /dev/null +++ b/RealEstateTransactions/RealEstateTransactions/Repositories/Implementations/ServicesRepository.cs @@ -0,0 +1,37 @@ +using RealEstateTransactions.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RealEstateTransactions.Repositories.Implementations +{ + public class ServicesRepository : IServicesRepository + { + public void CreateService(Services service) + { + + } + + public void DeleteService(int id) + { + + } + + public Services ReadService(int id) + { + return Services.CreateService(0, "", 0); + } + + public IEnumerable ReadServices() + { + return []; + } + + public void UpdateService(Services service) + { + + } + } +} diff --git a/RealEstateTransactions/RealEstateTransactions/Resources/Add.png b/RealEstateTransactions/RealEstateTransactions/Resources/Add.png new file mode 100644 index 0000000..c153386 Binary files /dev/null and b/RealEstateTransactions/RealEstateTransactions/Resources/Add.png differ diff --git a/RealEstateTransactions/RealEstateTransactions/Resources/Delete.png b/RealEstateTransactions/RealEstateTransactions/Resources/Delete.png new file mode 100644 index 0000000..a74db83 Binary files /dev/null and b/RealEstateTransactions/RealEstateTransactions/Resources/Delete.png differ diff --git a/RealEstateTransactions/RealEstateTransactions/Resources/ERka.png b/RealEstateTransactions/RealEstateTransactions/Resources/ERka.png new file mode 100644 index 0000000..ca4deb4 Binary files /dev/null and b/RealEstateTransactions/RealEstateTransactions/Resources/ERka.png differ diff --git a/RealEstateTransactions/RealEstateTransactions/Resources/Update.png b/RealEstateTransactions/RealEstateTransactions/Resources/Update.png new file mode 100644 index 0000000..81bca65 Binary files /dev/null and b/RealEstateTransactions/RealEstateTransactions/Resources/Update.png differ diff --git a/RealEstateTransactions/RealEstateTransactions/Resources/фон.png b/RealEstateTransactions/RealEstateTransactions/Resources/фон.png new file mode 100644 index 0000000..da78895 Binary files /dev/null and b/RealEstateTransactions/RealEstateTransactions/Resources/фон.png differ diff --git a/RealEstateTransactions/Temp.txt b/RealEstateTransactions/Temp.txt new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/RealEstateTransactions/Temp.txt @@ -0,0 +1 @@ + \ No newline at end of file