проблема с пдф

This commit is contained in:
Алексей Крюков 2024-05-18 03:40:04 +04:00
parent 149206f442
commit aa04448a6e
33 changed files with 1589 additions and 126 deletions

View File

@ -18,14 +18,16 @@ namespace TypographyBusinessLogic.BusinessLogics
private readonly IComponentStorage _componentStorage;
private readonly IPrintedStorage _printedStorage;
private readonly IOrderStorage _orderStorage;
private readonly IShopStorage _shopStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IPrintedStorage printedStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
public ReportLogic(IPrintedStorage printedStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_printedStorage = printedStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
_shopStorage = shopStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
@ -118,5 +120,62 @@ namespace TypographyBusinessLogic.BusinessLogics
Orders = GetOrders(model)
});
}
public void SaveShopsToWordFile(ReportBindingModel model)
{
_saveToWord.CreateTableDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список магазинов",
Shops = _shopStorage.GetFullList()
});
}
public void SaveShopPrintedsToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateShopReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Загруженность магазинов",
ShopPrinteds = GetShopPrinteds()
});
}
public List<ReportShopPrintedsViewModel> GetShopPrinteds()
{
var shops = _shopStorage.GetFullList();
var list = new List<ReportShopPrintedsViewModel>();
foreach (var shop in shops)
{
var record = new ReportShopPrintedsViewModel
{
ShopName = shop.ShopName,
Printeds = new List<Tuple<string, int>>(),
Count = 0
};
foreach (var carCount in shop.ShopPrinteds.Values)
{
record.Printeds.Add(new Tuple<string, int>(carCount.Item1.PrintedName, carCount.Item2));
record.Count += carCount.Item2;
}
list.Add(record);
}
return list;
}
public List<ReportDateOrdersViewModel> GetDateOrders()
{
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportDateOrdersViewModel
{
DateCreate = x.Key,
CountOrders = x.Count(),
SumOrders = x.Sum(y => y.Sum)
}).ToList();
}
public void SaveDateOrdersToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateReportDateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Заказы по датам",
DateOrders = GetDateOrders()
});
}
}
}

View File

@ -11,7 +11,7 @@ using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
using Microsoft.Extensions.Logging;
namespace TypographyBusinessLogic
namespace TypographyBusinessLogic.BusinessLogics
{
public class ShopLogic : IShopLogic
{
@ -49,7 +49,7 @@ namespace TypographyBusinessLogic
{
_logger.LogInformation("ReadList. Shop Name:{0}, ID:{1} ", model?.ShopName, model?.Id);
var list = (model == null) ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
if (list == null)
{

View File

@ -47,14 +47,14 @@ namespace TypographyBusinessLogic.OfficePackage
ColumnName = "B",
RowIndex = rowIndex,
Text = Component,
StyleInfo = ExcelStyleInfoType.TextWithBroder
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
rowIndex++;
}
@ -76,6 +76,68 @@ namespace TypographyBusinessLogic.OfficePackage
}
SaveExcel(info);
}
public void CreateShopReport(ExcelInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var pc in info.ShopPrinteds)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ShopName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (PrintedName, Count) in pc.Printeds)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = PrintedName,
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = pc.Count.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
/// <summary>
/// Создание excel-файла
/// </summary>

View File

@ -49,6 +49,39 @@ namespace TypographyBusinessLogic.OfficePackage
});
SavePdf(info);
}
public void CreateReportDateDoc(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "3cm", "3cm", "7cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Дата", "Количество", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var order in info.DateOrders)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.DateCreate.ToShortDateString(), order.CountOrders.ToString(), order.SumOrders.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
CreateParagraph(new PdfParagraph
{
Text = $"Итого: {info.DateOrders.Sum(x => x.SumOrders)}\t",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
SavePdf(info);
}
/// <summary>
/// Создание doc-файла
/// </summary>

View File

@ -40,6 +40,27 @@ namespace TypographyBusinessLogic.OfficePackage
}
SaveWord(info);
}
public void CreateTableDoc(WordInfo wordInfo)
{
CreateWord(wordInfo);
var list = new List<string>();
foreach (var shop in wordInfo.Shops)
{
list.Add(shop.ShopName);
list.Add(shop.Address);
list.Add(shop.DateOpening.ToString());
}
var wordTable = new WordTable
{
Headers = new List<string> {
"Название",
"Адрес",
"Дата открытия"},
Texts = list
};
CreateTable(wordTable);
SaveWord(wordInfo);
}
/// <summary>
/// Создание doc-файла
/// </summary>
@ -56,6 +77,11 @@ namespace TypographyBusinessLogic.OfficePackage
/// </summary>
/// <param name="info"></param>
protected abstract void SaveWord(WordInfo info);
/// <summary>
/// создание таблицы
/// </summary>
/// <param name="info"></param>
protected abstract void CreateTable(WordTable info);
}
}

