Compare commits

..

2 Commits

Author SHA1 Message Date
2269741c4e ищии 2024-11-05 22:04:36 +04:00
70c53604d6 ищи 2024-11-05 22:04:24 +04:00
41 changed files with 1424 additions and 2205 deletions

View File

@ -11,11 +11,19 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CreateVisualComponent" Version="1.0.0" /> <PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponentsTest" 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="NotVisualComponent" Version="1.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Controls\Controls.csproj" /> <ProjectReference Include="..\Controls\Controls.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

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

@ -11,6 +11,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CreateVisualComponent" Version="1.0.0" /> <PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponentsTest" 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="NotVisualComponent" Version="1.0.0" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" /> <PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
</ItemGroup> </ItemGroup>

View File

@ -35,21 +35,22 @@
// //
// textBoxNumber // textBoxNumber
// //
textBoxNumber.Location = new Point(25, 61); textBoxNumber.Dock = DockStyle.Fill;
textBoxNumber.Location = new Point(0, 0);
textBoxNumber.Name = "textBoxNumber"; textBoxNumber.Name = "textBoxNumber";
textBoxNumber.Size = new Size(213, 27); textBoxNumber.Size = new Size(242, 27);
textBoxNumber.TabIndex = 0; textBoxNumber.TabIndex = 0;
toolTipNumber.SetToolTip(textBoxNumber, "+79378811555"); textBoxNumber.Text = "(ХХХХ)ХХ-ХХ-ХХ";
toolTipNumber.SetToolTip(textBoxNumber, "(ХХХХ)ХХ-ХХ-ХХ");
textBoxNumber.Click += textBox_Enter; textBoxNumber.Click += textBox_Enter;
textBoxNumber.Text = "+79991144333";
// //
// CustomNumberBox // CustomTextBoxNumber
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBoxNumber); Controls.Add(textBoxNumber);
Name = "CustomNumberBox"; Name = "CustomTextBoxNumber";
Size = new Size(264, 150); Size = new Size(242, 30);
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }

View File

@ -105,7 +105,7 @@ namespace Controls
{ {
int visibleTime = 2000; int visibleTime = 2000;
ToolTip tooltip = new ToolTip(); ToolTip tooltip = new ToolTip();
tooltip.Show("+79991144333", textBoxNumber, 30, -20, visibleTime); tooltip.Show("(ХХХХ)ХХ-ХХ-ХХ", textBoxNumber, 30, -20, visibleTime);
} }
} }
} }

View File

@ -3,9 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118 VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1 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 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution 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}.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.ActiveCfg = Release|Any CPU
{BFBF856D-1D01-4B3E-A4F8-5C8C940EA6B6}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE 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("20241104155629_abobus")]
partial class abobus
{
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 abobus : 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,
};
}
}

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

