лаба 3 починила

This commit is contained in:
Anya 2024-12-24 22:02:09 +04:00
parent 2d739dc2d5
commit 8c6863dacc
19 changed files with 322 additions and 20 deletions

View File

@ -1,5 +1,4 @@
using ProjectFuel.Entities.Enums;
using ProjectFuel.Entities.Enums;
namespace ProjectFuel.Entities;

View File

@ -1,5 +1,4 @@
using ProjectFuel.Entities.Enums;
using ProjectFuel.Entities.Enums;
namespace ProjectFuel.Entities;

View File

@ -1,5 +1,4 @@
using ProjectFuel.Entities.Enums;
using ProjectFuel.Entities.Enums;
using ProjectFuel.Entities;
namespace ProjectFuel.Entities;

View File

@ -38,6 +38,7 @@
RefillToolStripMenuItem = new ToolStripMenuItem();
TripToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
@ -61,28 +62,28 @@
// CarsToolStripMenuItem
//
CarsToolStripMenuItem.Name = "CarsToolStripMenuItem";
CarsToolStripMenuItem.Size = new Size(359, 44);
CarsToolStripMenuItem.Size = new Size(267, 44);
CarsToolStripMenuItem.Text = "Машины";
CarsToolStripMenuItem.Click += CarsToolStripMenuItem_Click;
//
// DriversToolStripMenuItem
//
DriversToolStripMenuItem.Name = "DriversToolStripMenuItem";
DriversToolStripMenuItem.Size = new Size(359, 44);
DriversToolStripMenuItem.Size = new Size(267, 44);
DriversToolStripMenuItem.Text = "Водители";
DriversToolStripMenuItem.Click += DriversToolStripMenuItem_Click;
//
// FuelToolStripMenuItem
//
FuelToolStripMenuItem.Name = "FuelToolStripMenuItem";
FuelToolStripMenuItem.Size = new Size(359, 44);
FuelToolStripMenuItem.Size = new Size(267, 44);
FuelToolStripMenuItem.Text = "Топливо";
FuelToolStripMenuItem.Click += FuelToolStripMenuItem_Click;
//
// RoutesToolStripMenuItem
//
RoutesToolStripMenuItem.Name = "RoutesToolStripMenuItem";
RoutesToolStripMenuItem.Size = new Size(359, 44);
RoutesToolStripMenuItem.Size = new Size(267, 44);
RoutesToolStripMenuItem.Text = "Маршруты";
RoutesToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
//
@ -96,23 +97,32 @@
// RefillToolStripMenuItem
//
RefillToolStripMenuItem.Name = "RefillToolStripMenuItem";
RefillToolStripMenuItem.Size = new Size(359, 44);
RefillToolStripMenuItem.Size = new Size(249, 44);
RefillToolStripMenuItem.Text = "Заправка";
RefillToolStripMenuItem.Click += RefillToolStripMenuItem_Click;
//
// TripToolStripMenuItem
//
TripToolStripMenuItem.Name = "TripToolStripMenuItem";
TripToolStripMenuItem.Size = new Size(359, 44);
TripToolStripMenuItem.Size = new Size(249, 44);
TripToolStripMenuItem.Text = "Поездка";
TripToolStripMenuItem.Click += TripToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(116, 38);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// DirectoryReportToolStripMenuItem
//
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
DirectoryReportToolStripMenuItem.Size = new Size(559, 44);
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
//
// FormFuel
//
AutoScaleDimensions = new SizeF(13F, 32F);
@ -143,5 +153,6 @@
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem RefillToolStripMenuItem;
private ToolStripMenuItem TripToolStripMenuItem;
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
}
}

View File