View File

@ -10,6 +10,6 @@ namespace TypographyBusinessLogic.OfficePackage.HelperEnums
{
Title,
Text,
TextWithBroder
TextWithBorder
}
}

View File

@ -17,5 +17,10 @@ namespace TypographyBusinessLogic.OfficePackage.HelperModels
get;
set;
} = new();
public List<ReportShopPrintedsViewModel> ShopPrinteds
{
get;
set;
} = new();
}
}

View File

@ -14,5 +14,6 @@ namespace TypographyBusinessLogic.OfficePackage.HelperModels
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportOrdersViewModel> Orders { get; set; } = new();
public List<ReportDateOrdersViewModel> DateOrders { get; set; } = new();
}
}

View File

@ -12,5 +12,6 @@ namespace TypographyBusinessLogic.OfficePackage.HelperModels
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new();
public List<ShopViewModel> Shops { get; set; } = new();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TypographyBusinessLogic.OfficePackage.HelperModels
{
public class WordTable
{
public List<string> Headers { get; set; } = new();
public List<string> Texts { get; set; } = new();
}
}

View File

@ -166,7 +166,7 @@ namespace TypographyBusinessLogic.OfficePackage.Implements
return styleInfo switch
{
ExcelStyleInfoType.Title => 2U,
ExcelStyleInfoType.TextWithBroder => 1U,
ExcelStyleInfoType.TextWithBorder => 1U,
ExcelStyleInfoType.Text => 0U,
_ => 0U,
};

View File

@ -126,5 +126,85 @@ namespace TypographyBusinessLogic.OfficePackage.Implements
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Dispose();
}
protected override void CreateTable(WordTable table)
{
if (_docBody == null || table == null)
{
return;
}
Table tab = new Table();
TableProperties props = new TableProperties(
new TableBorders(
new TopBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new BottomBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new LeftBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new RightBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideHorizontalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideVerticalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
}
)
);
tab.AppendChild<TableProperties>(props);
TableGrid tableGrid = new TableGrid();
for (int i = 0; i < table.Headers.Count; i++)
{
tableGrid.AppendChild(new GridColumn());
}
tab.AppendChild(tableGrid);
TableRow tableRow = new TableRow();
foreach (var text in table.Headers)
{
tableRow.AppendChild(CreateTableCell(text));
}
tab.AppendChild(tableRow);
int height = table.Texts.Count / table.Headers.Count;
int width = table.Headers.Count;
for (int i = 0; i < height; i++)
{
tableRow = new TableRow();
for (int j = 0; j < width; j++)
{
var element = table.Texts[i * table.Headers.Count + j];
tableRow.AppendChild(CreateTableCell(element));
}
tab.AppendChild(tableRow);
}
_docBody.AppendChild(tab);
}
private TableCell CreateTableCell(string element)
{
var tableParagraph = new Paragraph();
var run = new Run();
run.AppendChild(new Text { Text = element });
tableParagraph.AppendChild(run);
var tableCell = new TableCell();
tableCell.AppendChild(tableParagraph);
return tableCell;
}
}
}

View File

@ -15,9 +15,9 @@ namespace TypographyContracts.BindingModels
public string ShopName { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public DateTime DateOpening { get; set; } = DateTime.Now;
public int MaxCountPrinteds { get; set; }
public DateTime DateOpening { get; set; } = DateTime.Now;
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; set; } = new();
}

View File

