diff --git a/ProjectPublishing/ProjectPublishing/Entities/Client.cs b/ProjectPublishing/ProjectPublishing/Entities/Client.cs new file mode 100644 index 0000000..160c8b9 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/Client.cs @@ -0,0 +1,27 @@ +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities; + +public class Client +{ + public int ID { get; private set; } + public string Name { get; private set; } = string.Empty; + public string INN { get; private set; } = string.Empty; + public ClientType ClientType { get; private set; } + public static Client CreateEntity(int id, string name, string inn, ClientType clientType) + { + return new Client + { + ID = id, + Name = name, + INN = inn, + ClientType = clientType + }; + } +} + diff --git a/ProjectPublishing/ProjectPublishing/Entities/Contact.cs b/ProjectPublishing/ProjectPublishing/Entities/Contact.cs new file mode 100644 index 0000000..3afc19b --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/Contact.cs @@ -0,0 +1,28 @@ +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities; + +public class Contact +{ + public int ID { get; private set; } + public string Name { get; private set; } = string.Empty; + public string Phone { get; private set; } = string.Empty; + public string Email { get; private set; } = string.Empty; + public int ClientID { get; private set; } + public static Contact CreateEntity(int id, string name, string phone, string email, int clientID) + { + return new Contact + { + ID = id, + Name = name, + Phone = phone, + Email = email, + ClientID = clientID + }; + } +} diff --git a/ProjectPublishing/ProjectPublishing/Entities/Enums/ClientType.cs b/ProjectPublishing/ProjectPublishing/Entities/Enums/ClientType.cs new file mode 100644 index 0000000..0428965 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/Enums/ClientType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities.Enums; + +public enum ClientType +{ + None = 0, + Individual = 1, + Organization = 2 +} diff --git a/ProjectPublishing/ProjectPublishing/Entities/Enums/OrderType.cs b/ProjectPublishing/ProjectPublishing/Entities/Enums/OrderType.cs new file mode 100644 index 0000000..ba9ceeb --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/Enums/OrderType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities.Enums; +[Flags] +public enum OrderType +{ + None = 0, + Book = 1, + Brochure = 2, + Booklet = 4, + Newsletter = 8 +} diff --git a/ProjectPublishing/ProjectPublishing/Entities/Enums/ProductType.cs b/ProjectPublishing/ProjectPublishing/Entities/Enums/ProductType.cs new file mode 100644 index 0000000..2240860 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/Enums/ProductType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities.Enums; +[Flags] +public enum ProductType +{ + None = 0, + Book = 1, + Brochure = 2, + Booklet = 4, + Newsletter = 8 +} diff --git a/ProjectPublishing/ProjectPublishing/Entities/Order.cs b/ProjectPublishing/ProjectPublishing/Entities/Order.cs new file mode 100644 index 0000000..e33d67a --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/Order.cs @@ -0,0 +1,28 @@ +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities; + +public class Order +{ + public int ID { get; private set; } + public int ClientID { get; private set; } + public DateTime OrderDate { get; private set; } + public IEnumerable OrderProduct { get; private set; } = []; + public string Description { get; private set; } = string.Empty; + public static Order CreateOperation(int id, int clientID, IEnumerable orderProducts, string description) + { + return new Order + { + ID = id, + ClientID = clientID, + OrderDate = DateTime.Now, + OrderProduct = orderProducts, + Description = description + }; + } +} diff --git a/ProjectPublishing/ProjectPublishing/Entities/OrderProduct.cs b/ProjectPublishing/ProjectPublishing/Entities/OrderProduct.cs new file mode 100644 index 0000000..6506757 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/OrderProduct.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities; + +public class OrderProduct +{ + public int ID { get; private set; } + public int OrderID { get; private set; } + public int ProductID { get; private set; } + public int Count { get; private set; } + public static OrderProduct CreateElement(int id, int productId, int count) + { + return new OrderProduct + { + ID = id, + ProductID = productId, + Count = count + }; + } +} diff --git a/ProjectPublishing/ProjectPublishing/Entities/PrintingHouse.cs b/ProjectPublishing/ProjectPublishing/Entities/PrintingHouse.cs new file mode 100644 index 0000000..2849dd7 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/PrintingHouse.cs @@ -0,0 +1,28 @@ +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities; + +public class PrintingHouse +{ + public int ID { get; private set; } + public string Name { get; private set; } = string.Empty; + public string Description { get; private set; } = string.Empty; + public string Phone { get; private set; } = string.Empty; + public int OrderID { get; private set; } + public static PrintingHouse CreateOperation(int id, string name, string description, string phone, int orderID) + { + return new PrintingHouse + { + ID = id, + Name = name, + Description = description, + Phone = phone, + OrderID = orderID + }; + } +} diff --git a/ProjectPublishing/ProjectPublishing/Entities/Product.cs b/ProjectPublishing/ProjectPublishing/Entities/Product.cs new file mode 100644 index 0000000..cd02f94 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Entities/Product.cs @@ -0,0 +1,24 @@ +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Entities; + +public class Product +{ + public int ID { get; private set; } + public string Description; + public ProductType ProductType { get; private set; } + public static Product CreateEntity(int id, ProductType productType, string description) + { + return new Product + { + ID = id, + Description = description, + ProductType = productType, + }; + } +} diff --git a/ProjectPublishing/ProjectPublishing/Form1.Designer.cs b/ProjectPublishing/ProjectPublishing/Form1.Designer.cs deleted file mode 100644 index 3752acd..0000000 --- a/ProjectPublishing/ProjectPublishing/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectPublishing -{ - 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/ProjectPublishing/ProjectPublishing/Form1.cs b/ProjectPublishing/ProjectPublishing/Form1.cs deleted file mode 100644 index a88ef72..0000000 --- a/ProjectPublishing/ProjectPublishing/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectPublishing -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectPublishing/ProjectPublishing/FormPublishing.Designer.cs b/ProjectPublishing/ProjectPublishing/FormPublishing.Designer.cs new file mode 100644 index 0000000..55ed7b9 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/FormPublishing.Designer.cs @@ -0,0 +1,136 @@ +namespace ProjectPublishing +{ + partial class FormPublishing + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip1 = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + заказчикиToolStripMenuItem = new ToolStripMenuItem(); + контактыToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + заказыToolStripMenuItem = new ToolStripMenuItem(); + отчётыToolStripMenuItem = new ToolStripMenuItem(); + типографииToolStripMenuItem = new ToolStripMenuItem(); + продуктыToolStripMenuItem1 = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(678, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказчикиToolStripMenuItem, контактыToolStripMenuItem, продуктыToolStripMenuItem1 }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // заказчикиToolStripMenuItem + // + заказчикиToolStripMenuItem.Name = "заказчикиToolStripMenuItem"; + заказчикиToolStripMenuItem.Size = new Size(180, 22); + заказчикиToolStripMenuItem.Text = "Заказчики"; + заказчикиToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // контактыToolStripMenuItem + // + контактыToolStripMenuItem.Name = "контактыToolStripMenuItem"; + контактыToolStripMenuItem.Size = new Size(180, 22); + контактыToolStripMenuItem.Text = "Контакты"; + контактыToolStripMenuItem.Click += ContactsToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, типографииToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // заказыToolStripMenuItem + // + заказыToolStripMenuItem.Name = "заказыToolStripMenuItem"; + заказыToolStripMenuItem.Size = new Size(180, 22); + заказыToolStripMenuItem.Text = "Заказы"; + заказыToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // + // отчётыToolStripMenuItem + // + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(60, 20); + отчётыToolStripMenuItem.Text = "Отчёты"; + // + // типографииToolStripMenuItem + // + типографииToolStripMenuItem.Name = "типографииToolStripMenuItem"; + типографииToolStripMenuItem.Size = new Size(180, 22); + типографииToolStripMenuItem.Text = "Типографии"; + типографииToolStripMenuItem.Click += PrintingHousesToolStripMenuItem_Click; + // + // продуктыToolStripMenuItem1 + // + продуктыToolStripMenuItem1.Name = "продуктыToolStripMenuItem1"; + продуктыToolStripMenuItem1.Size = new Size(180, 22); + продуктыToolStripMenuItem1.Text = "Продукты"; + продуктыToolStripMenuItem1.Click += ProductsToolStripMenuItem_Click; + // + // FormPublishing + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.PrintingHouse; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(678, 374); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormPublishing"; + Text = "Form1"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem заказчикиToolStripMenuItem; + private ToolStripMenuItem контактыToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem заказыToolStripMenuItem; + private ToolStripMenuItem продуктыToolStripMenuItem1; + private ToolStripMenuItem типографииToolStripMenuItem; + } +} diff --git a/ProjectPublishing/ProjectPublishing/FormPublishing.cs b/ProjectPublishing/ProjectPublishing/FormPublishing.cs new file mode 100644 index 0000000..68d83a9 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/FormPublishing.cs @@ -0,0 +1,78 @@ +using ProjectPublishing.Forms; +using Unity; + +namespace ProjectPublishing +{ + public partial class FormPublishing : Form + { + private readonly IUnityContainer _container; + public FormPublishing(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + private void ClientsToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ContactsToolStripMenuItem_Click(object sender, EventArgs + e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ProductsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void PrintingHousesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void OrdersToolStripMenuItem_Click(object sender,EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectPublishing/ProjectPublishing/FormPublishing.resx b/ProjectPublishing/ProjectPublishing/FormPublishing.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/FormPublishing.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/ProjectPublishing/ProjectPublishing/Forms/FormClient.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormClient.Designer.cs new file mode 100644 index 0000000..6086596 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormClient.Designer.cs @@ -0,0 +1,142 @@ +namespace ProjectPublishing.Forms +{ + partial class FormClient + { + /// + /// 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() + { + labelOrderName = new Label(); + labelClientINN = new Label(); + labelClientType = new Label(); + textBoxClientName = new TextBox(); + textBoxClientINN = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + comboBoxClientType = new ComboBox(); + SuspendLayout(); + // + // labelOrderName + // + labelOrderName.AutoSize = true; + labelOrderName.Location = new Point(44, 45); + labelOrderName.Name = "labelOrderName"; + labelOrderName.Size = new Size(88, 15); + labelOrderName.TabIndex = 0; + labelOrderName.Text = "Имя заказчика"; + // + // labelClientINN + // + labelClientINN.AutoSize = true; + labelClientINN.Location = new Point(44, 94); + labelClientINN.Name = "labelClientINN"; + labelClientINN.Size = new Size(34, 15); + labelClientINN.TabIndex = 1; + labelClientINN.Text = "ИНН"; + // + // labelClientType + // + labelClientType.AutoSize = true; + labelClientType.Location = new Point(44, 142); + labelClientType.Name = "labelClientType"; + labelClientType.Size = new Size(84, 15); + labelClientType.TabIndex = 2; + labelClientType.Text = "Тип заказчика"; + // + // textBoxClientName + // + textBoxClientName.Location = new Point(138, 42); + textBoxClientName.Name = "textBoxClientName"; + textBoxClientName.Size = new Size(217, 23); + textBoxClientName.TabIndex = 3; + // + // textBoxClientINN + // + textBoxClientINN.Location = new Point(138, 91); + textBoxClientINN.Name = "textBoxClientINN"; + textBoxClientINN.Size = new Size(217, 23); + textBoxClientINN.TabIndex = 4; + // + // buttonSave + // + buttonSave.Location = new Point(57, 219); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(250, 219); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // comboBoxClientType + // + comboBoxClientType.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxClientType.FormattingEnabled = true; + comboBoxClientType.Location = new Point(138, 139); + comboBoxClientType.Name = "comboBoxClientType"; + comboBoxClientType.Size = new Size(217, 23); + comboBoxClientType.TabIndex = 8; + // + // FormClient + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(439, 289); + Controls.Add(comboBoxClientType); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxClientINN); + Controls.Add(textBoxClientName); + Controls.Add(labelClientType); + Controls.Add(labelClientINN); + Controls.Add(labelOrderName); + Name = "FormClient"; + StartPosition = FormStartPosition.CenterParent; + Text = "Заказчик"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelOrderName; + private Label labelClientINN; + private Label labelClientType; + private TextBox textBoxClientName; + private TextBox textBoxClientINN; + private Button buttonSave; + private Button buttonCancel; + private ComboBox comboBoxClientType; + } +} \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormClient.cs b/ProjectPublishing/ProjectPublishing/Forms/FormClient.cs new file mode 100644 index 0000000..e18bb37 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormClient.cs @@ -0,0 +1,78 @@ +using ProjectPublishing.Entities; +using ProjectPublishing.Entities.Enums; +using ProjectPublishing.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; + +namespace ProjectPublishing.Forms +{ + public partial class FormClient : Form + { + private readonly IClientRepository _clientRepository; + private int? _clientId; + public int Id + { + set + { + try + { + var client = _clientRepository.ReadClientById(value); + if (client == null) + { + throw new InvalidDataException(nameof(client)); + } + textBoxClientName.Text = client.Name; + textBoxClientINN.Text = client.INN; + + _clientId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormClient(IClientRepository clientRepository) + { + InitializeComponent(); + comboBoxClientType.DataSource = Enum.GetValues(typeof(ClientType)); + _clientRepository = clientRepository ?? + throw new ArgumentNullException(nameof(clientRepository)); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxClientName.Text) || string.IsNullOrWhiteSpace(textBoxClientINN.Text) || + string.IsNullOrWhiteSpace(comboBoxClientType.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_clientId.HasValue) + { + _clientRepository.UpdateClient(CreateClient(_clientId.Value)); + } + else + { + _clientRepository.CreateClient(CreateClient(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Client CreateClient(int id) => Client.CreateEntity(id, textBoxClientName.Text, textBoxClientINN.Text, (ClientType)comboBoxClientType.SelectedItem!); + } +} diff --git a/ProjectPublishing/ProjectPublishing/Form1.resx b/ProjectPublishing/ProjectPublishing/Forms/FormClient.resx similarity index 93% rename from ProjectPublishing/ProjectPublishing/Form1.resx rename to ProjectPublishing/ProjectPublishing/Forms/FormClient.resx index 1af7de1..af32865 100644 --- a/ProjectPublishing/ProjectPublishing/Form1.resx +++ b/ProjectPublishing/ProjectPublishing/Forms/FormClient.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormClients.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormClients.Designer.cs new file mode 100644 index 0000000..9db9cc2 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormClients.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectPublishing.Forms +{ + partial class FormClients + { + /// + /// 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(583, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(133, 378); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(36, 154); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(65, 65); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackColor = SystemColors.Window; + buttonUpd.BackgroundImage = Properties.Resources.Edit; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(36, 83); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(65, 65); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = false; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(36, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(65, 65); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(583, 378); + dataGridView.TabIndex = 1; + // + // FormClients + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(716, 378); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormClients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Заказчики"; + Load += FormClients_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormClients.cs b/ProjectPublishing/ProjectPublishing/Forms/FormClients.cs new file mode 100644 index 0000000..f69d2bf --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormClients.cs @@ -0,0 +1,112 @@ +using ProjectPublishing.Repositories; +using ProjectPublishing.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectPublishing.Forms +{ + public partial class FormClients : Form + { + private readonly IUnityContainer _container; + private readonly IClientRepository _clientRepository; + public FormClients(IUnityContainer container, IClientRepository clientRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _clientRepository = clientRepository ?? + throw new + ArgumentNullException(nameof(clientRepository)); + } + private void FormClients_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 + { + _clientRepository.DeleteClient(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _clientRepository.ReadClients(); + 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/ProjectPublishing/ProjectPublishing/Forms/FormClients.resx b/ProjectPublishing/ProjectPublishing/Forms/FormClients.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormClients.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/ProjectPublishing/ProjectPublishing/Forms/FormContact.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormContact.Designer.cs new file mode 100644 index 0000000..3d122f5 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormContact.Designer.cs @@ -0,0 +1,162 @@ +namespace ProjectPublishing.Forms +{ + partial class FormContact + { + /// + /// 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() + { + textBoxName = new TextBox(); + labelName = new Label(); + labelPhone = new Label(); + label3 = new Label(); + label4 = new Label(); + textBoxPhone = new TextBox(); + textBoxEmail = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + comboBoxClient = new ComboBox(); + SuspendLayout(); + // + // textBoxName + // + textBoxName.Location = new Point(157, 40); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(140, 23); + textBoxName.TabIndex = 0; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(41, 48); + labelName.Name = "labelName"; + labelName.Size = new Size(31, 15); + labelName.TabIndex = 1; + labelName.Text = "Имя"; + // + // labelPhone + // + labelPhone.AutoSize = true; + labelPhone.Location = new Point(41, 88); + labelPhone.Name = "labelPhone"; + labelPhone.Size = new Size(55, 15); + labelPhone.TabIndex = 2; + labelPhone.Text = "Телефон"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(41, 131); + label3.Name = "label3"; + label3.Size = new Size(41, 15); + label3.TabIndex = 3; + label3.Text = "Почта"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(41, 176); + label4.Name = "label4"; + label4.Size = new Size(57, 15); + label4.TabIndex = 4; + label4.Text = "Заказчик"; + // + // textBoxPhone + // + textBoxPhone.Location = new Point(157, 85); + textBoxPhone.Name = "textBoxPhone"; + textBoxPhone.Size = new Size(140, 23); + textBoxPhone.TabIndex = 5; + // + // textBoxEmail + // + textBoxEmail.Location = new Point(157, 128); + textBoxEmail.Name = "textBoxEmail"; + textBoxEmail.Size = new Size(140, 23); + textBoxEmail.TabIndex = 7; + // + // buttonSave + // + buttonSave.Location = new Point(41, 239); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(222, 239); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // comboBoxClient + // + comboBoxClient.FormattingEnabled = true; + comboBoxClient.Location = new Point(157, 173); + comboBoxClient.Name = "comboBoxClient"; + comboBoxClient.Size = new Size(140, 23); + comboBoxClient.TabIndex = 10; + // + // FormContact + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(431, 294); + Controls.Add(comboBoxClient); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxEmail); + Controls.Add(textBoxPhone); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(labelPhone); + Controls.Add(labelName); + Controls.Add(textBoxName); + Name = "FormContact"; + Text = "FormContact"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBoxName; + private Label labelName; + private Label labelPhone; + private Label label3; + private Label label4; + private TextBox textBoxPhone; + private TextBox textBoxEmail; + private Button buttonSave; + private Button buttonCancel; + private ComboBox comboBoxClient; + } +} \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormContact.cs b/ProjectPublishing/ProjectPublishing/Forms/FormContact.cs new file mode 100644 index 0000000..37f48b3 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormContact.cs @@ -0,0 +1,81 @@ +using ProjectPublishing.Entities; +using ProjectPublishing.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; + +namespace ProjectPublishing.Forms +{ + public partial class FormContact : Form + { + private readonly IContactRepository _contactRepository; + private int? _contactId; + public int Id + { + set + { + try + { + var contact = _contactRepository.ReadContactById(value); + if (contact == null) + { + throw new + InvalidDataException(nameof(contact)); + } + textBoxName.Text = contact.Name; + textBoxPhone.Text = contact.Phone; + textBoxEmail.Text = contact.Email; + comboBoxClient.Text = contact.ClientID.ToString(); + _contactId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormContact(IContactRepository contactRepository) + { + InitializeComponent(); + _contactRepository = contactRepository ?? + throw new ArgumentNullException(nameof(contactRepository)); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) + || + string.IsNullOrWhiteSpace(textBoxPhone.Text) || string.IsNullOrWhiteSpace(textBoxEmail.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_contactId.HasValue) + { + _contactRepository.UpdateContact(CreateContact(_contactId.Value)); + } + else + { + _contactRepository.CreateContact(CreateContact(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => + Close(); + private Contact CreateContact(int id) => Contact.CreateEntity(id, textBoxName.Text, + textBoxPhone.Text, textBoxEmail.Text, Convert.ToInt32(comboBoxClient)); + } +} diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormContact.resx b/ProjectPublishing/ProjectPublishing/Forms/FormContact.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormContact.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/ProjectPublishing/ProjectPublishing/Forms/FormContacts.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormContacts.Designer.cs new file mode 100644 index 0000000..ef7a4ca --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormContacts.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectPublishing.Forms +{ + partial class FormContacts + { + /// + /// 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.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(557, 343); + dataGridView.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(557, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(133, 343); + panel1.TabIndex = 2; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(35, 154); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(65, 65); + buttonDel.TabIndex = 5; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackColor = SystemColors.Window; + buttonUpd.BackgroundImage = Properties.Resources.Edit; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(35, 83); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(65, 65); + buttonUpd.TabIndex = 4; + buttonUpd.UseVisualStyleBackColor = false; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(35, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(65, 65); + buttonAdd.TabIndex = 3; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormContacts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(690, 343); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormContacts"; + Text = "FormContacts"; + Load += FormContacts_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/ProjectPublishing/ProjectPublishing/Forms/FormContacts.cs b/ProjectPublishing/ProjectPublishing/Forms/FormContacts.cs new file mode 100644 index 0000000..e679cab --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormContacts.cs @@ -0,0 +1,107 @@ +using ProjectPublishing.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 Unity; + +namespace ProjectPublishing.Forms +{ + public partial class FormContacts : Form + { + private readonly IUnityContainer _container; + private readonly IContactRepository _contactRepository; + public FormContacts(IUnityContainer container, IContactRepository + contactRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _contactRepository = contactRepository ?? throw new ArgumentNullException(nameof(contactRepository)); + } + private void FormContacts_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 + { + _contactRepository.DeleteContact(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _contactRepository.ReadContacts(); + 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/ProjectPublishing/ProjectPublishing/Forms/FormContacts.resx b/ProjectPublishing/ProjectPublishing/Forms/FormContacts.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormContacts.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/ProjectPublishing/ProjectPublishing/Forms/FormOrder.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormOrder.Designer.cs new file mode 100644 index 0000000..35f7719 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormOrder.Designer.cs @@ -0,0 +1,171 @@ +namespace ProjectPublishing.Forms +{ + partial class FormOrder + { + /// + /// 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() + { + groupBoxProduct = new GroupBox(); + dataGridViewProducts = new DataGridView(); + labelClient = new Label(); + comboBoxClient = new ComboBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxDescription = new TextBox(); + labelDescription = new Label(); + ColumnProduct = new DataGridViewComboBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + groupBoxProduct.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit(); + SuspendLayout(); + // + // groupBoxProduct + // + groupBoxProduct.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxProduct.Controls.Add(dataGridViewProducts); + groupBoxProduct.Location = new Point(42, 123); + groupBoxProduct.Name = "groupBoxProduct"; + groupBoxProduct.Size = new Size(277, 253); + groupBoxProduct.TabIndex = 0; + groupBoxProduct.TabStop = false; + groupBoxProduct.Text = "Продукты"; + // + // dataGridViewProducts + // + dataGridViewProducts.AllowUserToResizeColumns = false; + dataGridViewProducts.AllowUserToResizeRows = false; + dataGridViewProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnCount }); + dataGridViewProducts.Location = new Point(6, 22); + dataGridViewProducts.MultiSelect = false; + dataGridViewProducts.Name = "dataGridViewProducts"; + dataGridViewProducts.RowHeadersVisible = false; + dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewProducts.Size = new Size(265, 225); + dataGridViewProducts.TabIndex = 0; + // + // labelClient + // + labelClient.AutoSize = true; + labelClient.Location = new Point(48, 30); + labelClient.Name = "labelClient"; + labelClient.Size = new Size(57, 15); + labelClient.TabIndex = 1; + labelClient.Text = "Заказчик"; + // + // comboBoxClient + // + comboBoxClient.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + comboBoxClient.FormattingEnabled = true; + comboBoxClient.Location = new Point(144, 27); + comboBoxClient.Name = "comboBoxClient"; + comboBoxClient.Size = new Size(121, 23); + comboBoxClient.TabIndex = 2; + // + // buttonSave + // + buttonSave.Location = new Point(42, 391); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(244, 391); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(144, 82); + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(121, 23); + textBoxDescription.TabIndex = 5; + // + // labelDescription + // + labelDescription.AutoSize = true; + labelDescription.Location = new Point(48, 85); + labelDescription.Name = "labelDescription"; + labelDescription.Size = new Size(62, 15); + labelDescription.TabIndex = 6; + labelDescription.Text = "Описание"; + // + // ColumnProduct + // + ColumnProduct.HeaderText = "Продукт"; + ColumnProduct.Name = "ColumnProduct"; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.Name = "ColumnCount"; + // + // FormOrder + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(359, 426); + Controls.Add(labelDescription); + Controls.Add(textBoxDescription); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxClient); + Controls.Add(labelClient); + Controls.Add(groupBoxProduct); + Name = "FormOrder"; + Text = "FormOrder"; + groupBoxProduct.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Label label2; + private Button buttonSave; + private CheckedListBox checkedListBoxOrderType; + private GroupBox groupBoxProduct; + private Label labelClient; + private ComboBox comboBoxClient; + private DataGridView dataGridViewProducts; + private Button buttonCancel; + private TextBox textBoxDescription; + private Label labelDescription; + private DataGridViewComboBoxColumn ColumnProduct; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormOrder.cs b/ProjectPublishing/ProjectPublishing/Forms/FormOrder.cs new file mode 100644 index 0000000..ecf3f22 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormOrder.cs @@ -0,0 +1,71 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectPublishing.Entities; +using ProjectPublishing.Entities.Enums; +using ProjectPublishing.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; + +namespace ProjectPublishing.Forms +{ + public partial class FormOrder : Form + { + private readonly IOrderRepository _orderRepository; + public FormOrder(IOrderRepository orderRepository, IClientRepository clientRepository, IProductRepository productRepository) + { + InitializeComponent(); + + _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository)); + + comboBoxClient.DataSource = clientRepository.ReadClients(); + comboBoxClient.DisplayMember = "Client"; + comboBoxClient.ValueMember = "Id"; + + ColumnProduct.DataSource = productRepository.ReadProducts(); + ColumnProduct.DisplayMember = "ProductType"; + ColumnProduct.ValueMember = "Id"; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + _orderRepository.CreateOrder(Order.CreateOperation(0,(int)comboBoxClient.SelectedValue!, + CreateListOrderProdutsFromDataGrid(), textBoxDescription.Text)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private List + CreateListOrderProdutsFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewProducts.Rows) + { + if (row.Cells["ColumnProduct"].Value == null || + row.Cells["ColumnCount"].Value == null) + { + continue; + } + list.Add(OrderProduct.CreateElement(0, Convert.ToInt32(row.Cells["ColumnProduct"].Value), + Convert.ToInt32(row.Cells["ColumnCount"].Value))); + } + return list; + } + + } +} diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormOrder.resx b/ProjectPublishing/ProjectPublishing/Forms/FormOrder.resx new file mode 100644 index 0000000..260600d --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormOrder.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/ProjectPublishing/ProjectPublishing/Forms/FormOrders.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormOrders.Designer.cs new file mode 100644 index 0000000..7bd9c16 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormOrders.Designer.cs @@ -0,0 +1,111 @@ +namespace ProjectPublishing.Forms +{ + partial class FormOrders + { + /// + /// 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(); + 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.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(499, 338); + dataGridView.TabIndex = 5; + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(499, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(133, 338); + panel1.TabIndex = 4; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(35, 83); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(65, 65); + buttonDel.TabIndex = 5; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(35, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(65, 65); + buttonAdd.TabIndex = 3; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormOrders + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(632, 338); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormOrders"; + Text = "FormOrders"; + Load += FormOrders_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel1; + private Button buttonDel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormOrders.cs b/ProjectPublishing/ProjectPublishing/Forms/FormOrders.cs new file mode 100644 index 0000000..6049dbd --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormOrders.cs @@ -0,0 +1,91 @@ +using ProjectPublishing.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 Unity; + +namespace ProjectPublishing.Forms +{ + public partial class FormOrders : Form + { + private readonly IUnityContainer _container; + private readonly IOrderRepository _orderRepository; + public FormOrders(IUnityContainer container, + IOrderRepository orderRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _orderRepository = orderRepository ?? + throw new + ArgumentNullException(nameof(orderRepository)); + } + private void FormOrders_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _orderRepository.DeleteOrder(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrders(); + 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/ProjectPublishing/ProjectPublishing/Forms/FormOrders.resx b/ProjectPublishing/ProjectPublishing/Forms/FormOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormOrders.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/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.Designer.cs new file mode 100644 index 0000000..24f7830 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.Designer.cs @@ -0,0 +1,162 @@ +namespace ProjectPublishing.Forms +{ + partial class FormPrintingHouse + { + /// + /// 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() + { + textBoxDescription = new TextBox(); + label5 = new Label(); + textBoxName = new TextBox(); + label4 = new Label(); + buttonCancel = new Button(); + labelOrder = new Label(); + buttonSave = new Button(); + textBoxPhone = new TextBox(); + labelPhone = new Label(); + comboBoxOrder = new ComboBox(); + SuspendLayout(); + // + // textBoxDescription + // + textBoxDescription.Location = new Point(197, 146); + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(151, 23); + textBoxDescription.TabIndex = 22; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(39, 149); + label5.Name = "label5"; + label5.Size = new Size(62, 15); + label5.TabIndex = 21; + label5.Text = "Описание"; + // + // textBoxName + // + textBoxName.Location = new Point(197, 92); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(151, 23); + textBoxName.TabIndex = 20; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(39, 95); + label4.Name = "label4"; + label4.Size = new Size(59, 15); + label4.TabIndex = 19; + label4.Text = "Название"; + // + // buttonCancel + // + buttonCancel.Location = new Point(273, 277); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 16; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // labelOrder + // + labelOrder.AutoSize = true; + labelOrder.Location = new Point(39, 39); + labelOrder.Name = "labelOrder"; + labelOrder.Size = new Size(37, 15); + labelOrder.TabIndex = 15; + labelOrder.Text = "Заказ"; + // + // buttonSave + // + buttonSave.Location = new Point(39, 277); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 23; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // textBoxPhone + // + textBoxPhone.Location = new Point(197, 197); + textBoxPhone.Name = "textBoxPhone"; + textBoxPhone.Size = new Size(151, 23); + textBoxPhone.TabIndex = 24; + // + // labelPhone + // + labelPhone.AutoSize = true; + labelPhone.Location = new Point(39, 200); + labelPhone.Name = "labelPhone"; + labelPhone.Size = new Size(55, 15); + labelPhone.TabIndex = 25; + labelPhone.Text = "Телефон"; + // + // comboBoxOrder + // + comboBoxOrder.FormattingEnabled = true; + comboBoxOrder.Location = new Point(197, 36); + comboBoxOrder.Name = "comboBoxOrder"; + comboBoxOrder.Size = new Size(151, 23); + comboBoxOrder.TabIndex = 26; + // + // FormPrintingHouse + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(415, 345); + Controls.Add(comboBoxOrder); + Controls.Add(labelPhone); + Controls.Add(textBoxPhone); + Controls.Add(buttonSave); + Controls.Add(textBoxDescription); + Controls.Add(label5); + Controls.Add(textBoxName); + Controls.Add(label4); + Controls.Add(buttonCancel); + Controls.Add(labelOrder); + Name = "FormPrintingHouse"; + Text = "FormPrintingHouse"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBoxDescription; + private Label label5; + private TextBox textBoxName; + private Label label4; + private Button buttonCancel; + private Label labelOrder; + private Button buttonSave; + private TextBox textBoxPhone; + private Label labelPhone; + private ComboBox comboBoxOrder; + } +} \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.cs b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.cs new file mode 100644 index 0000000..11d1081 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.cs @@ -0,0 +1,50 @@ +using ProjectPublishing.Entities; +using ProjectPublishing.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; + +namespace ProjectPublishing.Forms +{ + public partial class FormPrintingHouse : Form + { + private readonly IPrintingHouseRepository _printingHouseRepository; + public FormPrintingHouse(IPrintingHouseRepository printingHouseRepository, + IOrderRepository orderRepository) + { + InitializeComponent(); + _printingHouseRepository = printingHouseRepository ?? + throw new ArgumentNullException(nameof(printingHouseRepository)); + comboBoxOrder.DataSource = orderRepository.ReadOrders(); + comboBoxOrder.DisplayMember = "Description"; + comboBoxOrder.ValueMember = "Id"; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxOrder.SelectedIndex < 0 || + string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxPhone.Text.ToString()) + || string.IsNullOrWhiteSpace(textBoxDescription.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + _printingHouseRepository.CreatePrintingHouse(PrintingHouse.CreateOperation(0, textBoxName.Text!, textBoxDescription.Text!, + textBoxPhone.Text!, (int)comboBoxOrder.SelectedValue!)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.resx b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouse.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/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.Designer.cs new file mode 100644 index 0000000..a1ccd92 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.Designer.cs @@ -0,0 +1,97 @@ +namespace ProjectPublishing.Forms +{ + partial class FormPrintingHouses + { + /// + /// 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.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(587, 356); + dataGridView.TabIndex = 7; + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(587, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(133, 356); + panel1.TabIndex = 6; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(35, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(65, 65); + buttonAdd.TabIndex = 3; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormPrintingHouses + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(720, 356); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormPrintingHouses"; + Text = "FormPrintingHouses"; + Load += FormPrintingHouses_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/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.cs b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.cs new file mode 100644 index 0000000..a38dde9 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.cs @@ -0,0 +1,56 @@ +using ProjectPublishing.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 Unity; + +namespace ProjectPublishing.Forms +{ + public partial class FormPrintingHouses : Form + { + private readonly IUnityContainer _container; + private readonly IPrintingHouseRepository _printingHouseRepository; + public FormPrintingHouses(IUnityContainer container, + IPrintingHouseRepository printingHouseRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _printingHouseRepository = printingHouseRepository ?? + throw new ArgumentNullException(nameof(printingHouseRepository)); + } + private void FormPrintingHouses_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = + _printingHouseRepository.ReadPrintingHouses(); + } +} diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.resx b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormPrintingHouses.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/ProjectPublishing/ProjectPublishing/Forms/FormProduct.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormProduct.Designer.cs new file mode 100644 index 0000000..936d64e --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormProduct.Designer.cs @@ -0,0 +1,118 @@ +namespace ProjectPublishing.Forms +{ + partial class FormProduct + { + /// + /// 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() + { + labelProductType = new Label(); + labelDescription = new Label(); + checkedListBoxProductType = new CheckedListBox(); + textBoxDescription = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelProductType + // + labelProductType.AutoSize = true; + labelProductType.Location = new Point(44, 39); + labelProductType.Name = "labelProductType"; + labelProductType.Size = new Size(80, 15); + labelProductType.TabIndex = 0; + labelProductType.Text = "Тип продукта"; + // + // labelDescription + // + labelDescription.AutoSize = true; + labelDescription.Location = new Point(44, 155); + labelDescription.Name = "labelDescription"; + labelDescription.Size = new Size(62, 15); + labelDescription.TabIndex = 1; + labelDescription.Text = "Описание"; + // + // checkedListBoxProductType + // + checkedListBoxProductType.FormattingEnabled = true; + checkedListBoxProductType.Location = new Point(186, 39); + checkedListBoxProductType.Name = "checkedListBoxProductType"; + checkedListBoxProductType.Size = new Size(120, 94); + checkedListBoxProductType.TabIndex = 2; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(186, 152); + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(120, 23); + textBoxDescription.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(44, 226); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(231, 226); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormProduct + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(353, 277); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxDescription); + Controls.Add(checkedListBoxProductType); + Controls.Add(labelDescription); + Controls.Add(labelProductType); + Name = "FormProduct"; + Text = "Продукт"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelProductType; + private Label labelDescription; + private CheckedListBox checkedListBoxProductType; + private TextBox textBoxDescription; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormProduct.cs b/ProjectPublishing/ProjectPublishing/Forms/FormProduct.cs new file mode 100644 index 0000000..2135c3c --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormProduct.cs @@ -0,0 +1,95 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectPublishing.Entities; +using ProjectPublishing.Entities.Enums; +using ProjectPublishing.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; + +namespace ProjectPublishing.Forms +{ + public partial class FormProduct : Form + { + private readonly IProductRepository _productRepository; + private int? _productId; + public int Id + { + set + { + try + { + var product = _productRepository.ReadProductById(value); + if (product == null) + { + throw new + InvalidDataException(nameof(product)); + } + foreach (ProductType elem in Enum.GetValues(typeof(ProductType))) + { + if ((elem & product.ProductType) != 0) + { + checkedListBoxProductType.SetItemChecked(checkedListBoxProductType.Items.IndexOf(elem), true); + } + } + textBoxDescription.Text = product.Description; + _productId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormProduct(IProductRepository productRepository) + { + InitializeComponent(); + _productRepository = productRepository ?? + throw new ArgumentNullException(nameof(productRepository)); + foreach (var elem in Enum.GetValues(typeof(ProductType))) + { + checkedListBoxProductType.Items.Add(elem); + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDescription.Text) || checkedListBoxProductType.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_productId.HasValue) + { + _productRepository.UpdateProduct(CreateProduct(_productId.Value)); + } + else + { + _productRepository.CreateProduct(CreateProduct(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Product CreateProduct(int id) + { + ProductType productType = ProductType.None; + foreach (var elem in checkedListBoxProductType.CheckedItems) + { + productType |= (ProductType)elem; + } + return Product.CreateEntity(id, productType, textBoxDescription.Text); + } + } +} diff --git a/ProjectPublishing/ProjectPublishing/Forms/FormProduct.resx b/ProjectPublishing/ProjectPublishing/Forms/FormProduct.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormProduct.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/ProjectPublishing/ProjectPublishing/Forms/FormProducts.Designer.cs b/ProjectPublishing/ProjectPublishing/Forms/FormProducts.Designer.cs new file mode 100644 index 0000000..1b9aaaf --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormProducts.Designer.cs @@ -0,0 +1,97 @@ +namespace ProjectPublishing.Forms +{ + partial class FormProducts + { + /// + /// 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.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(525, 343); + dataGridView.TabIndex = 7; + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(525, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(133, 343); + panel1.TabIndex = 6; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(35, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(65, 65); + buttonAdd.TabIndex = 3; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormProducts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(658, 343); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormProducts"; + Text = "FormProducts"; + Load += FormProducts_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/ProjectPublishing/ProjectPublishing/Forms/FormProducts.cs b/ProjectPublishing/ProjectPublishing/Forms/FormProducts.cs new file mode 100644 index 0000000..30c46c0 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormProducts.cs @@ -0,0 +1,109 @@ +using ProjectPublishing.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 Unity; + +namespace ProjectPublishing.Forms +{ + public partial class FormProducts : Form + { + private readonly IUnityContainer _container; + private readonly IProductRepository _productRepository; + public FormProducts(IUnityContainer container, IProductRepository + productRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _productRepository = productRepository ?? + throw new ArgumentNullException(nameof(productRepository)); + } + private void FormProducts_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 + { + _productRepository.DeleteProduct(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _productRepository.ReadProducts(); + 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/ProjectPublishing/ProjectPublishing/Forms/FormProducts.resx b/ProjectPublishing/ProjectPublishing/Forms/FormProducts.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Forms/FormProducts.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/ProjectPublishing/ProjectPublishing/Program.cs b/ProjectPublishing/ProjectPublishing/Program.cs index 10acd16..247a339 100644 --- a/ProjectPublishing/ProjectPublishing/Program.cs +++ b/ProjectPublishing/ProjectPublishing/Program.cs @@ -1,3 +1,7 @@ +using ProjectPublishing.Repositories; +using ProjectPublishing.Repositories.Implementations; +using Unity; + namespace ProjectPublishing { internal static class Program @@ -11,7 +15,17 @@ namespace ProjectPublishing // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve ()); + } + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + return container; } } } \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/ProjectPublishing.csproj b/ProjectPublishing/ProjectPublishing/ProjectPublishing.csproj index 663fdb8..accbdf0 100644 --- a/ProjectPublishing/ProjectPublishing/ProjectPublishing.csproj +++ b/ProjectPublishing/ProjectPublishing/ProjectPublishing.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Properties/Resources.Designer.cs b/ProjectPublishing/ProjectPublishing/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b8405ef --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectPublishing.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("ProjectPublishing.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Add { + get { + object obj = ResourceManager.GetObject("Add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Del { + get { + object obj = ResourceManager.GetObject("Del", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Edit { + get { + object obj = ResourceManager.GetObject("Edit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap PrintingHouse { + get { + object obj = ResourceManager.GetObject("PrintingHouse", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectPublishing/ProjectPublishing/Properties/Resources.resx b/ProjectPublishing/ProjectPublishing/Properties/Resources.resx new file mode 100644 index 0000000..f53fc3e --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/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\PrintingHouse.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectPublishing/ProjectPublishing/Repositories/IClientRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/IClientRepository.cs new file mode 100644 index 0000000..58a0108 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/IClientRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectPublishing.Entities; + +namespace ProjectPublishing.Repositories; + +public interface IClientRepository +{ + IEnumerable ReadClients(); + Client ReadClientById(int id); + void CreateClient(Client client); + void UpdateClient(Client client); + void DeleteClient(int id); +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/IContactRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/IContactRepository.cs new file mode 100644 index 0000000..978cbf5 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/IContactRepository.cs @@ -0,0 +1,17 @@ +using ProjectPublishing.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories; + +public interface IContactRepository +{ + IEnumerable ReadContacts(); + Contact ReadContactById(int id); + void CreateContact(Contact contact); + void UpdateContact(Contact contact); + void DeleteContact(int id); +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/IOrderRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/IOrderRepository.cs new file mode 100644 index 0000000..a608a1a --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/IOrderRepository.cs @@ -0,0 +1,18 @@ +using ProjectPublishing.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories; + +public interface IOrderRepository +{ + IEnumerable ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, + int? clientID = null, int? printingHouseID = null); + Order ReadOrderById(int id); + void CreateOrder(Order order); + void UpdateOrder(Order order); + void DeleteOrder(int id); +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/IPrintingHouseRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/IPrintingHouseRepository.cs new file mode 100644 index 0000000..1d04006 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/IPrintingHouseRepository.cs @@ -0,0 +1,17 @@ +using ProjectPublishing.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories; + +public interface IPrintingHouseRepository +{ + IEnumerable ReadPrintingHouses(); + PrintingHouse ReadPrintingHouseById(int id); + void CreatePrintingHouse(PrintingHouse printingHouse); + void UpdatePrintingHouse(PrintingHouse printingHouse); + void DeletePrintingHouse(int id); +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/IProductRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/IProductRepository.cs new file mode 100644 index 0000000..6f59363 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/IProductRepository.cs @@ -0,0 +1,17 @@ +using ProjectPublishing.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories; + +public interface IProductRepository +{ + IEnumerable ReadProducts(); + Product ReadProductById(int id); + void CreateProduct(Product product); + void UpdateProduct(Product product); + void DeleteProduct(int id); +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ClientRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ClientRepository.cs new file mode 100644 index 0000000..1c91089 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ClientRepository.cs @@ -0,0 +1,34 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectPublishing.Entities; +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories.Implementations; +public class ClientRepository : IClientRepository +{ + public void CreateClient(Client client) + { + } + + public void DeleteClient(int id) + { + } + + public Client ReadClientById(int id) + { + return Client.CreateEntity(0, string.Empty, string.Empty, ClientType.None); + } + + public IEnumerable ReadClients() + { + return []; + } + + public void UpdateClient(Client client) + { + } +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ContactRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ContactRepository.cs new file mode 100644 index 0000000..a3d4e4b --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ContactRepository.cs @@ -0,0 +1,34 @@ +using ProjectPublishing.Entities; +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories.Implementations; + +public class ContactRepository : IContactRepository +{ + public void CreateContact(Contact contact) + { + } + + public void DeleteContact(int id) + { + } + + public Contact ReadContactById(int id) + { + return Contact.CreateEntity(0, string.Empty, string.Empty, string.Empty, 0); + } + + public IEnumerable ReadContacts() + { + return []; + } + + public void UpdateContact(Contact contact) + { + } +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/Implementations/OrderRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/OrderRepository.cs new file mode 100644 index 0000000..af3ec41 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/OrderRepository.cs @@ -0,0 +1,35 @@ +using ProjectPublishing.Entities; +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories.Implementations; + +public class OrderRepository : IOrderRepository +{ + public void CreateOrder(Order order) + { + } + + public void DeleteOrder(int id) + { + } + + public Order ReadOrderById(int id) + { + return Order.CreateOperation(0, 0, [], string.Empty); + } + + public IEnumerable ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, + int? clientID = null, int? printingHouseID = null) + { + return []; + } + + public void UpdateOrder(Order order) + { + } +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/Implementations/PrintingHouseRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/PrintingHouseRepository.cs new file mode 100644 index 0000000..04a8d52 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/PrintingHouseRepository.cs @@ -0,0 +1,33 @@ +using ProjectPublishing.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories.Implementations; + +public class PrintingHouseRepository : IPrintingHouseRepository +{ + public void CreatePrintingHouse(PrintingHouse printingHouse) + { + } + + public void DeletePrintingHouse(int id) + { + } + + public PrintingHouse ReadPrintingHouseById(int id) + { + return PrintingHouse.CreateOperation(0,string.Empty, string.Empty, string.Empty, 0); + } + + public IEnumerable ReadPrintingHouses() + { + return []; + } + + public void UpdatePrintingHouse(PrintingHouse printingHouse) + { + } +} diff --git a/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ProductRepository.cs b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ProductRepository.cs new file mode 100644 index 0000000..7670172 --- /dev/null +++ b/ProjectPublishing/ProjectPublishing/Repositories/Implementations/ProductRepository.cs @@ -0,0 +1,34 @@ +using ProjectPublishing.Entities; +using ProjectPublishing.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPublishing.Repositories.Implementations; + +public class ProductRepository : IProductRepository +{ + public void CreateProduct(Product product) + { + } + + public void DeleteProduct(int id) + { + } + + public Product ReadProductById(int id) + { + return Product.CreateEntity(0,ProductType.None, string.Empty); + } + + public IEnumerable ReadProducts() + { + return []; + } + + public void UpdateProduct(Product product) + { + } +} diff --git a/ProjectPublishing/ProjectPublishing/Resources/Add.png b/ProjectPublishing/ProjectPublishing/Resources/Add.png new file mode 100644 index 0000000..5e8fca3 Binary files /dev/null and b/ProjectPublishing/ProjectPublishing/Resources/Add.png differ diff --git a/ProjectPublishing/ProjectPublishing/Resources/Del.png b/ProjectPublishing/ProjectPublishing/Resources/Del.png new file mode 100644 index 0000000..5b12c4d Binary files /dev/null and b/ProjectPublishing/ProjectPublishing/Resources/Del.png differ diff --git a/ProjectPublishing/ProjectPublishing/Resources/Edit.png b/ProjectPublishing/ProjectPublishing/Resources/Edit.png new file mode 100644 index 0000000..14175b5 Binary files /dev/null and b/ProjectPublishing/ProjectPublishing/Resources/Edit.png differ diff --git a/ProjectPublishing/ProjectPublishing/Resources/PrintingHouse.jpg b/ProjectPublishing/ProjectPublishing/Resources/PrintingHouse.jpg new file mode 100644 index 0000000..c442f65 Binary files /dev/null and b/ProjectPublishing/ProjectPublishing/Resources/PrintingHouse.jpg differ