diff --git a/ProjectRepairWork/Entities/Contractors.cs b/ProjectRepairWork/Entities/Contractors.cs new file mode 100644 index 0000000..32b229b --- /dev/null +++ b/ProjectRepairWork/Entities/Contractors.cs @@ -0,0 +1,24 @@ +using ProjectRepairWork.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities; + +public class Contractors +{ + public int Id { get; private set; } + public string CompanyName { get; private set; } = string.Empty; + public string Contacts { get; private set; } = string.Empty; + public static Contractors CreatEntity(int id, string companyName, string contants) + { + return new Contractors + + { Id = id, + CompanyName = companyName, + Contacts = contants + }; + } +} diff --git a/ProjectRepairWork/Entities/Cost.cs b/ProjectRepairWork/Entities/Cost.cs new file mode 100644 index 0000000..563c4e2 --- /dev/null +++ b/ProjectRepairWork/Entities/Cost.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities; +public class Cost +{ + public int Id { get; private set; } + public int Price { get; private set; } + public static Cost CreatEntity(int id, int price) + { + return new Cost + { + Id = id, + + Price = price + }; + } +} diff --git a/ProjectRepairWork/Entities/Enums/MaterialsName.cs b/ProjectRepairWork/Entities/Enums/MaterialsName.cs new file mode 100644 index 0000000..05bf497 --- /dev/null +++ b/ProjectRepairWork/Entities/Enums/MaterialsName.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities.Enums; +[Flags] +public enum MaterialsName +{ + None = 0, + + Tiles = 1, // напольная плитка + + Wallpaper = 2, // обои + + Paints = 3, // краски + + Furniture = 4, // мебель + + Windows = 5, // окна + +} diff --git a/ProjectRepairWork/Entities/Enums/PremisesType.cs b/ProjectRepairWork/Entities/Enums/PremisesType.cs new file mode 100644 index 0000000..ab435c5 --- /dev/null +++ b/ProjectRepairWork/Entities/Enums/PremisesType.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities.Enums +{ + public enum PremisesType + { + None = 0, + + SivingSpace = 1, + + OfficeSpace = 2, + } +} diff --git a/ProjectRepairWork/Entities/Premises.cs b/ProjectRepairWork/Entities/Premises.cs new file mode 100644 index 0000000..53c4ad9 --- /dev/null +++ b/ProjectRepairWork/Entities/Premises.cs @@ -0,0 +1,31 @@ +using ProjectRepairWork.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities; +public class Premises +{ + public int Id { get; private set; } + public string ClientName { get; private set; } = string.Empty; + public string Address { get; private set; } = string.Empty; + public int Area { get; private set; } + public PremisesType PremisesType { get; private set; } + public DateTime DateStart { get; private set; } + public DateTime DateEnd { get; private set; } + public static Premises CreatEntity(int id, string clientName, string address, int area, DateTime dateStart, DateTime dateEnd, PremisesType premisesType) + { + return new Premises + { + Id = id, + ClientName = clientName, + Address = address, + Area = area, + DateStart = dateStart, + DateEnd = dateEnd, + PremisesType = premisesType + }; + } +} diff --git a/ProjectRepairWork/Entities/Repair.cs b/ProjectRepairWork/Entities/Repair.cs new file mode 100644 index 0000000..81d3774 --- /dev/null +++ b/ProjectRepairWork/Entities/Repair.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities; + +public class Repair +{ + public int Id { get; private set; } + public int ContractorsId { get; private set; } + public int PremisesId { get; private set; } + public IEnumerable RepairRepair { get; private set; } = []; + + + + public static Repair CreatOpertions(int id, int contractorsId, int premisesId, IEnumerable repairRepair) + { + return new Repair + { + Id = id, + ContractorsId = contractorsId, + PremisesId = premisesId, + RepairRepair = repairRepair, + + }; + } + +} diff --git a/ProjectRepairWork/Entities/RepairRepair.cs b/ProjectRepairWork/Entities/RepairRepair.cs new file mode 100644 index 0000000..f8b5675 --- /dev/null +++ b/ProjectRepairWork/Entities/RepairRepair.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities; + +public class RepairRepair +{ + public int Id { get; private set; } + public int WorkId { get; private set; } + public int Count { get; private set; } + + + public static RepairRepair CreatElement(int id, int workId, int count) + { + return new RepairRepair + { + Id = id, + WorkId = workId, + Count = count, + + }; + } + +} diff --git a/ProjectRepairWork/Entities/Works.cs b/ProjectRepairWork/Entities/Works.cs new file mode 100644 index 0000000..4022b67 --- /dev/null +++ b/ProjectRepairWork/Entities/Works.cs @@ -0,0 +1,24 @@ +using ProjectRepairWork.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Entities; + +public class Works +{ + public int Id { get; private set; } + public string WorkName { get; private set; } = string.Empty; + public MaterialsName MaterialsName { get; private set; } + public static Works CreatEntity(int id, string workName, MaterialsName materialsName) + { + return new Works + { + Id = id, + WorkName = workName, + MaterialsName = materialsName + }; + } +} diff --git a/ProjectRepairWork/Form1.Designer.cs b/ProjectRepairWork/Form1.Designer.cs deleted file mode 100644 index 6180970..0000000 --- a/ProjectRepairWork/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectRepairWork -{ - 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/ProjectRepairWork/Form1.cs b/ProjectRepairWork/Form1.cs deleted file mode 100644 index 639b6c7..0000000 --- a/ProjectRepairWork/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectRepairWork -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectRepairWork/FormRepairWork.Designer.cs b/ProjectRepairWork/FormRepairWork.Designer.cs new file mode 100644 index 0000000..9b22dfb --- /dev/null +++ b/ProjectRepairWork/FormRepairWork.Designer.cs @@ -0,0 +1,138 @@ +namespace ProjectRepairWork +{ + partial class FormRepairWork + { + /// + /// 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(); + ContractorsToolStripMenuItem = new ToolStripMenuItem(); + PremisesToolStripMenuItem = new ToolStripMenuItem(); + CostToolStripMenuItem = new ToolStripMenuItem(); + WorksToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + RepairToolStripMenuItem = 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 = "menuStrip"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ContractorsToolStripMenuItem, PremisesToolStripMenuItem, CostToolStripMenuItem, WorksToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(117, 24); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // ContractorsToolStripMenuItem + // + ContractorsToolStripMenuItem.Name = "ContractorsToolStripMenuItem"; + ContractorsToolStripMenuItem.Size = new Size(224, 26); + ContractorsToolStripMenuItem.Text = "Подрядчики"; + ContractorsToolStripMenuItem.Click += ContractorsToolStripMenuItem_Click; + // + // PremisesToolStripMenuItem + // + PremisesToolStripMenuItem.Name = "PremisesToolStripMenuItem"; + PremisesToolStripMenuItem.Size = new Size(224, 26); + PremisesToolStripMenuItem.Text = "Помещения"; + PremisesToolStripMenuItem.Click += PremisesToolStripMenuItem_Click; + // + // CostToolStripMenuItem + // + CostToolStripMenuItem.Name = "CostToolStripMenuItem"; + CostToolStripMenuItem.Size = new Size(224, 26); + CostToolStripMenuItem.Text = "Затраты"; + CostToolStripMenuItem.Click += CostToolStripMenuItem_Click; + // + // WorksToolStripMenuItem + // + WorksToolStripMenuItem.Name = "WorksToolStripMenuItem"; + WorksToolStripMenuItem.Size = new Size(224, 26); + WorksToolStripMenuItem.Text = "Работы"; + WorksToolStripMenuItem.Click += WorksToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RepairToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(95, 24); + операцииToolStripMenuItem.Text = "Операции"; + // + // RepairToolStripMenuItem + // + RepairToolStripMenuItem.Name = "RepairToolStripMenuItem"; + RepairToolStripMenuItem.Size = new Size(224, 26); + RepairToolStripMenuItem.Text = "Ремонт"; + RepairToolStripMenuItem.Click += RepairToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormRepairWork + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.photo_2024_11_11_02_05_26; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(800, 450); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormRepairWork"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Ремонтные работы"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem ContractorsToolStripMenuItem; + private ToolStripMenuItem PremisesToolStripMenuItem; + private ToolStripMenuItem CostToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem RepairToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem WorksToolStripMenuItem; + } +} diff --git a/ProjectRepairWork/FormRepairWork.cs b/ProjectRepairWork/FormRepairWork.cs new file mode 100644 index 0000000..78d7742 --- /dev/null +++ b/ProjectRepairWork/FormRepairWork.cs @@ -0,0 +1,76 @@ +using ProjectRepairWork.Forms; +using System.ComponentModel; +using Unity; + +namespace ProjectRepairWork +{ + public partial class FormRepairWork : Form + { + private readonly IUnityContainer _container; + public FormRepairWork(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void WorksToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void CostToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void PremisesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ContractorsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void RepairToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectRepairWork/FormRepairWork.resx b/ProjectRepairWork/FormRepairWork.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/ProjectRepairWork/FormRepairWork.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/ProjectRepairWork/Forms/FormContractor.Designer.cs b/ProjectRepairWork/Forms/FormContractor.Designer.cs new file mode 100644 index 0000000..4348f34 --- /dev/null +++ b/ProjectRepairWork/Forms/FormContractor.Designer.cs @@ -0,0 +1,118 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormContractor + { + /// + /// 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() + { + textBoxContacts = new TextBox(); + Contacts = new Label(); + textBoxCompanyName = new TextBox(); + CompanyName = new Label(); + ButtonCancel = new Button(); + ButtonSave = new Button(); + SuspendLayout(); + // + // textBoxContacts + // + textBoxContacts.Location = new Point(192, 95); + textBoxContacts.Name = "textBoxContacts"; + textBoxContacts.Size = new Size(200, 27); + textBoxContacts.TabIndex = 18; + textBoxContacts.Text = "+7"; + // + // Contacts + // + Contacts.AutoSize = true; + Contacts.Location = new Point(107, 98); + Contacts.Name = "Contacts"; + Contacts.Size = new Size(69, 20); + Contacts.TabIndex = 17; + Contacts.Text = "Телефон"; + // + // textBoxCompanyName + // + textBoxCompanyName.Location = new Point(192, 42); + textBoxCompanyName.Name = "textBoxCompanyName"; + textBoxCompanyName.Size = new Size(200, 27); + textBoxCompanyName.TabIndex = 16; + // + // CompanyName + // + CompanyName.AutoSize = true; + CompanyName.Location = new Point(12, 45); + CompanyName.Name = "CompanyName"; + CompanyName.Size = new Size(164, 20); + CompanyName.TabIndex = 15; + CompanyName.Text = "Название подрядчика"; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(223, 165); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(169, 29); + ButtonCancel.TabIndex = 20; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += Cancel_Click; + // + // ButtonSave + // + ButtonSave.Location = new Point(12, 165); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(169, 29); + ButtonSave.TabIndex = 19; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += Save_Click; + // + // FormContractor + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(403, 217); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(textBoxContacts); + Controls.Add(Contacts); + Controls.Add(textBoxCompanyName); + Controls.Add(CompanyName); + Name = "FormContractor"; + Text = "Подрядчик"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBoxContacts; + private Label Contacts; + private TextBox textBoxCompanyName; + private Label CompanyName; + private Button ButtonCancel; + private Button ButtonSave; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormContractor.cs b/ProjectRepairWork/Forms/FormContractor.cs new file mode 100644 index 0000000..9dbdafa --- /dev/null +++ b/ProjectRepairWork/Forms/FormContractor.cs @@ -0,0 +1,75 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Entities; +using ProjectRepairWork.Repositories.Implementation; +using ProjectRepairWork.Entities.Enums; +using System.Diagnostics.Contracts; + +namespace ProjectRepairWork.Forms +{ + public partial class FormContractor : Form + { + private readonly IContractorsRepository _contractorsRepository; + private int? _contractorsId; + + public int Id + { + set + { + try + { + var contractors = _contractorsRepository.ReadContractorsById(value); + if (contractors == null) + { + throw new InvalidDataException(nameof(contractors)); + } + textBoxCompanyName.Text = contractors.CompanyName; + textBoxContacts.Text = contractors.Contacts; + _contractorsId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormContractor(IContractorsRepository contractorsRepository) + { + InitializeComponent(); + _contractorsRepository = contractorsRepository ?? throw new ArgumentNullException(nameof(contractorsRepository)); + } + private void Cancel_Click(object sender, EventArgs e) => Close(); + private Contractors CreateContractors(int id) => Contractors.CreatEntity( + id, + textBoxCompanyName.Text, + textBoxContacts.Text); + + private void Save_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxCompanyName.Text) || + string.IsNullOrWhiteSpace(textBoxContacts.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_contractorsId.HasValue) + { + _contractorsRepository.UpdateContractors(CreateContractors(_contractorsId.Value)); + } + else + { + _contractorsRepository.CreateContractors(CreateContractors(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + } +} diff --git a/ProjectRepairWork/Form1.resx b/ProjectRepairWork/Forms/FormContractor.resx similarity index 93% rename from ProjectRepairWork/Form1.resx rename to ProjectRepairWork/Forms/FormContractor.resx index 1af7de1..af32865 100644 --- a/ProjectRepairWork/Form1.resx +++ b/ProjectRepairWork/Forms/FormContractor.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectRepairWork/Forms/FormContractors.Designer.cs b/ProjectRepairWork/Forms/FormContractors.Designer.cs new file mode 100644 index 0000000..d1fc8f0 --- /dev/null +++ b/ProjectRepairWork/Forms/FormContractors.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormContractors + { + /// + /// 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() + { + dataGridView = new DataGridView(); + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // 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.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(771, 446); + dataGridView.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(771, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(167, 446); + panel1.TabIndex = 2; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.free_icon_font_cross; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(32, 252); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(105, 92); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.free_icon_font_pencil_3917376; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(32, 137); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(105, 92); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.free_icon_font_plus; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(32, 12); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(105, 92); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // FormContractors + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(938, 446); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormContractors"; + Text = "Подрядчики"; + Load += FormContractors_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormContractors.cs b/ProjectRepairWork/Forms/FormContractors.cs new file mode 100644 index 0000000..ec739c8 --- /dev/null +++ b/ProjectRepairWork/Forms/FormContractors.cs @@ -0,0 +1,107 @@ +using ProjectRepairWork.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ProjectRepairWork.Forms +{ + + public partial class FormContractors : Form + { + private readonly IUnityContainer _container; + private readonly IContractorsRepository _contractorsRepository; + public FormContractors(IUnityContainer container, IContractorsRepository premisesRepository) + { + InitializeComponent(); + + _container = container ?? throw new ArgumentNullException(nameof(container)); + _contractorsRepository = premisesRepository ?? throw new ArgumentNullException(nameof(premisesRepository)); + } + + private void FormContractors_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _contractorsRepository.DeletedContractors(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _contractorsRepository.ReadContractors(); + private bool TryGetIdentifierFromSelectedRow(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/ProjectRepairWork/Forms/FormContractors.resx b/ProjectRepairWork/Forms/FormContractors.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormContractors.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/ProjectRepairWork/Forms/FormCost.Designer.cs b/ProjectRepairWork/Forms/FormCost.Designer.cs new file mode 100644 index 0000000..7b78b2c --- /dev/null +++ b/ProjectRepairWork/Forms/FormCost.Designer.cs @@ -0,0 +1,98 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormCost + { + /// + /// 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() + { + ButtonCancel = new Button(); + ButtonSave = new Button(); + numericUpDownPrice = new NumericUpDown(); + PriceLabel = new Label(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + SuspendLayout(); + // + // ButtonCancel + // + ButtonCancel.Location = new Point(220, 211); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(170, 29); + ButtonCancel.TabIndex = 16; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // ButtonSave + // + ButtonSave.Location = new Point(18, 211); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(170, 29); + ButtonSave.TabIndex = 15; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // numericUpDownPrice + // + numericUpDownPrice.Location = new Point(180, 97); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(200, 27); + numericUpDownPrice.TabIndex = 14; + numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // PriceLabel + // + PriceLabel.AutoSize = true; + PriceLabel.Location = new Point(72, 104); + PriceLabel.Name = "PriceLabel"; + PriceLabel.Size = new Size(83, 20); + PriceLabel.TabIndex = 13; + PriceLabel.Text = "Стоимость"; + // + // FormCost + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(408, 259); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(numericUpDownPrice); + Controls.Add(PriceLabel); + Name = "FormCost"; + Text = "Затрата"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button ButtonCancel; + private Button ButtonSave; + private NumericUpDown numericUpDownPrice; + private Label PriceLabel; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormCost.cs b/ProjectRepairWork/Forms/FormCost.cs new file mode 100644 index 0000000..735b3aa --- /dev/null +++ b/ProjectRepairWork/Forms/FormCost.cs @@ -0,0 +1,82 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Entities; +using ProjectRepairWork.Repositories.Implementation; +using System.Windows.Forms; +using ProjectRepairWork.Entities.Enums; + +namespace ProjectRepairWork.Forms +{ + public partial class FormCost : Form + { + + private readonly ICostRepository _costRepository; + private int? _costId; + + public int Id + { + set + { + try + { + var premises = _costRepository.ReadCostById(value); + if (premises == null) + { + throw new InvalidDataException(nameof(premises)); + } + numericUpDownPrice.Value = (decimal)premises.Price; + _costId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormCost(ICostRepository costRepository) + { + InitializeComponent(); + _costRepository = costRepository ?? throw new ArgumentNullException(nameof(costRepository)); + + } + + + + + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (numericUpDownPrice.Value == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_costId.HasValue) + { + _costRepository.UpdateCost(CreateCost(_costId.Value)); + } + else + { + _costRepository.CreateCost(CreateCost(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + private Cost CreateCost(int id) => Cost.CreatEntity( + id, Convert.ToInt32(numericUpDownPrice.Value)); + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + + + } +} diff --git a/ProjectRepairWork/Forms/FormCost.resx b/ProjectRepairWork/Forms/FormCost.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormCost.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/ProjectRepairWork/Forms/FormCosts.Designer.cs b/ProjectRepairWork/Forms/FormCosts.Designer.cs new file mode 100644 index 0000000..7cf31ba --- /dev/null +++ b/ProjectRepairWork/Forms/FormCosts.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormCosts + { + /// + /// 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() + { + dataGridView = new DataGridView(); + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // 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.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(633, 450); + dataGridView.TabIndex = 5; + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(633, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(167, 450); + panel1.TabIndex = 4; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.free_icon_font_cross; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(32, 252); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(105, 92); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.free_icon_font_pencil_3917376; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(32, 137); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(105, 92); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.free_icon_font_plus; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(32, 12); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(105, 92); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // FormCosts + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormCosts"; + Text = "Затраты"; + Load += FormCosts_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormCosts.cs b/ProjectRepairWork/Forms/FormCosts.cs new file mode 100644 index 0000000..9bc3699 --- /dev/null +++ b/ProjectRepairWork/Forms/FormCosts.cs @@ -0,0 +1,107 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Repositories.Implementation; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ProjectRepairWork.Forms +{ + public partial class FormCosts : Form + { + private readonly IUnityContainer _container; + private readonly ICostRepository _costRepository; + public FormCosts(ICostRepository costRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _costRepository = costRepository ?? throw new ArgumentNullException(nameof(costRepository)); + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _costRepository.DeletedCost(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _costRepository.ReadCost(); + private bool TryGetIdentifierFromSelectedRow(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; + } + + private void FormCosts_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectRepairWork/Forms/FormCosts.resx b/ProjectRepairWork/Forms/FormCosts.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormCosts.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/ProjectRepairWork/Forms/FormPremise.Designer.cs b/ProjectRepairWork/Forms/FormPremise.Designer.cs new file mode 100644 index 0000000..51b78d1 --- /dev/null +++ b/ProjectRepairWork/Forms/FormPremise.Designer.cs @@ -0,0 +1,212 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormPremise + { + /// + /// 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() + { + ClientName = new Label(); + textBoxClientName = new TextBox(); + Address = new Label(); + textBoxAddress = new TextBox(); + Area = new Label(); + dateTimePickerStart = new DateTimePicker(); + dateTimePickerEnd = new DateTimePicker(); + numericUpDownArea = new NumericUpDown(); + DateStart = new Label(); + DateEnd = new Label(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + labelPremisesType = new Label(); + comboBoxPremisesType = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownArea).BeginInit(); + SuspendLayout(); + // + // ClientName + // + ClientName.AutoSize = true; + ClientName.Location = new Point(96, 30); + ClientName.Name = "ClientName"; + ClientName.Size = new Size(98, 20); + ClientName.TabIndex = 0; + ClientName.Text = "Имя клиента"; + // + // textBoxClientName + // + textBoxClientName.Location = new Point(200, 30); + textBoxClientName.Name = "textBoxClientName"; + textBoxClientName.Size = new Size(200, 27); + textBoxClientName.TabIndex = 1; + // + // Address + // + Address.AutoSize = true; + Address.Location = new Point(143, 76); + Address.Name = "Address"; + Address.Size = new Size(51, 20); + Address.TabIndex = 2; + Address.Text = "Адрес"; + // + // textBoxAddress + // + textBoxAddress.Location = new Point(200, 76); + textBoxAddress.Name = "textBoxAddress"; + textBoxAddress.Size = new Size(200, 27); + textBoxAddress.TabIndex = 3; + // + // Area + // + Area.AutoSize = true; + Area.Location = new Point(85, 130); + Area.Name = "Area"; + Area.Size = new Size(109, 20); + Area.TabIndex = 4; + Area.Text = "Площадь, кв.м"; + // + // dateTimePickerStart + // + dateTimePickerStart.Location = new Point(200, 217); + dateTimePickerStart.Name = "dateTimePickerStart"; + dateTimePickerStart.Size = new Size(200, 27); + dateTimePickerStart.TabIndex = 6; + // + // dateTimePickerEnd + // + dateTimePickerEnd.Location = new Point(200, 250); + dateTimePickerEnd.Name = "dateTimePickerEnd"; + dateTimePickerEnd.Size = new Size(200, 27); + dateTimePickerEnd.TabIndex = 7; + // + // numericUpDownArea + // + numericUpDownArea.DecimalPlaces = 2; + numericUpDownArea.Location = new Point(200, 123); + numericUpDownArea.Name = "numericUpDownArea"; + numericUpDownArea.Size = new Size(200, 27); + numericUpDownArea.TabIndex = 8; + numericUpDownArea.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // DateStart + // + DateStart.AutoSize = true; + DateStart.Location = new Point(55, 222); + DateStart.Name = "DateStart"; + DateStart.Size = new Size(139, 20); + DateStart.TabIndex = 9; + DateStart.Text = "Дата начала работ"; + // + // DateEnd + // + DateEnd.AutoSize = true; + DateEnd.Location = new Point(28, 255); + DateEnd.Name = "DateEnd"; + DateEnd.Size = new Size(166, 20); + DateEnd.TabIndex = 10; + DateEnd.Text = "Дата окончания работ"; + // + // ButtonSave + // + ButtonSave.Location = new Point(28, 316); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(170, 29); + ButtonSave.TabIndex = 11; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += Save_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(230, 316); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(170, 29); + ButtonCancel.TabIndex = 12; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += Cancel_Click; + // + // labelPremisesType + // + labelPremisesType.AutoSize = true; + labelPremisesType.Location = new Point(72, 174); + labelPremisesType.Name = "labelPremisesType"; + labelPremisesType.Size = new Size(122, 20); + labelPremisesType.TabIndex = 13; + labelPremisesType.Text = "Тип помещения"; + // + // comboBoxPremisesType + // + comboBoxPremisesType.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPremisesType.FormattingEnabled = true; + comboBoxPremisesType.Location = new Point(200, 171); + comboBoxPremisesType.Name = "comboBoxPremisesType"; + comboBoxPremisesType.Size = new Size(200, 28); + comboBoxPremisesType.TabIndex = 14; + // + // FormPremise + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(424, 376); + Controls.Add(comboBoxPremisesType); + Controls.Add(labelPremisesType); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(DateEnd); + Controls.Add(DateStart); + Controls.Add(numericUpDownArea); + Controls.Add(dateTimePickerEnd); + Controls.Add(dateTimePickerStart); + Controls.Add(Area); + Controls.Add(textBoxAddress); + Controls.Add(Address); + Controls.Add(textBoxClientName); + Controls.Add(ClientName); + Name = "FormPremise"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Помещение"; + ((System.ComponentModel.ISupportInitialize)numericUpDownArea).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label ClientName; + private TextBox textBoxClientName; + private Label Address; + private TextBox textBoxAddress; + private Label Area; + private DateTimePicker dateTimePickerStart; + private DateTimePicker dateTimePickerEnd; + private NumericUpDown numericUpDownArea; + private Label DateStart; + private Label DateEnd; + private Button ButtonSave; + private Button ButtonCancel; + private Label labelPremisesType; + private ComboBox comboBoxPremisesType; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormPremise.cs b/ProjectRepairWork/Forms/FormPremise.cs new file mode 100644 index 0000000..3be6dde --- /dev/null +++ b/ProjectRepairWork/Forms/FormPremise.cs @@ -0,0 +1,88 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Entities; +using ProjectRepairWork.Repositories.Implementation; +using System.Windows.Forms; +using ProjectRepairWork.Entities.Enums; + +namespace ProjectRepairWork.Forms +{ + public partial class FormPremise : Form + { + private readonly IPremisesRepository _premisesRepository; + private int? _premisesId; + + public int Id + { + set + { + try + { + var premises = _premisesRepository.ReadPremisesById(value); + if (premises == null) + { + throw new InvalidDataException(nameof(premises)); + } + textBoxClientName.Text = premises.ClientName; + textBoxAddress.Text = premises.Address; + numericUpDownArea.Value = (decimal)premises.Area; + dateTimePickerStart.Value = DateTime.Now; + dateTimePickerEnd.Value = DateTime.Now; + comboBoxPremisesType.SelectedItem = premises.PremisesType; + _premisesId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormPremise(IPremisesRepository premisesRepository) + { + InitializeComponent(); + _premisesRepository = premisesRepository ?? throw new ArgumentNullException(nameof(premisesRepository)); + + comboBoxPremisesType.DataSource = Enum.GetValues(typeof(PremisesType)); + } + + private void Save_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxClientName.Text) || + string.IsNullOrWhiteSpace(textBoxAddress.Text) || + comboBoxPremisesType.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_premisesId.HasValue) + { + _premisesRepository.UpdatePremises(CreatePremises(_premisesId.Value)); + } + else + { + _premisesRepository.CreatePremises(CreatePremises(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void Cancel_Click(object sender, EventArgs e) => Close(); + + private Premises CreatePremises(int id) => Premises.CreatEntity( + id, + textBoxClientName.Text, + textBoxAddress.Text, + Convert.ToInt32(numericUpDownArea.Value), + dateTimePickerStart.Value, dateTimePickerStart.Value, (PremisesType)comboBoxPremisesType.SelectedItem!); + + + } +} diff --git a/ProjectRepairWork/Forms/FormPremise.resx b/ProjectRepairWork/Forms/FormPremise.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormPremise.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/ProjectRepairWork/Forms/FormPremises.Designer.cs b/ProjectRepairWork/Forms/FormPremises.Designer.cs new file mode 100644 index 0000000..18868db --- /dev/null +++ b/ProjectRepairWork/Forms/FormPremises.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormPremises + { + /// + /// 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() + { + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(771, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(167, 446); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.free_icon_font_cross; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(32, 252); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(105, 92); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.free_icon_font_pencil_3917376; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(32, 137); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(105, 92); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.free_icon_font_plus; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(32, 12); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(105, 92); + 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.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(771, 446); + dataGridView.TabIndex = 1; + // + // FormPremises + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(938, 446); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormPremises"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Помещения"; + Load += FormPremises_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonAdd; + private DataGridView dataGridView; + private Button ButtonDel; + private Button ButtonUpd; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormPremises.cs b/ProjectRepairWork/Forms/FormPremises.cs new file mode 100644 index 0000000..b663ec9 --- /dev/null +++ b/ProjectRepairWork/Forms/FormPremises.cs @@ -0,0 +1,96 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Entities; +using Unity; + +namespace ProjectRepairWork.Forms +{ + public partial class FormPremises : Form + { + private readonly IUnityContainer _container; + private readonly IPremisesRepository _premisesRepository; + + public FormPremises(IUnityContainer container, IPremisesRepository premisesRepository) + { + InitializeComponent(); + + _container = container ?? throw new ArgumentNullException(nameof(container)); + _premisesRepository = premisesRepository ?? throw new ArgumentNullException(nameof(premisesRepository)); + } + + 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 FormPremises_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _premisesRepository.DeletePremises(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _premisesRepository.ReadPremises(); + private bool TryGetIdentifierFromSelectedRow(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/ProjectRepairWork/Forms/FormPremises.resx b/ProjectRepairWork/Forms/FormPremises.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormPremises.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/ProjectRepairWork/Forms/FormRepair.Designer.cs b/ProjectRepairWork/Forms/FormRepair.Designer.cs new file mode 100644 index 0000000..f157cfc --- /dev/null +++ b/ProjectRepairWork/Forms/FormRepair.Designer.cs @@ -0,0 +1,160 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormRepair + { + /// + /// 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() + { + comboBoxPremises = new ComboBox(); + comboBoxContractors = new ComboBox(); + ButtonCancel = new Button(); + ButtonSave = new Button(); + label2 = new Label(); + label1 = new Label(); + dataGridViewWorks = new DataGridView(); + ColumnWork = new DataGridViewComboBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridViewWorks).BeginInit(); + SuspendLayout(); + // + // comboBoxPremises + // + comboBoxPremises.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPremises.FormattingEnabled = true; + comboBoxPremises.Location = new Point(152, 72); + comboBoxPremises.Margin = new Padding(3, 4, 3, 4); + comboBoxPremises.Name = "comboBoxPremises"; + comboBoxPremises.Size = new Size(199, 28); + comboBoxPremises.TabIndex = 27; + // + // comboBoxContractors + // + comboBoxContractors.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxContractors.FormattingEnabled = true; + comboBoxContractors.Location = new Point(152, 28); + comboBoxContractors.Margin = new Padding(3, 4, 3, 4); + comboBoxContractors.Name = "comboBoxContractors"; + comboBoxContractors.Size = new Size(199, 28); + comboBoxContractors.TabIndex = 26; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(368, 418); + ButtonCancel.Margin = new Padding(3, 4, 3, 4); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(110, 31); + ButtonCancel.TabIndex = 25; + ButtonCancel.Text = "Отменить"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // ButtonSave + // + ButtonSave.Location = new Point(14, 418); + ButtonSave.Margin = new Padding(3, 4, 3, 4); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(110, 31); + ButtonSave.TabIndex = 24; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(29, 69); + label2.Name = "label2"; + label2.Size = new Size(94, 20); + label2.TabIndex = 19; + label2.Text = "Помещения"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(29, 28); + label1.Name = "label1"; + label1.Size = new Size(95, 20); + label1.TabIndex = 18; + label1.Text = "Подрядчики"; + // + // dataGridViewWorks + // + dataGridViewWorks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewWorks.Columns.AddRange(new DataGridViewColumn[] { ColumnWork, ColumnCount }); + dataGridViewWorks.Location = new Point(14, 212); + dataGridViewWorks.Name = "dataGridViewWorks"; + dataGridViewWorks.RowHeadersVisible = false; + dataGridViewWorks.RowHeadersWidth = 51; + dataGridViewWorks.Size = new Size(464, 188); + dataGridViewWorks.TabIndex = 30; + // + // ColumnWork + // + ColumnWork.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ColumnWork.HeaderText = "Вид Работы"; + ColumnWork.MinimumWidth = 6; + ColumnWork.Name = "ColumnWork"; + ColumnWork.Resizable = DataGridViewTriState.True; + ColumnWork.SortMode = DataGridViewColumnSortMode.Automatic; + // + // ColumnCount + // + ColumnCount.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + // + // FormRepair + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(490, 462); + Controls.Add(dataGridViewWorks); + Controls.Add(comboBoxPremises); + Controls.Add(comboBoxContractors); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormRepair"; + Text = "Ремонт"; + ((System.ComponentModel.ISupportInitialize)dataGridViewWorks).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private ComboBox comboBoxPremises; + private ComboBox comboBoxContractors; + private Button ButtonCancel; + private Button ButtonSave; + private Label label2; + private Label label1; + private DataGridView dataGridViewWorks; + private DataGridViewComboBoxColumn ColumnWork; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormRepair.cs b/ProjectRepairWork/Forms/FormRepair.cs new file mode 100644 index 0000000..bd8fe15 --- /dev/null +++ b/ProjectRepairWork/Forms/FormRepair.cs @@ -0,0 +1,78 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Entities; +using ProjectRepairWork.Repositories.Implementation; +using System.Windows.Forms; +using ProjectRepairWork.Entities.Enums; + +namespace ProjectRepairWork.Forms +{ + public partial class FormRepair : Form + { + private readonly IRepairRepository _repairRepository; + + public FormRepair(IRepairRepository repairRepository, IContractorsRepository contractorsRepository, ICostRepository costRepository, IPremisesRepository premisesRepository, IWorksRepository worksRepository) + { + InitializeComponent(); + _repairRepository = repairRepository ?? throw new ArgumentNullException(nameof(repairRepository)); + + + + comboBoxContractors.DataSource = contractorsRepository.ReadContractors(); + comboBoxContractors.DisplayMember = "CompanyName"; + comboBoxContractors.ValueMember = "Id"; + + comboBoxPremises.DataSource = premisesRepository.ReadPremises(); + comboBoxPremises.DisplayMember = "Name"; + comboBoxPremises.ValueMember = "Id"; + + ColumnWork.DataSource = worksRepository.ReadWorks(); + ColumnWork.DisplayMember = "Name"; + ColumnWork.ValueMember = "Id"; + + + + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewWorks.RowCount < 1|| comboBoxContractors.SelectedIndex < 0 || + comboBoxPremises.SelectedIndex < 0) + + { + throw new Exception("Имеются незаполненные поля"); + } + + _repairRepository.CraeteRepair(Repair.CreatOpertions(0, + (int)comboBoxContractors.SelectedValue!, + (int)comboBoxPremises.SelectedValue!, CreateRepairFromDataGrid())); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateRepairFromDataGrid() + { + var list = new List(); + foreach(DataGridViewRow row in dataGridViewWorks.Rows) + { + if (row.Cells["ColumnWork"].Value == null || + row.Cells["ColumnCount"].Value == null) + { + continue; + } + list.Add(RepairRepair.CreatElement(0, + Convert.ToInt32(row.Cells["ColumnWork"].Value), + Convert.ToInt32(row.Cells["ColumnCount"].Value))); + } + return list; + } + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormRepair.resx b/ProjectRepairWork/Forms/FormRepair.resx new file mode 100644 index 0000000..6c3a593 --- /dev/null +++ b/ProjectRepairWork/Forms/FormRepair.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/ProjectRepairWork/Forms/FormRepairs.Designer.cs b/ProjectRepairWork/Forms/FormRepairs.Designer.cs new file mode 100644 index 0000000..1f42dd5 --- /dev/null +++ b/ProjectRepairWork/Forms/FormRepairs.Designer.cs @@ -0,0 +1,97 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormRepairs + { + /// + /// 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() + { + dataGridView = new DataGridView(); + panel1 = new Panel(); + ButtonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // 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.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(633, 450); + dataGridView.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(633, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(167, 450); + panel1.TabIndex = 2; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.free_icon_font_plus; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(32, 12); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(105, 92); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // FormRepairs + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormRepairs"; + Text = "Ремонтные работы"; + Load += FormRepairs_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel1; + private Button ButtonAdd; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormRepairs.cs b/ProjectRepairWork/Forms/FormRepairs.cs new file mode 100644 index 0000000..5b9fca8 --- /dev/null +++ b/ProjectRepairWork/Forms/FormRepairs.cs @@ -0,0 +1,52 @@ +using ProjectRepairWork.Repositories; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectRepairWork.Forms +{ + public partial class FormRepairs : Form + { + private readonly IUnityContainer _container; + private readonly IRepairRepository _repairRepository; + public FormRepairs(IUnityContainer container, IRepairRepository repairRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _repairRepository = repairRepository ?? throw new ArgumentNullException(nameof(repairRepository)); + } + + private void FormRepairs_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _repairRepository.ReadRepair(); + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectRepairWork/Forms/FormRepairs.resx b/ProjectRepairWork/Forms/FormRepairs.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormRepairs.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/ProjectRepairWork/Forms/FormWork.Designer.cs b/ProjectRepairWork/Forms/FormWork.Designer.cs new file mode 100644 index 0000000..8921e5a --- /dev/null +++ b/ProjectRepairWork/Forms/FormWork.Designer.cs @@ -0,0 +1,117 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormWork + { + /// + /// 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() + { + labelMaterialsName = new Label(); + textBoxWorksName = new TextBox(); + WorksName = new Label(); + Cancel = new Button(); + Save = new Button(); + checkedListBoxMaterialsName = new CheckedListBox(); + SuspendLayout(); + // + // labelMaterialsName + // + labelMaterialsName.AutoSize = true; + labelMaterialsName.Location = new Point(103, 80); + labelMaterialsName.Name = "labelMaterialsName"; + labelMaterialsName.Size = new Size(89, 20); + labelMaterialsName.TabIndex = 17; + labelMaterialsName.Text = "Материалы"; + // + // textBoxWorksName + // + textBoxWorksName.Location = new Point(198, 26); + textBoxWorksName.Name = "textBoxWorksName"; + textBoxWorksName.Size = new Size(200, 27); + textBoxWorksName.TabIndex = 16; + // + // WorksName + // + WorksName.AutoSize = true; + WorksName.Location = new Point(22, 29); + WorksName.Name = "WorksName"; + WorksName.Size = new Size(170, 20); + WorksName.TabIndex = 15; + WorksName.Text = "Название вида работы"; + // + // Cancel + // + Cancel.Location = new Point(228, 233); + Cancel.Name = "Cancel"; + Cancel.Size = new Size(170, 30); + Cancel.TabIndex = 20; + Cancel.Text = "Отмена"; + Cancel.UseVisualStyleBackColor = true; + Cancel.Click += Cancel_Click; + // + // Save + // + Save.Location = new Point(22, 233); + Save.Name = "Save"; + Save.Size = new Size(170, 30); + Save.TabIndex = 19; + Save.Text = "Сохранить"; + Save.UseVisualStyleBackColor = true; + Save.Click += Save_Click; + // + // checkedListBoxMaterialsName + // + checkedListBoxMaterialsName.FormattingEnabled = true; + checkedListBoxMaterialsName.Location = new Point(202, 80); + checkedListBoxMaterialsName.Name = "checkedListBoxMaterialsName"; + checkedListBoxMaterialsName.Size = new Size(196, 114); + checkedListBoxMaterialsName.TabIndex = 21; + // + // FormWork + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(410, 288); + Controls.Add(checkedListBoxMaterialsName); + Controls.Add(Cancel); + Controls.Add(Save); + Controls.Add(labelMaterialsName); + Controls.Add(textBoxWorksName); + Controls.Add(WorksName); + Name = "FormWork"; + Text = "Работа"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Label labelMaterialsName; + private TextBox textBoxWorksName; + private Label WorksName; + private Button Cancel; + private Button Save; + private CheckedListBox checkedListBoxMaterialsName; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormWork.cs b/ProjectRepairWork/Forms/FormWork.cs new file mode 100644 index 0000000..5bfa6c2 --- /dev/null +++ b/ProjectRepairWork/Forms/FormWork.cs @@ -0,0 +1,95 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Entities; +using ProjectRepairWork.Repositories.Implementation; +using System.Windows.Forms; +using ProjectRepairWork.Entities.Enums; + +namespace ProjectRepairWork.Forms +{ + public partial class FormWork : Form + { + + + private readonly IWorksRepository _worksRepository; + private int? _worksId; + + public int Id + { + set + { + try + { + var works = _worksRepository.ReadWorksById(value); + if (works == null) + { + throw new InvalidDataException(nameof(works)); + } + foreach (MaterialsName elem in Enum.GetValues(typeof(MaterialsName))) + { + if ((elem & works.MaterialsName) != 0) + { + + checkedListBoxMaterialsName.SetItemChecked(checkedListBoxMaterialsName.Items.IndexOf(elem), true); + } + } + textBoxWorksName.Text = works.WorkName; + _worksId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormWork(IWorksRepository worksRepository) + { + InitializeComponent(); + _worksRepository = worksRepository ?? throw new ArgumentNullException(nameof(worksRepository)); + foreach(var elem in Enum.GetValues(typeof(MaterialsName))) + { + checkedListBoxMaterialsName.Items.Add(elem); + } + } + private void Save_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxWorksName.Text) || + checkedListBoxMaterialsName.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_worksId.HasValue) + { + _worksRepository.UpdateWorks(CreateWorks(_worksId.Value)); + } + else + { + _worksRepository.CreateWorks(CreateWorks(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void Cancel_Click(object sender, EventArgs e) => Close(); + + private Works CreateWorks(int id) + { + MaterialsName materialsName = MaterialsName.None; + foreach(var elem in checkedListBoxMaterialsName.CheckedItems) + { + materialsName |= (MaterialsName)elem; + } + + return Works.CreatEntity(id, textBoxWorksName.Text, materialsName); + } + + } +} diff --git a/ProjectRepairWork/Forms/FormWork.resx b/ProjectRepairWork/Forms/FormWork.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormWork.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/ProjectRepairWork/Forms/FormWorks.Designer.cs b/ProjectRepairWork/Forms/FormWorks.Designer.cs new file mode 100644 index 0000000..f058306 --- /dev/null +++ b/ProjectRepairWork/Forms/FormWorks.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectRepairWork.Forms +{ + partial class FormWorks + { + /// + /// 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() + { + dataGridView = new DataGridView(); + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // 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.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(771, 446); + dataGridView.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(771, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(167, 446); + panel1.TabIndex = 2; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.free_icon_font_cross; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(32, 252); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(105, 92); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.free_icon_font_pencil_3917376; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(32, 137); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(105, 92); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.free_icon_font_plus; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(32, 12); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(105, 92); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // FormWorks + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(938, 446); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormWorks"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Работы"; + Load += FormWorks_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + } +} \ No newline at end of file diff --git a/ProjectRepairWork/Forms/FormWorks.cs b/ProjectRepairWork/Forms/FormWorks.cs new file mode 100644 index 0000000..de7b8c3 --- /dev/null +++ b/ProjectRepairWork/Forms/FormWorks.cs @@ -0,0 +1,108 @@ +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Repositories.Implementation; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ProjectRepairWork.Forms +{ + public partial class FormWorks : Form + { + private readonly IUnityContainer _container; + private readonly IWorksRepository _worksRepository; + public FormWorks(IUnityContainer container, IWorksRepository worksRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _worksRepository = worksRepository ?? throw new ArgumentNullException(nameof(worksRepository)); + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _worksRepository.DeleteWorks(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + + } + + private void FormWorks_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _worksRepository.ReadWorks(); + private bool TryGetIdentifierFromSelectedRow(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/ProjectRepairWork/Forms/FormWorks.resx b/ProjectRepairWork/Forms/FormWorks.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectRepairWork/Forms/FormWorks.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/ProjectRepairWork/Program.cs b/ProjectRepairWork/Program.cs index c93e286..df37fa6 100644 --- a/ProjectRepairWork/Program.cs +++ b/ProjectRepairWork/Program.cs @@ -1,3 +1,7 @@ +using Unity; +using ProjectRepairWork.Repositories; +using ProjectRepairWork.Repositories.Implementation; +using Unity.Lifetime; namespace ProjectRepairWork { internal static class Program @@ -11,7 +15,18 @@ namespace ProjectRepairWork // 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(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + return container; + } + } } \ No newline at end of file diff --git a/ProjectRepairWork/ProjectRepairWork.csproj b/ProjectRepairWork/ProjectRepairWork.csproj index 663fdb8..accbdf0 100644 --- a/ProjectRepairWork/ProjectRepairWork.csproj +++ b/ProjectRepairWork/ProjectRepairWork.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectRepairWork/Properties/Resources.Designer.cs b/ProjectRepairWork/Properties/Resources.Designer.cs new file mode 100644 index 0000000..89ae8d3 --- /dev/null +++ b/ProjectRepairWork/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectRepairWork.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("ProjectRepairWork.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 free_icon_font_cross { + get { + object obj = ResourceManager.GetObject("free-icon-font-cross", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap free_icon_font_pencil_3917376 { + get { + object obj = ResourceManager.GetObject("free-icon-font-pencil-3917376", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap free_icon_font_plus { + get { + object obj = ResourceManager.GetObject("free-icon-font-plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap photo_2024_11_11_02_05_26 { + get { + object obj = ResourceManager.GetObject("photo_2024-11-11_02-05-26", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectRepairWork/Properties/Resources.resx b/ProjectRepairWork/Properties/Resources.resx new file mode 100644 index 0000000..69ea6f6 --- /dev/null +++ b/ProjectRepairWork/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\free-icon-font-plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\photo_2024-11-11_02-05-26.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\free-icon-font-cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\free-icon-font-pencil-3917376.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectRepairWork/Repositories/IContractorsRepository.cs b/ProjectRepairWork/Repositories/IContractorsRepository.cs new file mode 100644 index 0000000..fd8a0c3 --- /dev/null +++ b/ProjectRepairWork/Repositories/IContractorsRepository.cs @@ -0,0 +1,18 @@ +using ProjectRepairWork.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories; + +public interface IContractorsRepository +{ + IEnumerable ReadContractors(); + + Contractors ReadContractorsById(int id); + void CreateContractors(Contractors contractors); + void UpdateContractors(Contractors contractors); + void DeletedContractors(int id); +} diff --git a/ProjectRepairWork/Repositories/ICostRepository.cs b/ProjectRepairWork/Repositories/ICostRepository.cs new file mode 100644 index 0000000..b231ab8 --- /dev/null +++ b/ProjectRepairWork/Repositories/ICostRepository.cs @@ -0,0 +1,18 @@ +using ProjectRepairWork.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories; + +public interface ICostRepository +{ + IEnumerable ReadCost(); + + Cost ReadCostById(int id); + void CreateCost(Cost cost); + void UpdateCost(Cost cost); + void DeletedCost(int id); +} diff --git a/ProjectRepairWork/Repositories/IPremisesRepository.cs b/ProjectRepairWork/Repositories/IPremisesRepository.cs new file mode 100644 index 0000000..1ec29ca --- /dev/null +++ b/ProjectRepairWork/Repositories/IPremisesRepository.cs @@ -0,0 +1,18 @@ +using ProjectRepairWork.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories; + +public interface IPremisesRepository +{ + IEnumerable ReadPremises(); + + Premises ReadPremisesById(int id); + void CreatePremises(Premises premises); + void UpdatePremises(Premises premises); + void DeletePremises(int id); +} diff --git a/ProjectRepairWork/Repositories/IRepairRepository.cs b/ProjectRepairWork/Repositories/IRepairRepository.cs new file mode 100644 index 0000000..6b8e90c --- /dev/null +++ b/ProjectRepairWork/Repositories/IRepairRepository.cs @@ -0,0 +1,14 @@ +using ProjectRepairWork.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories; + +public interface IRepairRepository +{ + IEnumerable ReadRepair(int? contractorsId = null, int? costId = null, int? worksId = null, int? premisesId = null); + void CraeteRepair(Repair repair); +} diff --git a/ProjectRepairWork/Repositories/IWorksRepository.cs b/ProjectRepairWork/Repositories/IWorksRepository.cs new file mode 100644 index 0000000..09ae5da --- /dev/null +++ b/ProjectRepairWork/Repositories/IWorksRepository.cs @@ -0,0 +1,18 @@ +using ProjectRepairWork.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories; + +public interface IWorksRepository +{ + IEnumerable ReadWorks(); + + Works ReadWorksById(int id); + void CreateWorks(Works works); + void UpdateWorks(Works works); + void DeleteWorks(int id); +} diff --git a/ProjectRepairWork/Repositories/Implementation/ContractorsRepository.cs b/ProjectRepairWork/Repositories/Implementation/ContractorsRepository.cs new file mode 100644 index 0000000..c88b4dc --- /dev/null +++ b/ProjectRepairWork/Repositories/Implementation/ContractorsRepository.cs @@ -0,0 +1,37 @@ +using ProjectRepairWork.Entities; +using ProjectRepairWork.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories.Implementation; + +public class ContractorsRepository : IContractorsRepository +{ + public void CreateContractors(Contractors contractors) + { + + } + + public void DeletedContractors(int id) + { + + } + + public IEnumerable ReadContractors() + { + return []; + } + + public Contractors ReadContractorsById(int id) + { + return Contractors.CreatEntity(0, string.Empty, string.Empty); + } + + public void UpdateContractors(Contractors contractors) + { + + } +} diff --git a/ProjectRepairWork/Repositories/Implementation/CostRepository.cs b/ProjectRepairWork/Repositories/Implementation/CostRepository.cs new file mode 100644 index 0000000..517b326 --- /dev/null +++ b/ProjectRepairWork/Repositories/Implementation/CostRepository.cs @@ -0,0 +1,37 @@ +using ProjectRepairWork.Entities; +using ProjectRepairWork.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories.Implementation; + +public class CostRepository : ICostRepository +{ + public void CreateCost(Cost cost) + { + + } + + public void DeletedCost(int id) + { + + } + + public IEnumerable ReadCost() + { + return []; + } + + public Cost ReadCostById(int id) + { + return Cost.CreatEntity(0, 0); + } + + public void UpdateCost(Cost cost) + { + + } +} diff --git a/ProjectRepairWork/Repositories/Implementation/PremisesRepository.cs b/ProjectRepairWork/Repositories/Implementation/PremisesRepository.cs new file mode 100644 index 0000000..4a48547 --- /dev/null +++ b/ProjectRepairWork/Repositories/Implementation/PremisesRepository.cs @@ -0,0 +1,35 @@ +using ProjectRepairWork.Entities; +using ProjectRepairWork.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories.Implementation; +public class PremisesRepository : IPremisesRepository +{ + public void CreatePremises(Premises premises) + { + + } + + public void DeletePremises(int id) + { + } + + public IEnumerable ReadPremises() + { + return []; + } + + public Premises ReadPremisesById(int id) + { + return Premises.CreatEntity(0, string.Empty, string.Empty, 0, DateTime.Now, DateTime.Now, PremisesType.None); + } + + public void UpdatePremises(Premises premises) + { + + } +} diff --git a/ProjectRepairWork/Repositories/Implementation/RepairRepository.cs b/ProjectRepairWork/Repositories/Implementation/RepairRepository.cs new file mode 100644 index 0000000..a98f3ac --- /dev/null +++ b/ProjectRepairWork/Repositories/Implementation/RepairRepository.cs @@ -0,0 +1,21 @@ +using ProjectRepairWork.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories.Implementation; + +public class RepairRepository : IRepairRepository +{ + public void CraeteRepair(Repair repair) + { + + } + + public IEnumerable ReadRepair(int? contractorsId = null, int? costId = null, int? worksId = null, int? premisesId = null) + { + return[]; + } +} diff --git a/ProjectRepairWork/Repositories/Implementation/WorksRepository.cs b/ProjectRepairWork/Repositories/Implementation/WorksRepository.cs new file mode 100644 index 0000000..2857579 --- /dev/null +++ b/ProjectRepairWork/Repositories/Implementation/WorksRepository.cs @@ -0,0 +1,37 @@ +using ProjectRepairWork.Entities; +using ProjectRepairWork.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRepairWork.Repositories.Implementation; + +public class WorksRepository : IWorksRepository +{ + public void CreateWorks(Works works) + { + + } + + public void DeleteWorks(int id) + { + + } + + public IEnumerable ReadWorks() + { + return []; + } + + public Works ReadWorksById(int id) + { + return Works.CreatEntity(0,string.Empty, MaterialsName.None); + } + + public void UpdateWorks(Works works) + { + + } +} diff --git a/ProjectRepairWork/Resources/free-icon-font-cross.png b/ProjectRepairWork/Resources/free-icon-font-cross.png new file mode 100644 index 0000000..5fd3ba6 Binary files /dev/null and b/ProjectRepairWork/Resources/free-icon-font-cross.png differ diff --git a/ProjectRepairWork/Resources/free-icon-font-pencil-3917376.png b/ProjectRepairWork/Resources/free-icon-font-pencil-3917376.png new file mode 100644 index 0000000..c6d1713 Binary files /dev/null and b/ProjectRepairWork/Resources/free-icon-font-pencil-3917376.png differ diff --git a/ProjectRepairWork/Resources/free-icon-font-plus.png b/ProjectRepairWork/Resources/free-icon-font-plus.png new file mode 100644 index 0000000..3a5a0e6 Binary files /dev/null and b/ProjectRepairWork/Resources/free-icon-font-plus.png differ diff --git a/ProjectRepairWork/Resources/photo_2024-11-11_02-05-26.jpg b/ProjectRepairWork/Resources/photo_2024-11-11_02-05-26.jpg new file mode 100644 index 0000000..c5b6266 Binary files /dev/null and b/ProjectRepairWork/Resources/photo_2024-11-11_02-05-26.jpg differ