Вроде работает

This commit is contained in:
Danil Markov 2023-03-27 19:39:11 +04:00
parent aade043bf1
commit 4a88074155
20 changed files with 867 additions and 259 deletions

View File

@ -49,8 +49,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
{
if (document.DocumentBlanks.ContainsKey(blank.Id))
{
record.Blanks.Add(new Tuple<string,
int>(blank.BlankName, document.DocumentBlanks[blank.Id].Item2));
record.Blanks.Add(new Tuple<string, int>(blank.BlankName, document.DocumentBlanks[blank.Id].Item2));
record.TotalCount +=
document.DocumentBlanks[blank.Id].Item2;
}
@ -90,12 +89,12 @@ namespace LawFirmBusinessLogic.BusinessLogics
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список компонент",
Title = "Список бланков",
Blanks = _blankStorage.GetFullList()
});
}
/// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel
/// Сохранение продукта с указаеним компонент в файл-Excel
/// </summary>
/// <param name="model"></param>
public void SaveDocumentBlankToExcelFile(ReportBindingModel model)
@ -103,7 +102,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список компонент",
Title = "Документы и их бланки",
DocumentBlanks = GetDocumentBlank()
});
}
@ -117,8 +116,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
{
FileName = model.FileName,
Title = "Список заказов",
DateFrom = model.DateFrom!.Value,
DateTo = model.DateTo!.Value,
DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
Orders = GetOrders(model)
});
}

View File

@ -31,27 +31,25 @@ namespace LawFirmBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.BlankName,
Text = pc.DocumentName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var document in pc.Documents)
foreach (var (Blanks, Count) in pc.Blanks)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = document.Item1,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Blanks,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = document.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}

View File

@ -22,7 +22,10 @@ namespace LawFirmBusinessLogic.OfficePackage
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> {(blank.BlankName, new WordTextProperties { Size = "24", }) },
Texts = new List<(string, WordTextProperties)> {
(blank.BlankName + " - ", new WordTextProperties { Size = "24", Bold=true}),
(blank.Price.ToString(), new WordTextProperties { Size = "24", })
},
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -54,8 +54,7 @@ namespace LawFirmBusinessLogic.OfficePackage.Implements
var properties = new ParagraphProperties();
properties.AppendChild(new Justification()
{
Val =
GetJustificationValues(paragraphProperties.JustificationType)
Val = GetJustificationValues(paragraphProperties.JustificationType)
});
properties.AppendChild(new SpacingBetweenLines
{
@ -67,8 +66,7 @@ namespace LawFirmBusinessLogic.OfficePackage.Implements
{
paragraphMarkRunProperties.AppendChild(new FontSize
{
Val =
paragraphProperties.Size
Val = paragraphProperties.Size
});
}
properties.AppendChild(paragraphMarkRunProperties);

View File

@ -18,7 +18,7 @@ namespace LawFirmContracts.ViewModels
[DisplayName("Статус")]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
[DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; }
}

View File

@ -4,6 +4,6 @@
{
public string DocumentName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Blank, int Count)> Blanks { get; set; } = new();
public List<Tuple<string, int>> Blanks { get; set; } = new();
}
}

View File

@ -40,14 +40,14 @@ namespace LawFirmDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
{
return new();
}
using var context = new LawFirmDatabase();
return context.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
return context.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo).Select(x => GetViewModel(x)).ToList();
}
public List<OrderViewModel> GetFullList()

View File

@ -60,8 +60,7 @@ namespace LawFirmDatabaseImplement.Models
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement,
DocumentName = Document.DocumentName
DateImplement = DateImplement
};
}
}

View File

@ -23,7 +23,7 @@ namespace LawFirmFileImplement.Implements
{
return new();
}
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
return source.Orders.Where(x => x.Id.Equals(model.Id) || model.DateFrom <= model.DateFrom && model.DateFrom <= model.DateTo).Select(x => GetViewModel(x)).ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{

View File

@ -25,13 +25,13 @@ namespace LawFirmListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue)
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
{
result.Add(GetViewModel(order));
}

View File