@ -28,116 +28,78 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
components = new System.ComponentModel.Container(); menuStrip1 = new MenuStrip();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); созданиеДоставкиToolStripMenuItem = new ToolStripMenuItem();
toolTip = new ToolTip(components); созданиеТипаДоставкиToolStripMenuItem = new ToolStripMenuItem();
largeTextComponent1 = new Controls.LargeTextComponent(components); pDFДокументToolStripMenuItem = new ToolStripMenuItem();
buttonLargeText = new Button(); excelОтчётToolStripMenuItem = new ToolStripMenuItem();
tableComponent1 = new Controls.TableComponent(components); wordДиаграммаToolStripMenuItem = new ToolStripMenuItem();
button1 = new Button(); menuStrip1.SuspendLayout();
diagramComponent1 = new Controls.DiagramComponent(components);
button2 = new Button();
pictureBox1 = new PictureBox();
textBox1 = new TextBox();
customListBox1 = new Controls.CustomListBox();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// toolTip // menuStrip1
// //
toolTip.ToolTipTitle = "AAAA"; menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { созданиеДоставкиToolStripMenuItem, созданиеТипаДоставкиToolStripMenuItem, pDFДокументToolStripMenuItem, excelОтчётToolStripMenuItem, wordДиаграммаToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 28);
menuStrip1.TabIndex = 1;
menuStrip1.Text = "menuStrip1";
// //
// buttonLargeText // созданиеДоставкиToolStripMenuItem
// //
buttonLargeText.Location = new Point(28, 21); созданиеДоставкиToolStripMenuItem.Name = "созданиеДоставкиToolStripMenuItem";
buttonLargeText.Name = "buttonLargeText"; созданиеДоставкиToolStripMenuItem.Size = new Size(156, 24);
buttonLargeText.Size = new Size(310, 51); созданиеДоставкиToolStripMenuItem.Text = "Создание доставки";
buttonLargeText.TabIndex = 9;
buttonLargeText.Text = "СОЗДАТЬ PDF ТЕКСТ";
buttonLargeText.UseVisualStyleBackColor = true;
buttonLargeText.Click += buttonLargeText_CLick;
// //
// button1 // созданиеТипаДоставкиToolStripMenuItem
// //
button1.Location = new Point(28, 94); созданиеТипаДоставкиToolStripMenuItem.Name = "созданиеТипаДоставкиToolStripMenuItem";
button1.Name = "button1"; созданиеТипаДоставкиToolStripMenuItem.Size = new Size(192, 24);
button1.Size = new Size(310, 66); созданиеТипаДоставкиToolStripMenuItem.Text = "Создание типа доставки";
button1.TabIndex = 10; созданиеТипаДоставкиToolStripMenuItem.Click += созданиеТипаДоставкиToolStripMenuItem_Click;
button1.Text = "СОЗДАТЬ ТАБЛИЦУ PDF";
button1.UseVisualStyleBackColor = true;
button1.Click += buttonCreateTable_Click;
// //
// button2 // pDFДокументToolStripMenuItem
// //
button2.Location = new Point(28, 185); pDFДокументToolStripMenuItem.Name = "pDFДокументToolStripMenuItem";
button2.Name = "button2"; pDFДокументToolStripMenuItem.Size = new Size(118, 24);
button2.Size = new Size(310, 72); pDFДокументToolStripMenuItem.Text = "PDF документ";
button2.TabIndex = 11;
button2.Text = "СОЗДАТЬ ДИАГРАММУ PDF";
button2.UseVisualStyleBackColor = true;
button2.Click += buttonDiagram_Click;
// //
// pictureBox1 // excelОтчётToolStripMenuItem
// //
pictureBox1.BackgroundImage = (Image)resources.GetObject("pictureBox1.BackgroundImage"); excelОтчётToolStripMenuItem.Name = "excelОтчётToolStripMenuItem";
pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; excelОтчётToolStripMenuItem.Size = new Size(98, 24);
pictureBox1.Location = new Point(359, 21); excelОтчётToolStripMenuItem.Text = "Excel отчёт";
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(364, 348);
pictureBox1.TabIndex = 12;
pictureBox1.TabStop = false;
// //
// textBox1 // wordДиаграммаToolStripMenuItem
// //
textBox1.Location = new Point(371, 314); wordДиаграммаToolStripMenuItem.Name = "wordДиаграммаToolStripMenuItem";
textBox1.Name = "textBox1"; wordДиаграммаToolStripMenuItem.Size = new Size(141, 24);
textBox1.Size = new Size(336, 27); wordДиаграммаToolStripMenuItem.Text = "Word диаграмма";
textBox1.TabIndex = 13;
textBox1.Text = "НАЖМИТЕ НА КНОПКУ ЧТОБЫ СОЗДАТЬ";
textBox1.TextAlign = HorizontalAlignment.Center;
textBox1.TextChanged += textBox1_TextChanged;
//
// customListBox1
//
customListBox1.Location = new Point(378, 43);
customListBox1.Name = "customListBox1";
customListBox1.SelectedRow = -1;
customListBox1.Size = new Size(608, 265);
customListBox1.TabIndex = 14;
// //
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1123, 381); ClientSize = new Size(800, 450);
Controls.Add(customListBox1); Controls.Add(menuStrip1);
Controls.Add(textBox1); MainMenuStrip = menuStrip1;
Controls.Add(button2);
Controls.Add(buttonLargeText);
Controls.Add(button1);
Controls.Add(pictureBox1);
Name = "FormMain"; Name = "FormMain";
Text = "FormMain"; Text = "FormMain";
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
private void ButtonLargeText_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
#endregion #endregion
private ToolTip toolTip;
private Controls.LargeTextComponent largeTextComponent1; private MenuStrip menuStrip1;
private Button buttonLargeText; private ToolStripMenuItem созданиеДоставкиToolStripMenuItem;
private Controls.TableComponent tableComponent1; private ToolStripMenuItem созданиеТипаДоставкиToolStripMenuItem;
private Button button1; private ToolStripMenuItem pDFДокументToolStripMenuItem;
private Controls.DiagramComponent diagramComponent1; private ToolStripMenuItem excelОтчётToolStripMenuItem;
private Button button2; private ToolStripMenuItem wordДиаграммаToolStripMenuItem;
private PictureBox pictureBox1;
private TextBox textBox1;
private Controls.CustomListBox customListBox1;
} }
} }

