Отчёт по магазинам в word
This commit is contained in:
parent
1f48e676f2
commit
2e66e6e59f
51
GarmentFactory/FormMain.Designer.cs
generated
51
GarmentFactory/FormMain.Designer.cs
generated
@ -1,26 +1,26 @@
|
|||||||
namespace GarmentFactoryView
|
namespace GarmentFactoryView
|
||||||
{
|
{
|
||||||
partial class FormMain
|
partial class FormMain
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
@ -46,6 +46,7 @@
|
|||||||
textilesToolStripMenuItem = new ToolStripMenuItem();
|
textilesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
textileComponentsToolStripMenuItem = new ToolStripMenuItem();
|
textileComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ordersToolStripMenuItem = new ToolStripMenuItem();
|
ordersToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
магазиныВDocToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -182,7 +183,7 @@
|
|||||||
//
|
//
|
||||||
// отчётыToolStripMenuItem
|
// отчётыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem });
|
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem, магазиныВDocToolStripMenuItem });
|
||||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||||
отчётыToolStripMenuItem.Size = new Size(73, 24);
|
отчётыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||||
@ -208,6 +209,13 @@
|
|||||||
ordersToolStripMenuItem.Text = "Заказы";
|
ordersToolStripMenuItem.Text = "Заказы";
|
||||||
ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// магазиныВDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
магазиныВDocToolStripMenuItem.Name = "магазиныВDocToolStripMenuItem";
|
||||||
|
магазиныВDocToolStripMenuItem.Size = new Size(274, 26);
|
||||||
|
магазиныВDocToolStripMenuItem.Text = "Магазины в doc";
|
||||||
|
магазиныВDocToolStripMenuItem.Click += магазиныВDocToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -231,7 +239,7 @@
|
|||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private Button buttonCreateOrder;
|
private Button buttonCreateOrder;
|
||||||
@ -251,5 +259,6 @@
|
|||||||
private ToolStripMenuItem textilesToolStripMenuItem;
|
private ToolStripMenuItem textilesToolStripMenuItem;
|
||||||
private ToolStripMenuItem textileComponentsToolStripMenuItem;
|
private ToolStripMenuItem textileComponentsToolStripMenuItem;
|
||||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem магазиныВDocToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,15 +52,15 @@ namespace GarmentFactoryView
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
if (service is FormComponents form)
|
if (service is FormComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void текстилиToolStripMenuItem_Click(object sender, EventArgs e)
|
private void текстилиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -102,114 +102,124 @@ namespace GarmentFactoryView
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||||
|
|
||||||
if (service is FormShops form)
|
if (service is FormShops form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||||
if (service is FormCreateOrder form)
|
if (service is FormCreateOrder form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonCompletedOrder_Click(object sender, EventArgs e)
|
private void ButtonCompletedOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void пополнениеМагазинаToolStripMenuItem1_Click(object sender, EventArgs e)
|
private void пополнениеМагазинаToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddTextile));
|
var service = Program.ServiceProvider?.GetService(typeof(FormAddTextile));
|
||||||
|
|
||||||
if (service is FormAddTextile form)
|
if (service is FormAddTextile form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void продажаТовараToolStripMenuItem_Click(object sender, EventArgs e)
|
private void продажаТовараToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellTextile));
|
var service = Program.ServiceProvider?.GetService(typeof(FormSellTextile));
|
||||||
if (service is FormSellTextile form)
|
if (service is FormSellTextile form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void магазиныВDocToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
|
||||||
namespace GarmentFactoryBusinessLogic.BusinessLogics
|
namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
@ -18,16 +19,18 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
|||||||
private readonly IComponentStorage _componentStorage;
|
private readonly IComponentStorage _componentStorage;
|
||||||
private readonly ITextileStorage _textileStorage;
|
private readonly ITextileStorage _textileStorage;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
|
||||||
public ReportLogic(ITextileStorage textileStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
public ReportLogic(ITextileStorage textileStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
|
||||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||||
{
|
{
|
||||||
_textileStorage = textileStorage;
|
_textileStorage = textileStorage;
|
||||||
_componentStorage = componentStorage;
|
_componentStorage = componentStorage;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
@ -106,5 +109,55 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
|||||||
Orders = GetOrders(model)
|
Orders = GetOrders(model)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ReportShopsViewModel> GetShops()
|
||||||
|
{
|
||||||
|
return _shopStorage.GetFullList().Select(x => new ReportShopsViewModel
|
||||||
|
{
|
||||||
|
ShopName = x.ShopName,
|
||||||
|
Textiles = x.ShopTextiles.Select(x => (x.Value.Item1.TextileName, x.Value.Item2)).ToList(),
|
||||||
|
TotalCount = x.ShopTextiles.Select(x => x.Value.Item2).Sum()
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//public List<ReportGroupOrdersViewModel> GetGroupedOrders()
|
||||||
|
//{
|
||||||
|
// return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupOrdersViewModel
|
||||||
|
// {
|
||||||
|
// Date = x.Key,
|
||||||
|
// OrdersCount = x.Count(),
|
||||||
|
// OrdersSum = x.Select(y => y.Sum).Sum()
|
||||||
|
// }).ToList();
|
||||||
|
//}
|
||||||
|
|
||||||
|
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateShopsDoc(new WordShopInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список магазинов",
|
||||||
|
Shops = _shopStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//public void SaveShopsToExcelFile(ReportBindingModel model)
|
||||||
|
//{
|
||||||
|
// _saveToExcel.CreateShopTextilesReport(new ExcelShop
|
||||||
|
// {
|
||||||
|
// FileName = model.FileName,
|
||||||
|
// Title = "Наполненость магазинов",
|
||||||
|
// ShopTextiles = GetShops()
|
||||||
|
// });
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
//{
|
||||||
|
// _saveToPdf.CreateGroupedOrdersDoc(new PdfGroupedOrdersInfo
|
||||||
|
// {
|
||||||
|
// FileName = model.FileName,
|
||||||
|
// Title = "Список заказов сгруппированных по дате заказов",
|
||||||
|
// GroupedOrders = GetGroupedOrders()
|
||||||
|
// });
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using GarmentFactoryBusinessLogic.OfficePackage;
|
||||||
|
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -43,11 +45,52 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
|
|||||||
SaveWord(info);
|
SaveWord(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CreateShopsDoc(WordShopInfo info)
|
||||||
|
{
|
||||||
|
CreateWord(info);
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "3000", "3000", "3000" });
|
||||||
|
CreateRow(new WordRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Название", "Адрес", "Дата открытия" },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
Bold = true,
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var shop in info.Shops)
|
||||||
|
{
|
||||||
|
CreateRow(new WordRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { shop.ShopName, shop.Address, shop.DateOpen.ToString() },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "22",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveWord(info);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание doc-файла
|
/// Создание doc-файла
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info"></param>
|
/// <param name="info"></param>
|
||||||
protected abstract void CreateWord(WordInfo info);
|
protected abstract void CreateWord(IDocumentInfo info);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание абзаца с текстом
|
/// Создание абзаца с текстом
|
||||||
@ -60,6 +103,9 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
|
|||||||
/// Сохранение файла
|
/// Сохранение файла
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info"></param>
|
/// <param name="info"></param>
|
||||||
protected abstract void SaveWord(WordInfo info);
|
protected abstract void SaveWord(IDocumentInfo info);
|
||||||
|
|
||||||
|
protected abstract void CreateTable(List<string> colums);
|
||||||
|
protected abstract void CreateRow(WordRowParameters rowParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using GarmentFactoryContracts.ViewModels;
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using GarmentFactoryBusinessLogic.OfficePackage;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -7,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordInfo
|
public class WordInfo : IDocumentInfo
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordRowParameters
|
||||||
|
{
|
||||||
|
public List<string> Texts { get; set; } = new();
|
||||||
|
public WordTextProperties TextProperties { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordShopInfo : IDocumentInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ShopViewModel> Shops { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
14
GarmentFactoryBusinessLogic/OfficePackage/IDocument.cs
Normal file
14
GarmentFactoryBusinessLogic/OfficePackage/IDocument.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public interface IDocumentInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -85,7 +85,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateWord(WordInfo info)
|
protected override void CreateWord(IDocumentInfo info)
|
||||||
{
|
{
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
@ -123,7 +123,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
|||||||
_docBody.AppendChild(docParagraph);
|
_docBody.AppendChild(docParagraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SaveWord(WordInfo info)
|
protected override void SaveWord(IDocumentInfo info)
|
||||||
{
|
{
|
||||||
if (_docBody == null || _wordDocument == null)
|
if (_docBody == null || _wordDocument == null)
|
||||||
{
|
{
|
||||||
@ -135,5 +135,77 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
|||||||
|
|
||||||
_wordDocument.Close();
|
_wordDocument.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Table? _lastTable;
|
||||||
|
protected override void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (_docBody == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_lastTable = new Table();
|
||||||
|
|
||||||
|
var tableProp = new TableProperties();
|
||||||
|
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||||
|
tableProp.AppendChild(new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||||
|
));
|
||||||
|
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||||
|
_lastTable.AppendChild(tableProp);
|
||||||
|
|
||||||
|
TableGrid tableGrid = new TableGrid();
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
tableGrid.AppendChild(new GridColumn() { Width = column });
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(tableGrid);
|
||||||
|
|
||||||
|
_docBody.AppendChild(_lastTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateRow(WordRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (_docBody == null || _lastTable == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TableRow docRow = new TableRow();
|
||||||
|
foreach (var column in rowParameters.Texts)
|
||||||
|
{
|
||||||
|
var docParagraph = new Paragraph();
|
||||||
|
WordParagraph paragraph = new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (column, rowParameters.TextProperties) },
|
||||||
|
TextProperties = rowParameters.TextProperties
|
||||||
|
};
|
||||||
|
|
||||||
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||||
|
|
||||||
|
foreach (var run in paragraph.Texts)
|
||||||
|
{
|
||||||
|
var docRun = new Run();
|
||||||
|
|
||||||
|
var properties = new RunProperties();
|
||||||
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
|
if (run.Item2.Bold)
|
||||||
|
{
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
}
|
||||||
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
|
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
|
|
||||||
|
docParagraph.AppendChild(docRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableCell docCell = new TableCell();
|
||||||
|
docCell.AppendChild(docParagraph);
|
||||||
|
docRow.AppendChild(docCell);
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(docRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,9 @@ namespace GarmentFactoryContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
|
||||||
|
void SaveShopsToWordFile(ReportBindingModel model);
|
||||||
|
//void SaveShopsToExcelFile(ReportBindingModel model);
|
||||||
|
//void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
GarmentFactoryContracts/ViewModels/ReportShopsViewModel.cs
Normal file
15
GarmentFactoryContracts/ViewModels/ReportShopsViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportShopsViewModel
|
||||||
|
{
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
public List<(string textile, int count)> Textiles { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user