Лаба4, промежуток.
This commit is contained in:
parent
76db4ba2e3
commit
c9d4eb055c
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -11,18 +12,27 @@ public class Agent
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Имя")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
|
public string Surname { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Квалификация")]
|
||||||
public Qualification Qualification { get; private set; }
|
public Qualification Qualification { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Категория")]
|
||||||
public Category Category { get; private set; }
|
public Category Category { get; private set; }
|
||||||
|
|
||||||
public static Agent CreateEntity(int id, string name, Qualification qualification, Category category)
|
public string FullName => $"{Name} {Surname}";
|
||||||
|
|
||||||
|
public static Agent CreateEntity(int id, string name, string surname, Qualification qualification, Category category)
|
||||||
{
|
{
|
||||||
return new Agent
|
return new Agent
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Name = name ?? string.Empty,
|
Name = name ?? string.Empty,
|
||||||
|
Surname = surname ?? string.Empty,
|
||||||
Qualification = qualification,
|
Qualification = qualification,
|
||||||
Category = category
|
Category = category
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using System;
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -10,12 +12,27 @@ public class Contract
|
|||||||
{
|
{
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата продажи")]
|
||||||
public DateTime SaleDate { get; private set; }
|
public DateTime SaleDate { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int PurchasingCompanyID { get; private set; }
|
public int PurchasingCompanyID { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int AgentsID { get; private set; }
|
public int AgentsID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Агент-реализатор")]
|
||||||
|
public string AgentsName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Компания-закупщик")]
|
||||||
|
public string CompanyName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Номенклатура")]
|
||||||
|
public string Product => ProductSales != null ?
|
||||||
|
string.Join(", ", ProductSales.Select(x => $"{x.ProductName} {x.ProductQuantity}")) :
|
||||||
|
string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<ProductSales> ProductSales { get; private set; } = [];
|
public IEnumerable<ProductSales> ProductSales { get; private set; } = [];
|
||||||
|
|
||||||
public static Contract CreateOperation(int contractID, int purchasingCompanyID, int agentsID, IEnumerable<ProductSales> productSales)
|
public static Contract CreateOperation(int contractID, int purchasingCompanyID, int agentsID, IEnumerable<ProductSales> productSales)
|
||||||
@ -30,16 +47,11 @@ public class Contract
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Contract CreateOperation(TempProductSales tempProductSales,
|
public void SetProductSales(IEnumerable<ProductSales> productSales)
|
||||||
IEnumerable<ProductSales> productSales)
|
|
||||||
{
|
{
|
||||||
return new Contract
|
if (productSales != null && productSales.Any())
|
||||||
{
|
{
|
||||||
ID = tempProductSales.ID,
|
ProductSales = productSales;
|
||||||
AgentsID = tempProductSales.AgentsId,
|
}
|
||||||
SaleDate = tempProductSales.SaleDate,
|
|
||||||
PurchasingCompanyID = tempProductSales.PurchasingCompanyId,
|
|
||||||
ProductSales = productSales
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -9,12 +10,25 @@ namespace TradeAndProcurementEnterprice.Entities;
|
|||||||
public class DelegateToAgents
|
public class DelegateToAgents
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int ProductArticle { get; private set; }
|
public int ProductArticle { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int AgentsID { get; private set; }
|
public int AgentsID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номенклатура")]
|
||||||
|
public string ProductName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Имя агента")]
|
||||||
|
public string AgentsName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Количество товара")]
|
||||||
public int Quantity { get; private set; }
|
public int Quantity { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Дата передачи")]
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
public static DelegateToAgents CreateOperation(int id, int productArticle, int agentsID, int quantity)
|
public static DelegateToAgents CreateOperation(int id, int productArticle, int agentsID, int quantity)
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TradeAndProcurementEnterprice.Entities.Enums;
|
using TradeAndProcurementEnterprice.Entities.Enums;
|
||||||
|
|
||||||
namespace TradeAndProcurementEnterprice.Entities;
|
namespace TradeAndProcurementEnterprice.Entities;
|
||||||
@ -11,14 +7,20 @@ public class Product
|
|||||||
{
|
{
|
||||||
public int Article { get; private set; }
|
public int Article { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номенклатура")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Цена")]
|
||||||
public decimal SellingPrice { get; private set; }
|
public decimal SellingPrice { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Единица измерения")]
|
||||||
public Units Unit { get; private set; }
|
public Units Unit { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Категория")]
|
||||||
public Category Category { get; private set; }
|
public Category Category { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Количество на складе")]
|
||||||
public int InventoryQuantity { get; private set; }
|
public int InventoryQuantity { get; private set; }
|
||||||
|
|
||||||
public static Product CreateEntity(int article, string name, decimal sellingPrice, Units unit,
|
public static Product CreateEntity(int article, string name, decimal sellingPrice, Units unit,
|
||||||
|
@ -12,6 +12,8 @@ public class ProductSales
|
|||||||
|
|
||||||
public int ProductArticle { get; private set; }
|
public int ProductArticle { get; private set; }
|
||||||
|
|
||||||
|
public string ProductName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int ProductQuantity { get; private set; }
|
public int ProductQuantity { get; private set; }
|
||||||
|
|
||||||
public static ProductSales CreateElement(int id, int prodictArticle, int productQuantity)
|
public static ProductSales CreateElement(int id, int prodictArticle, int productQuantity)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -10,6 +11,7 @@ public class PurchasingCompany
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Наименование компании")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static PurchasingCompany CreateEntity(int id, string name)
|
public static PurchasingCompany CreateEntity(int id, string name)
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace TradeAndProcurementEnterprice.Entities;
|
|
||||||
|
|
||||||
public class TempProductSales
|
|
||||||
{
|
|
||||||
public int ID { get; private set; }
|
|
||||||
|
|
||||||
public int AgentsId { get; private set; }
|
|
||||||
|
|
||||||
public DateTime SaleDate { get; private set; }
|
|
||||||
|
|
||||||
public int PurchasingCompanyId { get; private set; }
|
|
||||||
|
|
||||||
public int ProductArticle { get; private set; }
|
|
||||||
|
|
||||||
public int ProductQuantity { get; private set; }
|
|
||||||
}
|
|
@ -36,15 +36,16 @@
|
|||||||
labelQualification = new Label();
|
labelQualification = new Label();
|
||||||
labelName = new Label();
|
labelName = new Label();
|
||||||
checkedListBoxCategory = new CheckedListBox();
|
checkedListBoxCategory = new CheckedListBox();
|
||||||
|
labelSurname = new Label();
|
||||||
|
textBoxSurname = new TextBox();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.Location = new Point(280, 412);
|
buttonCancel.Location = new Point(151, 227);
|
||||||
buttonCancel.Margin = new Padding(6, 6, 6, 6);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(156, 49);
|
buttonCancel.Size = new Size(84, 23);
|
||||||
buttonCancel.TabIndex = 16;
|
buttonCancel.TabIndex = 16;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
@ -53,10 +54,9 @@
|
|||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonSave.Location = new Point(80, 412);
|
buttonSave.Location = new Point(43, 227);
|
||||||
buttonSave.Margin = new Padding(6, 6, 6, 6);
|
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(156, 49);
|
buttonSave.Size = new Size(84, 23);
|
||||||
buttonSave.TabIndex = 17;
|
buttonSave.TabIndex = 17;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
@ -67,76 +67,88 @@
|
|||||||
comboBoxQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
comboBoxQualification.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
comboBoxQualification.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxQualification.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxQualification.FormattingEnabled = true;
|
comboBoxQualification.FormattingEnabled = true;
|
||||||
comboBoxQualification.Location = new Point(217, 124);
|
comboBoxQualification.Location = new Point(115, 103);
|
||||||
comboBoxQualification.Margin = new Padding(6, 6, 6, 6);
|
|
||||||
comboBoxQualification.Name = "comboBoxQualification";
|
comboBoxQualification.Name = "comboBoxQualification";
|
||||||
comboBoxQualification.Size = new Size(273, 40);
|
comboBoxQualification.Size = new Size(149, 23);
|
||||||
comboBoxQualification.TabIndex = 14;
|
comboBoxQualification.TabIndex = 14;
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
textBoxName.Location = new Point(217, 38);
|
textBoxName.Location = new Point(117, 18);
|
||||||
textBoxName.Margin = new Padding(6, 6, 6, 6);
|
|
||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(273, 39);
|
textBoxName.Size = new Size(149, 23);
|
||||||
textBoxName.TabIndex = 11;
|
textBoxName.TabIndex = 11;
|
||||||
//
|
//
|
||||||
// labelCategory
|
// labelCategory
|
||||||
//
|
//
|
||||||
labelCategory.AutoSize = true;
|
labelCategory.AutoSize = true;
|
||||||
labelCategory.Location = new Point(39, 220);
|
labelCategory.Location = new Point(19, 148);
|
||||||
labelCategory.Margin = new Padding(6, 0, 6, 0);
|
|
||||||
labelCategory.Name = "labelCategory";
|
labelCategory.Name = "labelCategory";
|
||||||
labelCategory.Size = new Size(126, 32);
|
labelCategory.Size = new Size(63, 15);
|
||||||
labelCategory.TabIndex = 7;
|
labelCategory.TabIndex = 7;
|
||||||
labelCategory.Text = "Категория";
|
labelCategory.Text = "Категория";
|
||||||
//
|
//
|
||||||
// labelQualification
|
// labelQualification
|
||||||
//
|
//
|
||||||
labelQualification.AutoSize = true;
|
labelQualification.AutoSize = true;
|
||||||
labelQualification.Location = new Point(43, 130);
|
labelQualification.Location = new Point(21, 106);
|
||||||
labelQualification.Margin = new Padding(6, 0, 6, 0);
|
|
||||||
labelQualification.Name = "labelQualification";
|
labelQualification.Name = "labelQualification";
|
||||||
labelQualification.Size = new Size(174, 32);
|
labelQualification.Size = new Size(88, 15);
|
||||||
labelQualification.TabIndex = 8;
|
labelQualification.TabIndex = 8;
|
||||||
labelQualification.Text = "Квалификация";
|
labelQualification.Text = "Квалификация";
|
||||||
//
|
//
|
||||||
// labelName
|
// labelName
|
||||||
//
|
//
|
||||||
labelName.AutoSize = true;
|
labelName.AutoSize = true;
|
||||||
labelName.Location = new Point(39, 53);
|
labelName.Location = new Point(21, 25);
|
||||||
labelName.Margin = new Padding(6, 0, 6, 0);
|
|
||||||
labelName.Name = "labelName";
|
labelName.Name = "labelName";
|
||||||
labelName.Size = new Size(67, 32);
|
labelName.Size = new Size(31, 15);
|
||||||
labelName.TabIndex = 10;
|
labelName.TabIndex = 10;
|
||||||
labelName.Text = "ФИО";
|
labelName.Text = "Имя";
|
||||||
//
|
//
|
||||||
// checkedListBoxCategory
|
// checkedListBoxCategory
|
||||||
//
|
//
|
||||||
checkedListBoxCategory.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
checkedListBoxCategory.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
checkedListBoxCategory.FormattingEnabled = true;
|
checkedListBoxCategory.FormattingEnabled = true;
|
||||||
checkedListBoxCategory.Location = new Point(217, 211);
|
checkedListBoxCategory.Location = new Point(115, 144);
|
||||||
checkedListBoxCategory.Margin = new Padding(6, 6, 6, 6);
|
|
||||||
checkedListBoxCategory.Name = "checkedListBoxCategory";
|
checkedListBoxCategory.Name = "checkedListBoxCategory";
|
||||||
checkedListBoxCategory.Size = new Size(273, 148);
|
checkedListBoxCategory.Size = new Size(149, 58);
|
||||||
checkedListBoxCategory.TabIndex = 18;
|
checkedListBoxCategory.TabIndex = 18;
|
||||||
//
|
//
|
||||||
|
// labelSurname
|
||||||
|
//
|
||||||
|
labelSurname.AutoSize = true;
|
||||||
|
labelSurname.Location = new Point(21, 66);
|
||||||
|
labelSurname.Name = "labelSurname";
|
||||||
|
labelSurname.Size = new Size(58, 15);
|
||||||
|
labelSurname.TabIndex = 10;
|
||||||
|
labelSurname.Text = "Фамилия";
|
||||||
|
//
|
||||||
|
// textBoxSurname
|
||||||
|
//
|
||||||
|
textBoxSurname.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
textBoxSurname.Location = new Point(117, 59);
|
||||||
|
textBoxSurname.Name = "textBoxSurname";
|
||||||
|
textBoxSurname.Size = new Size(149, 23);
|
||||||
|
textBoxSurname.TabIndex = 12;
|
||||||
|
//
|
||||||
// FormAgent
|
// FormAgent
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(549, 504);
|
ClientSize = new Size(301, 285);
|
||||||
Controls.Add(checkedListBoxCategory);
|
Controls.Add(checkedListBoxCategory);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(comboBoxQualification);
|
Controls.Add(comboBoxQualification);
|
||||||
|
Controls.Add(textBoxSurname);
|
||||||
Controls.Add(textBoxName);
|
Controls.Add(textBoxName);
|
||||||
Controls.Add(labelCategory);
|
Controls.Add(labelCategory);
|
||||||
|
Controls.Add(labelSurname);
|
||||||
Controls.Add(labelQualification);
|
Controls.Add(labelQualification);
|
||||||
Controls.Add(labelName);
|
Controls.Add(labelName);
|
||||||
Margin = new Padding(6, 6, 6, 6);
|
MinimumSize = new Size(317, 290);
|
||||||
MinimumSize = new Size(575, 575);
|
|
||||||
Name = "FormAgent";
|
Name = "FormAgent";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Агент-реализатор";
|
Text = "Агент-реализатор";
|
||||||
@ -154,5 +166,7 @@
|
|||||||
private Label labelQualification;
|
private Label labelQualification;
|
||||||
private Label labelName;
|
private Label labelName;
|
||||||
private CheckedListBox checkedListBoxCategory;
|
private CheckedListBox checkedListBoxCategory;
|
||||||
|
private Label labelSurname;
|
||||||
|
private TextBox textBoxSurname;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,6 +35,7 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
textBoxName.Text = agent.Name;
|
textBoxName.Text = agent.Name;
|
||||||
|
textBoxSurname.Text = agent.Surname;
|
||||||
comboBoxQualification.SelectedItem = agent.Qualification; foreach (Category elem in Enum.GetValues(typeof(Category)))
|
comboBoxQualification.SelectedItem = agent.Qualification; foreach (Category elem in Enum.GetValues(typeof(Category)))
|
||||||
{
|
{
|
||||||
if ((elem & agent.Category) != 0)
|
if ((elem & agent.Category) != 0)
|
||||||
@ -69,7 +70,8 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) || checkedListBoxCategory.CheckedItems.Count == 0 || comboBoxQualification.SelectedIndex < 1)
|
if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxSurname.Text) ||
|
||||||
|
checkedListBoxCategory.CheckedItems.Count == 0 || comboBoxQualification.SelectedIndex < 1)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля!");
|
throw new Exception("Имеются незаполненные поля!");
|
||||||
}
|
}
|
||||||
@ -101,7 +103,7 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
category |= (Category)elem;
|
category |= (Category)elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Agent.CreateEntity(id, textBoxName.Text, (Qualification)comboBoxQualification.SelectedItem,
|
return Agent.CreateEntity(id, textBoxName.Text, textBoxSurname.Text, (Qualification)comboBoxQualification.SelectedItem,
|
||||||
category);
|
category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,12 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _agentsRepository.ReadAgents();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _agentsRepository.ReadAgents();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["FullName"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdFromSelectedRow(out int id)
|
private bool TryGetIdFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
comboBoxPurchasingCompany.ValueMember = "Id";
|
comboBoxPurchasingCompany.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxAgent.DataSource = agentsRepository.ReadAgents();
|
comboBoxAgent.DataSource = agentsRepository.ReadAgents();
|
||||||
comboBoxAgent.DisplayMember = "Name";
|
comboBoxAgent.DisplayMember = "FullName";
|
||||||
comboBoxAgent.ValueMember = "Id";
|
comboBoxAgent.ValueMember = "Id";
|
||||||
|
|
||||||
ColumnProduct.DataSource = productRepository.ReadProducts();
|
ColumnProduct.DataSource = productRepository.ReadProducts();
|
||||||
|
@ -53,6 +53,11 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _contractRepository.ReadContracts();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _contractRepository.ReadContracts();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["SaleDate"].DefaultCellStyle.Format = "dd.MM.yyyy";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
comboBoxProduct.ValueMember = "Article";
|
comboBoxProduct.ValueMember = "Article";
|
||||||
|
|
||||||
comboBoxAgent.DataSource = agentsRepository.ReadAgents();
|
comboBoxAgent.DataSource = agentsRepository.ReadAgents();
|
||||||
comboBoxAgent.DisplayMember = "Name";
|
comboBoxAgent.DisplayMember = "FullName";
|
||||||
comboBoxAgent.ValueMember = "Id";
|
comboBoxAgent.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,11 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при добавлении!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _delegateToAgentRepository.ReadDelegatesToAgent();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _delegateToAgentRepository.ReadDelegatesToAgent();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["Date"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,11 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _productRepository.ReadProducts();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _productRepository.ReadProducts();
|
||||||
|
dataGridViewData.Columns["Article"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdFromSelectedRow(out int id)
|
private bool TryGetIdFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -97,8 +97,11 @@ namespace TradeAndProcurementEnterprice.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _companyRepository.ReadCompanies();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _companyRepository.ReadCompanies();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
private bool TryGetIdFromSelectedRow(out int id)
|
private bool TryGetIdFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -35,7 +35,7 @@ internal class TableReport
|
|||||||
{
|
{
|
||||||
new ExcelBuilder(filePath)
|
new ExcelBuilder(filePath)
|
||||||
.AddHeader("Сводка по передвижению товара", 0, 4)
|
.AddHeader("Сводка по передвижению товара", 0, 4)
|
||||||
.AddParagraph("За период", 0)
|
.AddParagraph($"За период с {startDate: dd.MM.yyyy} по {endDate: dd.MM.yyyy}", 0)
|
||||||
.AddTable([10, 10, 15, 15], GetData(productArticle, startDate, endDate))
|
.AddTable([10, 10, 15, 15], GetData(productArticle, startDate, endDate))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
@ -51,11 +51,10 @@ internal class TableReport
|
|||||||
private List<string[]> GetData(int productArticle, DateTime startDate, DateTime endDate)
|
private List<string[]> GetData(int productArticle, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = _contractRepository
|
var data = _contractRepository
|
||||||
.ReadContracts()
|
.ReadContracts(dateFrom: startDate, dateTo: endDate, productArticle: productArticle)
|
||||||
.Where(x => x.SaleDate >= startDate && x.SaleDate <= endDate && x.ProductSales.Any(y => y.ProductArticle == productArticle))
|
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
x.AgentsID,
|
x.AgentsName,
|
||||||
CurrentDate = x.SaleDate,
|
CurrentDate = x.SaleDate,
|
||||||
CountIn = (int?)null,
|
CountIn = (int?)null,
|
||||||
CountOut = x.ProductSales.FirstOrDefault(y => y.ProductArticle == productArticle)?.ProductQuantity
|
CountOut = x.ProductSales.FirstOrDefault(y => y.ProductArticle == productArticle)?.ProductQuantity
|
||||||
@ -66,7 +65,7 @@ internal class TableReport
|
|||||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.ProductArticle == productArticle)
|
.Where(x => x.Date >= startDate && x.Date <= endDate && x.ProductArticle == productArticle)
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
x.AgentsID,
|
x.AgentsName,
|
||||||
CurrentDate = x.Date,
|
CurrentDate = x.Date,
|
||||||
CountIn = (int?)x.Quantity,
|
CountIn = (int?)x.Quantity,
|
||||||
CountOut = (int?)null
|
CountOut = (int?)null
|
||||||
|
@ -10,7 +10,7 @@ namespace TradeAndProcurementEnterprice.Repositories;
|
|||||||
public interface IContractRepository
|
public interface IContractRepository
|
||||||
{
|
{
|
||||||
IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null,
|
IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null,
|
||||||
int? productArticle = null, int? agentID = null, int? purchasingCompaniID = null);
|
int? productArticle = null, int? agentID = null, int? purchasingCompanyID = null);
|
||||||
|
|
||||||
void CreateContract(Contract contract);
|
void CreateContract(Contract contract);
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ internal class AgentsRepository : IAgentsRepository
|
|||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Agents (Name, Qualification, Category)
|
INSERT INTO Agents (Name, Surname, Qualification, Category)
|
||||||
VALUES (@Name, @Qualification, @Category)";
|
VALUES (@Name, @Surname, @Qualification, @Category)";
|
||||||
connection.Execute(queryInsert, agent);
|
connection.Execute(queryInsert, agent);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -118,6 +118,7 @@ WHERE Id=@id";
|
|||||||
UPDATE Agents
|
UPDATE Agents
|
||||||
SET
|
SET
|
||||||
Name=@Name,
|
Name=@Name,
|
||||||
|
Surname=@Surname,
|
||||||
Qualification=@Qualification,
|
Qualification=@Qualification,
|
||||||
Category=@Category
|
Category=@Category
|
||||||
WHERE Id=@Id";
|
WHERE Id=@Id";
|
||||||
|
@ -57,20 +57,75 @@ VALUES (@ID, @ProductArticle, @ProductQuantity)";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, int? productArticle = null, int? agentID = null, int? purchasingCompaniID = null)
|
public IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, int? productArticle = null,
|
||||||
|
int? agentID = null, int? purchasingCompanyID = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов.");
|
_logger.LogInformation("Получение всех объектов.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var builder = new QueryBuilder();
|
||||||
|
if (dateFrom.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("c.SaleDate >= @dateForm");
|
||||||
|
}
|
||||||
|
if (dateTo.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("c.SaleDate <= @dateTo");
|
||||||
|
}
|
||||||
|
if (productArticle.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("c.ProductArticle = @productArticle");
|
||||||
|
}
|
||||||
|
if (agentID.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("c.AgentsId = @agentsID");
|
||||||
|
}
|
||||||
|
if (purchasingCompanyID.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("c.PurchasingCompanyID = @purchasingCompanyID");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @$"
|
||||||
SELECT c.*, ps.ProductArticle, ps.ProductQuantity FROM Contracts c
|
SELECT
|
||||||
INNER JOIN ProductSales ps ON ps.ID = c.ID";
|
c.*,
|
||||||
var contracts = connection.Query<TempProductSales>(querySelect);
|
CONCAT(a.Name, ' ', a.Surname) as AgentsName,
|
||||||
|
pc.Name as CompanyName,
|
||||||
|
ps.ProductArticle,
|
||||||
|
ps.ProductQuantity,
|
||||||
|
p.Name as ProductName
|
||||||
|
FROM Contracts c
|
||||||
|
LEFT JOIN Agents a on a.Id = c.AgentsId
|
||||||
|
LEFT JOIN purchasingcompanies pc on pc.Id = c.PurchasingCompanyID
|
||||||
|
INNER JOIN ProductSales ps ON ps.ID = c.ID
|
||||||
|
LEFT JOIN Products p on p.Article = ps.ProductArticle
|
||||||
|
{builder.Build()}";
|
||||||
|
|
||||||
|
var salesDict = new Dictionary<int, List<ProductSales>>();
|
||||||
|
|
||||||
|
var contracts = connection.Query<Contract, ProductSales, Contract>(querySelect,
|
||||||
|
(sales, contract) =>
|
||||||
|
{
|
||||||
|
if (!salesDict.TryGetValue(sales.ID, out var ps))
|
||||||
|
{
|
||||||
|
ps = [];
|
||||||
|
salesDict.Add(sales.ID, ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
ps.Add(contract);
|
||||||
|
return sales;
|
||||||
|
}, splitOn: "ProductArticle", param: new { dateFrom, dateTo, productArticle, agentID, purchasingCompanyID });
|
||||||
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(contracts));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(contracts));
|
||||||
return contracts.GroupBy(x => x.ID, y => y,
|
|
||||||
(key, value) => Contract.CreateOperation(value.First(),
|
return salesDict.Select(x =>
|
||||||
value.Select(z => ProductSales.CreateElement(0, z.ProductArticle, z.ProductQuantity)))).ToList();
|
{
|
||||||
|
var c = contracts.First(y => y.ID == x.Key);
|
||||||
|
c.SetProductSales(x.Value);
|
||||||
|
return c;
|
||||||
|
}).ToArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -43,13 +43,38 @@ VALUES (@ProductArticle, @AgentsID, @Quantity, @Date)";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<DelegateToAgents> ReadDelegatesToAgent(DateTime? dateFrom = null, DateTime? dateTo = null, int? productArticle = null, int? agentID = null)
|
public IEnumerable<DelegateToAgents> ReadDelegatesToAgent(DateTime? dateFrom = null, DateTime? dateTo = null,
|
||||||
|
int? productArticle = null, int? agentID = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов.");
|
_logger.LogInformation("Получение всех объектов.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
/*var builder = new QueryBuilder();
|
||||||
|
if (dateFrom.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("dta.Date >= @dateFrom"); }
|
||||||
|
if (dateTo.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("dta.Date <= @dateTo");
|
||||||
|
}
|
||||||
|
if (productArticle.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("dta.ProductArticle = @productArticle");
|
||||||
|
}
|
||||||
|
if (agentID.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("dta.AgentsId = @agentsID");
|
||||||
|
}*/
|
||||||
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM DelegateToAgents";
|
var querySelect = @$"SELECT
|
||||||
|
dta.*,
|
||||||
|
p.Name as ProductName,
|
||||||
|
CONCAT(a.Name, ' ', a.Surname) as AgentsName
|
||||||
|
FROM DelegateToAgents dta
|
||||||
|
LEFT JOIN Agents a on a.Id = dta.AgentsId
|
||||||
|
LEFT JOIN Products p on p.Article = dta.ProductArticle";
|
||||||
|
//{builder.Build()}";
|
||||||
var delegatesToAgents = connection.Query<DelegateToAgents>(querySelect);
|
var delegatesToAgents = connection.Query<DelegateToAgents>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(delegatesToAgents));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(delegatesToAgents));
|
||||||
return delegatesToAgents;
|
return delegatesToAgents;
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TradeAndProcurementEnterprice.Repositories.Implementations;
|
||||||
|
|
||||||
|
internal class QueryBuilder
|
||||||
|
{
|
||||||
|
private readonly StringBuilder _builder;
|
||||||
|
|
||||||
|
public QueryBuilder()
|
||||||
|
{
|
||||||
|
_builder = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryBuilder AddCondition(string condition)
|
||||||
|
{
|
||||||
|
if (_builder.Length > 0)
|
||||||
|
{
|
||||||
|
_builder.Append(" AND ");
|
||||||
|
}
|
||||||
|
_builder.Append(condition);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Build()
|
||||||
|
{
|
||||||
|
if (_builder.Length == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"WHERE {_builder}";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user