@ -32,16 +32,16 @@
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.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
this.buttonOrderReady = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
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.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@ -69,17 +69,48 @@
// бланкиToolStripMenuItem
//
this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem";
this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
this.бланкиToolStripMenuItem.Text = "Бланки";
this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click);
//
// документыToolStripMenuItem
//
this.документыToolStripMenuItem.Name = окументыToolStripMenuItem";
this.документыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.документыToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
this.документыToolStripMenuItem.Text = "Документы";
this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click);
//
// отчетыToolStripMenuItem
//
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.списокКомпонентовToolStripMenuItem,
this.компонентыПоИзделиямToolStripMenuItem,
this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокКомпонентовToolStripMenuItem
//
this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.BlanksReportToolStripMenuItem_Click);
//
// компонентыПоИзделиямToolStripMenuItem
//
this.компонентыПоИзделиямToolStripMenuItem.Name = омпонентыПоИзделиямToolStripMenuItem";
this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.DocumentBlanksReportToolStripMenuItem_Click);
//
// списокЗаказовToolStripMenuItem
//
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersReportToolStripMenuItem_Click);
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
@ -143,34 +174,6 @@
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
//
// отчетыToolStripMenuItem
//
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.списокКомпонентовToolStripMenuItem,
this.компонентыПоИзделиямToolStripMenuItem,
this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокКомпонентовToolStripMenuItem
//
this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
//
// компонентыПоИзделиямToolStripMenuItem
//
this.компонентыПоИзделиямToolStripMenuItem.Name = омпонентыПоИзделиямToolStripMenuItem";
this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
//
// списокЗаказовToolStripMenuItem
//
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -186,6 +189,7 @@
this.MainMenuStrip = this.menuStrip1;
this.Name = "FormMain";
this.Text = "Юридическая фирма";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();

View File

@ -1,4 +1,5 @@
using LawFirmContracts.BindingModels;
using LawFirmBusinessLogic.BusinessLogics;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmDataModels.Enums;
using Microsoft.Extensions.Logging;
@ -10,11 +11,14 @@ namespace LawFirmView
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
@ -162,5 +166,39 @@ namespace LawFirmView
form.ShowDialog();
}
}
private void BlanksReportToolStripMenuItem_Click(object sender, EventArgs
e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveBlanksToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
private void DocumentBlanksReportToolStripMenuItem_Click(object sender,
EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks));
if (service is FormReportDocumentBlanks form)
{
form.ShowDialog();
}
}
private void OrdersReportToolStripMenuItem_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormReportOrders));
if (service is FormReportOrders form)
{
form.ShowDialog();
}
}
}
}

View File

@ -44,6 +44,7 @@
this.buttonSaveToExcel.TabIndex = 0;
this.buttonSaveToExcel.Text = "Сохранить в Excel";
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
//
// dataGridView
//
@ -62,12 +63,12 @@
//
// ColumnBlank
//
this.ColumnBlank.HeaderText = "Бланк";
this.ColumnBlank.HeaderText = "Документ";
this.ColumnBlank.Name = "ColumnBlank";
//
// ColumnDocument
//
this.ColumnDocument.HeaderText = "Документ";
this.ColumnDocument.HeaderText = "Бланк";
this.ColumnDocument.Name = "ColumnDocument";
//
// ColumnCount

View File

