доделать надо много + непонятно

This commit is contained in:
nezui1 2024-12-09 02:26:02 +04:00
parent 51d95da83b
commit 70b60799da
12 changed files with 300 additions and 115 deletions

View File

@ -18,6 +18,6 @@ public class AccessoiresOrder
public static AccessoiresOrder CreateElement(int id, int orderId, int count)
{
return new AccessoiresOrder { Id = id, OrderId = orderId, Count = count};
return new AccessoiresOrder { Id = id, OrderId = orderId, Count = count };
}
}

View File

@ -37,6 +37,7 @@
OrderToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
документСоСправочникамиToolStripMenuItem = new ToolStripMenuItem();
excelToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
@ -46,7 +47,8 @@
menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(784, 24);
menuStrip.Padding = new Padding(7, 3, 0, 3);
menuStrip.Size = new Size(896, 30);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
@ -54,27 +56,27 @@
//
справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AccossoriesToolStripMenuItem, MasterToolStripMenuItem, ServiceToolStripMenuItem });
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
справочникToolStripMenuItem.Size = new Size(94, 20);
справочникToolStripMenuItem.Size = new Size(117, 24);
справочникToolStripMenuItem.Text = "Справочники";
//
// AccossoriesToolStripMenuItem
//
AccossoriesToolStripMenuItem.Name = "AccossoriesToolStripMenuItem";
AccossoriesToolStripMenuItem.Size = new Size(180, 22);
AccossoriesToolStripMenuItem.Size = new Size(207, 26);
AccossoriesToolStripMenuItem.Text = "Комплектующие";
AccossoriesToolStripMenuItem.Click += AccossoriesToolStripMenuItem_Click;
//
// MasterToolStripMenuItem
//
MasterToolStripMenuItem.Name = "MasterToolStripMenuItem";
MasterToolStripMenuItem.Size = new Size(180, 22);
MasterToolStripMenuItem.Size = new Size(207, 26);
MasterToolStripMenuItem.Text = "Мастер";
MasterToolStripMenuItem.Click += MasterToolStripMenuItem_Click;
//
// ServiceToolStripMenuItem
//
ServiceToolStripMenuItem.Name = "ServiceToolStripMenuItem";
ServiceToolStripMenuItem.Size = new Size(180, 22);
ServiceToolStripMenuItem.Size = new Size(207, 26);
ServiceToolStripMenuItem.Text = "Услуга";
ServiceToolStripMenuItem.Click += ServiceToolStripMenuItem_Click;
//
@ -82,39 +84,47 @@
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { OrderToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(75, 20);
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// OrderToolStripMenuItem
//
OrderToolStripMenuItem.Name = "OrderToolStripMenuItem";
OrderToolStripMenuItem.Size = new Size(104, 22);
OrderToolStripMenuItem.Size = new Size(130, 26);
OrderToolStripMenuItem.Text = "Заказ";
OrderToolStripMenuItem.Click += OrderToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документСоСправочникамиToolStripMenuItem });
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документСоСправочникамиToolStripMenuItem, excelToolStripMenuItem });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// документСоСправочникамиToolStripMenuItem
//
документСоСправочникамиToolStripMenuItem.Name = окументСоСправочникамиToolStripMenuItem";
документСоСправочникамиToolStripMenuItem.Size = new Size(235, 22);
документСоСправочникамиToolStripMenuItem.Size = new Size(294, 26);
документСоСправочникамиToolStripMenuItem.Text = "Документ со справочниками";
документСоСправочникамиToolStripMenuItem.Click += DirecotryReportToolStripMenuItem_Click;
//
// excelToolStripMenuItem
//
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
excelToolStripMenuItem.Size = new Size(294, 26);
excelToolStripMenuItem.Text = "Excel";
excelToolStripMenuItem.Click += excelToolStripMenuItem_Click;
//
// FormCompRepair
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.morskie_kamni_raznocvetnaya_galka;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(784, 411);
ClientSize = new Size(896, 548);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Margin = new Padding(3, 4, 3, 4);
Name = "FormCompRepair";
StartPosition = FormStartPosition.CenterScreen;
Text = "Фирма по ремонту техники";
@ -135,5 +145,6 @@
private ToolStripMenuItem MasterToolStripMenuItem;
private ToolStripMenuItem ServiceToolStripMenuItem;
private ToolStripMenuItem документСоСправочникамиToolStripMenuItem;
private ToolStripMenuItem excelToolStripMenuItem;
}
}

View File

@ -73,5 +73,17 @@ namespace ProjectCompRepair
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void excelToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAccessoriesReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -42,30 +42,34 @@
//
// dateTimePickerDateEnd
//
dateTimePickerDateEnd.Location = new Point(173, 232);
dateTimePickerDateEnd.Location = new Point(198, 309);
dateTimePickerDateEnd.Margin = new Padding(3, 4, 3, 4);
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
dateTimePickerDateEnd.Size = new Size(200, 23);
dateTimePickerDateEnd.Size = new Size(228, 27);
dateTimePickerDateEnd.TabIndex = 0;
//
// dateTimePickerDateBegin
//
dateTimePickerDateBegin.Location = new Point(173, 192);
dateTimePickerDateBegin.Location = new Point(198, 256);
dateTimePickerDateBegin.Margin = new Padding(3, 4, 3, 4);
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
dateTimePickerDateBegin.Size = new Size(200, 23);
dateTimePickerDateBegin.Size = new Size(228, 27);
dateTimePickerDateBegin.TabIndex = 1;
//
// textBoxFilePath
//
textBoxFilePath.Location = new Point(173, 81);
textBoxFilePath.Location = new Point(198, 108);
textBoxFilePath.Margin = new Padding(3, 4, 3, 4);
textBoxFilePath.Name = "textBoxFilePath";
textBoxFilePath.Size = new Size(168, 23);
textBoxFilePath.Size = new Size(191, 27);
textBoxFilePath.TabIndex = 2;
//
// buttonSelectFilePath
//
buttonSelectFilePath.Location = new Point(347, 81);
buttonSelectFilePath.Location = new Point(397, 108);
buttonSelectFilePath.Margin = new Padding(3, 4, 3, 4);
buttonSelectFilePath.Name = "buttonSelectFilePath";
buttonSelectFilePath.Size = new Size(26, 23);
buttonSelectFilePath.Size = new Size(30, 31);
buttonSelectFilePath.TabIndex = 3;
buttonSelectFilePath.Text = "button1";
buttonSelectFilePath.UseVisualStyleBackColor = true;
@ -74,52 +78,54 @@
// comboBoxAccessories
//
comboBoxAccessories.FormattingEnabled = true;
comboBoxAccessories.Location = new Point(173, 138);
comboBoxAccessories.Location = new Point(198, 184);
comboBoxAccessories.Margin = new Padding(3, 4, 3, 4);
comboBoxAccessories.Name = "comboBoxAccessories";
comboBoxAccessories.Size = new Size(200, 23);
comboBoxAccessories.Size = new Size(228, 28);
comboBoxAccessories.TabIndex = 4;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(60, 84);
label1.Location = new Point(69, 112);
label1.Name = "label1";
label1.Size = new Size(38, 15);
label1.Size = new Size(50, 20);
label1.TabIndex = 5;
label1.Text = "label1";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(60, 141);
label2.Location = new Point(69, 188);
label2.Name = "label2";
label2.Size = new Size(38, 15);
label2.Size = new Size(50, 20);
label2.TabIndex = 6;
label2.Text = "label2";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(60, 198);
label3.Location = new Point(69, 264);
label3.Name = "label3";
label3.Size = new Size(38, 15);
label3.Size = new Size(50, 20);
label3.TabIndex = 7;
label3.Text = "label3";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(60, 238);
label4.Location = new Point(69, 317);
label4.Name = "label4";
label4.Size = new Size(38, 15);
label4.Size = new Size(50, 20);
label4.TabIndex = 8;
label4.Text = "label4";
//
// buttonMakeReport
//
buttonMakeReport.Location = new Point(153, 317);
buttonMakeReport.Location = new Point(175, 423);
buttonMakeReport.Margin = new Padding(3, 4, 3, 4);
buttonMakeReport.Name = "buttonMakeReport";
buttonMakeReport.Size = new Size(75, 23);
buttonMakeReport.Size = new Size(86, 31);
buttonMakeReport.TabIndex = 9;
buttonMakeReport.Text = "button2";
buttonMakeReport.UseVisualStyleBackColor = true;
@ -127,9 +133,9 @@
//
// FormAccessoriesReport
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
ClientSize = new Size(535, 600);
Controls.Add(buttonMakeReport);
Controls.Add(label4);
Controls.Add(label3);
@ -140,6 +146,7 @@
Controls.Add(textBoxFilePath);
Controls.Add(dateTimePickerDateBegin);
Controls.Add(dateTimePickerDateEnd);
Margin = new Padding(3, 4, 3, 4);
Name = "FormAccessoriesReport";
Text = "FormAccessoriesReport";
ResumeLayout(false);

View File

@ -0,0 +1,45 @@
namespace ProjectCompRepair.Forms
{
partial class FormAccessorieslDistributionReport
{
/// <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()
{
SuspendLayout();
//
// FormAccessorieslDistributionReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(432, 362);
Name = "FormAccessorieslDistributionReport";
Text = "FormAccessorieslDistributionReport";
ResumeLayout(false);
}
#endregion
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectCompRepair.Forms
{
public partial class FormAccessorieslDistributionReport : Form
{
public FormAccessorieslDistributionReport()
{
InitializeComponent();
}
}
}

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

@ -1,47 +1,48 @@
//using Microsoft.Extensions.Logging;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using ProjectCompRepair.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//namespace ProjectCompRepair.Reports;
namespace ProjectCompRepair.Reports;
//internal class ChartReport
//{
// private readonly IFeedingAnimalRepository _feedingAnimalRepository;
// private readonly ILogger<ChartReport> _logger;
internal class ChartReport
{
private readonly IAccessoriesRepository _accessoriesRepository;
private readonly ILogger<ChartReport> _logger;
// public ChartReport(IFeedingAnimalRepository feedingAnimalRepository, ILogger<ChartReport> logger)
// {
// _feedingAnimalRepository = feedingAnimalRepository ?? throw new ArgumentNullException(nameof(feedingAnimalRepository));
// _logger = logger ?? throw new ArgumentNullException(nameof(logger));
// }
public ChartReport(IAccessoriesRepository accessoriesRepository, ILogger<ChartReport> logger)
{
_accessoriesRepository = accessoriesRepository ?? throw new ArgumentNullException(nameof(accessoriesRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
// public bool CreateChart(string filePath, DateTime dateTime)
// {
// try
// {
// new PdfBuilder(filePath)
// .AddHeader("Питание животных")
// .AddPieChart("Выданные корма", GetData(dateTime))
// .Build();
// return true;
// }
// catch (Exception ex)
// {
// _logger.LogError(ex, "Ошибка при формировании документа");
// return false;
// }
// }
public bool CreateChart(string filePath, DateTime dateTime)
{
try
{
new PdfBuilder(filePath)
.AddHeader("Комплектующих")
.AddPieChart("потраченные комплектующие", GetData(dateTime))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
// private List<(string Caption, double Value)> GetData(DateTime dateTime)
// {
// return _feedingAnimalRepository
// .ReadFeedingAnimals()
// .Where(x => x.FeedingDate.Date == dateTime.Date)
// .GroupBy(x => x.AnimalId, (key, group) => new { Id = key, Count = group.Sum(x => x.Ration) })
// .Select(x => (x.Id.ToString(), (double)x.Count))
// .ToList();
// }
//}
private List<(string Caption, double Value)> GetData(DateTime dateTime)
{
return _accessoriesRepository
.ReadAccessories()
.Where(x => x.Date.Date == dateTime.Date)
.GroupBy(x => x.Id, (key, group) => new { Id = key, Count = group.Sum(x => x.Count) })
.Select(x => (x.Id.ToString(), (double)x.Count))
.ToList();
}
}

View File

@ -63,10 +63,10 @@ internal class ExcelBuilder
{
throw new ArgumentNullException(nameof(data));
}
if (data.Any(x => x.Length != columnsWidths.Length))
{
throw new InvalidOperationException("widths.Length != data.Length");
}
//if (data.Any(x => x.Length != columnsWidths.Length))
//{
// throw new InvalidOperationException("widths.Length != data.Length");
//}
uint counter = 1;
int coef = 2;

View File

@ -15,7 +15,7 @@ internal class TableReport
private readonly IAccessoriesRepository _accessoriesRepository;
private readonly ILogger<TableReport> _logger;
internal static readonly string[] item = ["Дата", "Тип комплектующего", "кол-во"];
internal static readonly string[] item = ["Дата", "вход", "выход"];
public TableReport(IOrderRepository orderRepository, IAccessoriesRepository accessoriesRepository, ILogger<TableReport> logger)
{
@ -31,7 +31,7 @@ internal class TableReport
new ExcelBuilder(filePath)
.AddHeader("Сводка по движению корма", 0, 4)
.AddParagraph("за период", 0)
.AddTable([10, 10, 15, 15], GetData(accessoriesId, startDate, endDate))
.AddTable([10, 15, 15], GetData(accessoriesId, startDate, endDate))
.Build();
return true;
}
@ -45,7 +45,7 @@ internal class TableReport
private List<string[]> GetData(int accessoriesId, DateTime startDate, DateTime endDate)
{
var data = _orderRepository.ReadOrder()
.Where(x => x.Date >= startDate && x.Date <= endDate && x.AccessoiresOrders.Any(y => y.Id == accessoriesId))
.Where(x => x.Date >= startDate && x.Date <= endDate && x.AccessoiresOrders.Any(y => y.Id == y.Id))
.Select(x => new {Date = x.Date, CountIn = x.AccessoiresOrders.FirstOrDefault(y => y.Id == accessoriesId)?.Count, CountOut = (int?)null })
.Union(
_accessoriesRepository

View File

@ -1,19 +0,0 @@
using ProjectCompRepair.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories;
public interface IAccessoriesOrderRepository
{
void CreateAccessoriesOrder(AccessoiresOrder accessoriesOrder);
void DeleteAccessoriesOrder(int id);
IEnumerable<AccessoiresOrder> ReadAccessoiresOrder(int? Id = 0, int? orderId = 0, int? count = 0);
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories.Implemantations;
public class AccessoriesOrderRepository
{
}