лаба 8 готова не знаю работает или нет но у меня ноут сдох

This commit is contained in:
Полина Чубыкина 2024-05-19 19:03:16 +04:00
parent 46e9841ebd
commit 6cd3d8dd1d
28 changed files with 135 additions and 97 deletions

View File

@ -22,5 +22,5 @@ namespace ConfectioneryContracts.Attributes
public int Width { get; private set; }
public GridViewAutoSize GridViewAutoSize { get; private set; }
public bool IsUseAutoSize { get; private set; }
}s
}
}

View File

@ -6,34 +6,49 @@ using System.Threading.Tasks;
using ConfectioneryDataModels.Models;
using System.ComponentModel;
using ConfectioneryDataModels.Enums;
using ConfectioneryContracts.Attributes;
namespace ConfectioneryContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Номер")]
[Column(title: "Номер", width: 100)]
public int Id { get; set; }
[Column(visible: false)]
public int PastryId { get; set; }
[DisplayName("Выпечка")]
[Column(title: "Выпечка", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string PastryName { get; set; } = string.Empty;
[Column(visible: false)]
public int ClientId { get; set; }
[DisplayName("ФИО клиента")]
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ClientFIO { get; set; } = string.Empty;
[Column(visible: false)]
public string ClientEmail { get; set; } = string.Empty;
[Column(visible: false)]
public int? ImplementerId { get; set; }
[DisplayName("ФИО исполнителя")]
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Количество")]
[Column(title: "Количество", width: 100)]
public int Count { get; set; }
[DisplayName("Сумма")]
[Column(title: "Сумма", width: 120)]
public double Sum { get; set; }
[DisplayName("Статус")]
[Column(title: "Статус", width: 100)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")]
[Column(title: "Дата создания", width: 120)]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")]
[Column(title: "Дата выполнения", width: 120)]
public DateTime? DateImplement { get; set; }
}
}

View File

@ -17,6 +17,7 @@ namespace ConfectioneryContracts.ViewModels
public string PastryName { get; set; } = string.Empty;
[Column(title: "Цена", width: 150)]
public double Price { get; set; }
[Column(visible: false)]
public Dictionary<int, (IComponentModel, int)> PastryComponents
{
get;

View File

@ -106,8 +106,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
{
throw new ArgumentNullException("Некорректно введен пароль клиента", nameof(model.Password));
}
_logger.LogInformation("Client. Id: {id}, FIO: {fio}, email: {email}, password: {password}", model.Id, model.ClientFIO, model.Email,
model.Password);
_logger.LogInformation("Client. Id: {id}, FIO: {fio}, email: {email}, password: {password}", model.Id, model.ClientFIO, model.Email, model.Password);
var element = _clientStorage.GetElement(new ClientSearchModel
{
Email = model.Email

View File

@ -14,7 +14,7 @@ namespace ConfectioneryDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-0CI5KVE\SQLEXPRESS;Initial Catalog=ConfectioneryDatabase4;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-0CI5KVE\SQLEXPRESS;Initial Catalog=ConfectioneryDatabase5;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -20,4 +20,8 @@
<ProjectReference Include="..\ConfectionaryDataModels\ConfectioneryDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations
{
[DbContext(typeof(ConfectioneryDatabase))]
[Migration("20240518134247_InitialCreate")]
[Migration("20240519124411_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />

View File

@ -11,4 +11,8 @@
<ProjectReference Include="..\ConfectionaryDataModels\ConfectioneryDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -7,17 +7,23 @@ using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models;
using System.Xml.Linq;
using System.Runtime.Serialization;
namespace ConfectioneryFileImplement.Models
{
[DataContract]
public class Client : IClientModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
public string Email { get; private set; } = string.Empty;
[DataMember]
public string Password { get; private set; } = string.Empty;
public static Client? Create(ClientBindingModel model)

View File

@ -1,14 +1,19 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models
{
[DataContract]
public class Component : IComponentModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ComponentName { get; private set; } = string.Empty;
[DataMember]
public double Cost { get; set; }
public static Component? Create(ComponentBindingModel model)

View File

@ -4,18 +4,25 @@ using ConfectioneryDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models
{
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string ImplementerFIO { get; set; } = string.Empty;
[DataMember]
public string Password { get; set; } = string.Empty;
[DataMember]
public int WorkExperience { get; set; }
[DataMember]
public int Qualification { get; set; }
public static Implementer? Create(ImplementerBindingModel? model)

View File

@ -4,25 +4,29 @@ using ConfectioneryDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models
{
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string MessageId { get; private set; } = string.Empty;
[DataMember]
public int? ClientId { get; private set; }
[DataMember]
public string SenderName { get; private set; } = string.Empty;
[DataMember]
public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
public string Subject { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty;
public static MessageInfo? Create(MessageInfoBindingModel model)

View File

@ -2,28 +2,39 @@
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Enums;
using ConfectioneryDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace ConfectioneryFileImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public int PastryId { get; private set; }
[DataMember]
public int ClientId { get; private set; }
[DataMember]
public int? ImplementerId { get; private set; }
[DataMember]
public int Count { get; private set; }
[DataMember]
public double Sum { get; private set; }
[DataMember]
public OrderStatus Status { get; private set; }
[DataMember]
public DateTime DateCreate { get; private set; }
[DataMember]
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)

View File

@ -7,13 +7,18 @@ using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Models;
using System.Xml.Linq;
using System.Runtime.Serialization;
namespace ConfectioneryFileImplement.Models
{
[DataContract]
internal class Pastry : IPastryModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string PastryName { get; private set; } = string.Empty;
[DataMember]
public double Price { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IComponentModel, int)>? _pastryComponents = null;

View File

@ -16,4 +16,8 @@
<ProjectReference Include="..\ConfectionaryDataModels\ConfectioneryDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -11,6 +11,6 @@
"SmtpClientPort": "587",
"PopHost": "pop.gmail.com",
"PopPort": "995",
"MailLogin": "@gmail.com",
"MailLogin": "tsutsumonn@gmail.com",
"MailPassword": "ndbp ruep dfbl dnbg"
}

View File

@ -5,7 +5,7 @@
<add key="SmtpClientPort" value="587" />
<add key="PopHost" value="pop.gmail.com" />
<add key="PopPort" value="995" />
<add key="MailLogin" value="@gmail.com" />
<add key="MailLogin" value="tsutsumonn@gmail.com" />
<add key="MailPassword" value="ndbp ruep dfbl dnbg" />
</appSettings>
</configuration>

View File

@ -1,5 +1,6 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Logging;
using System;
@ -46,33 +47,25 @@ namespace ConfectioneryView
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
if (service is FormComponent form)
{
var form = DependencyManager.Instance.Resolve<FormComponent>();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormComponent));
if (service is FormComponent form)
{
form.Id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
var form = DependencyManager.Instance.Resolve<FormComponent>();
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{

View File

@ -1,5 +1,6 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -45,23 +46,18 @@ namespace ConfectioneryView
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
{
var form = DependencyManager.Instance.Resolve<FormImplementer>();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
{
var form = DependencyManager.Instance.Resolve<FormImplementer>();
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
@ -69,7 +65,6 @@ namespace ConfectioneryView
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{

View File

@ -10,6 +10,7 @@ using System.Windows.Forms;
using Microsoft.Extensions.Logging;
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
namespace ConfectioneryView
{
@ -46,23 +47,18 @@ namespace ConfectioneryView
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
if (service is FormPastry form)
{
var form = DependencyManager.Instance.Resolve<FormPastry>();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
if (service is FormPastry form)
{
var form = DependencyManager.Instance.Resolve<FormPastry>();
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
@ -70,7 +66,6 @@ namespace ConfectioneryView
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{

View File

@ -12,6 +12,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ConfectioneryContracts.DI;
namespace ConfectioneryView
{
@ -85,42 +86,32 @@ namespace ConfectioneryView
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
if (service is FormPastryComponent form)
{
var form = DependencyManager.Instance.Resolve<FormPastryComponent>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ComponentModel == null)
{
return;
}
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
_logger.LogInformation("Adding new component: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
if (_pastryComponents.ContainsKey(form.Id))
{
_pastryComponents[form.Id] = (form.ComponentModel,
form.Count);
_pastryComponents[form.Id] = (form.ComponentModel, form.Count);
}
else
{
_pastryComponents.Add(form.Id, (form.ComponentModel,
form.Count));
_pastryComponents.Add(form.Id, (form.ComponentModel, form.Count));
}
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
if (service is FormPastryComponent form)
{
int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
var form = DependencyManager.Instance.Resolve<FormPastryComponent>();
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _pastryComponents[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
@ -129,13 +120,12 @@ namespace ConfectioneryView
{
return;
}
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
_logger.LogInformation("Component editing: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
_pastryComponents[form.Id] = (form.ComponentModel, form.Count);
LoadData();
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{