diff --git a/BusinessLogic/BusinessLogic.csproj b/BusinessLogic/BusinessLogic.csproj
index 832c28f..f81d09f 100644
--- a/BusinessLogic/BusinessLogic.csproj
+++ b/BusinessLogic/BusinessLogic.csproj
@@ -13,8 +13,11 @@
+
+
+
diff --git a/BusinessLogic/BusinessLogic/BarcodeLogic.cs b/BusinessLogic/BusinessLogic/BarcodeLogic.cs
index 660f594..375c9ca 100644
--- a/BusinessLogic/BusinessLogic/BarcodeLogic.cs
+++ b/BusinessLogic/BusinessLogic/BarcodeLogic.cs
@@ -10,10 +10,11 @@ namespace BusinessLogic.BusinessLogic
{
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);
- return barCode.SaveAsPng($"product{model.Id}.png");
+ if (save) return barCode.SaveAsPng($"product{model.Id}.png");
+ return barCode;
}
}
}
diff --git a/BusinessLogic/BusinessLogic/ReportLogic.cs b/BusinessLogic/BusinessLogic/ReportLogic.cs
new file mode 100644
index 0000000..619fefe
--- /dev/null
+++ b/BusinessLogic/BusinessLogic/ReportLogic.cs
@@ -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;
+ }
+ ///
+ /// Получение списка компонент с указанием, в каких изделиях используются
+ ///
+ ///
+ public List GetSupplyProduct()
+ {
+ var products = _productStorage.GetFullList();
+ var supplies = _supplyStorage.GetFullList();
+ var list = new List();
+ foreach (var supply in supplies)
+ {
+ var record = new ReportSupplyProductViewModel
+ {
+ SupplyName = supply.Name,
+ Products = new List>(),
+ TotalCount = 0
+ };
+ foreach (var product in products)
+ {
+ if (supply.Products.ContainsKey(product.Id))
+ {
+ record.Products.Add(new Tuple(product.Name, supply.Products[product.Id].Item2));
+ record.TotalCount += supply.Products[product.Id].Item2;
+ }
+ }
+ list.Add(record);
+ }
+ return list;
+ }
+ ///
+ /// Сохранение заказов в файл-Pdf
+ ///
+ ///
+ 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,
+ })
+ });
+ }
+ }
+}
diff --git a/BusinessLogic/BusinessLogic/SupplyLogic.cs b/BusinessLogic/BusinessLogic/SupplyLogic.cs
index b246c0d..03df5ff 100644
--- a/BusinessLogic/BusinessLogic/SupplyLogic.cs
+++ b/BusinessLogic/BusinessLogic/SupplyLogic.cs
@@ -111,6 +111,14 @@ namespace BusinessLogic.BusinessLogic
return false;
}
model.Status = newStatus;
+ if (newStatus == SupplyStatus.Arriving)
+ {
+ model.DateArriving = DateTime.UtcNow;
+ }
+ if (newStatus == SupplyStatus.Completed)
+ {
+ model.DateComplete = DateTime.UtcNow;
+ }
if (_supplyStorage.Update(model) == null)
{
model.Status--;
diff --git a/BusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/BusinessLogic/OfficePackage/AbstractSaveToPdf.cs
new file mode 100644
index 0000000..5b58544
--- /dev/null
+++ b/BusinessLogic/OfficePackage/AbstractSaveToPdf.cs
@@ -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 { "5cm", "10cm"});
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { "Id", "Информация" },
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { info.Supply.Id.ToString(), info.Supply.Name, },
+ Style = "Normal",
+ ParagraphAlignment = PdfParagraphAlignmentType.Left
+ });
+ CreateParagraph(new PdfParagraph
+ {
+ Text = "Товары",
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ CreateTable(new List { "5cm", "5cm", "3cm", "2cm" });
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { "Id", "Название", "Цена", "Кол-во" },
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ foreach (var product in info.Supply.Products.Values)
+ {
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { 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 columns);
+ protected abstract void CreateRow(PdfRowParameters rowParameters);
+ protected abstract void CreateImage(string path);
+ protected abstract void SavePdf(PdfInfo info);
+ }
+}
diff --git a/BusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/BusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs
new file mode 100644
index 0000000..cb665c5
--- /dev/null
+++ b/BusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs
@@ -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
+ }
+}
diff --git a/BusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/BusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
new file mode 100644
index 0000000..d283468
--- /dev/null
+++ b/BusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
@@ -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();
+ }
+}
diff --git a/BusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/BusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
new file mode 100644
index 0000000..563d69b
--- /dev/null
+++ b/BusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
@@ -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; }
+ }
+}
diff --git a/BusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/BusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
new file mode 100644
index 0000000..6054e4f
--- /dev/null
+++ b/BusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
@@ -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 Texts { get; set; } = new();
+ public string Style { get; set; } = string.Empty;
+ public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
+ }
+}
diff --git a/BusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/BusinessLogic/OfficePackage/Implements/SaveToPdf.cs
new file mode 100644
index 0000000..654366d
--- /dev/null
+++ b/BusinessLogic/OfficePackage/Implements/SaveToPdf.cs
@@ -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,
+ };
+ }
+ ///
+ /// Создание стилей для документа
+ ///
+ ///
+ 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 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);
+ }
+ }
+}
diff --git a/Contracts/BindingModels/ReportBindingModel.cs b/Contracts/BindingModels/ReportBindingModel.cs
new file mode 100644
index 0000000..0a77572
--- /dev/null
+++ b/Contracts/BindingModels/ReportBindingModel.cs
@@ -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; }
+ }
+}
diff --git a/Contracts/BindingModels/SupplyBindingModel.cs b/Contracts/BindingModels/SupplyBindingModel.cs
index 44ba57c..61600d3 100644
--- a/Contracts/BindingModels/SupplyBindingModel.cs
+++ b/Contracts/BindingModels/SupplyBindingModel.cs
@@ -14,6 +14,8 @@ namespace Contracts.BindingModels
public string Name { get; set; } = string.Empty;
public Guid SupplierId { get; set; }
public DateTime Date { get; set; }
+ public DateTime? DateArriving { get; set; }
+ public DateTime? DateComplete { get; set; }
public double Price { get; set; }
public SupplyStatus Status { get; set; }
public Dictionary SupplyProducts { get; set; } = new();
diff --git a/Contracts/BusinessLogicContracts/IReportLogic.cs b/Contracts/BusinessLogicContracts/IReportLogic.cs
new file mode 100644
index 0000000..c0707be
--- /dev/null
+++ b/Contracts/BusinessLogicContracts/IReportLogic.cs
@@ -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
+ {
+ ///
+ /// Получение списка компонент с указанием, в каких изделиях используются
+ ///
+ ///
+ List GetSupplyProduct();
+ ///
+ /// Сохранение заказов в файл-Pdf
+ ///
+ ///
+ void SaveSuppliesToPdfFile(ReportBindingModel model);
+ }
+}
diff --git a/Contracts/ViewModels/ReportSupplyProductViewModel.cs b/Contracts/ViewModels/ReportSupplyProductViewModel.cs
new file mode 100644
index 0000000..fcf1ba2
--- /dev/null
+++ b/Contracts/ViewModels/ReportSupplyProductViewModel.cs
@@ -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> Products { get; set; } = new();
+ }
+}
diff --git a/Contracts/ViewModels/ReportSupplyViewModel.cs b/Contracts/ViewModels/ReportSupplyViewModel.cs
new file mode 100644
index 0000000..b85c166
--- /dev/null
+++ b/Contracts/ViewModels/ReportSupplyViewModel.cs
@@ -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;
+ }
+}
diff --git a/Contracts/ViewModels/SupplyViewModel.cs b/Contracts/ViewModels/SupplyViewModel.cs
index 08f7046..992a4a6 100644
--- a/Contracts/ViewModels/SupplyViewModel.cs
+++ b/Contracts/ViewModels/SupplyViewModel.cs
@@ -18,6 +18,8 @@ namespace Contracts.ViewModels
public double Price { get; set; }
public Dictionary Products { get; set; } = new();
public DateTime Date { get; set; }
+ public DateTime? DateArriving { get; set; }
+ public DateTime? DateComplete { get; set; }
public SupplyStatus Status { get; set; }
}
}
diff --git a/DataModels/Models/ISupply.cs b/DataModels/Models/ISupply.cs
index fff5ab5..4dda0a7 100644
--- a/DataModels/Models/ISupply.cs
+++ b/DataModels/Models/ISupply.cs
@@ -13,6 +13,8 @@ namespace DataModels.Models
double Price { get; }
Guid SupplierId { get; }
DateTime Date { get; }
+ DateTime? DateArriving { get; }
+ DateTime? DateComplete { get; }
SupplyStatus Status { get; }
Dictionary SupplyProducts { get; }
}
diff --git a/DatabaseImplement/Migrations/20240625085945_dates_migration.Designer.cs b/DatabaseImplement/Migrations/20240625085945_dates_migration.Designer.cs
new file mode 100644
index 0000000..a814e7a
--- /dev/null
+++ b/DatabaseImplement/Migrations/20240625085945_dates_migration.Designer.cs
@@ -0,0 +1,496 @@
+//
+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
+ {
+ ///
+ 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("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Location")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ProductId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProductId");
+
+ b.ToTable("MediaFiles");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Amount")
+ .HasColumnType("integer");
+
+ b.Property("IsBeingSold")
+ .HasColumnType("boolean");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.Property("Rate")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.ToTable("Products");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.Purchase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("DatePurchase")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Purchases");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.PurchaseProducts", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("ProductId")
+ .HasColumnType("uuid");
+
+ b.Property("PurchaseId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchaseId");
+
+ b.ToTable("PurchaseProducts");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.Sell", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("DateSell")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Sells");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.SellProducts", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("ProductId")
+ .HasColumnType("uuid");
+
+ b.Property("SellId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("SellId");
+
+ b.ToTable("SellProducts");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.Supplier", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Deals")
+ .HasColumnType("integer");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Suppliers");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.SupplierProduct", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("ProductId")
+ .HasColumnType("uuid");
+
+ b.Property("SupplierId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("SupplierId");
+
+ b.ToTable("SupplierProducts");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.Supply", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateArriving")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateComplete")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("SupplierId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SupplierId");
+
+ b.ToTable("Supplies");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.SupplyDoc", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("SupplyId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.ToTable("SupplyDocs");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.SupplyProduct", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("ProductId")
+ .HasColumnType("uuid");
+
+ b.Property("SupplyId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("SupplyId");
+
+ b.ToTable("SupplyProducts");
+ });
+
+ modelBuilder.Entity("DatabaseImplement.Models.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Birthday")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("FirstName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("OnlyImportantMails")
+ .HasColumnType("boolean");
+
+ b.Property("PasswordHash")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("RoleId")
+ .HasColumnType("uuid");
+
+ b.Property("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
+ }
+ }
+}
diff --git a/DatabaseImplement/Migrations/20240625085945_dates_migration.cs b/DatabaseImplement/Migrations/20240625085945_dates_migration.cs
new file mode 100644
index 0000000..c228ce6
--- /dev/null
+++ b/DatabaseImplement/Migrations/20240625085945_dates_migration.cs
@@ -0,0 +1,60 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace DatabaseImplement.Migrations
+{
+ ///
+ public partial class dates_migration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "DateArriving",
+ table: "Supplies",
+ type: "timestamp with time zone",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ 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);
+ }
+
+ ///
+ 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");
+ }
+ }
+}
diff --git a/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs b/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs
index 1d1117b..013f054 100644
--- a/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs
+++ b/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs
@@ -41,6 +41,8 @@ namespace DatabaseImplement.Migrations
b.HasKey("Id");
+ b.HasIndex("ProductId");
+
b.ToTable("MediaFiles");
});
@@ -226,6 +228,12 @@ namespace DatabaseImplement.Migrations
b.Property("Date")
.HasColumnType("timestamp with time zone");
+ b.Property("DateArriving")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateComplete")
+ .HasColumnType("timestamp with time zone");
+
b.Property("Name")
.IsRequired()
.HasColumnType("text");
@@ -326,6 +334,17 @@ namespace DatabaseImplement.Migrations
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")
diff --git a/DatabaseImplement/Models/Supply.cs b/DatabaseImplement/Models/Supply.cs
index 060d97c..2d65060 100644
--- a/DatabaseImplement/Models/Supply.cs
+++ b/DatabaseImplement/Models/Supply.cs
@@ -25,6 +25,8 @@ namespace DatabaseImplement.Models
public Guid SupplierId { get; set; }
[Required]
public DateTime Date { get; set; }
+ public DateTime? DateArriving { get; private set; }
+ public DateTime? DateComplete { get; private set; }
[Required]
public SupplyStatus Status { get; set; } = SupplyStatus.Pending;
private Dictionary? _supplyProducts = null;
@@ -53,6 +55,8 @@ namespace DatabaseImplement.Models
Name = model.Name,
Price = model.Price,
Date = model.Date,
+ DateArriving = model.DateArriving,
+ DateComplete = model.DateComplete,
SupplierId = model.SupplierId,
Products = model.SupplyProducts.Select(x => new
SupplyProduct
@@ -66,6 +70,8 @@ namespace DatabaseImplement.Models
public void Update(SupplyBindingModel model)
{
Status = model.Status;
+ DateArriving = model.DateArriving;
+ DateComplete = model.DateComplete;
}
public SupplyViewModel GetViewModel
{
@@ -80,6 +86,8 @@ namespace DatabaseImplement.Models
Products = SupplyProducts,
SupplierId = SupplierId,
Date = Date,
+ DateArriving = DateArriving,
+ DateComplete = DateComplete,
Status = Status,
SupplierName = Supplier.Name,
};
diff --git a/WinFormsApp/FormMain.Designer.cs b/WinFormsApp/FormMain.Designer.cs
index 1567d57..2f38434 100644
--- a/WinFormsApp/FormMain.Designer.cs
+++ b/WinFormsApp/FormMain.Designer.cs
@@ -28,6 +28,7 @@
///
private void InitializeComponent()
{
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
dataGridView = new DataGridView();
buttonCreateSupply = new Button();
menuStrip1 = new MenuStrip();
@@ -35,6 +36,11 @@
поставщикиToolStripMenuItem = new ToolStripMenuItem();
buttonSupplyStatusArriving = 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();
menuStrip1.SuspendLayout();
SuspendLayout();
@@ -101,11 +107,58 @@
buttonSupplyStatusCompleted.UseVisualStyleBackColor = true;
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
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(901, 384);
+ Controls.Add(buttonRefresh);
+ Controls.Add(buttonPrintReport);
+ Controls.Add(buttonCreateReport);
Controls.Add(buttonSupplyStatusCompleted);
Controls.Add(buttonSupplyStatusArriving);
Controls.Add(buttonCreateSupply);
@@ -131,5 +184,10 @@
private ToolStripMenuItem поставщикиToolStripMenuItem;
private Button buttonSupplyStatusArriving;
private Button buttonSupplyStatusCompleted;
+ private Button buttonCreateReport;
+ private Button buttonPrintReport;
+ private PrintPreviewDialog printPreviewDialog;
+ private PrintDialog printDialog;
+ private Button buttonRefresh;
}
}
\ No newline at end of file
diff --git a/WinFormsApp/FormMain.cs b/WinFormsApp/FormMain.cs
index e9fa189..7ca4a5e 100644
--- a/WinFormsApp/FormMain.cs
+++ b/WinFormsApp/FormMain.cs
@@ -8,8 +8,11 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
+using System.Drawing.Printing;
using System.Linq;
+using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -22,13 +25,15 @@ namespace WinFormsApp
private readonly ISupplyLogic _supplyLogic;
private readonly IProductLogic _productLogic;
private readonly ISupplierLogic _supplierLogic;
- public FormMain(ILogger logger, ISupplierLogic supplierLogic, ISupplyLogic supplyLogic, IProductLogic productLogic)
+ private readonly IReportLogic _reportLogic;
+ public FormMain(ILogger logger, ISupplierLogic supplierLogic, ISupplyLogic supplyLogic, IProductLogic productLogic, IReportLogic reportLogic)
{
InitializeComponent();
_supplierLogic = supplierLogic;
_supplyLogic = supplyLogic;
_productLogic = productLogic;
_logger = logger;
+ _reportLogic = reportLogic;
}
private void FormMain_Load(object sender, EventArgs e)
@@ -45,6 +50,8 @@ namespace WinFormsApp
if (list != null)
{
dataGridView.DataSource = list;
+ dataGridView.Columns["SupplierId"].Visible = false;
+ dataGridView.Columns["Products"].Visible = false;
}
_logger.LogInformation("Загрузка поставок");
}
@@ -120,7 +127,9 @@ namespace WinFormsApp
var operationResult = _supplyLogic.StatusUpdate(new SupplyBindingModel
{
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);
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();
+ }
}
}
diff --git a/WinFormsApp/FormMain.resx b/WinFormsApp/FormMain.resx
index a0623c8..a85b19c 100644
--- a/WinFormsApp/FormMain.resx
+++ b/WinFormsApp/FormMain.resx
@@ -120,4 +120,34 @@
17, 17
+
+ 132, 17
+
+
+
+
+ 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
+
+
+
+ 286, 17
+
\ No newline at end of file
diff --git a/WinFormsApp/FormPreviewPDF.Designer.cs b/WinFormsApp/FormPreviewPDF.Designer.cs
new file mode 100644
index 0000000..cee0077
--- /dev/null
+++ b/WinFormsApp/FormPreviewPDF.Designer.cs
@@ -0,0 +1,105 @@
+namespace WinFormsApp
+{
+ partial class FormPreviewPDF
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/WinFormsApp/FormPreviewPDF.cs b/WinFormsApp/FormPreviewPDF.cs
new file mode 100644
index 0000000..47a67ed
--- /dev/null
+++ b/WinFormsApp/FormPreviewPDF.cs
@@ -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)
+ {
+
+ }
+ }
+}
diff --git a/WinFormsApp/FormPreviewPDF.resx b/WinFormsApp/FormPreviewPDF.resx
new file mode 100644
index 0000000..24f9693
--- /dev/null
+++ b/WinFormsApp/FormPreviewPDF.resx
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
+ LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAhU3lzdGVtLldpbmRvd3MuRm9ybXMu
+ QXhIb3N0K1N0YXRlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAACEAAAACAQAAAAEAAAAAAAAAAAAAAAAM
+ AAAAAA4AANgTAADYEwAACw==
+
+
+
\ No newline at end of file
diff --git a/WinFormsApp/FormProducts.cs b/WinFormsApp/FormProducts.cs
index 2b931a1..a1ab921 100644
--- a/WinFormsApp/FormProducts.cs
+++ b/WinFormsApp/FormProducts.cs
@@ -100,6 +100,12 @@ namespace WinFormsApp
IsBeingSold = checkBoxIsSold.Checked,
};
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;
if (!operationResult)
{
@@ -196,7 +202,7 @@ namespace WinFormsApp
{
Id = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value,
Name = Convert.ToString(dataGridView.SelectedRows[0].Cells["Name"].Value),
- });
+ }, true);
pictureBox1.Image = barcode.Image;
_barcode = BarcodeReader.Read($"product{barcode.Value}.png");
}
diff --git a/WinFormsApp/Program.cs b/WinFormsApp/Program.cs
index 2cf562f..18696a5 100644
--- a/WinFormsApp/Program.cs
+++ b/WinFormsApp/Program.cs
@@ -6,6 +6,9 @@ using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Contracts.BusinessLogicContracts;
using BusinessLogic.BusinessLogic;
+using BusinessLogic.OfficePackage.Implements;
+using BusinessLogic.OfficePackage;
+using System.Text;
namespace WinFormsApp
{
@@ -19,6 +22,8 @@ namespace WinFormsApp
[STAThread]
static void Main()
{
+
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
@@ -44,6 +49,9 @@ namespace WinFormsApp
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -53,6 +61,7 @@ namespace WinFormsApp
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
}
}
diff --git a/WinFormsApp/WinFormsApp.csproj b/WinFormsApp/WinFormsApp.csproj
index 4a12fd9..7d85a86 100644
--- a/WinFormsApp/WinFormsApp.csproj
+++ b/WinFormsApp/WinFormsApp.csproj
@@ -8,6 +8,26 @@
enable
+
+
+ tlbimp
+ 0
+ 1
+ 05bfd3f1-6319-4f30-b752-c7a22889bcc4
+ 0
+ false
+ true
+
+
+ aximp
+ 0
+ 1
+ 05bfd3f1-6319-4f30-b752-c7a22889bcc4
+ 0
+ false
+
+
+
all
diff --git a/WinFormsApp/nlog.config b/WinFormsApp/nlog.config
new file mode 100644
index 0000000..645d06b
--- /dev/null
+++ b/WinFormsApp/nlog.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file