@ -36,5 +36,30 @@ namespace TypographyContracts.BusinessLogicsContracts
/// </summary>
/// <param name="model"></param>
void SaveOrdersToPdfFile(ReportBindingModel model);
/// <summary>
/// Сохранение магазинов в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveShopsToWordFile(ReportBindingModel model);
/// <summary>
/// Сохранение магазинов с указаеним продуктов в файл-Excel
/// </summary>
/// <param name="model"></param>
void SaveShopPrintedsToExcelFile(ReportBindingModel model);
/// <summary>
/// Получение списка магазинов
/// </summary>
/// <returns></returns>
List<ReportShopPrintedsViewModel> GetShopPrinteds();
/// <summary>
/// Получение списка заказов с группировкой по датам
/// </summary>
/// <returns></returns>
List<ReportDateOrdersViewModel> GetDateOrders();
/// <summary>
/// Сохранение заказов с группировкой по датам в файл-Pdf
/// </summary>
/// <param name="model"></param>
void SaveDateOrdersToPdfFile(ReportBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TypographyContracts.ViewModels
{
public class ReportDateOrdersViewModel
{
public DateTime DateCreate { get; set; }
public int CountOrders { get; set; }
public double SumOrders { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TypographyContracts.ViewModels
{
public class ReportShopPrintedsViewModel
{
public string ShopName { get; set; } = string.Empty;
public int Count { get; set; }
public List<Tuple<string, int>> Printeds { get; set; } = new();
}
}

View File

@ -19,5 +19,4 @@
<ProjectReference Include="..\TypographyContracts\TypographyContracts.csproj" />
<ProjectReference Include="..\TypographyDataModels\TypographyDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -32,6 +32,16 @@
справочникиToolStripMenuItem = new ToolStripMenuItem();
компонентыToolStripMenuItem = new ToolStripMenuItem();
изделиеToolStripMenuItem = new ToolStripMenuItem();
магазиныToolStripMenuItem = new ToolStripMenuItem();
пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
продажаИзделийToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
списокИзделийToolStripMenuItem = new ToolStripMenuItem();
компонентыПоИзделиямToolStripMenuItem1 = new ToolStripMenuItem();
списокЗаказовToolStripMenuItem1 = new ToolStripMenuItem();
списокМагазиновToolStripMenuItem = new ToolStripMenuItem();
загруженностьМагазинаToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовПоДатамToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem();
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
@ -49,7 +59,7 @@
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1146, 28);
@ -58,7 +68,7 @@
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, магазиныToolStripMenuItem });
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, магазиныToolStripMenuItem, пополнениеМагазинаToolStripMenuItem, продажаИзделийToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
@ -66,16 +76,86 @@
// компонентыToolStripMenuItem
//
компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
компонентыToolStripMenuItem.Size = new Size(182, 26);
компонентыToolStripMenuItem.Size = new Size(251, 26);
компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
компонентыToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
//
// изделиеToolStripMenuItem
//
изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
изделиеToolStripMenuItem.Size = new Size(182, 26);
изделиеToolStripMenuItem.Size = new Size(251, 26);
изделиеToolStripMenuItem.Text = "Изделие";
изделиеToolStripMenuItem.Click += ЗакускаToolStripMenuItem_Click;
изделиеToolStripMenuItem.Click += PrintedsToolStripMenuItem_Click;
//
// магазиныToolStripMenuItem
//
магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
магазиныToolStripMenuItem.Size = new Size(251, 26);
магазиныToolStripMenuItem.Text = "Магазины";
магазиныToolStripMenuItem.Click += shopsToolStripMenuItem_Click;
//
// пополнениеМагазинаToolStripMenuItem
//
пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
пополнениеМагазинаToolStripMenuItem.Size = new Size(251, 26);
пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
пополнениеМагазинаToolStripMenuItem.Click += shopsSupplyToolStripMenuItem_Click;
//
// продажаИзделийToolStripMenuItem
//
продажаИзделийToolStripMenuItem.Name = "продажаИзделийToolStripMenuItem";
продажаИзделийToolStripMenuItem.Size = new Size(251, 26);
продажаИзделийToolStripMenuItem.Text = "Продажа изделий";
продажаИзделийToolStripMenuItem.Click += sellPrintedsToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокИзделийToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem1, списокЗаказовToolStripMenuItem1, списокМагазиновToolStripMenuItem, загруженностьМагазинаToolStripMenuItem, списокЗаказовПоДатамToolStripMenuItem });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокИзделийToolStripMenuItem
//
списокИзделийToolStripMenuItem.Name = "списокИзделийToolStripMenuItem";
списокИзделийToolStripMenuItem.Size = new Size(276, 26);
списокИзделийToolStripMenuItem.Text = "Список изделий";
списокИзделийToolStripMenuItem.Click += printedsListToolStripMenuItem_Click;
//
// компонентыПоИзделиямToolStripMenuItem1
//
компонентыПоИзделиямToolStripMenuItem1.Name = омпонентыПоИзделиямToolStripMenuItem1";
компонентыПоИзделиямToolStripMenuItem1.Size = new Size(276, 26);
компонентыПоИзделиямToolStripMenuItem1.Text = "Компоненты по изделиям";
компонентыПоИзделиямToolStripMenuItem1.Click += componentsByPrintedsToolStripMenuItem_Click;
//
// списокЗаказовToolStripMenuItem1
//
списокЗаказовToolStripMenuItem1.Name = "списокЗаказовToolStripMenuItem1";
списокЗаказовToolStripMenuItem1.Size = new Size(276, 26);
списокЗаказовToolStripMenuItem1.Text = "Список заказов";
списокЗаказовToolStripMenuItem1.Click += ordersListToolStripMenuItem_Click;
//
// списокМагазиновToolStripMenuItem
//
списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
списокМагазиновToolStripMenuItem.Size = new Size(276, 26);
списокМагазиновToolStripMenuItem.Text = "Список магазинов";
списокМагазиновToolStripMenuItem.Click += shopsListToolStripMenuItem_Click;
//
// загруженностьМагазинаToolStripMenuItem
//
загруженностьМагазинаToolStripMenuItem.Name = агруженностьМагазинаToolStripMenuItem";
загруженностьМагазинаToolStripMenuItem.Size = new Size(276, 26);
загруженностьМагазинаToolStripMenuItem.Text = "Загруженность магазина";
загруженностьМагазинаToolStripMenuItem.Click += storeCongestionToolStripMenuItem_Click;
//
// списокЗаказовПоДатамToolStripMenuItem
//
списокЗаказовПоДатамToolStripMenuItem.Name = "списокЗаказовПоДатамToolStripMenuItem";
списокЗаказовПоДатамToolStripMenuItem.Size = new Size(276, 26);
списокЗаказовПоДатамToolStripMenuItem.Text = "Список заказов по датам";
списокЗаказовПоДатамToolStripMenuItem.Click += listOdOrdersByDatesToolStripMenuItem_Click;
//
// отчётыToolStripMenuItem
//
@ -96,14 +176,14 @@
компонентыПоИзделиямToolStripMenuItem.Name = омпонентыПоИзделиямToolStripMenuItem";
компонентыПоИзделиямToolStripMenuItem.Size = new Size(276, 26);
компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
компонентыПоИзделиямToolStripMenuItem.Click += ComponentProductsToolStripMenuItem_Click;
компонентыПоИзделиямToolStripMenuItem.Click += componentsByPrintedsToolStripMenuItem_Click;
//
// списокЗаказовToolStripMenuItem
//
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
списокЗаказовToolStripMenuItem.Size = new Size(276, 26);
списокЗаказовToolStripMenuItem.Text = "Список заказов";
списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
списокЗаказовToolStripMenuItem.Click += ordersListToolStripMenuItem_Click;
//
// dataGridView
//
@ -165,7 +245,7 @@
buttonUpd.TabIndex = 6;
buttonUpd.Text = "Обновить список";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
buttonUpd.Click += ButtonRef_Click;
//
// FormMain
//
@ -206,5 +286,15 @@
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
private ToolStripMenuItem продажаИзделийToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem списокИзделийToolStripMenuItem;
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem1;
private ToolStripMenuItem списокЗаказовToolStripMenuItem1;
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
private ToolStripMenuItem загруженностьМагазинаToolStripMenuItem;
private ToolStripMenuItem списокЗаказовПоДатамToolStripMenuItem;
}
}

