Compare commits

...

20 Commits
main ... Lab3

Author SHA1 Message Date
8e1c9fddf3 а 2024-11-06 02:29:54 +04:00
9f7ccfd039 ч 2024-11-06 02:29:51 +04:00
deb181b802 а 2024-11-06 02:29:29 +04:00
c877e5ef03 ща буит мясо 2024-11-06 02:29:24 +04:00
2269741c4e ищии 2024-11-05 22:04:36 +04:00
70c53604d6 ищи 2024-11-05 22:04:24 +04:00
70c30c1b3a . 2024-10-23 09:21:48 +04:00
41d624668f случайно начал 3 тут 2024-10-23 09:21:37 +04:00
64c5d64d30 можете сдавать 2024-10-22 22:57:47 +04:00
b7276eb339 6 2024-10-22 22:18:54 +04:00
f6c9b56bb1 хз 2024-10-22 22:16:45 +04:00
21fc0e3e1d ща буду ломать 2024-10-07 11:33:14 +04:00
b56ba80fad ну доделал 2 лабу 2024-10-06 18:45:39 +04:00
17d45a0339 largeTextPfg 2024-10-06 17:39:02 +04:00
6b8069c9d9 Сдал) всё изи 2024-09-06 10:49:14 +04:00
1ead8266cc Сижу на паре, ща буду сдавать) если коммитов дальлше нет - сдал 2024-09-06 10:38:12 +04:00
3939413204 тяп ляп готово 2024-09-06 00:43:56 +04:00
b671cbbcad List??? 2024-09-05 23:08:08 +04:00
1df675da5a fix 2024-09-05 21:53:15 +04:00
b7ef886c3c number + combo 2024-09-05 21:45:49 +04:00
70 changed files with 3826 additions and 60 deletions

47
COP_25/Forms/Forms.csproj Normal file
View File

