Отчет списка магазинов в word файл
This commit is contained in:
parent
8a60e580e8
commit
9a7407f156
28
LawFirm/LawFirm/FormMain.Designer.cs
generated
28
LawFirm/LawFirm/FormMain.Designer.cs
generated
@ -32,11 +32,11 @@
|
|||||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.списокДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.списокДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.бланкиПоДокументамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.бланкиПоДокументамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||||
this.buttonSetToWork = new System.Windows.Forms.Button();
|
this.buttonSetToWork = new System.Windows.Forms.Button();
|
||||||
@ -45,6 +45,7 @@
|
|||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
this.buttonSupplyShop = new System.Windows.Forms.Button();
|
this.buttonSupplyShop = new System.Windows.Forms.Button();
|
||||||
this.buttonSellDocuments = new System.Windows.Forms.Button();
|
this.buttonSellDocuments = new System.Windows.Forms.Button();
|
||||||
|
this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.menuStrip.SuspendLayout();
|
this.menuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -85,12 +86,20 @@
|
|||||||
this.документыToolStripMenuItem.Text = "Документы";
|
this.документыToolStripMenuItem.Text = "Документы";
|
||||||
this.документыToolStripMenuItem.Click += new System.EventHandler(this.документыToolStripMenuItem_Click);
|
this.документыToolStripMenuItem.Click += new System.EventHandler(this.документыToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// магазиныToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||||
|
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(170, 26);
|
||||||
|
this.магазиныToolStripMenuItem.Text = "Магазины";
|
||||||
|
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.списокДокументовToolStripMenuItem,
|
this.списокДокументовToolStripMenuItem,
|
||||||
this.бланкиПоДокументамToolStripMenuItem,
|
this.бланкиПоДокументамToolStripMenuItem,
|
||||||
this.списокЗаказовToolStripMenuItem});
|
this.списокЗаказовToolStripMenuItem,
|
||||||
|
this.списокМагазиновToolStripMenuItem});
|
||||||
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
|
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
|
||||||
this.отчетыToolStripMenuItem.Text = "Отчеты";
|
this.отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
@ -116,13 +125,6 @@
|
|||||||
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||||
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
|
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// магазиныToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
|
||||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(170, 26);
|
|
||||||
this.магазиныToolStripMenuItem.Text = "Магазины";
|
|
||||||
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
@ -203,6 +205,13 @@
|
|||||||
this.buttonSellDocuments.UseVisualStyleBackColor = true;
|
this.buttonSellDocuments.UseVisualStyleBackColor = true;
|
||||||
this.buttonSellDocuments.Click += new System.EventHandler(this.buttonSellDocuments_Click);
|
this.buttonSellDocuments.Click += new System.EventHandler(this.buttonSellDocuments_Click);
|
||||||
//
|
//
|
||||||
|
// списокМагазиновToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
|
||||||
|
this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(252, 26);
|
||||||
|
this.списокМагазиновToolStripMenuItem.Text = "Список магазинов";
|
||||||
|
this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.списокМагазиновToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
@ -248,5 +257,6 @@
|
|||||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||||
private Button buttonSupplyShop;
|
private Button buttonSupplyShop;
|
||||||
private Button buttonSellDocuments;
|
private Button buttonSellDocuments;
|
||||||
|
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -104,6 +104,19 @@ namespace LawFirmView
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void списокМагазиновToolStripMenuItem_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
@ -18,14 +18,16 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
private readonly IBlankStorage _blankStorage;
|
private readonly IBlankStorage _blankStorage;
|
||||||
private readonly IDocumentStorage _documentStorage;
|
private readonly IDocumentStorage _documentStorage;
|
||||||
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(IDocumentStorage documentStorage, IBlankStorage blankStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
public ReportLogic(IDocumentStorage documentStorage, IBlankStorage blankStorage, IOrderStorage orderStorage, IShopStorage shopStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||||
{
|
{
|
||||||
_documentStorage = documentStorage;
|
_documentStorage = documentStorage;
|
||||||
_blankStorage = blankStorage;
|
_blankStorage = blankStorage;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
_saveToPdf = saveToPdf;
|
_saveToPdf = saveToPdf;
|
||||||
@ -107,5 +109,15 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateTableDoc(new WordInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список магазинов",
|
||||||
|
Shops = _shopStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,38 @@ namespace LawFirmBusinessLogic.OfficePackage
|
|||||||
}
|
}
|
||||||
SaveWord(info);
|
SaveWord(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CreateTableDoc(WordInfo wordInfo)
|
||||||
|
{
|
||||||
|
CreateWord(wordInfo);
|
||||||
|
var list = new List<string>();
|
||||||
|
foreach (var shop in wordInfo.Shops)
|
||||||
|
{
|
||||||
|
list.Add(shop.Name);
|
||||||
|
list.Add(shop.Adress);
|
||||||
|
list.Add(shop.OpeningDate.ToString());
|
||||||
|
}
|
||||||
|
//list.AddRange(wordInfo.Shops.Select(x => (x.ShopName, new WordTextProperties { Bold = true, Size = "24" })));
|
||||||
|
var wordTable = new WordTable
|
||||||
|
{
|
||||||
|
Headers = new List<string> {
|
||||||
|
"Название",
|
||||||
|
"Адрес",
|
||||||
|
"Дата открытия"},
|
||||||
|
Texts = list
|
||||||
|
};
|
||||||
|
CreateTable(wordTable);
|
||||||
|
|
||||||
|
SaveWord(wordInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Создание doc-файла
|
/// Создание doc-файла
|
||||||
protected abstract void CreateWord(WordInfo info);
|
protected abstract void CreateWord(WordInfo info);
|
||||||
/// Создание абзаца с текстом
|
/// Создание абзаца с текстом
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
/// Сохранение файла
|
/// Сохранение файла
|
||||||
protected abstract void SaveWord(WordInfo info);
|
protected abstract void SaveWord(WordInfo info);
|
||||||
|
protected abstract void CreateTable(WordTable info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,6 @@ namespace LawFirmBusinessLogic.OfficePackage.HelperModels
|
|||||||
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;
|
||||||
public List<DocumentViewModel> Documents { get; set; } = new();
|
public List<DocumentViewModel> Documents { get; set; } = new();
|
||||||
|
public List<ShopViewModel> Shops { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LawFirmBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordTable
|
||||||
|
{
|
||||||
|
public List<string> Headers { get; set; } = new();
|
||||||
|
public List<string> Texts { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -112,5 +112,86 @@ namespace LawFirmBusinessLogic.OfficePackage.Implements
|
|||||||
_wordDocument.MainDocumentPart!.Document.Save();
|
_wordDocument.MainDocumentPart!.Document.Save();
|
||||||
_wordDocument.Close();
|
_wordDocument.Close();
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,7 @@ namespace LawFirmContracts.BusinessLogicContracts
|
|||||||
void SaveProductComponentToExcelFile(ReportBindingModel model);
|
void SaveProductComponentToExcelFile(ReportBindingModel model);
|
||||||
/// Сохранение заказов в файл-Pdf
|
/// Сохранение заказов в файл-Pdf
|
||||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
// Сохранение магазинов в файл-Word
|
||||||
|
void SaveShopsToWordFile(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user