View File

@ -13,16 +13,16 @@ using Microsoft.Extensions.Logging;
using TypographyDataModels.Enums;
using AbstractShopView;
using TypographyBusinessLogic.BusinessLogics;
using DocumentFormat.OpenXml.Spreadsheet;
using TypographyPlantView;
namespace TypographyView
{
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
@ -30,14 +30,13 @@ namespace TypographyView
_orderLogic = orderLogic;
_reportLogic = reportLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
_logger.LogInformation("Загрузка заказов");
try
{
var list = _orderLogic.ReadList(null);
@ -45,16 +44,81 @@ namespace TypographyView
{
dataGridView.DataSource = list;
dataGridView.Columns["PrintedId"].Visible = false;
dataGridView.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Orders loading");
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Orders loading error");
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
// управление менюшкой
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form)
{
form.ShowDialog();
}
}
private void PrintedsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds));
if (service is FormPrinteds form)
{
form.ShowDialog();
}
}
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
}
private void shopsSupplyToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMakeShipment));
if (service is FormMakeShipment form)
{
form.ShowDialog();
}
}
private void printedsListToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SavePrintedsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void componentsByPrintedsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportPrintedComponents));
if (service is FormReportPrintedComponents form)
{
form.ShowDialog();
}
}
private void ordersListToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form)
{
form.ShowDialog();
}
}
private void sellPrintedsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShopSell));
@ -64,41 +128,38 @@ namespace TypographyView
}
}
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
private void shopsListToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form)
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveShopsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void storeCongestionToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportShopPrinteds));
if (service is FormReportShopPrinteds form)
{
form.ShowDialog();
}
}
private void ЗакускаToolStripMenuItem_Click(object sender, EventArgs e)
private void listOdOrdersByDatesToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds));
if (service is FormPrinteds form)
{
form.ShowDialog();
}
}
private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
}
private void ПополнениеМагазиныToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMakeShipment));
if (service is FormMakeShipment form)
var service = Program.ServiceProvider?.GetService(typeof(FormReportDateOrders));
if (service is FormReportDateOrders form)
{
form.ShowDialog();
}
}
// управление заказами
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
@ -108,13 +169,24 @@ namespace TypographyView
LoadData();
}
}
private OrderBindingModel CreateBindingModel(int id)
{
return new OrderBindingModel
{
Id = id,
PrintedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["PrintedId"].Value),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
};
}
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Order №{id}. Status changes to 'В работе'", id);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id));
@ -126,18 +198,18 @@ namespace TypographyView
}
catch (Exception ex)
{
_logger.LogError(ex, "Error taking an order to work");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonOrderReady_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Order №{id}. Status changes to 'Готов'", id);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id));
@ -149,49 +221,17 @@ namespace TypographyView
}
catch (Exception ex)
{
_logger.LogError(ex, "Order readiness marking error");
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs
e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SavePrintedsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
private void ComponentProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportPrintedComponents));
if (service is FormReportPrintedComponents form)
{
form.ShowDialog();
}
}
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form)
{
form.ShowDialog();
}
}
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Order №{id}. Status changes to 'Выдан'", id);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id));
@ -199,32 +239,19 @@ e)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
_logger.LogInformation("Order №{id} issued", id);
_logger.LogInformation("Заказ №{id} выдан", id);
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Order issue marking error");
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private OrderBindingModel CreateBindingModel(int id)
{
return new OrderBindingModel
{
Id = id,
PrintedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["PrintedId"].Value),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = (System.DateTime)dataGridView.SelectedRows[0].Cells["DateCreate"].Value,
};
}
}
}

