Правки

This commit is contained in:
nikbel2004@outlook.com 2024-05-15 17:14:09 +04:00
parent 238ad8df99
commit 7483b0f99d
26 changed files with 55 additions and 46 deletions

View File

@ -144,7 +144,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password)); throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password));
} }
if (!Regex.IsMatch(model.Email, @"^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$", RegexOptions.IgnoreCase)) if (!Regex.IsMatch(model.Email, @"^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$", RegexOptions.IgnoreCase))
{ {
throw new ArgumentException("Некорректная почта", nameof(model.Email)); throw new ArgumentException("Некорректная почта", nameof(model.Email));
} }

View File

@ -1,15 +1,15 @@
using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContracts; using FurnitureAssemblyContracts.BusinessLogicsContracts;
using MailKit.Net.Pop3;
using MailKit.Security;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Mail;
using System.Net; using System.Net;
using System.Net.Mail;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using MailKit.Security;
using MailKit.Net.Pop3;
namespace FurnitureAssemblyBusinessLogic.MailWorker namespace FurnitureAssemblyBusinessLogic.MailWorker
{ {

View File

@ -31,19 +31,19 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
uint rowIndex = 2; uint rowIndex = 2;
foreach (var mwp in info.FurnitureWorkPieces) foreach (var fwp in info.FurnitureWorkPieces)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = mwp.FurnitureName, Text = fwp.FurnitureName,
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
foreach (var (WorkPiece, Count) in mwp.WorkPieces) foreach (var (WorkPiece, Count) in fwp.WorkPieces)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
@ -76,7 +76,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
{ {
ColumnName = "C", ColumnName = "C",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = mwp.TotalCount.ToString(), Text = fwp.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });

View File

@ -9,10 +9,10 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
// Модель параграфов, которые есть в тексте // Модель параграфов, которые есть в тексте
public class WordParagraph public class WordParagraph
{ {
//набор текстов в абзаце (для случая, если в абзаце текст разных стилей) // Набор текстов в абзаце (для случая, если в абзаце текст разных стилей)
public List<(string, WordTextProperties)> Texts { get; set; } = new(); public List<(string, WordTextProperties)> Texts { get; set; } = new();
//свойства параграфа, если они есть // Свойства параграфа, если они есть
public WordTextProperties? TextProperties { get; set; } public WordTextProperties? TextProperties { get; set; }
public List<List<(string, WordTextProperties)>> RowTexts { get; set; } = new(); public List<List<(string, WordTextProperties)>> RowTexts { get; set; } = new();

View File

@ -310,7 +310,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
else else
{ {
// Все ячейки должны быть последовательно друг за другом расположены // Все ячейки должны быть последовательно друг за другом расположены
// нужно определить, после какой вставлять // Нужно определить, после какой вставлять
Cell? refCell = null; Cell? refCell = null;
foreach (Cell rowCell in row.Elements<Cell>()) foreach (Cell rowCell in row.Elements<Cell>())
@ -385,7 +385,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
} }
_spreadsheetDocument.WorkbookPart!.Workbook.Save(); _spreadsheetDocument.WorkbookPart!.Workbook.Save();
_spreadsheetDocument.Close(); _spreadsheetDocument.Dispose();
} }
} }
} }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels namespace FurnitureAssemblyContracts.BindingModels
{ {
// Класс для обмена информацией по почте // Класс для обмена информацией по почте. Сущность "Отправка на почту"
public class MailSendInfoBindingModel public class MailSendInfoBindingModel
{ {
public string MailAddress { get; set; } = string.Empty; public string MailAddress { get; set; } = string.Empty;

View File

@ -12,12 +12,12 @@ namespace FurnitureAssemblyContracts.BindingModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int FurnitureId { get; set; }
public int ClientId { get; set; } public int ClientId { get; set; }
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
public int FurnitureId { get; set; }
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels namespace FurnitureAssemblyContracts.BindingModels
{ {
// Реализация сущности "Отчёт"
public class ReportBindingModel public class ReportBindingModel
{ {
public string FileName { get; set; } = string.Empty; public string FileName { get; set; } = string.Empty;

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{ {
// Бизнес-логика для клиентов
public interface IClientLogic public interface IClientLogic
{ {
List<ClientViewModel> ReadList(ClientSearchModel? model); List<ClientViewModel> ReadList(ClientSearchModel? model);

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{ {
// Бизнес-логика для исполнителей
public interface IImplementerLogic public interface IImplementerLogic
{ {
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model); List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{ {
// Бизнес-логика для сообщений
public interface IMessageInfoLogic public interface IMessageInfoLogic
{ {
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model); List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);

View File

@ -11,10 +11,10 @@ namespace FurnitureAssemblyContracts.SearchModels
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? ClientFIO { get; set; }
public string? Email { get; set; } public string? Email { get; set; }
public string? ClientFIO { get; set; }
public string? Password { get; set; } public string? Password { get; set; }
} }
} }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.SearchModels namespace FurnitureAssemblyContracts.SearchModels
{ {
// Модель для поиска сообщений // Модель для поиска сущности "Сообщение"
public class MessageInfoSearchModel public class MessageInfoSearchModel
{ {
public string? MessageId { get; set; } public string? MessageId { get; set; }

View File

@ -16,13 +16,15 @@ namespace FurnitureAssemblyContracts.SearchModels
// для поиска по клиенту // для поиска по клиенту
public int? ClientId { get; set; } public int? ClientId { get; set; }
// для поиска по исполнителю // Для поиска по исполнителю
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
// Два поля для возможности производить выборку
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
// Для статуса заказа
public OrderStatus? Status { get; set; } public OrderStatus? Status { get; set; }
} }
} }

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels namespace FurnitureAssemblyContracts.ViewModels
{ {
// Класс для отображения информации о клиентах
public class ClientViewModel : IClientModel public class ClientViewModel : IClientModel
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels namespace FurnitureAssemblyContracts.ViewModels
{ {
// Класс для отображения информации об исполнителях
public class ImplementerViewModel : IImplementerModel public class ImplementerViewModel : IImplementerModel
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.ViewModels namespace FurnitureAssemblyContracts.ViewModels
{ {
// Класс для отображения пользователю информации о сообщениях
public class MessageInfoViewModel : IMessageInfoModel public class MessageInfoViewModel : IMessageInfoModel
{ {
public string MessageId { get; set; } = string.Empty; public string MessageId { get; set; } = string.Empty;

View File

@ -15,11 +15,6 @@ namespace FurnitureAssemblyContracts.ViewModels
[DisplayName("Номер")] [DisplayName("Номер")]
public int Id { get; set; } public int Id { get; set; }
public int FurnitureId { get; set; }
[DisplayName("Изделие")]
public string FurnitureName { get; set; } = string.Empty;
public int ClientId { get; set; } public int ClientId { get; set; }
[DisplayName("ФИО клиента")] [DisplayName("ФИО клиента")]
@ -30,6 +25,11 @@ namespace FurnitureAssemblyContracts.ViewModels
[DisplayName("ФИО исполнителя")] [DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
public int FurnitureId { get; set; }
[DisplayName("Изделие")]
public string FurnitureName { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyDataModels.Models namespace FurnitureAssemblyDataModels.Models
{ {
// Модель исполнителя // Интерфейс, отвечающий за исполнителя
public interface IImplementerModel : IId public interface IImplementerModel : IId
{ {
string ImplementerFIO { get; } string ImplementerFIO { get; }

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyDataModels.Models namespace FurnitureAssemblyDataModels.Models
{ {
// Интерфейс, отвечающий за сообщения
public interface IMessageInfoModel public interface IMessageInfoModel
{ {
string MessageId { get; } string MessageId { get; }

View File

@ -16,7 +16,6 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
{ {
public ClientViewModel? GetElement(ClientSearchModel model) public ClientViewModel? GetElement(ClientSearchModel model)
{ {
using var context = new FurnitureAssemblyDatabase(); using var context = new FurnitureAssemblyDatabase();
if (model.Id.HasValue) if (model.Id.HasValue)

View File

@ -101,13 +101,13 @@ namespace FurnitureAssemblyDatabaseImplement.Models
var furniture = context.Furnitures.First(x => x.Id == Id); var furniture = context.Furnitures.First(x => x.Id == Id);
foreach(var mwp in model.FurnitureWorkPieces) foreach(var fwp in model.FurnitureWorkPieces)
{ {
context.FurnitureWorkPieces.Add(new FurnitureWorkPiece context.FurnitureWorkPieces.Add(new FurnitureWorkPiece
{ {
Furniture = furniture, Furniture = furniture,
WorkPiece = context.WorkPieces.First(x => x.Id == mwp.Key), WorkPiece = context.WorkPieces.First(x => x.Id == fwp.Key),
Count = mwp.Value.Item2 Count = fwp.Value.Item2
}); });
context.SaveChanges(); context.SaveChanges();

View File

@ -6,6 +6,6 @@
<add key="PopHost" value="pop.gmail.com" /> <add key="PopHost" value="pop.gmail.com" />
<add key="PopPort" value="995" /> <add key="PopPort" value="995" />
<add key="MailLogin" value="furniturecoup73@gmail.com" /> <add key="MailLogin" value="furniturecoup73@gmail.com" />
<add key="MailPassword" value="hwba frfa mmbo bpji" /> <add key="MailPassword" value= "hwba frfa mmbo bpji" />
</appSettings> </appSettings>
</configuration> </configuration>

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

@ -31,7 +31,7 @@
buttonAdd = new Button(); buttonAdd = new Button();
buttonUpdate = new Button(); buttonUpdate = new Button();
buttonDelete = new Button(); buttonDelete = new Button();
buttonRef = new Button(); buttonRefresh = new Button();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
@ -66,15 +66,15 @@
buttonDelete.UseVisualStyleBackColor = true; buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click; buttonDelete.Click += ButtonDelete_Click;
// //
// buttonRef // buttonRefresh
// //
buttonRef.Location = new Point(640, 245); buttonRefresh.Location = new Point(640, 245);
buttonRef.Name = "buttonRef"; buttonRefresh.Name = "buttonRefresh";
buttonRef.Size = new Size(116, 50); buttonRefresh.Size = new Size(116, 50);
buttonRef.TabIndex = 3; buttonRefresh.TabIndex = 3;
buttonRef.Text = "Обновить"; buttonRefresh.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true; buttonRefresh.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click; buttonRefresh.Click += ButtonRefresh_Click;
// //
// dataGridView // dataGridView
// //
@ -92,7 +92,7 @@
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(781, 450); ClientSize = new Size(781, 450);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Controls.Add(buttonRef); Controls.Add(buttonRefresh);
Controls.Add(buttonDelete); Controls.Add(buttonDelete);
Controls.Add(buttonUpdate); Controls.Add(buttonUpdate);
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
@ -108,7 +108,7 @@
private Button buttonAdd; private Button buttonAdd;
private Button buttonUpdate; private Button buttonUpdate;
private Button buttonDelete; private Button buttonDelete;
private Button buttonRef; private Button buttonRefresh;
private DataGridView dataGridView; private 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();
} }