@ -94,5 +94,18 @@ namespace ProjectFuel
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormDirectoryReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,113 @@
namespace ProjectFuel.Forms_
{
partial class FormDirectoryReport
{
/// <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()
{
checkBox1 = new CheckBox();
checkBox2 = new CheckBox();
checkBox3 = new CheckBox();
checkBox4 = new CheckBox();
buttonBuild = new Button();
SuspendLayout();
//
// checkBox1
//
checkBox1.AutoSize = true;
checkBox1.Location = new Point(67, 71);
checkBox1.Name = "checkBox1";
checkBox1.Size = new Size(184, 36);
checkBox1.TabIndex = 0;
checkBox1.Text = "Автомобили";
checkBox1.UseVisualStyleBackColor = true;
//
// checkBox2
//
checkBox2.AutoSize = true;
checkBox2.Location = new Point(67, 140);
checkBox2.Name = "checkBox2";
checkBox2.Size = new Size(151, 36);
checkBox2.TabIndex = 1;
checkBox2.Text = "Водители";
checkBox2.UseVisualStyleBackColor = true;
//
// checkBox3
//
checkBox3.AutoSize = true;
checkBox3.Location = new Point(67, 215);
checkBox3.Name = "checkBox3";
checkBox3.Size = new Size(141, 36);
checkBox3.TabIndex = 2;
checkBox3.Text = "Топливо";
checkBox3.UseVisualStyleBackColor = true;
//
// checkBox4
//
checkBox4.AutoSize = true;
checkBox4.Location = new Point(67, 282);
checkBox4.Name = "checkBox4";
checkBox4.Size = new Size(149, 36);
checkBox4.TabIndex = 3;
checkBox4.Text = "Маршрут";
checkBox4.UseVisualStyleBackColor = true;
//
// buttonBuild
//
buttonBuild.Location = new Point(494, 179);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(225, 46);
buttonBuild.TabIndex = 4;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += buttonBuild_Click;
//
// FormDirectoryReport
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonBuild);
Controls.Add(checkBox4);
Controls.Add(checkBox3);
Controls.Add(checkBox2);
Controls.Add(checkBox1);
Name = "FormDirectoryReport";
StartPosition = FormStartPosition.CenterParent;
Text = "FormDirectoryReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBox1;
private CheckBox checkBox2;
private CheckBox checkBox3;
private CheckBox checkBox4;
private Button buttonBuild;
}
}

View File

@ -0,0 +1,54 @@
using ProjectFuel.Reports;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectFuel.Forms_
{
public partial class FormDirectoryReport : Form
{
private readonly IUnityContainer _container;
public FormDirectoryReport(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void buttonBuild_Click(object sender, EventArgs e)
{
try
{
if (!checkBox1.Checked && !checkBox2.Checked && !checkBox3.Checked && !checkBox4.Checked)
throw new Exception("Не выбран ни один справочник для выгрузки");
var sfd = new SaveFileDialog()
{
Filter = "Docx Files | *.docx"
};
if (sfd.ShowDialog() != DialogResult.OK)
throw new Exception("Не выбран файла для отчета");
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBox1.Checked, checkBox2.Checked, checkBox3.Checked, checkBox4.Checked))
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

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

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>

View File

@ -1,5 +1,4 @@
using ProjectFuel.Entities;
using ProjectFuel.Entities;
namespace ProjectFuel.Repositories;

View File

@ -1,5 +1,5 @@
using ProjectFuel.Entities;
using ProjectFuel.Entities;
namespace ProjectFuel.Repositories;

View File

@ -1,5 +1,5 @@
using ProjectFuel.Entities;
using ProjectFuel.Entities;
namespace ProjectFuel.Repositories;

View File

@ -1,5 +1,5 @@
using ProjectFuel.Entities;
using ProjectFuel.Entities;
namespace ProjectFuel.Repositories;

View File

@ -1,5 +1,5 @@
using ProjectFuel.Entities;
using ProjectFuel.Entities;
namespace ProjectFuel.Repositories;

View File

@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectFuel.Entities;
using ProjectFuel.Entities;
using ProjectFuel.Repositories;
namespace ProjectFuel.Repositories.Implementations;

View File

@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectFuel.Entities;
using ProjectFuel.Entities;
using ProjectFuel.Repositories;
namespace ProjectFuel.Repositories.Implementations;

View File

@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectFuel.Entities;
using ProjectFuel.Entities;
using ProjectFuel.Repositories;
namespace ProjectFuel.Repositories.Implementations;

View File

@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectFuel.Entities;
using ProjectFuel.Entities;
using ProjectFuel.Repositories;
namespace ProjectFuel.Repositories.Implementations;

View File

@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectFuel.Entities;
using ProjectFuel.Entities;
using ProjectFuel.Repositories;
namespace ProjectFuel.Repositories.Implementations;