View File

@ -1,17 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
using Microsoft.Extensions.Logging;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
namespace TypographyView
{

View File

@ -0,0 +1,90 @@
namespace TypographyView
{
partial class FormReportDateOrders
{
/// <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()
{
panel = new Panel();
ButtonToPdf = new Button();
buttonMake = new Button();
panel.SuspendLayout();
SuspendLayout();
//
// panel
//
panel.Controls.Add(ButtonToPdf);
panel.Controls.Add(buttonMake);
panel.Dock = DockStyle.Top;
panel.Location = new Point(0, 0);
panel.Margin = new Padding(3, 4, 3, 4);
panel.Name = "panel";
panel.Size = new Size(914, 61);
panel.TabIndex = 0;
//
// ButtonToPdf
//
ButtonToPdf.Location = new Point(151, 16);
ButtonToPdf.Margin = new Padding(3, 4, 3, 4);
ButtonToPdf.Name = "ButtonToPdf";
ButtonToPdf.Size = new Size(86, 31);
ButtonToPdf.TabIndex = 7;
ButtonToPdf.Text = "В PDF";
ButtonToPdf.UseVisualStyleBackColor = true;
ButtonToPdf.Click += buttonToPDF_Click;
//
// buttonMake
//
buttonMake.Location = new Point(14, 16);
buttonMake.Margin = new Padding(3, 4, 3, 4);
buttonMake.Name = "buttonMake";
buttonMake.Size = new Size(131, 31);
buttonMake.TabIndex = 6;
buttonMake.Text = "Сформировать";
buttonMake.UseVisualStyleBackColor = true;
buttonMake.Click += buttonMake_Click;
//
// FormReportDateOrders
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(914, 600);
Controls.Add(panel);
Margin = new Padding(3, 4, 3, 4);
Name = "FormReportDateOrders";
Text = "Отчет по дням заказа";
FormClosed += FormReportDateOrders_FormClosed;
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button ButtonToPdf;
private Button buttonMake;
}
}

View File

@ -0,0 +1,75 @@
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using Microsoft.Reporting.WinForms;
namespace TypographyView
{
public partial class FormReportDateOrders : Form
{
private readonly ReportViewer reportViewer;
private readonly ILogger _logger;
private readonly IReportLogic _logic;
private readonly FileStream _fileStream;
public FormReportDateOrders(ILogger<FormReportDateOrders> logger, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_logic = reportLogic;
reportViewer = new ReportViewer
{
Dock = DockStyle.Fill
};
_fileStream = new FileStream("ReportOrdersByDate.rdlc", FileMode.Open);
reportViewer.LocalReport.LoadReportDefinition(_fileStream);
Controls.Clear();
Controls.Add(reportViewer);
Controls.Add(panel);
}
private void buttonMake_Click(object sender, EventArgs e)
{
try
{
var dataSource = _logic.GetDateOrders();
var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на весь период по датам");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonToPDF_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveDateOrdersToPdfFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка заказов на весь период по датам");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void FormReportDateOrders_FormClosed(object sender, FormClosedEventArgs e)
{
_fileStream.Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,107 @@
namespace TypographyPlantView
{
partial class FormReportShopPrinteds
{
/// <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()
{
buttonSaveToExcel = new Button();
dataGridView = new DataGridView();
Shop = new DataGridViewTextBoxColumn();
Printed = new DataGridViewTextBoxColumn();
Count = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonSaveToExcel
//
buttonSaveToExcel.Location = new Point(14, 16);
buttonSaveToExcel.Margin = new Padding(3, 4, 3, 4);
buttonSaveToExcel.Name = "buttonSaveToExcel";
buttonSaveToExcel.Size = new Size(146, 31);
buttonSaveToExcel.TabIndex = 0;
buttonSaveToExcel.Text = "Сохранить в Excel";
buttonSaveToExcel.UseVisualStyleBackColor = true;
buttonSaveToExcel.Click += buttonSaveToExcel_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Shop, Printed, Count });
dataGridView.Location = new Point(14, 55);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(887, 529);
dataGridView.TabIndex = 1;
//
// Shop
//
Shop.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
Shop.HeaderText = "Shop";
Shop.MinimumWidth = 6;
Shop.Name = "Shop";
//
// Printed
//
Printed.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
Printed.HeaderText = "Printed";
Printed.MinimumWidth = 6;
Printed.Name = "Printed";
//
// Count
//
Count.HeaderText = "Count";
Count.MinimumWidth = 6;
Count.Name = "Count";
Count.Width = 125;
//
// FormReportShopPrinteds
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(914, 600);
Controls.Add(dataGridView);
Controls.Add(buttonSaveToExcel);
Margin = new Padding(3, 4, 3, 4);
Name = "FormReportShopPrinteds";
Text = "Отчет магазинов по изделиям";
Load += FormReportShopPrinteds_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonSaveToExcel;
private DataGridView dataGridView;
private DataGridViewTextBoxColumn Shop;
private DataGridViewTextBoxColumn Printed;
private DataGridViewTextBoxColumn Count;
}
}

View File

@ -0,0 +1,72 @@
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace TypographyPlantView
{
public partial class FormReportShopPrinteds : Form
{
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportShopPrinteds(ILogger<FormReportShopPrinteds> logger, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_logic = reportLogic;
}
private void buttonSaveToExcel_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog
{
Filter = "xlsx|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveShopPrintedsToExcelFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка магазинов с автомобилями в них");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка магазинов с автомобилями в них");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void FormReportShopPrinteds_Load(object sender, EventArgs e)
{
try
{
var dict = _logic.GetShopPrinteds();
if (dict != null)
{
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
foreach (var listElem in elem.Printeds)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}
dataGridView.Rows.Add(new object[] { "Всего:", "", elem.Count });
dataGridView.Rows.Add(Array.Empty<object>());
}
}
_logger.LogInformation("Загрузка списка магазинов с авто в них");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка магазинов с авто в них");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,126 @@
<?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>
<metadata name="Shop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -3,10 +3,6 @@ using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using TypographyContracts.SearchModels;
using TypographyDataModels.Models;
using System.Windows.Forms;
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
namespace TypographyView
{

View File

@ -1,4 +1,4 @@
namespace AutomobilePlantView
namespace TypographyView
{
partial class FormShopSell
{

View File

@ -11,7 +11,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutomobilePlantView
namespace TypographyView
{
public partial class FormShopSell : Form
{

View File

@ -10,8 +10,6 @@ using System.Windows.Forms;
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using TypographyView;
namespace TypographyView
{

View File

@ -8,6 +8,7 @@ using NLog.Extensions.Logging;
using TypographyBusinessLogic.OfficePackage.Implements;
using TypographyBusinessLogic.OfficePackage;
using AbstractShopView;
using TypographyPlantView;
namespace TypographyView
{
@ -43,6 +44,13 @@ namespace TypographyView
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPrintedLogic, PrintedLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
@ -51,6 +59,12 @@ namespace TypographyView
services.AddTransient<FormPrinted>();
services.AddTransient<FormPrintedComponent>();
services.AddTransient<FormPrinteds>();
services.AddTransient<FormReportShopPrinteds>();
services.AddTransient<FormReportDateOrders>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormMakeShipment>();
services.AddTransient<FormShopSell>();
}
}
}

View File

@ -0,0 +1,424 @@
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="TypographyContractsViewModels">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSetOrders">
<Query>
<DataSourceName>TypographyContractsViewModels</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<Fields>
<Field Name="DateCreate">
<DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="CountOrders">
<DataField>CountOrders</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="SumOrders">
<DataField>SumOrders</DataField>
<rd:TypeName>System.Double</rd:TypeName>
</Field>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>TypographyContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportDateOrdersViewModel</rd:TableName>
<rd:ObjectDataSourceType>TypographyContracts.ViewModels.ReportDateOrdersViewModel, TypographyContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="TextboxTitle">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Заказы</Value>
<Style>
<FontSize>16pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Height>1cm</Height>
<Width>21cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>6.01401cm</Width>
</TablixColumn>
<TablixColumn>
<Width>6.56042cm</Width>
</TablixColumn>
<TablixColumn>
<Width>6.12687cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Дата</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox3">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Количество</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox3</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Сумма</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox2</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="DateCreate">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!DateCreate.Value</Value>
<Style>
<Format>d</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>DateCreate</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="CountOrders">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!CountOrders.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>CountOrders</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="SumOrders">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!SumOrders.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>SumOrders</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Подробности" />
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSetOrders</DataSetName>
<Top>1.95474cm</Top>
<Left>1.16099cm</Left>
<Height>1.2cm</Height>
<Width>18.7013cm</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
<Style>Double</Style>
</Border>
</Style>
</Tablix>
<Textbox Name="TextboxTotalSum">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Всего:</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>11.23542cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="SumTotal">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!SumOrders.Value, "DataSetOrders")</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>13.73542cm</Left>
<Height>0.6cm</Height>
<Width>6.12687cm</Width>
<ZIndex>3</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</ReportItems>
<Height>5.72875cm</Height>
<Style />
</Body>
<Width>21cm</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
<LeftMargin>2cm</LeftMargin>
<RightMargin>2cm</RightMargin>
<TopMargin>2cm</TopMargin>
<BottomMargin>2cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
</ReportSection>
</ReportSections>
<ReportParameters>
<ReportParameter Name="ReportParameterPeriod">
<DataType>String</DataType>
<Nullable>true</Nullable>
<Prompt>ReportParameter1</Prompt>
</ReportParameter>
</ReportParameters>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns>
<NumberOfRows>2</NumberOfRows>
<CellDefinitions>
<CellDefinition>
<ColumnIndex>0</ColumnIndex>
<RowIndex>0</RowIndex>
<ParameterName>ReportParameterPeriod</ParameterName>
</CellDefinition>
</CellDefinitions>
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
</Report>

View File

@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyBusinessLogic", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyFileImplement", "..\TypographyFileImplement\TypographyFileImplement.csproj", "{DCBDF361-C514-4319-A542-5629650E7E8A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypographyDatabaseImplements", "..\TypographyShopDatabaseImplements\TypographyDatabaseImplements.csproj", "{53696C80-7558-41F5-AF69-73ACA345C92B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyDatabaseImplements", "..\TypographyShopDatabaseImplements\TypographyDatabaseImplements.csproj", "{53696C80-7558-41F5-AF69-73ACA345C92B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution