Готовая лабораторная работа 5 (усложнёнка)

This commit is contained in:
nikbel2004@outlook.com 2024-05-11 02:22:10 +04:00
parent d203230644
commit 7e7bfa54b0
13 changed files with 68 additions and 57 deletions

View File

@ -30,13 +30,13 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
using var context = new FurnitureAssemblyDatabase();
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue) if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
{ {
return new(); return new();
} }
using var context = new FurnitureAssemblyDatabase();
return context.Orders return context.Orders
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId) .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId)
.Include(x => x.Furniture) .Include(x => x.Furniture)

View File

@ -34,6 +34,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
{ {
return null; return null;
} }
return new Client() return new Client()
{ {
Id = model.Id, Id = model.Id,
@ -49,6 +50,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
{ {
return; return;
} }
ClientFIO = model.ClientFIO; ClientFIO = model.ClientFIO;
Email = model.Email; Email = model.Email;
Password = model.Password; Password = model.Password;

View File

@ -21,10 +21,10 @@ namespace FurnitureAssemblyListImplement
// Список для хранения заказов // Список для хранения заказов
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
//список для хранения Магазинов // Список для хранения Магазинов
public List<Shop> Shops { get; set; } public List<Shop> Shops { get; set; }
//список для хранения Клиентов // Список для хранения Клиентов
public List<Client> Clients { get; set; } public List<Client> Clients { get; set; }
public DataListSingleton() public DataListSingleton()

View File

@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" /> <ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" />
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" /> <ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
<ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" /> <ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -25,14 +25,14 @@ namespace FurnitureAssemblyView
{ {
get get
{ {
if(_list == null) if (_list == null)
{ {
return null; return null;
} }
foreach(var elem in _list) foreach (var elem in _list)
{ {
if(elem.Id == Id) if (elem.Id == Id)
{ {
return elem; return elem;
} }
@ -51,7 +51,7 @@ namespace FurnitureAssemblyView
_list = logic.ReadList(null); _list = logic.ReadList(null);
if(_list != null) if (_list != null)
{ {
comboBoxWorkPiece.DisplayMember = "WorkPieceName"; comboBoxWorkPiece.DisplayMember = "WorkPieceName";
comboBoxWorkPiece.ValueMember = "Id"; comboBoxWorkPiece.ValueMember = "Id";

View File

@ -74,7 +74,7 @@
buttonRef.TabIndex = 3; buttonRef.TabIndex = 3;
buttonRef.Text = "Обновить"; buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true; buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click; buttonRef.Click += ButtonRefresh_Click;
// //
// dataGridView // dataGridView
// //

View File

@ -118,7 +118,7 @@ namespace FurnitureAssemblyView
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }

View File

@ -49,7 +49,9 @@ namespace FurnitureAssemblyView
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["FurnitureId"].Visible = false; dataGridView.Columns["FurnitureId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false;
} dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }

View File

@ -35,7 +35,7 @@ namespace FurnitureAssemblyView
Dock = DockStyle.Fill Dock = DockStyle.Fill
}; };
reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\NikBe\\source\\repos\\TP\\Hard\\Lab4\\FurnitureAssembly\\FurnitureAssemblyView\\ReportOrders.rdlc", FileMode.Open)); reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
Controls.Clear(); Controls.Clear();
Controls.Add(reportViewer); Controls.Add(reportViewer);

View File

@ -78,7 +78,7 @@
buttonRef.TabIndex = 3; buttonRef.TabIndex = 3;
buttonRef.Text = "Обновить"; buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true; buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click; buttonRef.Click += ButtonRefresh_Click;
// //
// dataGridView // dataGridView
// //

View File

@ -40,7 +40,7 @@ namespace FurnitureAssemblyView
var list = _logic.ReadList(null); var list = _logic.ReadList(null);
// Растягиваем колонку Название на всю ширину, колонку Id скрываем // Растягиваем колонку Название на всю ширину, колонку Id скрываем
if(list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
@ -49,7 +49,7 @@ namespace FurnitureAssemblyView
_logger.LogInformation("Загрузка заготовок"); _logger.LogInformation("Загрузка заготовок");
} }
catch(Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки заготовок"); _logger.LogError(ex, "Ошибка загрузки заготовок");
@ -120,7 +120,7 @@ namespace FurnitureAssemblyView
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }

View File

@ -1,33 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" /> <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.ReportingServices.ReportViewerControl.Winforms" Version="140.340.80" /> <PackageReference Include="Microsoft.ReportingServices.ReportViewerControl.Winforms" Version="140.340.80" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="160.1000.6" /> <PackageReference Include="Microsoft.SqlServer.Types" Version="160.1000.6" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" /> <PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" /> <ProjectReference Include="..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj" />
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" /> <ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
<ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" /> <ProjectReference Include="..\FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj" />
<ProjectReference Include="..\FurnitureAssemblyFileImplement\FurnitureAssemblyFileImplement.csproj" /> <ProjectReference Include="..\FurnitureAssemblyFileImplement\FurnitureAssemblyFileImplement.csproj" />
<ProjectReference Include="..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj" /> <ProjectReference Include="..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="ReportOrders.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -31,6 +31,7 @@ namespace FurnitureAssemblyView
_serviceProvider = services.BuildServiceProvider(); _serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>()); Application.Run(_serviceProvider.GetRequiredService<FormMain>());
} }
private static void ConfigureServices(ServiceCollection services) private static void ConfigureServices(ServiceCollection services)
{ {
services.AddLogging(option => services.AddLogging(option =>