diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Agent.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Agent.cs new file mode 100644 index 0000000..470a1c0 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Agent.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities.Enums; + +namespace TradeAndProcurementEnterprice.Entities; + +public class Agent +{ + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public Qualification Qualification { get; private set; } + + public Category Category { get; private set; } + + public static Agent CreateEntity(int id, string name, Qualification qualification, Category category) + { + return new Agent + { + Id = id, + Name = name ?? string.Empty, + Qualification = qualification, + Category = category + }; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Contract.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Contract.cs new file mode 100644 index 0000000..e6d4c35 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Contract.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TradeAndProcurementEnterprice.Entities; + +public class Contract +{ + public int ContractID { get; private set; } + + public DateTime SaleTime { get; private set; } + + public int PurchasingCompanyID { get; private set; } + + public int AgentsID { get; private set; } + + public IEnumerable ProductSales { get; private set; } = []; + + public static Contract CreateOperation(int contractID, int purchasingCompanyID, int agentsID, IEnumerable productSales) + { + return new Contract + { + ContractID = contractID, + SaleTime = DateTime.Now, + PurchasingCompanyID = purchasingCompanyID, + AgentsID = agentsID, + ProductSales = productSales + }; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/DelegateToAgents.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/DelegateToAgents.cs new file mode 100644 index 0000000..20562f9 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/DelegateToAgents.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TradeAndProcurementEnterprice.Entities; + +public class DelegateToAgents +{ + public int Id { get; private set; } + public int ProductArticle { get; private set; } + + public int AgentsID { get; private set; } + + public int Quantity { get; private set; } + + public DateTime Date { get; private set; } + + public static DelegateToAgents CreateOperation(int id, int productArticle, int agentsID, int quantity) + { + return new DelegateToAgents + { + Id = id, + ProductArticle = productArticle, + AgentsID = agentsID, + Date = DateTime.Now, + Quantity = quantity + }; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Category.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Category.cs new file mode 100644 index 0000000..3e3ffd0 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Category.cs @@ -0,0 +1,18 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TradeAndProcurementEnterprice.Entities.Enums; + +[Flags] +public enum Category +{ + None = 0, + Dairy = 1, + Groceries = 2, + Frozen = 4, + Other = 8 +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Qualification.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Qualification.cs new file mode 100644 index 0000000..74ab134 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Qualification.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TradeAndProcurementEnterprice.Entities.Enums; + +public enum Qualification +{ + None = 0, + Junior = 1, + Middle = 2, + Senior = 3 +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Unit.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Unit.cs new file mode 100644 index 0000000..ca16b6b --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Enums/Unit.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TradeAndProcurementEnterprice.Entities.Enums; + +public enum Unit +{ + Kilogram = 0, + Piece = 1, + Liter = 2 +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Product.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Product.cs new file mode 100644 index 0000000..95a080f --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/Product.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities.Enums; + +namespace TradeAndProcurementEnterprice.Entities; + +public class Product +{ + public int Article { get; private set; } + + public string Nomenclature { get; private set; } = string.Empty; + + public decimal SellingPrice { get; private set; } + + public Unit Unit { get; private set; } + + public Category Category { get; private set; } + + public int InventoryQuantity { get; private set; } + + public static Product CreateEntity(int article, string nomenclature, decimal sellingPrice, Unit unit, + Category category, int inventoryQuantity) + { + return new Product + { + Article = article, + Nomenclature = nomenclature ?? string.Empty, + SellingPrice = sellingPrice, + Unit = unit, + Category = category, + InventoryQuantity = inventoryQuantity + }; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/ProductSales.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/ProductSales.cs new file mode 100644 index 0000000..57e432c --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/ProductSales.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TradeAndProcurementEnterprice.Entities; + +public class ProductSales +{ + public int Id { get; private set; } + + public int ProductArticle { get; private set; } + + public int ProductQuantity { get; private set; } + + public static ProductSales CreateElement(int id, int prodictArticle, int productQuantity) + { + return new ProductSales + { + Id = id, + ProductArticle = prodictArticle, + ProductQuantity = productQuantity + }; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/PurchasingCompany.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/PurchasingCompany.cs new file mode 100644 index 0000000..cf203e5 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Entities/PurchasingCompany.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TradeAndProcurementEnterprice.Entities; + +public class PurchasingCompany +{ + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public static PurchasingCompany CreateEntity(int id, string name) + { + return new PurchasingCompany + { + Id = id, + Name = name + }; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.Designer.cs deleted file mode 100644 index 53a1524..0000000 --- a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace TradeAndProcurementEnterprice -{ - 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 - } -} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.cs deleted file mode 100644 index c7e4439..0000000 --- a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TradeAndProcurementEnterprice -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.Designer.cs new file mode 100644 index 0000000..2eb19f2 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.Designer.cs @@ -0,0 +1,140 @@ +namespace TradeAndProcurementEnterprice +{ + partial class FormEnterprice + { + /// + /// 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(); + catalogToolStripMenuItem = new ToolStripMenuItem(); + agentsToolStripMenuItem = new ToolStripMenuItem(); + nomenclatureToolStripMenuItem = new ToolStripMenuItem(); + purchasingCompanyToolStripMenuItem = new ToolStripMenuItem(); + operationToolStripMenuItem = new ToolStripMenuItem(); + contractsToolStripMenuItem1 = new ToolStripMenuItem(); + delegateToAgentsToolStripMenuItem = new ToolStripMenuItem(); + reportToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.ImageScalingSize = new Size(32, 32); + menuStrip1.Items.AddRange(new ToolStripItem[] { catalogToolStripMenuItem, operationToolStripMenuItem, reportToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Padding = new Padding(3, 1, 0, 1); + menuStrip1.Size = new Size(650, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // catalogToolStripMenuItem + // + catalogToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { agentsToolStripMenuItem, nomenclatureToolStripMenuItem, purchasingCompanyToolStripMenuItem }); + catalogToolStripMenuItem.Name = "catalogToolStripMenuItem"; + catalogToolStripMenuItem.Size = new Size(94, 22); + catalogToolStripMenuItem.Text = "Справочники"; + // + // agentsToolStripMenuItem + // + agentsToolStripMenuItem.Name = "agentsToolStripMenuItem"; + agentsToolStripMenuItem.Size = new Size(195, 22); + agentsToolStripMenuItem.Text = "Агенты-реализаторы"; + agentsToolStripMenuItem.Click += AgentsToolStripMenuItem_Click; + // + // nomenclatureToolStripMenuItem + // + nomenclatureToolStripMenuItem.Name = "nomenclatureToolStripMenuItem"; + nomenclatureToolStripMenuItem.Size = new Size(195, 22); + nomenclatureToolStripMenuItem.Text = "Номенклатура"; + nomenclatureToolStripMenuItem.Click += NomenclatureToolStripMenuItem_Click; + // + // purchasingCompanyToolStripMenuItem + // + purchasingCompanyToolStripMenuItem.Name = "purchasingCompanyToolStripMenuItem"; + purchasingCompanyToolStripMenuItem.Size = new Size(195, 22); + purchasingCompanyToolStripMenuItem.Text = "Компании закупщики"; + purchasingCompanyToolStripMenuItem.Click += PurchasingCompanyToolStripMenuItem_Click; + // + // operationToolStripMenuItem + // + operationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { contractsToolStripMenuItem1, delegateToAgentsToolStripMenuItem }); + operationToolStripMenuItem.Name = "operationToolStripMenuItem"; + operationToolStripMenuItem.Size = new Size(75, 22); + operationToolStripMenuItem.Text = "Операции"; + // + // contractsToolStripMenuItem1 + // + contractsToolStripMenuItem1.Name = "contractsToolStripMenuItem1"; + contractsToolStripMenuItem1.Size = new Size(174, 22); + contractsToolStripMenuItem1.Text = "Продажи"; + contractsToolStripMenuItem1.Click += ContractsToolStripMenuItem1_Click; + // + // delegateToAgentsToolStripMenuItem + // + delegateToAgentsToolStripMenuItem.Name = "delegateToAgentsToolStripMenuItem"; + delegateToAgentsToolStripMenuItem.Size = new Size(174, 22); + delegateToAgentsToolStripMenuItem.Text = "Передача агентам"; + delegateToAgentsToolStripMenuItem.Click += DelegateToAgentsToolStripMenuItem_Click; + // + // reportToolStripMenuItem + // + reportToolStripMenuItem.Name = "reportToolStripMenuItem"; + reportToolStripMenuItem.Size = new Size(60, 22); + reportToolStripMenuItem.Text = "Отчёты"; + // + // FormEnterprice + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.photo_2024_12_03_21_34_38; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(650, 339); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Margin = new Padding(2, 1, 2, 1); + Name = "FormEnterprice"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Торгово закупочное предприятие"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem catalogToolStripMenuItem; + private ToolStripMenuItem agentsToolStripMenuItem; + private ToolStripMenuItem nomenclatureToolStripMenuItem; + private ToolStripMenuItem operationToolStripMenuItem; + private ToolStripMenuItem reportToolStripMenuItem; + private ToolStripMenuItem purchasingCompanyToolStripMenuItem; + private ToolStripMenuItem contractsToolStripMenuItem1; + private ToolStripMenuItem delegateToAgentsToolStripMenuItem; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.cs new file mode 100644 index 0000000..3a814c3 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.cs @@ -0,0 +1,82 @@ +using TradeAndProcurementEnterprice.Forms; +using Unity; + +namespace TradeAndProcurementEnterprice +{ + public partial class FormEnterprice : Form + { + private readonly IUnityContainer _container; + + public FormEnterprice(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + + private void AgentsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " !", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void NomenclatureToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " !", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void PurchasingCompanyToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " !", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ContractsToolStripMenuItem1_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " !", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void DelegateToAgentsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " !", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormEnterprice_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.resx new file mode 100644 index 0000000..b48baf1 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/FormEnterprice.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.Designer.cs new file mode 100644 index 0000000..6ca1722 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.Designer.cs @@ -0,0 +1,158 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormAgent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCancel = new Button(); + buttonSave = new Button(); + comboBoxQualification = new ComboBox(); + textBoxName = new TextBox(); + labelCategory = new Label(); + labelQualification = new Label(); + labelName = new Label(); + checkedListBoxCategory = new CheckedListBox(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(280, 412); + buttonCancel.Margin = new Padding(6, 6, 6, 6); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(156, 49); + buttonCancel.TabIndex = 16; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(80, 412); + buttonSave.Margin = new Padding(6, 6, 6, 6); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(156, 49); + buttonSave.TabIndex = 17; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // comboBoxQualification + // + comboBoxQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxQualification.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxQualification.FormattingEnabled = true; + comboBoxQualification.Location = new Point(217, 124); + comboBoxQualification.Margin = new Padding(6, 6, 6, 6); + comboBoxQualification.Name = "comboBoxQualification"; + comboBoxQualification.Size = new Size(273, 40); + comboBoxQualification.TabIndex = 14; + // + // textBoxName + // + textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxName.Location = new Point(217, 38); + textBoxName.Margin = new Padding(6, 6, 6, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(273, 39); + textBoxName.TabIndex = 11; + // + // labelCategory + // + labelCategory.AutoSize = true; + labelCategory.Location = new Point(39, 220); + labelCategory.Margin = new Padding(6, 0, 6, 0); + labelCategory.Name = "labelCategory"; + labelCategory.Size = new Size(126, 32); + labelCategory.TabIndex = 7; + labelCategory.Text = "Категория"; + // + // labelQualification + // + labelQualification.AutoSize = true; + labelQualification.Location = new Point(43, 130); + labelQualification.Margin = new Padding(6, 0, 6, 0); + labelQualification.Name = "labelQualification"; + labelQualification.Size = new Size(174, 32); + labelQualification.TabIndex = 8; + labelQualification.Text = "Квалификация"; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(39, 53); + labelName.Margin = new Padding(6, 0, 6, 0); + labelName.Name = "labelName"; + labelName.Size = new Size(67, 32); + labelName.TabIndex = 10; + labelName.Text = "ФИО"; + // + // checkedListBoxCategory + // + checkedListBoxCategory.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + checkedListBoxCategory.FormattingEnabled = true; + checkedListBoxCategory.Location = new Point(217, 211); + checkedListBoxCategory.Margin = new Padding(6, 6, 6, 6); + checkedListBoxCategory.Name = "checkedListBoxCategory"; + checkedListBoxCategory.Size = new Size(273, 148); + checkedListBoxCategory.TabIndex = 18; + // + // FormAgent + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(549, 504); + Controls.Add(checkedListBoxCategory); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxQualification); + Controls.Add(textBoxName); + Controls.Add(labelCategory); + Controls.Add(labelQualification); + Controls.Add(labelName); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(575, 575); + Name = "FormAgent"; + StartPosition = FormStartPosition.CenterParent; + Text = "Агент-реализатор"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private ComboBox comboBoxQualification; + private TextBox textBoxName; + private Label labelCategory; + private Label labelQualification; + private Label labelName; + private CheckedListBox checkedListBoxCategory; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.cs new file mode 100644 index 0000000..8b2d9c7 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.cs @@ -0,0 +1,108 @@ +using Microsoft.VisualBasic.FileIO; +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 TradeAndProcurementEnterprice.Entities; +using TradeAndProcurementEnterprice.Entities.Enums; +using TradeAndProcurementEnterprice.Repositories; + +namespace TradeAndProcurementEnterprice.Forms +{ + + public partial class FormAgent : Form + { + + private readonly IAgentsRepository _agentsRepository; + + private int? _agentsId; + + public int Id + { + set + { + try + { + var agent = _agentsRepository.ReadAgentByID(value); + if (agent == null) + { + throw new InvalidDataException(nameof(agent)); + } + + textBoxName.Text = agent.Name; + comboBoxQualification.SelectedItem = agent.Qualification; foreach (Category elem in Enum.GetValues(typeof(Category))) + { + if ((elem & agent.Category) != 0) + { + checkedListBoxCategory.SetItemChecked(checkedListBoxCategory.Items.IndexOf(elem), true); + } + } + _agentsId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных!", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormAgent(IAgentsRepository agentsRepository) + { + InitializeComponent(); + _agentsRepository = agentsRepository ?? + throw new ArgumentNullException(nameof(agentsRepository)); + + comboBoxQualification.DataSource = Enum.GetValues(typeof(Qualification)); + + foreach (var elem in Enum.GetValues(typeof(Category))) + { + checkedListBoxCategory.Items.Add(elem); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || checkedListBoxCategory.CheckedItems.Count == 0 || comboBoxQualification.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля!"); + } + + if (_agentsId.HasValue) + { + _agentsRepository.UpdateAgent(CreateAgent(_agentsId.Value)); + } + else + { + _agentsRepository.CreateAgent(CreateAgent(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Agent CreateAgent(int id) + { + Category category = Category.None; + foreach (var elem in checkedListBoxCategory.CheckedItems) + { + category |= (Category)elem; + } + + return Agent.CreateEntity(id, textBoxName.Text, (Qualification)comboBoxQualification.SelectedItem, + category); + } + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.resx similarity index 92% rename from TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.resx rename to TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.resx index 1af7de1..8b2ff64 100644 --- a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Form1.resx +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgent.resx @@ -1,17 +1,17 @@  - diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.Designer.cs new file mode 100644 index 0000000..2cc2a35 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.Designer.cs @@ -0,0 +1,134 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormAgents + { + /// + /// 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(); + buttonEdit = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonEdit); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(1196, 0); + panel1.Margin = new Padding(6, 6, 6, 6); + panel1.Name = "panel1"; + panel1.Size = new Size(178, 929); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.remove; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(32, 390); + buttonDel.Margin = new Padding(6, 6, 6, 6); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(121, 139); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonEdit + // + buttonEdit.BackgroundImage = Properties.Resources.edit; + buttonEdit.BackgroundImageLayout = ImageLayout.Stretch; + buttonEdit.Location = new Point(32, 203); + buttonEdit.Margin = new Padding(6, 6, 6, 6); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(121, 139); + buttonEdit.TabIndex = 2; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += ButtonEdit_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(32, 26); + buttonAdd.Margin = new Padding(6, 6, 6, 6); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(121, 139); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.Margin = new Padding(6, 6, 6, 6); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 82; + dataGridViewData.RowTemplate.Height = 25; + dataGridViewData.Size = new Size(1196, 929); + dataGridViewData.TabIndex = 1; + // + // FormAgents + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1374, 929); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(1000, 630); + Name = "FormAgents"; + StartPosition = FormStartPosition.CenterParent; + Text = "Агенты-реализаторы"; + Load += FormAgents_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private Button buttonDel; + private Button buttonEdit; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.cs new file mode 100644 index 0000000..4effb14 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using TradeAndProcurementEnterprice.Repositories; +using TradeAndProcurementEnterprice.Repositories.Implementations; +using Unity; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormAgents : Form + { + private readonly IUnityContainer _container; + + private readonly IAgentsRepository _agentsRepository; + + public FormAgents(IUnityContainer container, IAgentsRepository agentsRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _agentsRepository = agentsRepository ?? + throw new ArgumentNullException(nameof(agentsRepository)); + } + + private void FormAgents_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 ButtonEdit_Click(object sender, EventArgs e) + { + if (!TryGetIdFromSelectedRow(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 (!TryGetIdFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _agentsRepository.DeleteAgent(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _agentsRepository.ReadAgents(); + + private bool TryGetIdFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormAgents.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.Designer.cs new file mode 100644 index 0000000..2daca3b --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.Designer.cs @@ -0,0 +1,189 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormContract + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCancel = new Button(); + buttonSave = new Button(); + comboBoxPurchasingCompany = new ComboBox(); + comboBoxAgent = new ComboBox(); + labelAgent = new Label(); + labelPurchatingCompany = new Label(); + groupBox1 = new GroupBox(); + dataGridViewProduct = new DataGridView(); + ColumnProduct = new DataGridViewComboBoxColumn(); + ColumnQuantity = new DataGridViewTextBoxColumn(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).BeginInit(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(292, 653); + buttonCancel.Margin = new Padding(6); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(156, 49); + buttonCancel.TabIndex = 32; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(50, 653); + buttonSave.Margin = new Padding(6); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(156, 49); + buttonSave.TabIndex = 33; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // comboBoxPurchasingCompany + // + comboBoxPurchasingCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxPurchasingCompany.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPurchasingCompany.FormattingEnabled = true; + comboBoxPurchasingCompany.Location = new Point(221, 34); + comboBoxPurchasingCompany.Margin = new Padding(6); + comboBoxPurchasingCompany.Name = "comboBoxPurchasingCompany"; + comboBoxPurchasingCompany.Size = new Size(241, 40); + comboBoxPurchasingCompany.TabIndex = 29; + // + // comboBoxAgent + // + comboBoxAgent.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxAgent.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxAgent.FormattingEnabled = true; + comboBoxAgent.Location = new Point(221, 126); + comboBoxAgent.Margin = new Padding(6); + comboBoxAgent.Name = "comboBoxAgent"; + comboBoxAgent.Size = new Size(241, 40); + comboBoxAgent.TabIndex = 30; + // + // labelAgent + // + labelAgent.Location = new Point(39, 111); + labelAgent.Margin = new Padding(6, 0, 6, 0); + labelAgent.Name = "labelAgent"; + labelAgent.Size = new Size(167, 77); + labelAgent.TabIndex = 27; + labelAgent.Text = "Агент-\r\nреализатор"; + // + // labelPurchatingCompany + // + labelPurchatingCompany.Location = new Point(43, 23); + labelPurchatingCompany.Margin = new Padding(6, 0, 6, 0); + labelPurchatingCompany.Name = "labelPurchatingCompany"; + labelPurchatingCompany.Size = new Size(163, 68); + labelPurchatingCompany.TabIndex = 28; + labelPurchatingCompany.Text = "Компания закупщик"; + // + // groupBox1 + // + groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox1.Controls.Add(dataGridViewProduct); + groupBox1.Location = new Point(43, 218); + groupBox1.Margin = new Padding(6); + groupBox1.Name = "groupBox1"; + groupBox1.Padding = new Padding(6); + groupBox1.Size = new Size(422, 422); + groupBox1.TabIndex = 34; + groupBox1.TabStop = false; + groupBox1.Text = "Продукт"; + // + // dataGridViewProduct + // + dataGridViewProduct.AllowUserToResizeColumns = false; + dataGridViewProduct.AllowUserToResizeRows = false; + dataGridViewProduct.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProduct.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnQuantity }); + dataGridViewProduct.Location = new Point(6, 41); + dataGridViewProduct.Margin = new Padding(6); + dataGridViewProduct.MultiSelect = false; + dataGridViewProduct.Name = "dataGridViewProduct"; + dataGridViewProduct.RowHeadersVisible = false; + dataGridViewProduct.RowHeadersWidth = 82; + dataGridViewProduct.RowTemplate.Height = 25; + dataGridViewProduct.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewProduct.Size = new Size(404, 375); + dataGridViewProduct.TabIndex = 0; + // + // ColumnProduct + // + ColumnProduct.HeaderText = "Наименование"; + ColumnProduct.MinimumWidth = 10; + ColumnProduct.Name = "ColumnProduct"; + ColumnProduct.Width = 200; + // + // ColumnQuantity + // + ColumnQuantity.HeaderText = "Количесво"; + ColumnQuantity.MinimumWidth = 10; + ColumnQuantity.Name = "ColumnQuantity"; + ColumnQuantity.Width = 200; + // + // FormContract + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(497, 727); + Controls.Add(groupBox1); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxPurchasingCompany); + Controls.Add(comboBoxAgent); + Controls.Add(labelAgent); + Controls.Add(labelPurchatingCompany); + Margin = new Padding(6); + MinimumSize = new Size(480, 730); + Name = "FormContract"; + StartPosition = FormStartPosition.CenterParent; + Text = "Контракт"; + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private ComboBox comboBoxPurchasingCompany; + private ComboBox comboBoxAgent; + private Label labelAgent; + private Label labelPurchatingCompany; + private GroupBox groupBox1; + private DataGridView dataGridViewProduct; + private DataGridViewComboBoxColumn ColumnProduct; + private DataGridViewTextBoxColumn ColumnQuantity; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.cs new file mode 100644 index 0000000..ad41ba6 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.cs @@ -0,0 +1,75 @@ +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 TradeAndProcurementEnterprice.Entities; +using TradeAndProcurementEnterprice.Repositories; +using TradeAndProcurementEnterprice.Repositories.Implementations; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormContract : Form + { + private readonly IContractRepository _contractRepository; + + public FormContract(IContractRepository contractRepository, IAgentsRepository agentsRepository, + IPurchasingCompanyRepository purchasingCompanyRepository, IProductRepository productRepository) + { + InitializeComponent(); + _contractRepository = contractRepository ?? + throw new ArgumentNullException(nameof(contractRepository)); + + comboBoxPurchasingCompany.DataSource = purchasingCompanyRepository.ReadCompanies(); + comboBoxPurchasingCompany.DisplayMember = "Name"; + comboBoxPurchasingCompany.ValueMember = "Id"; + + comboBoxAgent.DataSource = agentsRepository.ReadAgents(); + comboBoxAgent.DisplayMember = "Name"; + comboBoxAgent.ValueMember = "Id"; + + ColumnProduct.DataSource = productRepository.ReadProducts(); + ColumnProduct.DisplayMember = "Nomenclature"; + ColumnProduct.ValueMember = "Article"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxAgent.SelectedIndex < 0 || comboBoxPurchasingCompany.SelectedIndex < 0 || dataGridViewProduct.RowCount < 1) + { + throw new Exception("Имеются незаполненные поля!"); + } + + _contractRepository.CreateContract(Contract.CreateOperation(0, + (int)comboBoxPurchasingCompany.SelectedValue!, (int)comboBoxAgent.SelectedValue!, CreateListProductSalesFromDataGrid())); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListProductSalesFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewProduct.Rows) + { + if (row.Cells["ColumnProduct"].Value == null || row.Cells["ColumnQuantity"].Value == null) + { + continue; + } + + list.Add(ProductSales.CreateElement(0, Convert.ToInt32(row.Cells["ColumnProduct"]), Convert.ToInt32(row.Cells["ColumnQuantity"]))); + } + return list; + } + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.resx new file mode 100644 index 0000000..70d9360 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContract.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.Designer.cs new file mode 100644 index 0000000..6a4a595 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.Designer.cs @@ -0,0 +1,104 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormContracts + { + /// + /// 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(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(1196, 0); + panel1.Margin = new Padding(6, 6, 6, 6); + panel1.Name = "panel1"; + panel1.Size = new Size(178, 929); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(32, 26); + buttonAdd.Margin = new Padding(6, 6, 6, 6); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(121, 139); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.Margin = new Padding(6, 6, 6, 6); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 82; + dataGridViewData.RowTemplate.Height = 25; + dataGridViewData.Size = new Size(1196, 929); + dataGridViewData.TabIndex = 1; + // + // FormContracts + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1374, 929); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(1000, 630); + Name = "FormContracts"; + StartPosition = FormStartPosition.CenterParent; + Text = "Продажи"; + Load += FormContracts_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.cs new file mode 100644 index 0000000..3731f3f --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.cs @@ -0,0 +1,58 @@ +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 TradeAndProcurementEnterprice.Repositories; +using TradeAndProcurementEnterprice.Repositories.Implementations; +using Unity; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormContracts : Form + { + private readonly IUnityContainer _container; + + private readonly IContractRepository _contractRepository; + + public FormContracts(IUnityContainer container, IContractRepository contractRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _contractRepository = contractRepository ?? + throw new ArgumentNullException(nameof(contractRepository)); + } + + private void FormContracts_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() => dataGridViewData.DataSource = _contractRepository.ReadContracts(); + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormContracts.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.Designer.cs new file mode 100644 index 0000000..96db5c9 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.Designer.cs @@ -0,0 +1,160 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormDelegateToAgent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCancel = new Button(); + buttonSave = new Button(); + numericUpDownQuantity = new NumericUpDown(); + comboBoxAgent = new ComboBox(); + labelQuantity = new Label(); + labelAgent = new Label(); + labelProduct = new Label(); + comboBoxProduct = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).BeginInit(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(282, 309); + buttonCancel.Margin = new Padding(6, 6, 6, 6); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(156, 49); + buttonCancel.TabIndex = 24; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(82, 309); + buttonSave.Margin = new Padding(6, 6, 6, 6); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(156, 49); + buttonSave.TabIndex = 25; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // numericUpDownQuantity + // + numericUpDownQuantity.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownQuantity.Location = new Point(219, 128); + numericUpDownQuantity.Margin = new Padding(6, 6, 6, 6); + numericUpDownQuantity.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownQuantity.Name = "numericUpDownQuantity"; + numericUpDownQuantity.Size = new Size(277, 39); + numericUpDownQuantity.TabIndex = 23; + // + // comboBoxAgent + // + comboBoxAgent.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxAgent.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxAgent.FormattingEnabled = true; + comboBoxAgent.Location = new Point(219, 220); + comboBoxAgent.Margin = new Padding(6, 6, 6, 6); + comboBoxAgent.Name = "comboBoxAgent"; + comboBoxAgent.Size = new Size(273, 40); + comboBoxAgent.TabIndex = 22; + // + // labelQuantity + // + labelQuantity.AutoSize = true; + labelQuantity.Location = new Point(41, 132); + labelQuantity.Margin = new Padding(6, 0, 6, 0); + labelQuantity.Name = "labelQuantity"; + labelQuantity.Size = new Size(144, 32); + labelQuantity.TabIndex = 15; + labelQuantity.Text = "Количество"; + // + // labelAgent + // + labelAgent.Location = new Point(41, 208); + labelAgent.Margin = new Padding(6, 0, 6, 0); + labelAgent.Name = "labelAgent"; + labelAgent.Size = new Size(150, 75); + labelAgent.TabIndex = 17; + labelAgent.Text = "Агент-\r\nреализатор"; + // + // labelProduct + // + labelProduct.AutoSize = true; + labelProduct.Location = new Point(41, 45); + labelProduct.Margin = new Padding(6, 0, 6, 0); + labelProduct.Name = "labelProduct"; + labelProduct.Size = new Size(181, 32); + labelProduct.TabIndex = 19; + labelProduct.Text = "Наименование"; + // + // comboBoxProduct + // + comboBoxProduct.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxProduct.FormattingEnabled = true; + comboBoxProduct.Location = new Point(219, 38); + comboBoxProduct.Margin = new Padding(6, 6, 6, 6); + comboBoxProduct.Name = "comboBoxProduct"; + comboBoxProduct.Size = new Size(273, 40); + comboBoxProduct.TabIndex = 22; + // + // FormDelegateToAgent + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(554, 409); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownQuantity); + Controls.Add(comboBoxProduct); + Controls.Add(comboBoxAgent); + Controls.Add(labelQuantity); + Controls.Add(labelAgent); + Controls.Add(labelProduct); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(580, 480); + Name = "FormDelegateToAgent"; + StartPosition = FormStartPosition.CenterParent; + Text = "Передача агентам"; + ((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Button buttonCancel; + private Button buttonSave; + private NumericUpDown numericUpDownQuantity; + private ComboBox comboBoxAgent; + private Label labelQuantity; + private Label labelAgent; + private Label labelProduct; + private ComboBox comboBoxProduct; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.cs new file mode 100644 index 0000000..52b110b --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.cs @@ -0,0 +1,56 @@ +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 TradeAndProcurementEnterprice.Entities; +using TradeAndProcurementEnterprice.Repositories; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormDelegateToAgent : Form + { + private readonly IDelegateToAgentRepository _delegateToAgentRepository; + + public FormDelegateToAgent(IDelegateToAgentRepository delegateToAgentRepository, IProductRepository productRepository, + IAgentsRepository agentsRepository) + { + InitializeComponent(); + _delegateToAgentRepository = delegateToAgentRepository ?? + throw new ArgumentNullException(nameof(delegateToAgentRepository)); + + comboBoxProduct.DataSource = productRepository.ReadProducts(); + comboBoxProduct.DisplayMember = "Nomenclature"; + comboBoxProduct.ValueMember = "Article"; + + comboBoxAgent.DataSource = agentsRepository.ReadAgents(); + comboBoxAgent.DisplayMember = "Name"; + comboBoxAgent.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxProduct.SelectedIndex < 0 || comboBoxAgent.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля!"); + } + + _delegateToAgentRepository.CreateDelegatesToAgent(DelegateToAgents.CreateOperation(0, + (int)comboBoxProduct.SelectedValue!, Convert.ToInt32(numericUpDownQuantity.Value), + (int)comboBoxAgent.SelectedValue!)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegateToAgent.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.Designer.cs new file mode 100644 index 0000000..119fddf --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.Designer.cs @@ -0,0 +1,104 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormDelegatesToAgents + { + /// + /// 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(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(1196, 0); + panel1.Margin = new Padding(6, 6, 6, 6); + panel1.Name = "panel1"; + panel1.Size = new Size(178, 929); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(32, 26); + buttonAdd.Margin = new Padding(6, 6, 6, 6); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(121, 139); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.Margin = new Padding(6, 6, 6, 6); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 82; + dataGridViewData.RowTemplate.Height = 25; + dataGridViewData.Size = new Size(1196, 929); + dataGridViewData.TabIndex = 1; + // + // FormDelegatesToAgents + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1374, 929); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(1000, 630); + Name = "FormDelegatesToAgents"; + StartPosition = FormStartPosition.CenterParent; + Text = "Передача товара агентам-реализаторам"; + Load += FormDelegatesToAgents_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.cs new file mode 100644 index 0000000..c198d49 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.cs @@ -0,0 +1,56 @@ +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 TradeAndProcurementEnterprice.Repositories; +using Unity; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormDelegatesToAgents : Form + { + private readonly IUnityContainer _container; + + private readonly IDelegateToAgentRepository _delegateToAgentRepository; + + public FormDelegatesToAgents(IUnityContainer container, IDelegateToAgentRepository delegateToAgentRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _delegateToAgentRepository = delegateToAgentRepository ?? + throw new ArgumentNullException(nameof(delegateToAgentRepository)); + } + + private void FormDelegatesToAgents_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() => dataGridViewData.DataSource = _delegateToAgentRepository.ReadDelegatesToAgent(); + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormDelegatesToAgents.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.Designer.cs new file mode 100644 index 0000000..d3e8586 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.Designer.cs @@ -0,0 +1,200 @@ +namespace TradeAndProcurementEnterprice.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() + { + labelNomenclature = new Label(); + labelPrice = new Label(); + labelUnit = new Label(); + labelCategory = new Label(); + labelInventoryQuantity = new Label(); + textBoxNomenclature = new TextBox(); + numericUpDownPrice = new NumericUpDown(); + comboBoxUnit = new ComboBox(); + numericUpDownQuantity = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + comboBoxCategory = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).BeginInit(); + SuspendLayout(); + // + // labelNomenclature + // + labelNomenclature.AutoSize = true; + labelNomenclature.Location = new Point(26, 27); + labelNomenclature.Name = "labelNomenclature"; + labelNomenclature.Size = new Size(180, 33); + labelNomenclature.TabIndex = 0; + labelNomenclature.Text = "Номенклатура"; + // + // labelPrice + // + labelPrice.Location = new Point(26, 84); + labelPrice.Name = "labelPrice"; + labelPrice.Size = new Size(158, 73); + labelPrice.TabIndex = 0; + labelPrice.Text = "Цена за единицу"; + // + // labelUnit + // + labelUnit.Location = new Point(26, 163); + labelUnit.Name = "labelUnit"; + labelUnit.Size = new Size(158, 73); + labelUnit.TabIndex = 0; + labelUnit.Text = "Единица измерения"; + // + // labelCategory + // + labelCategory.AutoSize = true; + labelCategory.Location = new Point(26, 270); + labelCategory.Name = "labelCategory"; + labelCategory.Size = new Size(131, 33); + labelCategory.TabIndex = 0; + labelCategory.Text = "Категория"; + // + // labelInventoryQuantity + // + labelInventoryQuantity.Location = new Point(26, 331); + labelInventoryQuantity.Name = "labelInventoryQuantity"; + labelInventoryQuantity.Size = new Size(158, 72); + labelInventoryQuantity.TabIndex = 0; + labelInventoryQuantity.Text = "Количество на складе"; + // + // textBoxNomenclature + // + textBoxNomenclature.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxNomenclature.Location = new Point(248, 24); + textBoxNomenclature.Name = "textBoxNomenclature"; + textBoxNomenclature.Size = new Size(237, 41); + textBoxNomenclature.TabIndex = 1; + // + // numericUpDownPrice + // + numericUpDownPrice.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownPrice.DecimalPlaces = 2; + numericUpDownPrice.Location = new Point(248, 100); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(237, 41); + numericUpDownPrice.TabIndex = 2; + // + // comboBoxUnit + // + comboBoxUnit.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxUnit.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxUnit.FormattingEnabled = true; + comboBoxUnit.Location = new Point(248, 179); + comboBoxUnit.Name = "comboBoxUnit"; + comboBoxUnit.Size = new Size(237, 41); + comboBoxUnit.TabIndex = 3; + // + // numericUpDownQuantity + // + numericUpDownQuantity.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + numericUpDownQuantity.Location = new Point(248, 343); + numericUpDownQuantity.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownQuantity.Name = "numericUpDownQuantity"; + numericUpDownQuantity.Size = new Size(237, 41); + numericUpDownQuantity.TabIndex = 4; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(44, 424); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(201, 46); + buttonSave.TabIndex = 5; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(274, 424); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(201, 46); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // comboBoxCategory + // + comboBoxCategory.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxCategory.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCategory.FormattingEnabled = true; + comboBoxCategory.Location = new Point(248, 262); + comboBoxCategory.Name = "comboBoxCategory"; + comboBoxCategory.Size = new Size(237, 41); + comboBoxCategory.TabIndex = 14; + // + // FormProduct + // + AutoScaleDimensions = new SizeF(15F, 33F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(559, 514); + Controls.Add(comboBoxCategory); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownQuantity); + Controls.Add(comboBoxUnit); + Controls.Add(numericUpDownPrice); + Controls.Add(textBoxNomenclature); + Controls.Add(labelInventoryQuantity); + Controls.Add(labelCategory); + Controls.Add(labelUnit); + Controls.Add(labelPrice); + Controls.Add(labelNomenclature); + Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point); + MinimumSize = new Size(585, 585); + Name = "FormProduct"; + StartPosition = FormStartPosition.CenterParent; + Text = "Номенклатура"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQuantity).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelNomenclature; + private Label labelPrice; + private Label labelUnit; + private Label labelCategory; + private Label labelInventoryQuantity; + private TextBox textBoxNomenclature; + private NumericUpDown numericUpDownPrice; + private ComboBox comboBoxUnit; + private NumericUpDown numericUpDownQuantity; + private Button buttonSave; + private Button buttonCancel; + private ComboBox comboBoxCategory; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.cs new file mode 100644 index 0000000..b32d5ed --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.cs @@ -0,0 +1,92 @@ +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 TradeAndProcurementEnterprice.Repositories; +using TradeAndProcurementEnterprice.Entities; +using TradeAndProcurementEnterprice.Entities.Enums; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormProduct : Form + { + private readonly IProductRepository _productRepository; + + private int? _productArticle; + + public int Article + { + set + { + try + { + var product = _productRepository.ReadProductByArticle(value); + if (product == null) + { + throw new InvalidDataException(nameof(product)); + } + + textBoxNomenclature.Text = product.Nomenclature; + numericUpDownPrice.Value = product.SellingPrice; + comboBoxUnit.SelectedItem = product.Unit; + comboBoxCategory.SelectedItem = product.Category; + numericUpDownQuantity.Value = product.InventoryQuantity; + _productArticle = 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)); + + comboBoxUnit.DataSource = Enum.GetValues(typeof(Unit)); + comboBoxCategory.DataSource = Enum.GetValues(typeof(Category)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrEmpty(textBoxNomenclature.Text) || comboBoxUnit.SelectedIndex < 1 + || comboBoxCategory.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля!"); + } + + if (_productArticle.HasValue) + { + _productRepository.UpdateProduct(CreateProduct(_productArticle.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 article) => Product.CreateEntity(article, textBoxNomenclature.Text, + numericUpDownPrice.Value, (Unit)comboBoxUnit.SelectedItem, (Category)comboBoxCategory.SelectedItem, + Convert.ToInt32(numericUpDownQuantity.Value)); + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProduct.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.Designer.cs new file mode 100644 index 0000000..22a2a1a --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.Designer.cs @@ -0,0 +1,134 @@ +namespace TradeAndProcurementEnterprice.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() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonEdit = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonEdit); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(1196, 0); + panel1.Margin = new Padding(6, 6, 6, 6); + panel1.Name = "panel1"; + panel1.Size = new Size(178, 929); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.remove; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(32, 390); + buttonDel.Margin = new Padding(6, 6, 6, 6); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(121, 139); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonEdit + // + buttonEdit.BackgroundImage = Properties.Resources.edit; + buttonEdit.BackgroundImageLayout = ImageLayout.Stretch; + buttonEdit.Location = new Point(32, 203); + buttonEdit.Margin = new Padding(6, 6, 6, 6); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(121, 139); + buttonEdit.TabIndex = 2; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += ButtonEdit_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(32, 26); + buttonAdd.Margin = new Padding(6, 6, 6, 6); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(121, 139); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.Margin = new Padding(6, 6, 6, 6); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 82; + dataGridViewData.RowTemplate.Height = 25; + dataGridViewData.Size = new Size(1196, 929); + dataGridViewData.TabIndex = 1; + // + // FormProducts + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1374, 929); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(1000, 630); + Name = "FormProducts"; + StartPosition = FormStartPosition.CenterParent; + Text = "Номенклатура"; + Load += FormProducts_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private Button buttonDel; + private Button buttonEdit; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.cs new file mode 100644 index 0000000..9b4748e --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.cs @@ -0,0 +1,113 @@ +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 TradeAndProcurementEnterprice.Repositories; +using Unity; + +namespace TradeAndProcurementEnterprice.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 ButtonEdit_Click(object sender, EventArgs e) + { + if (!TryGetIdFromSelectedRow(out var findId)) + { + return; + } + + try + { + var form = _container.Resolve(); + form.Article = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdFromSelectedRow(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() => dataGridViewData.DataSource = _productRepository.ReadProducts(); + + private bool TryGetIdFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Article"].Value); + return true; + } + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormProducts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.Designer.cs new file mode 100644 index 0000000..a0184c4 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.Designer.cs @@ -0,0 +1,134 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormPurchasingCompanies + { + /// + /// 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(); + buttonEdit = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonEdit); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(1196, 0); + panel1.Margin = new Padding(6, 6, 6, 6); + panel1.Name = "panel1"; + panel1.Size = new Size(178, 929); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.remove; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(32, 390); + buttonDel.Margin = new Padding(6, 6, 6, 6); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(121, 139); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonEdit + // + buttonEdit.BackgroundImage = Properties.Resources.edit; + buttonEdit.BackgroundImageLayout = ImageLayout.Stretch; + buttonEdit.Location = new Point(32, 203); + buttonEdit.Margin = new Padding(6, 6, 6, 6); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(121, 139); + buttonEdit.TabIndex = 2; + buttonEdit.UseVisualStyleBackColor = true; + buttonEdit.Click += ButtonEdit_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(32, 26); + buttonAdd.Margin = new Padding(6, 6, 6, 6); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(121, 139); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.Margin = new Padding(6, 6, 6, 6); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 82; + dataGridViewData.RowTemplate.Height = 25; + dataGridViewData.Size = new Size(1196, 929); + dataGridViewData.TabIndex = 1; + // + // FormPurchasingCompanies + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1374, 929); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(1000, 630); + Name = "FormPurchasingCompanies"; + StartPosition = FormStartPosition.CenterParent; + Text = "Компании закупщики"; + Load += FormPurchasingCompanies_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private Button buttonDel; + private Button buttonEdit; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.cs new file mode 100644 index 0000000..5ac48ae --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using TradeAndProcurementEnterprice.Repositories; +using TradeAndProcurementEnterprice.Repositories.Implementations; +using Unity; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormPurchasingCompanies : Form + { + private readonly IUnityContainer _container; + + private readonly IPurchasingCompanyRepository _companyRepository; + + public FormPurchasingCompanies(IUnityContainer container, IPurchasingCompanyRepository companyRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _companyRepository = companyRepository ?? + throw new ArgumentNullException(nameof(companyRepository)); + } + + private void FormPurchasingCompanies_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 ButtonEdit_Click(object sender, EventArgs e) + { + if (!TryGetIdFromSelectedRow(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 (!TryGetIdFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _companyRepository.DeleteCompany(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _companyRepository.ReadCompanies(); + + private bool TryGetIdFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompanies.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.Designer.cs new file mode 100644 index 0000000..f6e1fc9 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.Designer.cs @@ -0,0 +1,104 @@ +namespace TradeAndProcurementEnterprice.Forms +{ + partial class FormPurchasingCompany + { + /// + /// 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(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // textBoxName + // + textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxName.Location = new Point(243, 46); + textBoxName.Margin = new Padding(6, 6, 6, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(271, 39); + textBoxName.TabIndex = 19; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(50, 49); + labelName.Margin = new Padding(6, 0, 6, 0); + labelName.Name = "labelName"; + labelName.Size = new Size(181, 32); + labelName.TabIndex = 18; + labelName.Text = "Наименование"; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(91, 121); + buttonSave.Margin = new Padding(6, 6, 6, 6); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(156, 49); + buttonSave.TabIndex = 21; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(290, 121); + buttonCancel.Margin = new Padding(6, 6, 6, 6); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(156, 49); + buttonCancel.TabIndex = 20; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormPurchasingCompany + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(564, 219); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(labelName); + Margin = new Padding(6, 6, 6, 6); + MinimumSize = new Size(590, 290); + Name = "FormPurchasingCompany"; + StartPosition = FormStartPosition.CenterParent; + Text = "Компания закупщик"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private TextBox textBoxName; + private Label labelName; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.cs new file mode 100644 index 0000000..1094673 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.cs @@ -0,0 +1,84 @@ +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 TradeAndProcurementEnterprice.Entities; +using TradeAndProcurementEnterprice.Entities.Enums; +using TradeAndProcurementEnterprice.Repositories; +using TradeAndProcurementEnterprice.Repositories.Implementations; + +namespace TradeAndProcurementEnterprice.Forms +{ + public partial class FormPurchasingCompany : Form + { + private readonly IPurchasingCompanyRepository _purchasingCompanyRepository; + + private int? _companyId; + + public int Id + { + set + { + try + { + var company = _purchasingCompanyRepository.ReadCompaniesByID(value); + if (company == null) + { + throw new InvalidDataException(nameof(company)); + } + + textBoxName.Text = company.Name; + _companyId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных!", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormPurchasingCompany(IPurchasingCompanyRepository purchasingCompanyRepository) + { + InitializeComponent(); + _purchasingCompanyRepository = purchasingCompanyRepository ?? + throw new ArgumentNullException(nameof(purchasingCompanyRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля!"); + } + + if (_companyId.HasValue) + { + _purchasingCompanyRepository.UpdateCompanies(CreateCompany(_companyId.Value)); + } + else + { + _purchasingCompanyRepository.CreateCompany(CreateCompany(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private PurchasingCompany CreateCompany(int id) => + PurchasingCompany.CreateEntity(id, textBoxName.Text); + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Forms/FormPurchasingCompany.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Program.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Program.cs index 1edaf68..e0feeeb 100644 --- a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Program.cs +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Program.cs @@ -1,3 +1,8 @@ +using TradeAndProcurementEnterprice.Repositories; +using TradeAndProcurementEnterprice.Repositories.Implementations; +using Unity; +using Unity.Lifetime; + namespace TradeAndProcurementEnterprice { internal static class Program @@ -11,7 +16,20 @@ namespace TradeAndProcurementEnterprice // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + + return container; } } } \ No newline at end of file diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Properties/Resources.Designer.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Properties/Resources.Designer.cs new file mode 100644 index 0000000..27e7917 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace TradeAndProcurementEnterprice.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("TradeAndProcurementEnterprice.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 edit { + get { + object obj = ResourceManager.GetObject("edit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap photo_2024_12_03_21_34_38 { + get { + object obj = ResourceManager.GetObject("photo_2024-12-03_21-34-38", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap remove { + get { + object obj = ResourceManager.GetObject("remove", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Properties/Resources.resx b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Properties/Resources.resx new file mode 100644 index 0000000..72bc2f4 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/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\photo_2024-12-03_21-34-38.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\remove.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/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IAgentsRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IAgentsRepository.cs new file mode 100644 index 0000000..274d8ec --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IAgentsRepository.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories; + +public interface IAgentsRepository +{ + IEnumerable ReadAgents(); + + Agent ReadAgentByID(int id); + + void CreateAgent(Agent agent); + + void UpdateAgent(Agent agent); + + void DeleteAgent(int id); +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IContractRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IContractRepository.cs new file mode 100644 index 0000000..4d9604a --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IContractRepository.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories; + +public interface IContractRepository +{ + IEnumerable ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, + int? productArticle = null, int? agentID = null, int? purchasingCompaniID = null); + + void CreateContract(Contract contract); +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IDelegateToAgentRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IDelegateToAgentRepository.cs new file mode 100644 index 0000000..a52dc92 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IDelegateToAgentRepository.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories; + +public interface IDelegateToAgentRepository +{ + IEnumerable ReadDelegatesToAgent(DateTime? dateFrom = null, DateTime? dateTo = null, + int? productArticle = null, int? agentID = null); + + void CreateDelegatesToAgent(DelegateToAgents delegateToAgents); +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IProductRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IProductRepository.cs new file mode 100644 index 0000000..c1f43f1 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IProductRepository.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories; + +public interface IProductRepository +{ + IEnumerable ReadProducts(); + + Product ReadProductByArticle(int article); + + void CreateProduct(Product product); + + void UpdateProduct(Product product); + + void DeleteProduct(int article); +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IPurchasingCompanyRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IPurchasingCompanyRepository.cs new file mode 100644 index 0000000..9c92ef4 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/IPurchasingCompanyRepository.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories; + +public interface IPurchasingCompanyRepository +{ + IEnumerable ReadCompanies(); + + PurchasingCompany ReadCompaniesByID(int id); + + void CreateCompany(PurchasingCompany agent); + + void UpdateCompanies(PurchasingCompany agent); + + void DeleteCompany(int id); +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/AgentsRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/AgentsRepository.cs new file mode 100644 index 0000000..188c681 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/AgentsRepository.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories.Implementations; + +public class AgentsRepository : IAgentsRepository +{ + public void CreateAgent(Agent agent) + { + } + + public void DeleteAgent(int id) + { + } + + public Agent ReadAgentByID(int id) + { + return Agent.CreateEntity(0, string.Empty, Entities.Enums.Qualification.Junior, Entities.Enums.Category.Other); + } + + public IEnumerable ReadAgents() + { + return []; + } + + public void UpdateAgent(Agent agent) + { + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/ContractRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/ContractRepository.cs new file mode 100644 index 0000000..f261b2b --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/ContractRepository.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories.Implementations; + +public class ContractRepository : IContractRepository +{ + public void CreateContract(Contract contract) + { + } + + public IEnumerable ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, int? productArticle = null, int? agentID = null, int? purchasingCompaniID = null) + { + return []; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/DelegateToAgentRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/DelegateToAgentRepository.cs new file mode 100644 index 0000000..49625ca --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/DelegateToAgentRepository.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories.Implementations; + +public class DelegateToAgentRepository : IDelegateToAgentRepository +{ + public void CreateDelegatesToAgent(DelegateToAgents delegateToAgents) + { + } + + public IEnumerable ReadDelegatesToAgent(DateTime? dateFrom = null, DateTime? dateTo = null, int? productArticle = null, int? agentID = null) + { + return []; + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/ProductRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/ProductRepository.cs new file mode 100644 index 0000000..a34f1ab --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/ProductRepository.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories.Implementations; + +public class ProductRepository : IProductRepository +{ + public void CreateProduct(Product product) + { + } + + public void DeleteProduct(int article) + { + } + + public Product ReadProductByArticle(int article) + { + return Product.CreateEntity(0, string.Empty, 0, Entities.Enums.Unit.Piece, Entities.Enums.Category.Other, 0); + } + + public IEnumerable ReadProducts() + { + return []; + } + + public void UpdateProduct(Product product) + { + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/PurchasingCompanyRepository.cs b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/PurchasingCompanyRepository.cs new file mode 100644 index 0000000..ed5b353 --- /dev/null +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Repositories/Implementations/PurchasingCompanyRepository.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TradeAndProcurementEnterprice.Entities; + +namespace TradeAndProcurementEnterprice.Repositories.Implementations; + +public class PurchasingCompanyRepository : IPurchasingCompanyRepository +{ + public void CreateCompany(PurchasingCompany agent) + { + } + + public void DeleteCompany(int id) + { + } + + public IEnumerable ReadCompanies() + { + return []; + } + + public PurchasingCompany ReadCompaniesByID(int id) + { + return PurchasingCompany.CreateEntity(0, string.Empty); + } + + public void UpdateCompanies(PurchasingCompany agent) + { + } +} diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/add.png b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/add.png new file mode 100644 index 0000000..c56faf8 Binary files /dev/null and b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/add.png differ diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/edit.png b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/edit.png new file mode 100644 index 0000000..965f6a6 Binary files /dev/null and b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/edit.png differ diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/photo_2024-12-03_21-34-38.jpg b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/photo_2024-12-03_21-34-38.jpg new file mode 100644 index 0000000..16ab5c9 Binary files /dev/null and b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/photo_2024-12-03_21-34-38.jpg differ diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/remove.png b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/remove.png new file mode 100644 index 0000000..ab02768 Binary files /dev/null and b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/Resources/remove.png differ diff --git a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice.csproj b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice.csproj index b57c89e..0f76343 100644 --- a/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice.csproj +++ b/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice/TradeAndProcurementEnterprice.csproj @@ -6,6 +6,26 @@ enable true enable + 12.0 + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file