@ -28,8 +28,8 @@ namespace LawFirmView
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.BlankName, "", "" });
foreach (var listElem in elem.Documents)
dataGridView.Rows.Add(new object[] { elem.DocumentName, "", "" });
foreach (var listElem in elem.Blanks)
{
dataGridView.Rows.Add(new object[] { "",
listElem.Item1, listElem.Item2 });
@ -50,5 +50,34 @@ elem.TotalCount });
}
}
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog
{
Filter = "xlsx|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveDocumentBlankToExcelFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Saving list of computers by components");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error saving list of computers by components");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -66,13 +66,4 @@
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnBlank.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnDocument.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -1,4 +1,4 @@
namespace TravelCompanyView
namespace LawFirmView
{
partial class FormReportOrders
{
@ -28,103 +28,104 @@
/// </summary>
private void InitializeComponent()
{
labelFrom = new Label();
dateTimePickerFrom = new DateTimePicker();
labelTo = new Label();
dateTimePickerTo = new DateTimePicker();
buttonMake = new Button();
buttonToPDF = new Button();
panel = new Panel();
panel.SuspendLayout();
SuspendLayout();
//
// labelFrom
//
labelFrom.AutoSize = true;
labelFrom.Location = new Point(11, 16);
labelFrom.Name = "labelFrom";
labelFrom.Size = new Size(23, 25);
labelFrom.TabIndex = 0;
labelFrom.Text = "С";
//
// dateTimePickerFrom
//
dateTimePickerFrom.Location = new Point(40, 11);
dateTimePickerFrom.Name = "dateTimePickerFrom";
dateTimePickerFrom.Size = new Size(224, 31);
dateTimePickerFrom.TabIndex = 1;
//
// labelTo
//
labelTo.AutoSize = true;
labelTo.Location = new Point(270, 16);
labelTo.Name = "labelTo";
labelTo.Size = new Size(33, 25);
labelTo.TabIndex = 2;
labelTo.Text = "по";
//
// dateTimePickerTo
//
dateTimePickerTo.Location = new Point(309, 11);
dateTimePickerTo.Name = "dateTimePickerTo";
dateTimePickerTo.Size = new Size(224, 31);
dateTimePickerTo.TabIndex = 3;
this.buttonMake = new System.Windows.Forms.Button();
this.buttonToPdf = new System.Windows.Forms.Button();
this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker();
this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.panel = new System.Windows.Forms.Panel();
this.panel.SuspendLayout();
this.SuspendLayout();
//
// buttonMake
//
buttonMake.Location = new Point(613, 11);
buttonMake.Name = "buttonMake";
buttonMake.Size = new Size(170, 34);
buttonMake.TabIndex = 4;
buttonMake.Text = "Сформировать";
buttonMake.UseVisualStyleBackColor = true;
buttonMake.Click += ButtonMake_Click;
this.buttonMake.Location = new System.Drawing.Point(354, 3);
this.buttonMake.Name = "buttonMake";
this.buttonMake.Size = new System.Drawing.Size(127, 23);
this.buttonMake.TabIndex = 0;
this.buttonMake.Text = "Сформировать";
this.buttonMake.UseVisualStyleBackColor = true;
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
//
// buttonToPDF
// buttonToPdf
//
buttonToPDF.Location = new Point(1061, 11);
buttonToPDF.Name = "buttonToPDF";
buttonToPDF.Size = new Size(170, 34);
buttonToPDF.TabIndex = 5;
buttonToPDF.Text = "В PDF";
buttonToPDF.UseVisualStyleBackColor = true;
buttonToPDF.Click += ButtonToPdf_Click;
this.buttonToPdf.Location = new System.Drawing.Point(487, 5);
this.buttonToPdf.Name = "buttonToPdf";
this.buttonToPdf.Size = new System.Drawing.Size(75, 22);
this.buttonToPdf.TabIndex = 1;
this.buttonToPdf.Text = "В PDF";
this.buttonToPdf.UseVisualStyleBackColor = true;
this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click);
//
// dateTimePickerFrom
//
this.dateTimePickerFrom.Location = new System.Drawing.Point(28, 3);
this.dateTimePickerFrom.Name = "dateTimePickerFrom";
this.dateTimePickerFrom.Size = new System.Drawing.Size(144, 23);
this.dateTimePickerFrom.TabIndex = 2;
//
// dateTimePickerTo
//
this.dateTimePickerTo.Location = new System.Drawing.Point(204, 3);
this.dateTimePickerTo.Name = "dateTimePickerTo";
this.dateTimePickerTo.Size = new System.Drawing.Size(144, 23);
this.dateTimePickerTo.TabIndex = 3;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(15, 15);
this.label1.TabIndex = 4;
this.label1.Text = "С";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(178, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(21, 15);
this.label2.TabIndex = 5;
this.label2.Text = "по";
//
// panel
//
panel.Controls.Add(buttonToPDF);
panel.Controls.Add(dateTimePickerTo);
panel.Controls.Add(buttonMake);
panel.Controls.Add(labelTo);
panel.Controls.Add(dateTimePickerFrom);
panel.Controls.Add(labelFrom);
panel.Dock = DockStyle.Top;
panel.Location = new Point(0, 0);
panel.Name = "panel";
panel.Size = new Size(1244, 56);
panel.TabIndex = 6;
this.panel.Controls.Add(this.dateTimePickerFrom);
this.panel.Controls.Add(this.buttonToPdf);
this.panel.Controls.Add(this.label1);
this.panel.Controls.Add(this.buttonMake);
this.panel.Controls.Add(this.label2);
this.panel.Controls.Add(this.dateTimePickerTo);
this.panel.Location = new System.Drawing.Point(0, 0);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(893, 32);
this.panel.TabIndex = 6;
//
// FormReportOrders
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1244, 450);
Controls.Add(panel);
Name = "FormReportOrders";
Text = "Заказы";
panel.ResumeLayout(false);
panel.PerformLayout();
ResumeLayout(false);
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(892, 325);
this.Controls.Add(this.panel);
this.Name = "FormReportOrders";
this.Text = "FormReportOrders";
this.Load += new System.EventHandler(this.FormReportOrders_Load);
this.panel.ResumeLayout(false);
this.panel.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Label labelFrom;
private DateTimePicker dateTimePickerFrom;
private Label labelTo;
private DateTimePicker dateTimePickerTo;
private Button buttonMake;
private Button buttonToPDF;
private Button buttonToPdf;
private DateTimePicker dateTimePickerFrom;
private DateTimePicker dateTimePickerTo;
private Label label1;
private Label label2;
private Panel panel;
}
}

