PIbd-24 Antonova A.A. LabWork_4 #4
@ -1,6 +1,7 @@
|
||||
using ProjectCompanyFurniture.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -11,10 +12,13 @@ public class Client
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string Name { get; private set; }
|
||||
|
||||
[DisplayName("Тип клиента")]
|
||||
public ClientType ClientType { get; private set; }
|
||||
|
||||
[DisplayName("Оптовик")]
|
||||
public bool Optovik { get; private set; }
|
||||
|
||||
public static Client CreateEntity(int id, string name, ClientType clientType, bool optovik)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,17 +11,29 @@ public class Invoice
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int ClientID { get; set; }
|
||||
|
||||
[DisplayName("Клиент")]
|
||||
public string ClientName { get; set; }
|
||||
|
||||
// 0 или 1
|
||||
[DisplayName("Наличие промокода")]
|
||||
public int AvailabilityOfPromotionalCode { get; set; }
|
||||
|
||||
[DisplayName("Процент скидки")]
|
||||
public int DiscountPercentage { get; set; }
|
||||
|
||||
[DisplayName("Отпускная цена")]
|
||||
public int SellingPrice { get; set; }
|
||||
|
||||
[DisplayName("Дата")]
|
||||
public DateTime DateInvoice { get; set; }
|
||||
|
||||
[DisplayName("Продукты")]
|
||||
public string Product => Products != null ?
|
||||
string.Join(", ", Products.Select(x => $"{x.ProductName} {x.Count}")) : string.Empty;
|
||||
|
||||
public IEnumerable<InvoiceProduct> Products
|
||||
{
|
||||
get;
|
||||
|
@ -11,6 +11,8 @@ public class InvoiceProduct
|
||||
public int InvoiceID { get; private set; }
|
||||
|
||||
public int ProductID { get; private set; }
|
||||
|
||||
public string ProductName { get; private set; } = string.Empty;
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,6 +11,7 @@ public class Manufacturer
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
[DisplayName("Название фирмы")]
|
||||
public string Name { get; set; }
|
||||
|
||||
public static Manufacturer CreateEntity(int iD, string name)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,12 +11,21 @@ public class Product
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int ManufacturerID { get; private set; }
|
||||
|
||||
[DisplayName("Фирма")]
|
||||
public string ManufacturerName { get; private set; }
|
||||
|
||||
[DisplayName("Название товара")]
|
||||
public string Name { get; private set; }
|
||||
|
||||
[DisplayName("Производитель")]
|
||||
public string Category { get; private set; }
|
||||
|
||||
public string FullName => $"{Category} {Name}";
|
||||
|
||||
[DisplayName("Начальная цена")]
|
||||
public int StartingPrice { get; private set; }
|
||||
|
||||
public static Product CreateEntity(int id, int manufacturerID, string name, string category, int startingPrice)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using ProjectCompanyFurniture.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -11,12 +12,16 @@ public class ProductMovement
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
[DisplayName("Товар")]
|
||||
public int ProductID { get; private set; }
|
||||
|
||||
[DisplayName("Тип движения товара")]
|
||||
public Movement MovementType { get; private set; }
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; private set; }
|
||||
|
||||
[DisplayName("Дата")]
|
||||
public DateTime Date { get; private set; }
|
||||
|
||||
public static ProductMovement CreateOperation (int it, int productId, int count, Movement movementType)
|
||||
|
@ -28,7 +28,7 @@ namespace ProjectCompanyFurniture.Forms
|
||||
comboBoxClient.ValueMember = "ID";
|
||||
|
||||
ColumnProduct.DataSource = productRepository.ReadProducts();
|
||||
ColumnProduct.DisplayMember = "Name";
|
||||
ColumnProduct.DisplayMember = "FullName";
|
||||
ColumnProduct.ValueMember = "ID";
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,10 @@ public class ExcelBuilder
|
||||
|
||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header,
|
||||
StyleIndex.SimpleTextWithoutBorder);
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.BoldTextWithoutBorder);
|
||||
}
|
||||
_mergeCells.Append(new MergeCell()
|
||||
{
|
||||
@ -79,7 +78,7 @@ public class ExcelBuilder
|
||||
}));
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.SimpleTextWithoutBorder);
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
for (var i = 1; i < data.Count - 1; ++i)
|
||||
@ -208,8 +207,8 @@ public class ExcelBuilder
|
||||
{
|
||||
NumberFormatId = 1,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
@ -222,8 +221,8 @@ public class ExcelBuilder
|
||||
{
|
||||
NumberFormatId = 2,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
@ -254,7 +253,7 @@ public class ExcelBuilder
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorder = 1,
|
||||
BoldTextWithoutBorder = 2,
|
||||
BoldTextWithBorder = 3,
|
||||
BoldTextWithBorder = 3
|
||||
}
|
||||
|
||||
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||
|
@ -31,7 +31,7 @@ public class TableReport
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по движению товара", 0, 4)
|
||||
.AddParagraph("за период", 0)
|
||||
.AddParagraph("За период", 0)
|
||||
.AddTable([10, 10, 15, 15], GetData(productID, startDate, endDate))
|
||||
.Build();
|
||||
return true;
|
||||
|
@ -82,8 +82,10 @@ public class InvoiceRepository : IInvoiceRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT inv.*, ipr.ProductID, ipr.Count FROM Invoices inv
|
||||
INNER JOIN InvoiceProducts ipr ON ipr.InvoiceID = inv.ID";
|
||||
var querySelect = @"SELECT inv.*, cl.Name as ClientName, ipr.ProductID, ipr.Count
|
||||
FROM Invoices inv
|
||||
INNER JOIN InvoiceProducts ipr ON ipr.InvoiceID = inv.ID
|
||||
INNER JOIN Clients cl ON inv.ClientID = cl.ID";
|
||||
var invoices = connection.Query<TempInvoiceProduct>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(invoices));
|
||||
return invoices.GroupBy(x => x.ID, y => y,
|
||||
|
@ -110,7 +110,9 @@ public class ProductRepository : IProductRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Products";
|
||||
var querySelect = @"SELECT pr.*, man.Name as ManufacturerName
|
||||
FROM Products pr
|
||||
INNER JOIN Manufacturers man ON pr.ManufacturerID = man.ID";
|
||||
var products = connection.Query<Product>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(products));
|
||||
|
Loading…
x
Reference in New Issue
Block a user