View File

@ -1,6 +1,4 @@
using Controls; using System;
using Controls.Exceptions;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -9,8 +7,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Controls.Models;
using MigraDoc.DocumentObjectModel;
namespace Forms namespace Forms
{ {
@ -19,77 +15,15 @@ namespace Forms
public FormMain() public FormMain()
{ {
InitializeComponent(); InitializeComponent();
List<Person> people = new List<Person>()
{
new Person("aboba", "not aboba", "19"),
new Person("aboba2", "not aboba2", "25"),
new Person("aboba3", "not aboba3", "20"),
};
customListBox1.setTemplate("Дорогой дневниов чтобы описать всю {FirstName} {LastName} возраста {Age}", "{", "}");
customListBox1.FillProperty(people[0], 0, "FirstName");
customListBox1.FillProperty(people[0], 0, "LastName");
customListBox1.FillProperty(people[0], 0, "Age");
customListBox1.FillProperty(people[1], 1, "FirstName");
customListBox1.FillProperty(people[1], 1, "LastName");
customListBox1.FillProperty(people[1], 1, "Age");
customListBox1.FillProperty(people[2], 2, "FirstName");
customListBox1.FillProperty(people[2], 2, "LastName");
customListBox1.FillProperty(people[2], 2, "Age");
} }
private void buttonLargeText_CLick(object sender, EventArgs e) private void созданиеТипаДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
{ {
string[] strings = new string[] { "aboba", var service = Program.ServiceProvider?.GetService(typeof(DeliveryTypeForm));
"тут я пишу супер много текста( ну или не супер много ) для сдачи", if (service is DeliveryTypeForm form)
"best aboba",
"гружу сюда супер большой тексттттт" };
largeTextComponent1.CreateDocument("C:\\Ulstu\\COP\\Cop_25\\Controls\\docs\\text.pdf",
"OMEGA LABA 2", strings);
}
private void buttonCreateTable_Click(object sender, EventArgs e)
{ {
List<ColumnInfo> columnInfos = new List<ColumnInfo>() form.ShowDialog();
{ }
new ColumnInfo("FirstName","Имя",50), }
new ColumnInfo("LastName","Фамилия",100),
new ColumnInfo("Age","Возраст",75),
};
List<MergeCells> mergeCells = new List<MergeCells>()
{
new MergeCells("Данные", new int[] {0,2,2})
};
List<Person> people = new List<Person>()
{
new Person("aboba", "not aboba", "19"),
new Person("aboba2", "not aboba2", "25"),
new Person("aboba3", "not aboba3", "20"),
};
tableComponent1.CreateTable("C:\\Ulstu\\COP\\Cop_25\\Controls\\docs\\table.pdf",
"TABLE LUTI", mergeCells, columnInfos, people);
}
private void buttonDiagram_Click(object sender, EventArgs e)
{
Dictionary<string, List<Double>> data = new Dictionary<string, List<Double>>();
data.Add("aboba1", new List<double> { 12, 1, 2, 5, 2 });
data.Add("aboba2", new List<double> { 3, 2, 1, 3, 6 });
data.Add("aboba3", new List<double> { 7, 3, 1, 2, 5 });
diagramComponent1.CreateLineDiagram("C:\\Ulstu\\COP\\Cop_25\\Controls\\docs\\diagram.pdf",
"ZAGOLOVOK", "LINEYNAYA", data, LegendAlign.bottom);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -11,11 +11,19 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CreateVisualComponent" Version="1.0.0" /> <PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponentsTest" 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="NotVisualComponent" Version="1.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Controls\Controls.csproj" /> <ProjectReference Include="..\Controls\Controls.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forms
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Age { get; set; }
public Person(string fn, string ln, string ag)
{
FirstName = fn;
LastName = ln;
Age = ag;
}
public Person() { }
}
}

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 namespace Forms
{ {
internal static class Program internal static class Program
{ {
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
@ -11,7 +20,22 @@ namespace Forms
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new FormMain()); 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,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>