View File

@ -1,18 +1,16 @@
using Microsoft.Extensions.Logging;
using Microsoft.Reporting.WinForms;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using Microsoft.Reporting.WinForms;
using System.Windows.Forms;
namespace TravelCompanyView
namespace LawFirmView
{
public partial class FormReportOrders : Form
{
private readonly ReportViewer reportViewer;
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportOrders(ILogger<FormReportOrders> logger, IReportLogic logic)
{
InitializeComponent();
@ -20,53 +18,67 @@ namespace TravelCompanyView
_logic = logic;
reportViewer = new ReportViewer
{
Dock = DockStyle.Fill
Dock = DockStyle.Bottom
};
try
{
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
}catch(Exception ex){}
Controls.Clear();
Controls.Add(reportViewer);
Controls.Add(panel);
}
private void FormReportOrders_Load(object sender, EventArgs e)
{
}
private void ButtonMake_Click(object sender, EventArgs e)
{
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
{
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Дата начала должна быть меньше даты окончания",
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var dataSource = _logic.GetOrders(new ReportBindingModel
{
DateFrom = dateTimePickerFrom.Value,
DateTo = dateTimePickerTo.Value
DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)
});
var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
$"c{dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(),
dateTimePickerTo.Value.ToShortDateString());
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonToPdf_Click(object sender, EventArgs e)
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
{
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Дата начала должна быть меньше даты окончания",
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
using var dialog = new SaveFileDialog
{
Filter = "pdf|*.pdf"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
@ -74,16 +86,20 @@ namespace TravelCompanyView
_logic.SaveOrdersToPdfFile(new ReportBindingModel
{
FileName = dialog.FileName,
DateFrom = dateTimePickerFrom.Value,
DateTo = dateTimePickerTo.Value
DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc)
});
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(),
dateTimePickerTo.Value.ToShortDateString());
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}

View File

@ -1,4 +1,6 @@
using LawFirmBusinessLogic.BusinessLogics;
using LawFirmBusinessLogic.OfficePackage.Implements;
using LawFirmBusinessLogic.OfficePackage;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.StoragesContracts;
using LawFirmDatabaseImplement.Implements;
@ -40,6 +42,11 @@ namespace LawFirmView
services.AddTransient<IBlankLogic, BlankLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IDocumentLogic, DocumentLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>();
services.AddTransient<FormBlank>();

View File

@ -1,10 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<?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="LawFirmContractsViewModels">
<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>LawFirmContractsViewModels</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<Fields>
<Field Name="Id">
<DataField>Id</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="DateCreate">
<DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="DocumentName">
<DataField>DocumentName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="OrderStatus">
<DataField>OrderStatus</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Sum">
<DataField>Sum</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>LawFirmContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportOrdersViewModel</rd:TableName>
<rd:ObjectDataSourceType>LawFirmContracts.ViewModels.ReportOrdersViewModel, LawFirmContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="ReportParameterPeriod">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style>
<FontSize>14pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>1cm</Top>
<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>
<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>
<ZIndex>1</ZIndex>
<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>2.5cm</Width>
</TablixColumn>
<TablixColumn>
<Width>3.21438cm</Width>
</TablixColumn>
<TablixColumn>
<Width>8.23317cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox5">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Номер</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox5</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="Textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
@ -12,18 +180,373 @@
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style />
<Value>Дата создания</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Top>1.58432cm</Top>
<Left>5.89703cm</Left>
<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>
<TablixCell>
<CellContents>
<Textbox Name="Textbox7">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Сумма</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox7</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="Id">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Id.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Id</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="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="DocumentName">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!DocumentName.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>DocumentName</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="OrderStatus">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!OrderStatus.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>OrderStatus</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="Sum">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Sum.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Sum</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 />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Подробности" />
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSetOrders</DataSetName>
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Height>1.2cm</Height>
<Width>18.94755cm</Width>
<ZIndex>2</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>12cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>3</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!Sum.Value, "DataSetOrders")</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>14.5cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>4</ZIndex>
<Style>
<Border>
<Style>None</Style>
@ -35,10 +558,10 @@
</Style>
</Textbox>
</ReportItems>
<Height>2in</Height>
<Height>5.72875cm</Height>
<Style />
</Body>
<Width>6.5in</Width>
<Width>21cm</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
@ -72,5 +595,5 @@
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>c390064e-687c-47f6-8c0d-0531793cf115</rd:ReportID>
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
</Report>

1
LawFirm/Temp.txt Normal file
View File

@ -0,0 +1 @@