Merge branch 'main' of https://git.is.ulstu.ru/mfnefd/PIAPS_CW
This commit is contained in:
commit
e1673bca2c
@ -13,8 +13,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BarCode" Version="2024.6.1" />
|
<PackageReference Include="BarCode" Version="2024.6.1" />
|
||||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||||
|
<PackageReference Include="IronPrint" Version="2024.6.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -10,10 +10,11 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
public class BarcodeLogic
|
public class BarcodeLogic
|
||||||
{
|
{
|
||||||
public GeneratedBarcode CreateBarcode(ProductBindingModel model)
|
public GeneratedBarcode CreateBarcode(ProductBindingModel model, bool save)
|
||||||
{
|
{
|
||||||
var barCode = IronBarCode.BarcodeWriter.CreateBarcode(model.Id.ToString(), BarcodeEncoding.Code128);
|
var barCode = IronBarCode.BarcodeWriter.CreateBarcode(model.Id.ToString(), BarcodeEncoding.Code128);
|
||||||
return barCode.SaveAsPng($"product{model.Id}.png");
|
if (save) return barCode.SaveAsPng($"product{model.Id}.png");
|
||||||
|
return barCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
74
BusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
74
BusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using BusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using BusinessLogic.OfficePackage;
|
||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.BusinessLogicContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
|
||||||
|
namespace BusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class ReportLogic : IReportLogic
|
||||||
|
{
|
||||||
|
private readonly IProductStorage _productStorage;
|
||||||
|
private readonly ISupplyStorage _supplyStorage;
|
||||||
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
public ReportLogic(IProductStorage productStorage, ISupplyStorage supplyStorage, AbstractSaveToPdf saveToPdf)
|
||||||
|
{
|
||||||
|
_productStorage = productStorage;
|
||||||
|
_supplyStorage = supplyStorage;
|
||||||
|
_saveToPdf = saveToPdf;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка компонент с указанием, в каких изделиях используются
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ReportSupplyProductViewModel> GetSupplyProduct()
|
||||||
|
{
|
||||||
|
var products = _productStorage.GetFullList();
|
||||||
|
var supplies = _supplyStorage.GetFullList();
|
||||||
|
var list = new List<ReportSupplyProductViewModel>();
|
||||||
|
foreach (var supply in supplies)
|
||||||
|
{
|
||||||
|
var record = new ReportSupplyProductViewModel
|
||||||
|
{
|
||||||
|
SupplyName = supply.Name,
|
||||||
|
Products = new List<Tuple<string, int>>(),
|
||||||
|
TotalCount = 0
|
||||||
|
};
|
||||||
|
foreach (var product in products)
|
||||||
|
{
|
||||||
|
if (supply.Products.ContainsKey(product.Id))
|
||||||
|
{
|
||||||
|
record.Products.Add(new Tuple<string, int>(product.Name, supply.Products[product.Id].Item2));
|
||||||
|
record.TotalCount += supply.Products[product.Id].Item2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.Add(record);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение заказов в файл-Pdf
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
public void SaveSuppliesToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToPdf.CreateDoc(new PdfInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Накладная",
|
||||||
|
Date = model.Date!.Value,
|
||||||
|
Supply = _supplyStorage.GetElement(new SupplySearchModel()
|
||||||
|
{
|
||||||
|
Id = model.SupplyId,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -111,6 +111,14 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.Status = newStatus;
|
model.Status = newStatus;
|
||||||
|
if (newStatus == SupplyStatus.Arriving)
|
||||||
|
{
|
||||||
|
model.DateArriving = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
if (newStatus == SupplyStatus.Completed)
|
||||||
|
{
|
||||||
|
model.DateComplete = DateTime.UtcNow;
|
||||||
|
}
|
||||||
if (_supplyStorage.Update(model) == null)
|
if (_supplyStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status--;
|
model.Status--;
|
||||||
|
80
BusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
80
BusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using BusinessLogic.BusinessLogic;
|
||||||
|
using BusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using BusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public abstract class AbstractSaveToPdf
|
||||||
|
{
|
||||||
|
public void CreateDoc(PdfInfo info)
|
||||||
|
{
|
||||||
|
CreatePdf(info);
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"{info.Title}\nОт {DateTime.UtcNow}",
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
string dateArriving = info.Supply.DateArriving.HasValue ? info.Supply.DateArriving.ToString() : "-";
|
||||||
|
string dateComplete = info.Supply.DateComplete.HasValue ? info.Supply.DateComplete.ToString() : "-";
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"Поставщик: {info.Supply.SupplierName}\nДата создания поставки: {info.Supply.Date}\nДата отправления поставки: {dateArriving}\nДата получения поставки: {dateComplete}\nСтатус: {info.Supply.Status}",
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||||
|
});
|
||||||
|
CreateTable(new List<string> { "5cm", "10cm"});
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Id", "Информация" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { info.Supply.Id.ToString(), info.Supply.Name, },
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = "Товары",
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
CreateTable(new List<string> { "5cm", "5cm", "3cm", "2cm" });
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Id", "Название", "Цена", "Кол-во" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
foreach (var product in info.Supply.Products.Values)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { product.Item1.Id.ToString(), product.Item1.Name, product.Item1.Price.ToString(), product.Item2.ToString() },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"Итого: {info.Supply.Price}",
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||||
|
});
|
||||||
|
SavePdf(info);
|
||||||
|
}
|
||||||
|
protected abstract void CreatePdf(PdfInfo info);
|
||||||
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||||
|
protected abstract void CreateTable(List<string> columns);
|
||||||
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||||
|
protected abstract void CreateImage(string path);
|
||||||
|
protected abstract void SavePdf(PdfInfo info);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BusinessLogic.OfficePackage.HelperEnums
|
||||||
|
{
|
||||||
|
public enum PdfParagraphAlignmentType
|
||||||
|
{
|
||||||
|
Center,
|
||||||
|
Left,
|
||||||
|
Right
|
||||||
|
}
|
||||||
|
}
|
17
BusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
Normal file
17
BusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
public SupplyViewModel Supply { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
16
BusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
Normal file
16
BusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfParagraph
|
||||||
|
{
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
public string Style { get; set; } = string.Empty;
|
||||||
|
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
BusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
Normal file
16
BusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using BusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfRowParameters
|
||||||
|
{
|
||||||
|
public List<string> Texts { get; set; } = new();
|
||||||
|
public string Style { get; set; } = string.Empty;
|
||||||
|
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
111
BusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
111
BusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using BusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using BusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.DocumentObjectModel.Shapes;
|
||||||
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BusinessLogic.OfficePackage.Implements
|
||||||
|
{
|
||||||
|
public class SaveToPdf : AbstractSaveToPdf
|
||||||
|
{
|
||||||
|
private Document? _document;
|
||||||
|
private Section? _section;
|
||||||
|
private Table? _table;
|
||||||
|
private Image _image;
|
||||||
|
private static ParagraphAlignment
|
||||||
|
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||||
|
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||||
|
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||||
|
_ => ParagraphAlignment.Justify,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Создание стилей для документа
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="document"></param>
|
||||||
|
private static void DefineStyles(Document document)
|
||||||
|
{
|
||||||
|
var style = document.Styles["Normal"];
|
||||||
|
style.Font.Name = "Times New Roman";
|
||||||
|
style.Font.Size = 14;
|
||||||
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
|
style.Font.Bold = true;
|
||||||
|
}
|
||||||
|
protected override void CreatePdf(PdfInfo info)
|
||||||
|
{
|
||||||
|
_document = new Document();
|
||||||
|
DefineStyles(_document);
|
||||||
|
_section = _document.AddSection();
|
||||||
|
}
|
||||||
|
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||||
|
{
|
||||||
|
if (_section == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||||
|
paragraph.Format.SpaceAfter = "1cm";
|
||||||
|
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||||
|
paragraph.Style = pdfParagraph.Style;
|
||||||
|
}
|
||||||
|
protected override void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (_document == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_table = _document.LastSection.AddTable();
|
||||||
|
foreach (var elem in columns)
|
||||||
|
{
|
||||||
|
_table.AddColumn(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (_table == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var row = _table.AddRow();
|
||||||
|
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||||
|
{
|
||||||
|
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||||
|
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||||
|
{
|
||||||
|
row.Cells[i].Style = rowParameters.Style;
|
||||||
|
}
|
||||||
|
Unit borderWidth = 0.5;
|
||||||
|
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||||
|
row.Cells[i].Format.Alignment =
|
||||||
|
GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||||
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected override void CreateImage(string path)
|
||||||
|
{
|
||||||
|
if (_document == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_document.LastSection.AddImage(path);
|
||||||
|
}
|
||||||
|
protected override void SavePdf(PdfInfo info)
|
||||||
|
{
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = _document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(info.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Contracts/BindingModels/ReportBindingModel.cs
Normal file
15
Contracts/BindingModels/ReportBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ReportBindingModel
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
public Guid SupplyId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,8 @@ namespace Contracts.BindingModels
|
|||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public Guid SupplierId { get; set; }
|
public Guid SupplierId { get; set; }
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
public DateTime? DateArriving { get; set; }
|
||||||
|
public DateTime? DateComplete { get; set; }
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public SupplyStatus Status { get; set; }
|
public SupplyStatus Status { get; set; }
|
||||||
public Dictionary<Guid, (IProduct, int)> SupplyProducts { get; set; } = new();
|
public Dictionary<Guid, (IProduct, int)> SupplyProducts { get; set; } = new();
|
||||||
|
24
Contracts/BusinessLogicContracts/IReportLogic.cs
Normal file
24
Contracts/BusinessLogicContracts/IReportLogic.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IReportLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка компонент с указанием, в каких изделиях используются
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<ReportSupplyProductViewModel> GetSupplyProduct();
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение заказов в файл-Pdf
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
void SaveSuppliesToPdfFile(ReportBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
15
Contracts/ViewModels/ReportSupplyProductViewModel.cs
Normal file
15
Contracts/ViewModels/ReportSupplyProductViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportSupplyProductViewModel
|
||||||
|
{
|
||||||
|
public string SupplyName { get; set; } = string.Empty;
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
public List<Tuple<string, int>> Products { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
17
Contracts/ViewModels/ReportSupplyViewModel.cs
Normal file
17
Contracts/ViewModels/ReportSupplyViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportSupplyViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public double Price { get; set; }
|
||||||
|
public String Status { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,8 @@ namespace Contracts.ViewModels
|
|||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public Dictionary<Guid, (IProduct, int)> Products { get; set; } = new();
|
public Dictionary<Guid, (IProduct, int)> Products { get; set; } = new();
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
public DateTime? DateArriving { get; set; }
|
||||||
|
public DateTime? DateComplete { get; set; }
|
||||||
public SupplyStatus Status { get; set; }
|
public SupplyStatus Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ namespace DataModels.Models
|
|||||||
double Price { get; }
|
double Price { get; }
|
||||||
Guid SupplierId { get; }
|
Guid SupplierId { get; }
|
||||||
DateTime Date { get; }
|
DateTime Date { get; }
|
||||||
|
DateTime? DateArriving { get; }
|
||||||
|
DateTime? DateComplete { get; }
|
||||||
SupplyStatus Status { get; }
|
SupplyStatus Status { get; }
|
||||||
Dictionary<Guid, (IProduct, int)> SupplyProducts { get; }
|
Dictionary<Guid, (IProduct, int)> SupplyProducts { get; }
|
||||||
}
|
}
|
||||||
|
496
DatabaseImplement/Migrations/20240625085945_dates_migration.Designer.cs
generated
Normal file
496
DatabaseImplement/Migrations/20240625085945_dates_migration.Designer.cs
generated
Normal file
@ -0,0 +1,496 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
[Migration("20240625085945_dates_migration")]
|
||||||
|
partial class dates_migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.6")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Location")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProductId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("MediaFiles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Amount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<bool>("IsBeingSold")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<double>("Rate")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DatePurchase")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Purchases");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProductId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("PurchaseId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.HasIndex("PurchaseId");
|
||||||
|
|
||||||
|
b.ToTable("PurchaseProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Roles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateSell")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid?>("UserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("Sells");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProductId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SellId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.HasIndex("SellId");
|
||||||
|
|
||||||
|
b.ToTable("SellProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Deals")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Suppliers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProductId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SupplierId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.HasIndex("SupplierId");
|
||||||
|
|
||||||
|
b.ToTable("SupplierProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateArriving")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateComplete")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid>("SupplierId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SupplierId");
|
||||||
|
|
||||||
|
b.ToTable("Supplies");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SupplyId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("SupplyDocs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProductId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SupplyId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.HasIndex("SupplyId");
|
||||||
|
|
||||||
|
b.ToTable("SupplyProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Birthday")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("OnlyImportantMails")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid?>("RoleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("SecondName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("PurchaseProducts")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Purchase", "Purchase")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("PurchaseId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Purchase");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("SellProducts")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Sell", "Sell")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("SellId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Sell");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("SupplierId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Supplier");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Supplier", "Supplier")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("SupplierId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Supplier");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DatabaseImplement.Models.Supply", "Supply")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("SupplyId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
|
||||||
|
b.Navigation("Supply");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Role", "Role")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId");
|
||||||
|
|
||||||
|
b.Navigation("Role");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("PurchaseProducts");
|
||||||
|
|
||||||
|
b.Navigation("SellProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class dates_migration : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "DateArriving",
|
||||||
|
table: "Supplies",
|
||||||
|
type: "timestamp with time zone",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "DateComplete",
|
||||||
|
table: "Supplies",
|
||||||
|
type: "timestamp with time zone",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_MediaFiles_ProductId",
|
||||||
|
table: "MediaFiles",
|
||||||
|
column: "ProductId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_MediaFiles_Products_ProductId",
|
||||||
|
table: "MediaFiles",
|
||||||
|
column: "ProductId",
|
||||||
|
principalTable: "Products",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_MediaFiles_Products_ProductId",
|
||||||
|
table: "MediaFiles");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_MediaFiles_ProductId",
|
||||||
|
table: "MediaFiles");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DateArriving",
|
||||||
|
table: "Supplies");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DateComplete",
|
||||||
|
table: "Supplies");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -41,6 +41,8 @@ namespace DatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
b.ToTable("MediaFiles");
|
b.ToTable("MediaFiles");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -226,6 +228,12 @@ namespace DatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("Date")
|
b.Property<DateTime>("Date")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateArriving")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateComplete")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@ -326,6 +334,17 @@ namespace DatabaseImplement.Migrations
|
|||||||
b.ToTable("Users");
|
b.ToTable("Users");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.MediaFile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("DatabaseImplement.Models.User", "User")
|
b.HasOne("DatabaseImplement.Models.User", "User")
|
||||||
|
@ -25,6 +25,8 @@ namespace DatabaseImplement.Models
|
|||||||
public Guid SupplierId { get; set; }
|
public Guid SupplierId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
public DateTime? DateArriving { get; private set; }
|
||||||
|
public DateTime? DateComplete { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
public SupplyStatus Status { get; set; } = SupplyStatus.Pending;
|
public SupplyStatus Status { get; set; } = SupplyStatus.Pending;
|
||||||
private Dictionary<Guid, (IProduct, int)>? _supplyProducts = null;
|
private Dictionary<Guid, (IProduct, int)>? _supplyProducts = null;
|
||||||
@ -53,6 +55,8 @@ namespace DatabaseImplement.Models
|
|||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Price = model.Price,
|
Price = model.Price,
|
||||||
Date = model.Date,
|
Date = model.Date,
|
||||||
|
DateArriving = model.DateArriving,
|
||||||
|
DateComplete = model.DateComplete,
|
||||||
SupplierId = model.SupplierId,
|
SupplierId = model.SupplierId,
|
||||||
Products = model.SupplyProducts.Select(x => new
|
Products = model.SupplyProducts.Select(x => new
|
||||||
SupplyProduct
|
SupplyProduct
|
||||||
@ -66,6 +70,8 @@ namespace DatabaseImplement.Models
|
|||||||
public void Update(SupplyBindingModel model)
|
public void Update(SupplyBindingModel model)
|
||||||
{
|
{
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
|
DateArriving = model.DateArriving;
|
||||||
|
DateComplete = model.DateComplete;
|
||||||
}
|
}
|
||||||
public SupplyViewModel GetViewModel
|
public SupplyViewModel GetViewModel
|
||||||
{
|
{
|
||||||
@ -80,6 +86,8 @@ namespace DatabaseImplement.Models
|
|||||||
Products = SupplyProducts,
|
Products = SupplyProducts,
|
||||||
SupplierId = SupplierId,
|
SupplierId = SupplierId,
|
||||||
Date = Date,
|
Date = Date,
|
||||||
|
DateArriving = DateArriving,
|
||||||
|
DateComplete = DateComplete,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
SupplierName = Supplier.Name,
|
SupplierName = Supplier.Name,
|
||||||
};
|
};
|
||||||
|
58
WinFormsApp/FormMain.Designer.cs
generated
58
WinFormsApp/FormMain.Designer.cs
generated
@ -28,6 +28,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateSupply = new Button();
|
buttonCreateSupply = new Button();
|
||||||
menuStrip1 = new MenuStrip();
|
menuStrip1 = new MenuStrip();
|
||||||
@ -35,6 +36,11 @@
|
|||||||
поставщикиToolStripMenuItem = new ToolStripMenuItem();
|
поставщикиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
buttonSupplyStatusArriving = new Button();
|
buttonSupplyStatusArriving = new Button();
|
||||||
buttonSupplyStatusCompleted = new Button();
|
buttonSupplyStatusCompleted = new Button();
|
||||||
|
buttonCreateReport = new Button();
|
||||||
|
buttonPrintReport = new Button();
|
||||||
|
printPreviewDialog = new PrintPreviewDialog();
|
||||||
|
printDialog = new PrintDialog();
|
||||||
|
buttonRefresh = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -101,11 +107,58 @@
|
|||||||
buttonSupplyStatusCompleted.UseVisualStyleBackColor = true;
|
buttonSupplyStatusCompleted.UseVisualStyleBackColor = true;
|
||||||
buttonSupplyStatusCompleted.Click += buttonSupplyStatusCompleted_Click;
|
buttonSupplyStatusCompleted.Click += buttonSupplyStatusCompleted_Click;
|
||||||
//
|
//
|
||||||
|
// buttonCreateReport
|
||||||
|
//
|
||||||
|
buttonCreateReport.Location = new Point(707, 190);
|
||||||
|
buttonCreateReport.Name = "buttonCreateReport";
|
||||||
|
buttonCreateReport.Size = new Size(154, 44);
|
||||||
|
buttonCreateReport.TabIndex = 5;
|
||||||
|
buttonCreateReport.Text = "Сформировать отчет о поставке";
|
||||||
|
buttonCreateReport.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateReport.Click += buttonCreateReport_Click;
|
||||||
|
//
|
||||||
|
// buttonPrintReport
|
||||||
|
//
|
||||||
|
buttonPrintReport.Location = new Point(707, 261);
|
||||||
|
buttonPrintReport.Name = "buttonPrintReport";
|
||||||
|
buttonPrintReport.Size = new Size(154, 44);
|
||||||
|
buttonPrintReport.TabIndex = 6;
|
||||||
|
buttonPrintReport.Text = "Распечатать отчет";
|
||||||
|
buttonPrintReport.UseVisualStyleBackColor = true;
|
||||||
|
buttonPrintReport.Click += buttonPrintReport_Click;
|
||||||
|
//
|
||||||
|
// printPreviewDialog
|
||||||
|
//
|
||||||
|
printPreviewDialog.AutoScrollMargin = new Size(0, 0);
|
||||||
|
printPreviewDialog.AutoScrollMinSize = new Size(0, 0);
|
||||||
|
printPreviewDialog.ClientSize = new Size(400, 300);
|
||||||
|
printPreviewDialog.Enabled = true;
|
||||||
|
printPreviewDialog.Icon = (Icon)resources.GetObject("printPreviewDialog.Icon");
|
||||||
|
printPreviewDialog.Name = "printPreviewDialog";
|
||||||
|
printPreviewDialog.Visible = false;
|
||||||
|
//
|
||||||
|
// printDialog
|
||||||
|
//
|
||||||
|
printDialog.UseEXDialog = true;
|
||||||
|
//
|
||||||
|
// buttonRefresh
|
||||||
|
//
|
||||||
|
buttonRefresh.Location = new Point(707, 325);
|
||||||
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
|
buttonRefresh.Size = new Size(154, 47);
|
||||||
|
buttonRefresh.TabIndex = 7;
|
||||||
|
buttonRefresh.Text = "Обновить";
|
||||||
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefresh.Click += buttonRefresh_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(901, 384);
|
ClientSize = new Size(901, 384);
|
||||||
|
Controls.Add(buttonRefresh);
|
||||||
|
Controls.Add(buttonPrintReport);
|
||||||
|
Controls.Add(buttonCreateReport);
|
||||||
Controls.Add(buttonSupplyStatusCompleted);
|
Controls.Add(buttonSupplyStatusCompleted);
|
||||||
Controls.Add(buttonSupplyStatusArriving);
|
Controls.Add(buttonSupplyStatusArriving);
|
||||||
Controls.Add(buttonCreateSupply);
|
Controls.Add(buttonCreateSupply);
|
||||||
@ -131,5 +184,10 @@
|
|||||||
private ToolStripMenuItem поставщикиToolStripMenuItem;
|
private ToolStripMenuItem поставщикиToolStripMenuItem;
|
||||||
private Button buttonSupplyStatusArriving;
|
private Button buttonSupplyStatusArriving;
|
||||||
private Button buttonSupplyStatusCompleted;
|
private Button buttonSupplyStatusCompleted;
|
||||||
|
private Button buttonCreateReport;
|
||||||
|
private Button buttonPrintReport;
|
||||||
|
private PrintPreviewDialog printPreviewDialog;
|
||||||
|
private PrintDialog printDialog;
|
||||||
|
private Button buttonRefresh;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,8 +8,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Printing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@ -22,13 +25,15 @@ namespace WinFormsApp
|
|||||||
private readonly ISupplyLogic _supplyLogic;
|
private readonly ISupplyLogic _supplyLogic;
|
||||||
private readonly IProductLogic _productLogic;
|
private readonly IProductLogic _productLogic;
|
||||||
private readonly ISupplierLogic _supplierLogic;
|
private readonly ISupplierLogic _supplierLogic;
|
||||||
public FormMain(ILogger<FormMain> logger, ISupplierLogic supplierLogic, ISupplyLogic supplyLogic, IProductLogic productLogic)
|
private readonly IReportLogic _reportLogic;
|
||||||
|
public FormMain(ILogger<FormMain> logger, ISupplierLogic supplierLogic, ISupplyLogic supplyLogic, IProductLogic productLogic, IReportLogic reportLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_supplierLogic = supplierLogic;
|
_supplierLogic = supplierLogic;
|
||||||
_supplyLogic = supplyLogic;
|
_supplyLogic = supplyLogic;
|
||||||
_productLogic = productLogic;
|
_productLogic = productLogic;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_reportLogic = reportLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
@ -45,6 +50,8 @@ namespace WinFormsApp
|
|||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["SupplierId"].Visible = false;
|
||||||
|
dataGridView.Columns["Products"].Visible = false;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка поставок");
|
_logger.LogInformation("Загрузка поставок");
|
||||||
}
|
}
|
||||||
@ -120,7 +127,9 @@ namespace WinFormsApp
|
|||||||
var operationResult = _supplyLogic.StatusUpdate(new SupplyBindingModel
|
var operationResult = _supplyLogic.StatusUpdate(new SupplyBindingModel
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Status = (SupplyStatus)dataGridView.SelectedRows[0].Cells["Status"].Value
|
Status = (SupplyStatus)dataGridView.SelectedRows[0].Cells["Status"].Value,
|
||||||
|
DateArriving = (DateTime?)dataGridView.SelectedRows[0].Cells["DateArriving"].Value,
|
||||||
|
DateComplete = (DateTime?)dataGridView.SelectedRows[0].Cells["DateComplete"].Value,
|
||||||
}, SupplyStatus.Completed);
|
}, SupplyStatus.Completed);
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
@ -136,5 +145,55 @@ namespace WinFormsApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonCreateReport_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count != 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите одну поставку для формирования отчета", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveSuppliesToPdfFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = $"supplyreport{dataGridView.SelectedRows[0].Cells["Id"].Value}.pdf",
|
||||||
|
Date = (DateTime)dataGridView.SelectedRows[0].Cells["Date"].Value,
|
||||||
|
SupplyId = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение отчета о поставке");
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения отчета о поставке");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonPrintReport_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count != 1) return;
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormPreviewPDF));
|
||||||
|
if (service is FormPreviewPDF form)
|
||||||
|
{
|
||||||
|
var src = $"supplyreport{dataGridView.SelectedRows[0].Cells["Id"].Value}.pdf";
|
||||||
|
if (!File.Exists(src))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Отчёт о поставке не был найден. Сначала сформируйте отчёт по выбранной поставке.", "Ошибка");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
form.src = System.IO.Path.GetFullPath(src);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
IronPrint.Printer.PrintAsync(src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,4 +120,34 @@
|
|||||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="printPreviewDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>132, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
<data name="printPreviewDialog.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
AAABAAEAEBAAAAAAIAAoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
AAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
|
||||||
|
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
|
||||||
|
/wD///8A////AP///wD///8A////AP///wD///8A////APb29v/29vb/9vb2//b29v/29vb/9vb2//b2
|
||||||
|
9v////8A////AP///wD///8A9vb2//b29v/29vb/9vb2//b29v/29vb/QkJC/0JCQv9CQkL/QkJC/0JC
|
||||||
|
Qv/29vb/////AP///wD///8A////APb29v9CQkL/QkJC/0JCQv9CQkL/9vb2/0JCQv9CQkL/QkJC/0JC
|
||||||
|
Qv9CQkL/9vb2/////wD///8A////AP///wD29vb/QkJC/0JCQv9CQkL/QkJC//b29v9CQkL/QkJC/0JC
|
||||||
|
Qv9CQkL/QkJC//b29v////8A////AP///wD///8A9vb2/0JCQv9CQkL/QkJC/0JCQv/29vb/9vb2//b2
|
||||||
|
9v/29vb/9vb2//b29v/29vb/9vb2//b29v////8A////APb29v9CQkL/QkJC/0JCQv9CQkL/9vb2/0JC
|
||||||
|
Qv9CQkL/QkJC/0JCQv9CQkL/QkJC/0JCQv/29vb/////AP///wD29vb/QkJC/0JCQv9CQkL/QkJC//b2
|
||||||
|
9v9CQkL/QkJC/0JCQv9CQkL/QkJC/0JCQv9CQkL/9vb2/////wD///8A9vb2/0JCQv9CQkL/QkJC/0JC
|
||||||
|
Qv/29vb/QkJC/0JCQv9CQkL/QkJC/0JCQv9CQkL/QkJC//b29v////8A////APb29v/29vb/9vb2//b2
|
||||||
|
9v/29vb/9vb2/0JCQv9CQkL/QkJC/0JCQv9CQkL/QkJC/0JCQv/29vb/////AP///wD///8A////AP//
|
||||||
|
/wD///8A////APb29v9CQkL/QkJC/0JCQv9CQkL/QkJC/0JCQv9CQkL/9vb2/////wD///8A////AP//
|
||||||
|
/wD///8A////AP///wD29vb/QkJC/0JCQv9CQkL/QkJC/0JCQv9CQkL/QkJC//b29v////8A////AP//
|
||||||
|
/wD///8A////AP///wD///8A9vb2/0JCQv9CQkL/QkJC/0JCQv9CQkL/QkJC/0JCQv/29vb/////AP//
|
||||||
|
/wD///8A////AP///wD///8A////APb29v/29vb/9vb2//b29v/29vb/9vb2//b29v/29vb/9vb2////
|
||||||
|
/wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
|
||||||
|
/wD///8A
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="printDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>286, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
105
WinFormsApp/FormPreviewPDF.Designer.cs
generated
Normal file
105
WinFormsApp/FormPreviewPDF.Designer.cs
generated
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
namespace WinFormsApp
|
||||||
|
{
|
||||||
|
partial class FormPreviewPDF
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormPreviewPDF));
|
||||||
|
axAcropdf = new AxAcroPDFLib.AxAcroPDF();
|
||||||
|
panel1 = new Panel();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonPrint = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)axAcropdf).BeginInit();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// axAcropdf
|
||||||
|
//
|
||||||
|
axAcropdf.Dock = DockStyle.Top;
|
||||||
|
axAcropdf.Enabled = true;
|
||||||
|
axAcropdf.Location = new Point(0, 0);
|
||||||
|
axAcropdf.Name = "axAcropdf";
|
||||||
|
axAcropdf.OcxState = (AxHost.State)resources.GetObject("axAcropdf.OcxState");
|
||||||
|
axAcropdf.Size = new Size(478, 576);
|
||||||
|
axAcropdf.TabIndex = 0;
|
||||||
|
axAcropdf.Enter += axAcropdf_Enter;
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.Controls.Add(buttonCancel);
|
||||||
|
panel1.Controls.Add(buttonPrint);
|
||||||
|
panel1.Dock = DockStyle.Bottom;
|
||||||
|
panel1.Location = new Point(0, 540);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(478, 36);
|
||||||
|
panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Dock = DockStyle.Right;
|
||||||
|
buttonCancel.Location = new Point(262, 0);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(108, 36);
|
||||||
|
buttonCancel.TabIndex = 1;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonPrint
|
||||||
|
//
|
||||||
|
buttonPrint.Dock = DockStyle.Right;
|
||||||
|
buttonPrint.Location = new Point(370, 0);
|
||||||
|
buttonPrint.Name = "buttonPrint";
|
||||||
|
buttonPrint.Size = new Size(108, 36);
|
||||||
|
buttonPrint.TabIndex = 0;
|
||||||
|
buttonPrint.Text = "Распечатать";
|
||||||
|
buttonPrint.UseVisualStyleBackColor = true;
|
||||||
|
buttonPrint.Click += buttonPrint_Click;
|
||||||
|
//
|
||||||
|
// FormPreviewPDF
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(478, 576);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
Controls.Add(axAcropdf);
|
||||||
|
Name = "FormPreviewPDF";
|
||||||
|
Text = "FormPreviewPDF";
|
||||||
|
Load += FormPreviewPDF_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)axAcropdf).EndInit();
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private AxAcroPDFLib.AxAcroPDF axAcropdf;
|
||||||
|
private Panel panel1;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonPrint;
|
||||||
|
}
|
||||||
|
}
|
46
WinFormsApp/FormPreviewPDF.cs
Normal file
46
WinFormsApp/FormPreviewPDF.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace WinFormsApp
|
||||||
|
{
|
||||||
|
public partial class FormPreviewPDF : Form
|
||||||
|
{
|
||||||
|
public string src { get; set; }
|
||||||
|
public FormPreviewPDF()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonPrint_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormPreviewPDF_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
axAcropdf.src = src;
|
||||||
|
axAcropdf.LoadFile(src);
|
||||||
|
axAcropdf.setView("Fit");
|
||||||
|
axAcropdf.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void axAcropdf_Enter(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
128
WinFormsApp/FormPreviewPDF.resx
Normal file
128
WinFormsApp/FormPreviewPDF.resx
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="axAcropdf.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
|
||||||
|
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAhU3lzdGVtLldpbmRvd3MuRm9ybXMu
|
||||||
|
QXhIb3N0K1N0YXRlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAACEAAAACAQAAAAEAAAAAAAAAAAAAAAAM
|
||||||
|
AAAAAA4AANgTAADYEwAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
@ -100,6 +100,12 @@ namespace WinFormsApp
|
|||||||
IsBeingSold = checkBoxIsSold.Checked,
|
IsBeingSold = checkBoxIsSold.Checked,
|
||||||
};
|
};
|
||||||
var operationResult = _id.HasValue ? _productLogic.Update(model) : _productLogic.Create(model);
|
var operationResult = _id.HasValue ? _productLogic.Update(model) : _productLogic.Create(model);
|
||||||
|
var lastProductCreated = _productLogic.ReadList(null).Last();
|
||||||
|
_barcodeLogic.CreateBarcode(new ProductBindingModel()
|
||||||
|
{
|
||||||
|
Id = lastProductCreated.Id,
|
||||||
|
Name = lastProductCreated.Name,
|
||||||
|
}, true);
|
||||||
_id = null;
|
_id = null;
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
@ -196,7 +202,7 @@ namespace WinFormsApp
|
|||||||
{
|
{
|
||||||
Id = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value,
|
Id = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value,
|
||||||
Name = Convert.ToString(dataGridView.SelectedRows[0].Cells["Name"].Value),
|
Name = Convert.ToString(dataGridView.SelectedRows[0].Cells["Name"].Value),
|
||||||
});
|
}, true);
|
||||||
pictureBox1.Image = barcode.Image;
|
pictureBox1.Image = barcode.Image;
|
||||||
_barcode = BarcodeReader.Read($"product{barcode.Value}.png");
|
_barcode = BarcodeReader.Read($"product{barcode.Value}.png");
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ using Contracts.StorageContracts;
|
|||||||
using DatabaseImplement.Implements;
|
using DatabaseImplement.Implements;
|
||||||
using Contracts.BusinessLogicContracts;
|
using Contracts.BusinessLogicContracts;
|
||||||
using BusinessLogic.BusinessLogic;
|
using BusinessLogic.BusinessLogic;
|
||||||
|
using BusinessLogic.OfficePackage.Implements;
|
||||||
|
using BusinessLogic.OfficePackage;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace WinFormsApp
|
namespace WinFormsApp
|
||||||
{
|
{
|
||||||
@ -19,6 +22,8 @@ namespace WinFormsApp
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
@ -44,6 +49,9 @@ namespace WinFormsApp
|
|||||||
services.AddTransient<ISupplierLogic, SupplierLogic>();
|
services.AddTransient<ISupplierLogic, SupplierLogic>();
|
||||||
services.AddTransient<IProductLogic, ProductLogic>();
|
services.AddTransient<IProductLogic, ProductLogic>();
|
||||||
services.AddTransient<IMediaFileLogic, MediaFileLogic>();
|
services.AddTransient<IMediaFileLogic, MediaFileLogic>();
|
||||||
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
|
||||||
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormProducts>();
|
services.AddTransient<FormProducts>();
|
||||||
@ -53,6 +61,7 @@ namespace WinFormsApp
|
|||||||
services.AddTransient<FormSupplyProduct>();
|
services.AddTransient<FormSupplyProduct>();
|
||||||
services.AddTransient<FormSupplierProduct>();
|
services.AddTransient<FormSupplierProduct>();
|
||||||
services.AddTransient<FormMediaFiles>();
|
services.AddTransient<FormMediaFiles>();
|
||||||
|
services.AddTransient<FormPreviewPDF>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,26 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<COMReference Include="AcroPDFLib">
|
||||||
|
<WrapperTool>tlbimp</WrapperTool>
|
||||||
|
<VersionMinor>0</VersionMinor>
|
||||||
|
<VersionMajor>1</VersionMajor>
|
||||||
|
<Guid>05bfd3f1-6319-4f30-b752-c7a22889bcc4</Guid>
|
||||||
|
<Lcid>0</Lcid>
|
||||||
|
<Isolated>false</Isolated>
|
||||||
|
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||||
|
</COMReference>
|
||||||
|
<COMReference Include="AxAcroPDFLib">
|
||||||
|
<WrapperTool>aximp</WrapperTool>
|
||||||
|
<VersionMinor>0</VersionMinor>
|
||||||
|
<VersionMajor>1</VersionMajor>
|
||||||
|
<Guid>05bfd3f1-6319-4f30-b752-c7a22889bcc4</Guid>
|
||||||
|
<Lcid>0</Lcid>
|
||||||
|
<Isolated>false</Isolated>
|
||||||
|
</COMReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
15
WinFormsApp/nlog.config
Normal file
15
WinFormsApp/nlog.config
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
autoReload="true"
|
||||||
|
internalLogFile="c:\\logs\\internal.log"
|
||||||
|
internalLogLevel="Info">
|
||||||
|
<targets>
|
||||||
|
<target xsi:type="File" name="logfile" fileName="c:\\logs\\winforms.log"
|
||||||
|
layout="${longdate}|${level}|${logger}|${message}"/>
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
<logger name="*" minlevel="Info" writeTo="logfile" />
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
Loading…
Reference in New Issue
Block a user