@ -0,0 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponentsTest" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.35">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="NotVisualComponent" Version="1.0.0" />
<PackageReference Include="WinFormsLibrary" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Controls\Controls.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,101 @@
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class DeliveryLogic : IDeliveryLogic
{
private readonly IDeliveryStorage _providerStorage;
public DeliveryLogic(IDeliveryStorage providerStorage)
{
_providerStorage = providerStorage;
}
public List<DeliveryViewModel>? ReadList(DeliverySearchModel? model)
{
var list = model == null ? _providerStorage.GetFullList() : _providerStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public DeliveryViewModel? ReadElement(DeliverySearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _providerStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(DeliveryBindingModel model)
{
CheckModel(model);
if (_providerStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(DeliveryBindingModel model)
{
CheckModel(model);
if (_providerStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(DeliveryBindingModel model)
{
CheckModel(model, false);
if (_providerStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(DeliveryBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.FCs))
{
throw new ArgumentException("Введите ФИО курьера", nameof(model.FCs));
}
if (string.IsNullOrEmpty(model.DeliveryType))
{
throw new ArgumentException("Введите тип доставки", nameof(model.DeliveryType));
}
if (string.IsNullOrEmpty(model.Wishes))
{
throw new ArgumentException("Введите пожелания", nameof(model.Wishes));
}
}
}
}

View File

@ -0,0 +1,93 @@
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.BusinessLogic
{
public class DeliveryTypeLogic : IDeliveryTypeLogic
{
private readonly IDeliveryTypeStorage _orgTypeStorage;
public DeliveryTypeLogic(IDeliveryTypeStorage orgTypeStorage)
{
_orgTypeStorage = orgTypeStorage;
}
public List<DeliveryTypeViewModel>? ReadList(DeliveryTypeSearchModel? model)
{
var list = model == null ? _orgTypeStorage.GetFullList() : _orgTypeStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public DeliveryTypeViewModel? ReadElement(DeliveryTypeSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _orgTypeStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(DeliveryTypeBindingModel model)
{
CheckModel(model);
if (_orgTypeStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(DeliveryTypeBindingModel model)
{
CheckModel(model);
if (_orgTypeStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(DeliveryTypeBindingModel model)
{
CheckModel(model, false);
if (_orgTypeStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(DeliveryTypeBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentException("Введите название доставки", nameof(model.Name));
}
}
}
}

View File

@ -0,0 +1,22 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindlingModels
{
public class DeliveryBindingModel : IDeliveryModel
{
public int Id { get; set; }
public string FCs { get; set; } = string.Empty;
public string Wishes { get; set; } = string.Empty;
public string DeliveryType { get; set; } = string.Empty;
public string? DeliveryDate { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindlingModels
{
public class DeliveryTypeBindingModel : IDeliveryTypeModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindlingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface IDeliveryLogic
{
List<DeliveryViewModel>? ReadList(DeliverySearchModel? model);
DeliveryViewModel? ReadElement(DeliverySearchModel? model);
bool Create(DeliveryBindingModel model);
bool Update(DeliveryBindingModel model);
bool Delete(DeliveryBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindlingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicContracts
{
public interface IDeliveryTypeLogic
{
List<DeliveryTypeViewModel>? ReadList(DeliveryTypeSearchModel? model);
DeliveryTypeViewModel? ReadElement(DeliveryTypeSearchModel? model);
bool Create(DeliveryTypeBindingModel model);
bool Update(DeliveryTypeBindingModel model);
bool Delete(DeliveryTypeBindingModel model);
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class DeliverySearchModel
{
public int? Id { get; set; }
public string? FCs { get; set; }
public string? DeliveryType { get; set; }
public string? DeliveryDate { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class DeliveryTypeSearchModel
{
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindlingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IDeliveryStorage
{
List<DeliveryViewModel> GetFullList();
List<DeliveryViewModel> GetFilteredList(DeliverySearchModel model);
DeliveryViewModel? GetElement(DeliverySearchModel model);
DeliveryViewModel? Insert(DeliveryBindingModel model);
DeliveryViewModel? Update(DeliveryBindingModel model);
DeliveryViewModel? Delete(DeliveryBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindlingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IDeliveryTypeStorage
{
List<DeliveryTypeViewModel> GetFullList();
List<DeliveryTypeViewModel> GetFilteredList(DeliveryTypeSearchModel model);
DeliveryTypeViewModel? GetElement(DeliveryTypeSearchModel model);
DeliveryTypeViewModel? Insert(DeliveryTypeBindingModel model);
DeliveryTypeViewModel? Update(DeliveryTypeBindingModel model);
DeliveryTypeViewModel? Delete(DeliveryTypeBindingModel model);
}
}

View File

@ -0,0 +1,18 @@
using Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class DeliveryTypeViewModel : IDeliveryTypeModel
{
public int Id { get; set; }
[DisplayName("Название типа доставки")]
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,23 @@
using Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class DeliveryViewModel : IDeliveryModel
{
public int Id { get; set; }
[DisplayName("ФИО курьера")]
public string FCs { get; set; } = string.Empty;
[DisplayName("Пожелания")]
public string Wishes { get; set; } = string.Empty;
[DisplayName("Тип доставки")]
public string DeliveryType { get; set; } = string.Empty;
[DisplayName("Дата доставки")]
public string? DeliveryDate { get; set; }
}
}

View File

@ -1,6 +0,0 @@
namespace Controls
{
public class Class1
{
}
}

View File

@ -1,10 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponentsTest" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />
<PackageReference Include="NotVisualComponent" Version="1.0.0" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="docs\" />
<Folder Include="NuGetTeam\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,56 @@
namespace Controls
{
partial class CustomComboBox
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
comboBoxMain = new ComboBox();
SuspendLayout();
//
// comboBoxMain
//
comboBoxMain.FormattingEnabled = true;
comboBoxMain.Location = new Point(18, 62);
comboBoxMain.Name = "comboBoxMain";
comboBoxMain.Size = new Size(230, 28);
comboBoxMain.TabIndex = 0;
//
// CustomComboBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(comboBoxMain);
Name = "CustomComboBox";
Size = new Size(262, 150);
ResumeLayout(false);
}
#endregion
private ComboBox comboBoxMain;
}
}

View File

@ -0,0 +1,95 @@
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 Controls
{
public partial class CustomComboBox : UserControl
{
/// <summary>
/// Конструктор
/// </summary>
public CustomComboBox()
{
InitializeComponent();
}
/// <summary>
/// Очищение списка
/// </summary>
public void ComboBoxClear()
{
comboBoxMain.Items.Clear();
comboBoxMain.SelectedItem = null;
}
/// <summary>
/// Выбранный элемент
/// </summary>
public string SelectedItem
{
get
{
if (comboBoxMain.Items.Count == 0)
{
return " ";
}
if (comboBoxMain.SelectedItem == null)
{
return " ";
}
return comboBoxMain.SelectedItem.ToString()!;
}
set
{
if (comboBoxMain.Items.Contains(value))
{
comboBoxMain.SelectedItem = value;
}
}
}
/// <summary>
/// Публичное свойство
/// </summary>
public ComboBox.ObjectCollection ComboBoxItems
{
get { return comboBoxMain.Items; }
}
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
private EventHandler _onValueChangedEvent;
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
public event EventHandler ValueChanged
{
add
{
_onValueChangedEvent += value;
}
remove
{
_onValueChangedEvent -= value;
}
}
/// <summary>
/// Смена значения
/// </summary>
private void CustomComboBox_SelectedValueChanged(object sender, EventArgs e)
{
_onValueChangedEvent?.Invoke(sender, e);
}
}
}

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

@ -0,0 +1,58 @@
namespace Controls
{
partial class CustomListBox
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
listBoxMain = new ListBox();
SuspendLayout();
//
// listBoxMain
//
listBoxMain.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
listBoxMain.FormattingEnabled = true;
listBoxMain.ItemHeight = 20;
listBoxMain.Location = new Point(3, 3);
listBoxMain.Name = "listBoxMain";
listBoxMain.Size = new Size(270, 184);
listBoxMain.TabIndex = 0;
//
// CustomListBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBoxMain);
Name = "CustomListBox";
Size = new Size(276, 212);
ResumeLayout(false);
}
#endregion
private ListBox listBoxMain;
}
}

View File

@ -0,0 +1,150 @@
using Controls.Exceptions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Controls
{
public partial class CustomListBox : UserControl
{
/// <summary>
/// Конструктор по умолчанию
/// </summary>
public CustomListBox()
{
InitializeComponent();
}
private string template;
private string start;
private string end;
public void setTemplate(string _template, string _start, string _end)
{
if (string.IsNullOrEmpty(_template) || string.IsNullOrEmpty(_start) || string.IsNullOrEmpty(_end))
{
throw new ArgumentNullException("Wrong template");
}
template = _template;
start = _start;
end = _end;
}
public int SelectedRow
{
get
{
return listBoxMain.SelectedIndex;
}
set
{
if (value < 0) return;
listBoxMain.SelectedIndex = value;
}
}
public T GetObjectFromStr<T>() where T : class, new()
{
if (listBoxMain.SelectedIndex < 0)
{
return null;
}
string row = listBoxMain.SelectedItem.ToString();
T curObject = new T();
StringBuilder sb = new StringBuilder(row);
//MessageBox.Show(sb.ToString());
string[] words = template.Split(new[] { char.Parse(start), char.Parse(end) });
// Дорогой дневник, мне не подобрать слов чтобы описать всю {Mood}, что я испытал сегодня; {Date}
// Дорогой дневник, мне не подобрать слов чтобы описать всю радость, что я испытал сегодня; 01.01.01
StringBuilder myrow = new StringBuilder(row);
List<string> flexPartsTemplate = new();
foreach (string word in words)
{
if (row.Contains(word) && !string.IsNullOrEmpty(word))
{
myrow.Replace(word, end);
}
else
{
flexPartsTemplate.Add(word);
}
}
string[] flexParts = myrow.ToString().Split(end);
int i = 1;
StringBuilder result = new StringBuilder(template);
foreach (string word in flexPartsTemplate)
{
if (!string.IsNullOrEmpty(word))
{
result.Replace(word, flexParts[i]);
i++;
}
}
sb = result;
foreach (var property in typeof(T).GetProperties())
{
if (!property.CanWrite)
{
continue;
}
//MessageBox.Show(property.Name);
int startBorder = sb.ToString().IndexOf(start);
if (startBorder == -1)
{
break;
}
int endBorder = sb.ToString().IndexOf(end, startBorder + 1);
if (endBorder == -1)
{
break;
}
string propertyValue = sb.ToString(startBorder + 1, endBorder - startBorder - 1);
sb.Remove(0, endBorder + 1);
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
}
return curObject;
}
public void FillProperty<T>(T dataObject, int rowIndex, string propertyName)
{
while (listBoxMain.Items.Count <= rowIndex)
{
listBoxMain.Items.Add(template);
}
string row = listBoxMain.Items[rowIndex].ToString();
PropertyInfo propertyInfo = dataObject.GetType().GetProperty(propertyName);
if (propertyInfo != null)
{
var propertyValue = propertyInfo.GetValue(dataObject);
row = row.Replace($"{start}{propertyName}{end}", propertyValue.ToString());
listBoxMain.Items[rowIndex] = row;
}
}
public int CountRows()
{
return listBoxMain.Items.Count;
}
}
}

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

@ -0,0 +1,63 @@
namespace Controls
{
partial class CustomTextBoxNumber
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
textBoxNumber = new TextBox();
toolTipNumber = new ToolTip(components);
SuspendLayout();
//
// textBoxNumber
//
textBoxNumber.Dock = DockStyle.Fill;
textBoxNumber.Location = new Point(0, 0);
textBoxNumber.Name = "textBoxNumber";
textBoxNumber.Size = new Size(242, 27);
textBoxNumber.TabIndex = 0;
textBoxNumber.Text = "(ХХХХ)ХХ-ХХ-ХХ";
toolTipNumber.SetToolTip(textBoxNumber, "(ХХХХ)ХХ-ХХ-ХХ");
textBoxNumber.Click += textBox_Enter;
//
// CustomTextBoxNumber
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBoxNumber);
Name = "CustomTextBoxNumber";
Size = new Size(242, 30);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxNumber;
private ToolTip toolTipNumber;
}
}

View File

@ -0,0 +1,111 @@
using Controls.Exceptions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Controls
{
public partial class CustomTextBoxNumber : UserControl
{
/// <summary>
/// Конструктор
/// </summary>
public CustomTextBoxNumber()
{
InitializeComponent();
}
/// <summary>
/// Шаблон вводимого значения
/// </summary>
private string? _numberPattern;
/// <summary>
/// Шаблон вводимого значения
/// </summary>
public string? NumPattern
{
get { return _numberPattern; }
set { _numberPattern = value; }
}
/// <summary>
/// Введенное значение
/// </summary>
public string? TextBoxNumber
{
get
{
if (NumPattern == null)
{
throw new CustomNumberException("Шаблон не заполнен!");
}
Regex regex = new Regex(NumPattern);
if (regex.IsMatch(textBoxNumber.Text))
{
return textBoxNumber.Text;
}
else
{
throw new CustomNumberException(textBoxNumber.Text + " не соответствует шаблону!");
}
}
set
{
Regex regex = new Regex(NumPattern!);
if (regex.IsMatch(value))
{
textBoxNumber.Text = value;
}
}
}
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
private EventHandler _onValueChangedEvent;
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
public event EventHandler ValueChanged
{
add
{
_onValueChangedEvent += value;
}
remove
{
_onValueChangedEvent -= value;
}
}
/// <summary>
/// Смена значения
/// </summary>
private void CustomNumberBox_NumberChanged(object sender, EventArgs e)
{
_onValueChangedEvent?.Invoke(sender, e);
}
/// <summary>
/// Выведение подсказки на экран
/// </summary>
private void textBox_Enter(object sender, EventArgs e)
{
int visibleTime = 2000;
ToolTip tooltip = new ToolTip();
tooltip.Show("(ХХХХ)ХХ-ХХ-ХХ", textBoxNumber, 30, -20, visibleTime);
}
}
}

View File

@ -0,0 +1,123 @@
<?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>
<metadata name="toolTipNumber.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,36 @@
namespace Controls
{
partial class DiagramComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,98 @@
using PdfSharp.Charting;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Controls.Models;
namespace Controls
{
public partial class DiagramComponent : Component
{
public DiagramComponent()
{
InitializeComponent();
}
public DiagramComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateLineDiagram(string docPath, string title, string header, Dictionary<string, List<Double>> data, LegendAlign legendAlign = LegendAlign.top)
{
if (string.IsNullOrEmpty(docPath))
{
throw new ArgumentNullException("Введите путь до файла!");
}
if (string.IsNullOrEmpty(title))
{
throw new ArgumentNullException("Введите заголовок");
}
if (string.IsNullOrEmpty(header))
{
throw new ArgumentNullException("Введите заголовок для диаграммы");
}
if (data.Count == 0)
{
throw new ArgumentException("Нету данных");
}
Chart chart = new Chart(ChartType.Line);
chart.Legend.Docking = (DockingType)legendAlign;
chart.Legend.LineFormat.Visible = true;
foreach (var item in data)
{
Series series = chart.SeriesCollection.AddSeries();
series.Name = item.Key;
double[] vals = new double[item.Value.Count];
for (int i = 0; i < item.Value.Count; i++)
{
vals.SetValue(Convert.ToDouble(item.Value[i]), i);
}
series.Add(vals);
}
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Color = XColors.DarkGray;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.Legend.LineFormat.Visible = true;
ChartFrame chartFrame = new ChartFrame();
chartFrame.Location = new XPoint(50, 70);
chartFrame.Size = new XSize(500, 400);
chartFrame.Add(chart);
PdfDocument document = new PdfDocument(docPath);
PdfPage page = document.AddPage();
page.Size = PageSize.A4;
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Times New Roman", 14);
gfx.DrawString(title, font, XBrushes.Black, new XRect(20, 20, page.Width, page.Height), XStringFormats.TopLeft);
gfx.DrawString(header, font, XBrushes.Black, new XRect(20, 40, page.Width, page.Height), XStringFormats.TopCenter);
chartFrame.Draw(gfx);
document.Close();
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Controls.Exceptions
{
public class CustomNumberException : Exception
{
/// <summary>
/// Конструктор по умолчанию
/// </summary>
public CustomNumberException() { }
/// <summary>
/// Конструктор с сообщением ошибки
/// </summary>
public CustomNumberException(string message) : base(message)
{
}
}
}

View File

@ -0,0 +1,36 @@
namespace Controls
{
partial class LargeTextComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,68 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Controls
{
public partial class LargeTextComponent : Component
{
private Document? _document;
private Section? _section;
public LargeTextComponent()
{
InitializeComponent();
}
public LargeTextComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
[Obsolete]
public void CreateDocument(string docPath, string title, string[] rows)
{
if (string.IsNullOrEmpty(docPath))
{
throw new ArgumentNullException("Введите путь до файла!");
}
if (string.IsNullOrEmpty(title))
{
throw new ArgumentNullException("Введите заголовок");
}
if (rows.Length <= 0)
{
throw new ArgumentNullException("Нету данных для сохранения");
}
_document = new Document();
var style = _document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
_section = _document.AddSection();
var paragraph = _section.AddParagraph(title);
paragraph.Format.SpaceAfter = "0.1cm";
paragraph.Format.Font.Bold = true;
foreach (var row in rows)
{
_section.AddParagraph(row);
}
var renderer = new PdfDocumentRenderer(true);
renderer.Document = _document;
renderer.RenderDocument();
renderer.PdfDocument.Save(docPath);
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Controls.Models
{
public class ColumnInfo
{
public string PropertyName;
public string Header;
public int Width;
public ColumnInfo(string propertyName, string header, int width)
{
PropertyName = propertyName;
Header = header;
Width = width;
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Controls.Models
{
public enum LegendAlign
{
top,
bottom,
left,
right
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Controls.Models
{
public class MergeCells
{
public string Header;
public int[] Indexes;
public MergeCells(string header, int[] indexes)
{
Header = header;
Indexes = indexes;
}
}
}

View File

@ -0,0 +1,36 @@
namespace Controls
{
partial class TableComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Controls.Models;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
namespace Controls
{
public partial class TableComponent : Component
{
private Document? _document;
private Section? _section;
public TableComponent()
{
InitializeComponent();
}
public TableComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
[Obsolete]
public void CreateTable<T>(string docPath, string title, List<MergeCells>? mergeCells, List<ColumnInfo> colInfo, List<T> data) where T : class, new()
{
if (string.IsNullOrEmpty(docPath))
{
throw new ArgumentNullException("Введите путь до файла!");
}
if (string.IsNullOrEmpty(title))
{
throw new ArgumentNullException("Введите заголовок");
}
if (colInfo == null)
{
throw new ArgumentNullException("Введите все заголовки");
}
if (data == null)
{
throw new ArgumentNullException("Нету информации для вывода");
}
_document = new Document();
var style = _document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
_section = _document.AddSection();
var paragraph = _section.AddParagraph(title);
paragraph.Format.SpaceAfter = "0.3cm";
var table = _section.AddTable();
table.Borders.Visible = true;
for (int i = 0; i < colInfo.Count; i++)
{
table.AddColumn(colInfo[i].Width);
}
if (mergeCells != null)
{
table.AddRow();
}
var row = table.AddRow();
for (int i = 0; i < colInfo.Count; i++)
{
row[i].AddParagraph(colInfo[i].Header);
}
List<int> MergeColls = new List<int>();
if (mergeCells != null)
{
foreach (var cell in mergeCells)
{
MergeColls.AddRange(cell.Indexes[1..]);
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].MergeRight = cell.Indexes[2..].Length;
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].AddParagraph(cell.Header);
}
}
int cellsCount = table.Rows[1].Cells.Count;
if (MergeColls.Count != 0)
{
for (int i = 0; i < cellsCount; i++)
{
var cell = table.Rows[0].Cells[i];
if (!MergeColls.Contains(i + 1))
{
cell.MergeDown = 1;
cell.AddParagraph(colInfo[i].Header);
}
}
}
int rowData = 2;
foreach (var item in data)
{
var properties = item.GetType().GetProperties();
if (properties.Count() != cellsCount)
{
throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок");
}
for (int i = 0; i < properties.Count(); i++)
{
var property = properties[i];
var propValue = property.GetValue(item);
if (propValue == null) throw new Exception("Пустое поле");
if (property.Name == colInfo[i].PropertyName)
{
if (table.Rows.Count <= rowData) table.AddRow();
table.Rows[rowData].Cells[i].AddParagraph(propValue.ToString()!);
continue;
}
}
rowData++;
}
var renderer = new PdfDocumentRenderer(true);
renderer.Document = _document;
renderer.RenderDocument();
renderer.PdfDocument.Save(docPath);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,9 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controls", "Controls\Controls.csproj", "{6E871198-B573-409F-8879-E7FB65BDCB18}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Controls", "Controls\Controls.csproj", "{6E871198-B573-409F-8879-E7FB65BDCB18}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forms", "Forms\Forms.csproj", "{BFBF856D-1D01-4B3E-A4F8-5C8C940EA6B6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "Forms\Forms.csproj", "{BFBF856D-1D01-4B3E-A4F8-5C8C940EA6B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "Models\Models.csproj", "{0BBB6A57-B388-4892-8E75-33E7681BD41E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{1467FB76-8D2D-4F48-8D6B-D1FA8C85C554}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{8DD7D7EF-47E4-4F77-A8DE-D0F30EA6EC42}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{D454A67C-F6F6-48AC-9BB5-DCEF7D54AFA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -21,6 +29,22 @@ Global
{BFBF856D-1D01-4B3E-A4F8-5C8C940EA6B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BFBF856D-1D01-4B3E-A4F8-5C8C940EA6B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BFBF856D-1D01-4B3E-A4F8-5C8C940EA6B6}.Release|Any CPU.Build.0 = Release|Any CPU
{0BBB6A57-B388-4892-8E75-33E7681BD41E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0BBB6A57-B388-4892-8E75-33E7681BD41E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BBB6A57-B388-4892-8E75-33E7681BD41E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0BBB6A57-B388-4892-8E75-33E7681BD41E}.Release|Any CPU.Build.0 = Release|Any CPU
{1467FB76-8D2D-4F48-8D6B-D1FA8C85C554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1467FB76-8D2D-4F48-8D6B-D1FA8C85C554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1467FB76-8D2D-4F48-8D6B-D1FA8C85C554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1467FB76-8D2D-4F48-8D6B-D1FA8C85C554}.Release|Any CPU.Build.0 = Release|Any CPU
{8DD7D7EF-47E4-4F77-A8DE-D0F30EA6EC42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DD7D7EF-47E4-4F77-A8DE-D0F30EA6EC42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DD7D7EF-47E4-4F77-A8DE-D0F30EA6EC42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DD7D7EF-47E4-4F77-A8DE-D0F30EA6EC42}.Release|Any CPU.Build.0 = Release|Any CPU
{D454A67C-F6F6-48AC-9BB5-DCEF7D54AFA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D454A67C-F6F6-48AC-9BB5-DCEF7D54AFA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D454A67C-F6F6-48AC-9BB5-DCEF7D54AFA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D454A67C-F6F6-48AC-9BB5-DCEF7D54AFA6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,26 @@
using DatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement
{
public class Database : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"Host=localhost;Database=JewelryStoreDatabaseFull;Username=postgres;Password=postgres");
}
base.OnConfiguring(optionsBuilder);
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
}
public virtual DbSet<Delivery> Deliverys { get; set; }
public virtual DbSet<DeliveryType> DeliveryTypes { get; set; }
}
}

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.35">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.29" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\Controls\Controls.csproj" />
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,75 @@
using Contracts.BindlingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class DeliveryStorage : IDeliveryStorage
{
public List<DeliveryViewModel> GetFullList()
{
using var context = new Database();
return context.Deliverys.Select(x => x.GetViewModel).ToList();
}
public List<DeliveryViewModel> GetFilteredList(DeliverySearchModel model)
{
if (string.IsNullOrEmpty(model.DeliveryType))
{
return new();
}
using var context = new Database();
return context.Deliverys.Where(x => x.DeliveryType == model.DeliveryType).Select(x => x.GetViewModel).ToList();
}
public DeliveryViewModel? GetElement(DeliverySearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new Database();
return context.Deliverys.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public DeliveryViewModel? Insert(DeliveryBindingModel model)
{
var newDelivery = Delivery.Create(model);
if (newDelivery == null) return null;
using var context = new Database();
context.Deliverys.Add(newDelivery);
context.SaveChanges();
return newDelivery.GetViewModel;
}
public DeliveryViewModel? Update(DeliveryBindingModel model)
{
using var context = new Database();
var provider = context.Deliverys.FirstOrDefault(x => x.Id == model.Id);
if (provider == null) return null;
provider.Update(model);
context.SaveChanges();
return provider.GetViewModel;
}
public DeliveryViewModel? Delete(DeliveryBindingModel model)
{
using var context = new Database();
var element = context.Deliverys.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
context.Deliverys.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,76 @@
using Contracts.BindlingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class DeliveryTypeStorage : IDeliveryTypeStorage
{
public List<DeliveryTypeViewModel> GetFullList()
{
using var context = new Database();
return context.DeliveryTypes.Select(x => x.GetViewModel).ToList();
}
public List<DeliveryTypeViewModel> GetFilteredList(DeliveryTypeSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new Database();
return context.DeliveryTypes.Where(x => x.Name == model.Name).Select(x => x.GetViewModel).ToList();
}
public DeliveryTypeViewModel? GetElement(DeliveryTypeSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return null;
}
using var context = new Database();
return context.DeliveryTypes.FirstOrDefault(x => x.Name == model.Name)?.GetViewModel;
}
public DeliveryTypeViewModel? Insert(DeliveryTypeBindingModel model)
{
var newType = DeliveryType.Create(model);
if (newType == null) return null;
using var context = new Database();
context.DeliveryTypes.Add(newType);
context.SaveChanges();
return newType.GetViewModel;
}
public DeliveryTypeViewModel? Update(DeliveryTypeBindingModel model)
{
using var context = new Database();
var type = context.DeliveryTypes.FirstOrDefault(x => x.Id == model.Id);
if (type == null) return null;
type.Update(model);
context.SaveChanges();
return type.GetViewModel;
}
public DeliveryTypeViewModel? Delete(DeliveryTypeBindingModel model)
{
using var context = new Database();
var element = context.DeliveryTypes.FirstOrDefault(x => x.Name == model.Name);
if (element != null)
{
context.DeliveryTypes.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,73 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20241105214035_abobau")]
partial class abobau
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.35")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Delivery", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DeliveryDate")
.HasColumnType("text");
b.Property<string>("DeliveryType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FCs")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Wishes")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Deliverys");
});
modelBuilder.Entity("DatabaseImplement.Models.DeliveryType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("DeliveryTypes");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,51 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
public partial class abobau : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Deliverys",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
FCs = table.Column<string>(type: "text", nullable: false),
DeliveryType = table.Column<string>(type: "text", nullable: false),
Wishes = table.Column<string>(type: "text", nullable: false),
DeliveryDate = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Deliverys", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DeliveryTypes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeliveryTypes", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Deliverys");
migrationBuilder.DropTable(
name: "DeliveryTypes");
}
}
}

View File

@ -0,0 +1,71 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
partial class DatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.35")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Delivery", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("DeliveryDate")
.HasColumnType("text");
b.Property<string>("DeliveryType")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FCs")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Wishes")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Deliverys");
});
modelBuilder.Entity("DatabaseImplement.Models.DeliveryType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("DeliveryTypes");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,61 @@
using Contracts.BindlingModels;
using Contracts.ViewModels;
using Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class Delivery : IDeliveryModel
{
public int Id { get; private set; }
[Required]
public string FCs { get; private set; } = string.Empty;
[Required]
public string DeliveryType { get; private set; } = string.Empty;
[Required]
public string Wishes { get; private set; } = string.Empty;
public string? DeliveryDate { get; private set; }
public static Delivery? Create(DeliveryBindingModel model)
{
if (model == null) return null;
return new Delivery
{
Id = model.Id,
FCs = model.FCs,
DeliveryDate = model.DeliveryDate,
DeliveryType = model.DeliveryType,
Wishes = model.Wishes,
};
}
public void Update(DeliveryBindingModel model)
{
if (model == null) return;
FCs = model.FCs;
DeliveryDate = model.DeliveryDate;
Wishes = model.Wishes;
DeliveryType = model.DeliveryType;
}
public DeliveryViewModel GetViewModel => new()
{
Id = Id,
FCs = FCs,
DeliveryDate = DeliveryDate,
Wishes = Wishes,
DeliveryType = DeliveryType,
};
}
}

View File

@ -0,0 +1,44 @@
using Contracts.BindlingModels;
using Contracts.ViewModels;
using Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class DeliveryType : IDeliveryTypeModel
{
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
public static DeliveryType? Create(DeliveryTypeBindingModel model)
{
if (model == null) return null;
return new DeliveryType
{
Id = model.Id,
Name = model.Name,
};
}
public void Update(DeliveryTypeBindingModel model)
{
if (model == null) return;
Name = model.Name;
}
public DeliveryTypeViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
};
}
}

220
Cop_25/Forms/DeliveryForm.Designer.cs generated Normal file
View File

@ -0,0 +1,220 @@
namespace Forms
{
partial class DeliveryForm
{
/// <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()
{
tableLayoutPanel1 = new TableLayoutPanel();
comboBoxType = new ComboBox();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label1 = new Label();
inputComponentDate = new CreateVisualComponent.InputComponent();
textBoxFCs = new TextBox();
textBoxWishes = new TextBox();
tableLayoutPanel2 = new TableLayoutPanel();
buttonSave = new Button();
buttonCancel = new Button();
tableLayoutPanel1.SuspendLayout();
tableLayoutPanel2.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel1
//
tableLayoutPanel1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.ColumnCount = 4;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.Controls.Add(comboBoxType, 2, 1);
tableLayoutPanel1.Controls.Add(label2, 1, 0);
tableLayoutPanel1.Controls.Add(label3, 2, 0);
tableLayoutPanel1.Controls.Add(label4, 3, 0);
tableLayoutPanel1.Controls.Add(label1, 0, 0);
tableLayoutPanel1.Controls.Add(inputComponentDate, 3, 1);
tableLayoutPanel1.Controls.Add(textBoxFCs, 0, 1);
tableLayoutPanel1.Controls.Add(textBoxWishes, 1, 1);
tableLayoutPanel1.Location = new Point(12, 34);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 2;
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 30.2325573F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 69.76744F));
tableLayoutPanel1.Size = new Size(912, 92);
tableLayoutPanel1.TabIndex = 1;
//
// comboBoxType
//
comboBoxType.Anchor = AnchorStyles.Left | AnchorStyles.Right;
comboBoxType.Cursor = Cursors.IBeam;
comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(459, 45);
comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(222, 28);
comboBoxType.TabIndex = 2;
comboBoxType.SelectedIndexChanged += OnInputChange;
//
// label2
//
label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label2.AutoSize = true;
label2.Location = new Point(231, 0);
label2.Name = "label2";
label2.Size = new Size(222, 20);
label2.TabIndex = 1;
label2.Text = "Пожелания по доставке";
label2.TextAlign = ContentAlignment.MiddleCenter;
//
// label3
//
label3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label3.AutoSize = true;
label3.Location = new Point(459, 0);
label3.Name = "label3";
label3.Size = new Size(222, 20);
label3.TabIndex = 2;
label3.Text = "Тип доставки";
label3.TextAlign = ContentAlignment.MiddleCenter;
//
// label4
//
label4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label4.AutoSize = true;
label4.Location = new Point(687, 0);
label4.Name = "label4";
label4.Size = new Size(222, 20);
label4.TabIndex = 3;
label4.Text = "Дата доставки";
label4.TextAlign = ContentAlignment.MiddleCenter;
//
// label1
//
label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label1.AutoSize = true;
label1.Location = new Point(3, 0);
label1.Name = "label1";
label1.Size = new Size(222, 20);
label1.TabIndex = 0;
label1.Text = "ФИО";
label1.TextAlign = ContentAlignment.MiddleCenter;
//
// inputComponentDate
//
inputComponentDate.Anchor = AnchorStyles.Left | AnchorStyles.Right;
inputComponentDate.Location = new Point(687, 30);
inputComponentDate.Name = "inputComponentDate";
inputComponentDate.Size = new Size(222, 59);
inputComponentDate.TabIndex = 4;
//
// textBoxFCs
//
textBoxFCs.Anchor = AnchorStyles.Left | AnchorStyles.Right;
textBoxFCs.Location = new Point(3, 46);
textBoxFCs.Name = "textBoxFCs";
textBoxFCs.Size = new Size(222, 27);
textBoxFCs.TabIndex = 6;
textBoxFCs.TextChanged += OnInputChange;
//
// textBoxWishes
//
textBoxWishes.Anchor = AnchorStyles.Left | AnchorStyles.Right;
textBoxWishes.Location = new Point(231, 46);
textBoxWishes.Name = "textBoxWishes";
textBoxWishes.Size = new Size(222, 27);
textBoxWishes.TabIndex = 5;
textBoxWishes.TextChanged += OnInputChange;
//
// tableLayoutPanel2
//
tableLayoutPanel2.ColumnCount = 2;
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Controls.Add(buttonSave, 0, 0);
tableLayoutPanel2.Controls.Add(buttonCancel, 1, 0);
tableLayoutPanel2.Location = new Point(12, 132);
tableLayoutPanel2.Name = "tableLayoutPanel2";
tableLayoutPanel2.RowCount = 1;
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Size = new Size(250, 36);
tableLayoutPanel2.TabIndex = 2;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonSave.Location = new Point(3, 3);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(119, 30);
buttonSave.TabIndex = 0;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonCancel.Location = new Point(128, 3);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(119, 30);
buttonCancel.TabIndex = 1;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// DeliveryForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(936, 209);
Controls.Add(tableLayoutPanel2);
Controls.Add(tableLayoutPanel1);
Name = "DeliveryForm";
Text = "DeliveryForm";
FormClosing += ProviderForm_FormClosing;
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
tableLayoutPanel2.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ListBox listBox1;
private TableLayoutPanel tableLayoutPanel1;
private Label label2;
private Label label3;
private Label label4;
private Label label1;
private CreateVisualComponent.InputComponent inputComponentDate;
private ComboBox comboBoxType;
private TextBox textBoxWishes;
private TextBox textBoxFCs;
private TableLayoutPanel tableLayoutPanel2;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,129 @@
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using ControlsLibraryNet60.Input;
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 Forms
{
public partial class DeliveryForm : Form
{
private int? _id;
private readonly IDeliveryLogic _dLogic;
private readonly IDeliveryTypeLogic _dtLogic;
private bool isEdited;
public DeliveryForm(IDeliveryLogic dLogic, IDeliveryTypeLogic dtLogic, int? id = null)
{
InitializeComponent();
_id = id;
_dLogic = dLogic;
_dtLogic = dtLogic;
isEdited = false;
LoadData();
}
private void LoadData()
{
var list = _dtLogic.ReadList(null);
if (list != null)
{
foreach (var item in list)
{
comboBoxType.Items.Add(item.Name);
}
}
if (_id.HasValue)
{
var view = _dLogic.ReadElement(new DeliverySearchModel
{
Id = _id.Value,
});
textBoxWishes.Text = view.Wishes;
textBoxFCs.Text = view.FCs;
if (view.DeliveryDate != "Даты доставки нет")
{
inputComponentDate.Value = Convert.ToDateTime(view.DeliveryDate);
}
else
{
inputComponentDate.Value = null;
}
comboBoxType.SelectedItem = view.DeliveryType;
isEdited = false;
}
}
private void OnInputChange(object sender, EventArgs e)
{
isEdited = true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFCs.Text))
{
MessageBox.Show("Заполните поле ФИО курьера", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxWishes.Text))
{
MessageBox.Show("Заполните Пожелания ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if ((comboBoxType.SelectedItem == null))
{
MessageBox.Show("Выберите Тип доставки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
isEdited = false;
try
{
var model = new DeliveryBindingModel
{
Id = _id ?? 0,
FCs = textBoxFCs.Text,
Wishes = textBoxWishes.Text,
DeliveryDate = inputComponentDate.Value.ToString().Length >= 10 ? inputComponentDate.Value.ToString().Substring(0, 10) : "Даты доставки нет",
DeliveryType = comboBoxType.SelectedItem.ToString(),
};
var OperationResult = _id.HasValue ? _dLogic.Update(model) : _dLogic.Create(model);
if (!OperationResult)
{
throw new Exception("Ошибка при создании курьера.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProviderForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!isEdited) return;
var confirmResult = MessageBox.Show("Вы не сохранили изменения.\nВы действительно хотите выйти?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.No) e.Cancel = true;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

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

@ -0,0 +1,79 @@
namespace Forms
{
partial class DeliveryTypeForm
{
/// <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()
{
dataGridView = new DataGridView();
Type = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.BackgroundColor = Color.White;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Type });
dataGridView.GridColor = Color.Gray;
dataGridView.Location = new Point(14, 16);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.Size = new Size(393, 276);
dataGridView.TabIndex = 0;
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
dataGridView.KeyDown += dataGridView_KeyDown;
//
// Type
//
Type.HeaderText = "Типы доставок";
Type.MinimumWidth = 6;
Type.Name = "Type";
//
// DeliveryTypeForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(419, 306);
Controls.Add(dataGridView);
Margin = new Padding(3, 4, 3, 4);
Name = "DeliveryTypeForm";
Text = "Типы";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn Type;
}
}

View File

@ -0,0 +1,112 @@
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
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 Forms
{
public partial class DeliveryTypeForm : Form
{
private readonly IDeliveryTypeLogic _logic;
public DeliveryTypeForm(IDeliveryTypeLogic logic)
{
InitializeComponent();
_logic = logic;
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.Rows.Clear();
foreach (var item in list)
{
int rowIndex = dataGridView.Rows.Add(item.Name);
dataGridView.Rows[rowIndex].Tag = item.Id;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Insert)
{
for (int i = 0; i < dataGridView.Rows.Count; i++)
{
if (dataGridView.Rows[i].Cells[0].Value == null)
{
return;
}
}
dataGridView.Rows.Add();
}
else if (e.KeyCode == Keys.Delete)
{
if (MessageBox.Show("Удалить строку?", "Удаление", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
var name = dataGridView.SelectedCells[0].Value.ToString();
if (name != null)
{
_logic.Delete(new DeliveryTypeBindingModel
{
Name = name,
});
dataGridView.Rows.RemoveAt(dataGridView.SelectedCells[0].RowIndex);
}
}
}
}
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView.Rows.Count > 0)
{
var row = dataGridView.Rows[e.RowIndex];
var name = row.Cells[0].Value?.ToString() ?? string.Empty;
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("Введите название!");
return;
}
var id = row.Tag as int?;
if (id != null)
{
_logic.Update(new DeliveryTypeBindingModel
{
Id = id.Value,
Name = name
});
}
else
{
var newId = _logic.Create(new DeliveryTypeBindingModel
{
Name = name
});
row.Tag = newId;
}
}
}
}
}

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,39 +0,0 @@
namespace Forms
{
partial class Form1
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace Forms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

160
Cop_25/Forms/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,160 @@
namespace Forms
{
partial class FormMain
{
/// <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()
{
components = new System.ComponentModel.Container();
menuStrip1 = new MenuStrip();
созданиеДоставкиToolStripMenuItem = new ToolStripMenuItem();
создатьДоставкуToolStripMenuItem = new ToolStripMenuItem();
редактироватьДоставкуToolStripMenuItem = new ToolStripMenuItem();
удалитьДоставкуToolStripMenuItem = new ToolStripMenuItem();
созданиеТипаДоставкиToolStripMenuItem = new ToolStripMenuItem();
pDFДокументToolStripMenuItem = new ToolStripMenuItem();
excelОтчётToolStripMenuItem = new ToolStripMenuItem();
wordДиаграммаToolStripMenuItem = new ToolStripMenuItem();
редактироватьtoolStripMenuItem = new ToolStripMenuItem();
controlDataTreeTable = new ControlsLibraryNet60.Data.ControlDataTreeTable();
largeTextComponent = new Controls.LargeTextComponent(components);
componentDocumentWithChartPieWord = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord(components);
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { созданиеДоставкиToolStripMenuItem, созданиеТипаДоставкиToolStripMenuItem, pDFДокументToolStripMenuItem, excelОтчётToolStripMenuItem, wordДиаграммаToolStripMenuItem, редактироватьtoolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 28);
menuStrip1.TabIndex = 1;
menuStrip1.Text = "menuStrip1";
//
// созданиеДоставкиToolStripMenuItem
//
созданиеДоставкиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьДоставкуToolStripMenuItem, редактироватьДоставкуToolStripMenuItem, удалитьДоставкуToolStripMenuItem });
созданиеДоставкиToolStripMenuItem.Name = "созданиеДоставкиToolStripMenuItem";
созданиеДоставкиToolStripMenuItem.Size = new Size(131, 24);
созданиеДоставкиToolStripMenuItem.Text = "Меню доставок";
//
// создатьДоставкуToolStripMenuItem
//
создатьДоставкуToolStripMenuItem.Name = "создатьДоставкуToolStripMenuItem";
создатьДоставкуToolStripMenuItem.Size = new Size(258, 26);
создатьДоставкуToolStripMenuItem.Text = "Создать доставку";
создатьДоставкуToolStripMenuItem.Click += созданиеДоставкиToolStripMenuItem_Click;
//
// редактироватьДоставкуToolStripMenuItem
//
редактироватьДоставкуToolStripMenuItem.Name = "редактироватьДоставкуToolStripMenuItem";
редактироватьДоставкуToolStripMenuItem.Size = new Size(258, 26);
редактироватьДоставкуToolStripMenuItem.Text = "Редактировать доставку";
редактироватьДоставкуToolStripMenuItem.Click += editProviderToolStripMenuItem_Click;
//
// удалитьДоставкуToolStripMenuItem
//
удалитьДоставкуToolStripMenuItem.Name = "удалитьДоставкуToolStripMenuItem";
удалитьДоставкуToolStripMenuItem.Size = new Size(258, 26);
удалитьДоставкуToolStripMenuItem.Text = "Удалить доставку";
удалитьДоставкуToolStripMenuItem.Click += deleteProviderToolStripMenuItem_Click;
//
// созданиеТипаДоставкиToolStripMenuItem
//
созданиеТипаДоставкиToolStripMenuItem.Name = "созданиеТипаДоставкиToolStripMenuItem";
созданиеТипаДоставкиToolStripMenuItem.Size = new Size(192, 24);
созданиеТипаДоставкиToolStripMenuItem.Text = "Создание типа доставки";
созданиеТипаДоставкиToolStripMenuItem.Click += созданиеТипаДоставкиToolStripMenuItem_Click;
//
// pDFДокументToolStripMenuItem
//
pDFДокументToolStripMenuItem.Name = "pDFДокументToolStripMenuItem";
pDFДокументToolStripMenuItem.Size = new Size(118, 24);
pDFДокументToolStripMenuItem.Text = "PDF документ";
pDFДокументToolStripMenuItem.Click += pDFДокументToolStripMenuItem_Click;
//
// excelОтчётToolStripMenuItem
//
excelОтчётToolStripMenuItem.Name = "excelОтчётToolStripMenuItem";
excelОтчётToolStripMenuItem.Size = new Size(98, 24);
excelОтчётToolStripMenuItem.Text = "Excel отчёт";
//
// wordДиаграммаToolStripMenuItem
//
wordДиаграммаToolStripMenuItem.Name = "wordДиаграммаToolStripMenuItem";
wordДиаграммаToolStripMenuItem.Size = new Size(141, 24);
wordДиаграммаToolStripMenuItem.Text = "Word диаграмма";
wordДиаграммаToolStripMenuItem.Click += wordДиаграммаToolStripMenuItem_Click;
//
// редактироватьtoolStripMenuItem
//
редактироватьtoolStripMenuItem.Name = "редактироватьtoolStripMenuItem";
редактироватьtoolStripMenuItem.Size = new Size(189, 24);
редактироватьtoolStripMenuItem.Text = "Редактировать доставку";
//
// controlDataTreeTable
//
controlDataTreeTable.Location = new Point(0, 33);
controlDataTreeTable.Margin = new Padding(4, 5, 4, 5);
controlDataTreeTable.Name = "controlDataTreeTable";
controlDataTreeTable.Size = new Size(787, 320);
controlDataTreeTable.TabIndex = 2;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 367);
Controls.Add(controlDataTreeTable);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormMain";
Text = "FormMain";
Load += FormMain_Load;
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem созданиеДоставкиToolStripMenuItem;
private ToolStripMenuItem созданиеТипаДоставкиToolStripMenuItem;
private ToolStripMenuItem pDFДокументToolStripMenuItem;
private ToolStripMenuItem excelОтчётToolStripMenuItem;
private ToolStripMenuItem wordДиаграммаToolStripMenuItem;
private ToolStripMenuItem создатьДоставкуToolStripMenuItem;
private ToolStripMenuItem редактироватьДоставкуToolStripMenuItem;
private ToolStripMenuItem удалитьДоставкуToolStripMenuItem;
private ToolStripMenuItem редактироватьtoolStripMenuItem;
private ControlsLibraryNet60.Data.ControlDataTreeTable controlDataTreeTable;
private Controls.LargeTextComponent largeTextComponent;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord componentDocumentWithChartPieWord;
}
}

173
Cop_25/Forms/FormMain.cs Normal file
View File

@ -0,0 +1,173 @@
using ComponentsLibraryNet60.DocumentWithChart;
using ComponentsLibraryNet60.Models;
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using Controls;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
using CustomComponents;
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 Forms
{
public partial class FormMain : Form
{
private readonly IDeliveryLogic _dlogic;
private readonly IDeliveryTypeLogic _dtlogic;
public FormMain(IDeliveryLogic dLogic, IDeliveryTypeLogic dtLogic)
{
InitializeComponent();
_dlogic = dLogic;
_dtlogic = dtLogic;
TreeConfig();
LoadData();
}
private void TreeConfig()
{
DataTreeNodeConfig treeConfig = new();
treeConfig.NodeNames = new();
treeConfig.NodeNames.Enqueue("Id");
treeConfig.NodeNames.Enqueue("FCs");
treeConfig.NodeNames.Enqueue("Wishes");
treeConfig.NodeNames.Enqueue("DeliveryType");
treeConfig.NodeNames.Enqueue("DeliveryDate");
controlDataTreeTable.LoadConfig(treeConfig);
}
private void LoadData()
{
var list = _dlogic.ReadList(null);
if (list != null)
{
controlDataTreeTable.Clear();
controlDataTreeTable.AddTable(list);
}
}
private void созданиеТипаДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(DeliveryTypeForm));
if (service is DeliveryTypeForm form)
{
form.ShowDialog();
}
}
private void созданиеДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(DeliveryForm));
if (service is DeliveryForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id);
DeliveryForm form = new DeliveryForm(_dlogic, _dtlogic, id);
form.ShowDialog();
LoadData();
}
private void deleteProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
var confirmResult = MessageBox.Show("Вы действительно хотите удалить запись?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.Yes)
{
_dlogic.Delete(new DeliveryBindingModel
{
Id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id),
});
LoadData();
}
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void pDFДокументToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".pdf";
var list = _dlogic.ReadList(null);
if (list != null)
{
int i = 0;
foreach (var item in list)
{
if (item.DeliveryDate == "Даты доставки нет") i++;
}
string[] strings = new string[i];
int j = 0;
foreach (var item in list)
{
if (item.DeliveryDate == "Даты доставки нет") { strings[j] = ($"{item.FCs} : {item.Wishes}"); j++; }
}
largeTextComponent.CreateDocument(path, $"Отчет по доставкам без даты:", strings);
MessageBox.Show("Отчет готов");
}
}
private void wordДиаграммаToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".docx";
var list = _dlogic.ReadList(null);
var data = new List<(int Date, double Value)> { };
string header = "График доставок известной даты\n";
var chart = new Dictionary<string, List<(int Date, double Value)>> { };
int index = 1;
foreach (var type in _dtlogic.ReadList(null)!)
{
int sum = 0;
foreach (var item in list)
{
if (item.DeliveryType == type.Name)
{
sum++;
}
}
header += $"{index} - {type.Name}\n";
if (sum != 0) data.Add((index, sum));
index++;
}
chart.Add("ИП", data);
var conf = new ComponentDocumentWithChartConfig
{
FilePath = path,
Header = header,
ChartTitle = "Диаграмма по типам доставок",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = chart,
};
componentDocumentWithChartPieWord.CreateDoc(conf);
MessageBox.Show("Отчет готов");
}
}
}

129
Cop_25/Forms/FormMain.resx Normal file
View File

@ -0,0 +1,129 @@
<?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>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="largeTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>153, 17</value>
</metadata>
<metadata name="componentDocumentWithChartPieWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>348, 17</value>
</metadata>
</root>

View File

@ -2,10 +2,46 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponentsTest" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.35">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="NotVisualComponent" Version="1.0.0" />
<PackageReference Include="WinFormsLibrary" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Controls\Controls.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -1,7 +1,16 @@
using BusinessLogic.BusinessLogic;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace Forms
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -11,7 +20,22 @@ namespace Forms
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<IDeliveryTypeStorage, DeliveryTypeStorage>();
services.AddTransient<IDeliveryTypeLogic, DeliveryTypeLogic>();
services.AddTransient<IDeliveryLogic, DeliveryLogic>();
services.AddTransient<IDeliveryStorage, DeliveryStorage>();
services.AddTransient<FormMain>();
services.AddTransient<DeliveryTypeForm>();
services.AddTransient<DeliveryForm>(); ;
}
}
}

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Forms.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Forms.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public interface IDeliveryModel : IId
{
string FCs { get; }
string Wishes { get; }
string DeliveryType { get; }
string? DeliveryDate { get; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public interface IDeliveryTypeModel : IId
{
string Name { get; }
}
}

13
Cop_25/Models/IId.cs Normal file
View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />
</ItemGroup>
</Project>