This commit is contained in:
dasha 2023-03-29 20:00:53 +04:00
parent a355deeb56
commit 2dfdf5d21d
51 changed files with 3695 additions and 52 deletions

View File

@ -23,6 +23,20 @@ namespace BeautySaloonBusinessLogic
return true; return true;
} }
public OrderViewModel? ReadElement(OrderSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _orderStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model) public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{ {
var list = model == null ? _orderStorage.GetFullList() : var list = model == null ? _orderStorage.GetFullList() :
@ -34,6 +48,16 @@ namespace BeautySaloonBusinessLogic
return list; return list;
} }
public bool Update(OrderBindingModel model)
{
CheckModel(model);
if (_orderStorage.Update(model) == null)
{
return false;
}
return true;
}
private void CheckModel(OrderBindingModel model, bool withParams = true) private void CheckModel(OrderBindingModel model, bool withParams = true)
{ {
if (model == null) if (model == null)

View File

@ -10,7 +10,7 @@ namespace BeautySaloonContracts.BindingModels
public int ClientId { get; set; } public int ClientId { get; set; }
public int EmployeeId { get; set; } public int EmployeeId { get; set; }
public Dictionary<int, (TimeOnly, IServiceModel, IEmployeeModel)> OrderServices public Dictionary<int, (TimeOnly, IServiceModel, int)> OrderServices
{ {
get; get;
set; set;

View File

@ -7,6 +7,8 @@ namespace BeautySaloonContracts.BusinessLogicsContracts
public interface IOrderLogic public interface IOrderLogic
{ {
List<OrderViewModel>? ReadList(OrderSearchModel? model); List<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel model);
bool CreateOrder(OrderBindingModel model); bool CreateOrder(OrderBindingModel model);
bool Update(OrderBindingModel model);
} }
} }

View File

@ -10,6 +10,7 @@ namespace BeautySaloonContracts.StoragesContracts
List<OrderViewModel> GetFilteredList(OrderSearchModel model); List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model); OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model); OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model); OrderViewModel? Delete(OrderBindingModel model);
} }
} }

View File

@ -15,6 +15,8 @@ namespace BeautySaloonContracts.ViewModels
public string Surname { get; set; } = string.Empty; public string Surname { get; set; } = string.Empty;
[DisplayName("Отчество")] [DisplayName("Отчество")]
public string Patronymic { get; set; } = string.Empty; public string Patronymic { get; set; } = string.Empty;
[DisplayName("ФИО")]
public string FIO { get; set; } = string.Empty;
[DisplayName("Телефон")] [DisplayName("Телефон")]
public string Phone { get; set; } = string.Empty; public string Phone { get; set; } = string.Empty;
} }

View File

@ -21,7 +21,7 @@ namespace BeautySaloonContracts.ViewModels
public string EmployeeName { get; set; } = string.Empty; public string EmployeeName { get; set; } = string.Empty;
[DisplayName("Номер продавца")] [DisplayName("Номер продавца")]
public string EmployeePhone { get; set; } = string.Empty; public string EmployeePhone { get; set; } = string.Empty;
public Dictionary<int, (DateTime, IServiceModel, IEmployeeModel)> OrderServices public Dictionary<int, (TimeOnly, IServiceModel, int)> OrderServices
{ {
get; get;
set; set;

View File

@ -9,6 +9,6 @@ namespace BeautySaloonContracts.ViewModels
[DisplayName("Услуга")] [DisplayName("Услуга")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Цена")] [DisplayName("Цена")]
public double Price { get; set; } public decimal Price { get; set; }
} }
} }

View File

@ -7,6 +7,6 @@
decimal Sum { get; } decimal Sum { get; }
int ClientId { get; } int ClientId { get; }
int EmployeeId { get; } int EmployeeId { get; }
Dictionary<int, (TimeOnly, IServiceModel, IEmployeeModel)> OrderServices { get; } Dictionary<int, (TimeOnly, IServiceModel, int)> OrderServices { get; }
} }
} }

View File

@ -41,7 +41,7 @@ public partial class Employee : IEmployeeModel
public virtual ICollection<Order> Orders { get; } = new List<Order>(); public virtual ICollection<Order> Orders { get; } = new List<Order>();
public virtual Position Position { get; set; } = null!; public virtual Position Position { get; set; }
public virtual ICollection<ServiceOrder> ServiceOrders { get; } = new List<ServiceOrder>(); public virtual ICollection<ServiceOrder> ServiceOrders { get; } = new List<ServiceOrder>();
@ -84,5 +84,6 @@ public partial class Employee : IEmployeeModel
Phone = Phone, Phone = Phone,
PositionId = PositionId, PositionId = PositionId,
PositionName = Position.Name, PositionName = Position.Name,
FIO = Name + ' ' + Surname + ' ' + Patronymic,
}; };
} }

View File

@ -58,12 +58,14 @@ namespace BeautySaloonDatabaseImplement.Implements
public ClientViewModel? Insert(ClientBindingModel model) public ClientViewModel? Insert(ClientBindingModel model)
{ {
using var context = new NewdbContext();
model.Id = context.Clients
.Count() > 0 ? context.Clients.Max(x => x.Id) + 1 : 1;
var newClient = Client.Create(model); var newClient = Client.Create(model);
if (newClient == null) if (newClient == null)
{ {
return null; return null;
} }
using var context = new NewdbContext();
context.Clients.Add(newClient); context.Clients.Add(newClient);
context.SaveChanges(); context.SaveChanges();
return newClient.GetViewModel; return newClient.GetViewModel;

View File

@ -2,6 +2,7 @@
using BeautySaloonContracts.SearchModels; using BeautySaloonContracts.SearchModels;
using BeautySaloonContracts.StoragesContracts; using BeautySaloonContracts.StoragesContracts;
using BeautySaloonContracts.ViewModels; using BeautySaloonContracts.ViewModels;
using Microsoft.EntityFrameworkCore;
namespace BeautySaloonDatabaseImplement.Implements namespace BeautySaloonDatabaseImplement.Implements
{ {
@ -11,6 +12,7 @@ namespace BeautySaloonDatabaseImplement.Implements
{ {
using var context = new NewdbContext(); using var context = new NewdbContext();
var element = context.Employees var element = context.Employees
.Include(x => x.Position)
.FirstOrDefault(rec => rec.Id == model.Id); .FirstOrDefault(rec => rec.Id == model.Id);
if (element != null) if (element != null)
{ {
@ -26,10 +28,12 @@ namespace BeautySaloonDatabaseImplement.Implements
using var context = new NewdbContext(); using var context = new NewdbContext();
if (model.Id.HasValue) if (model.Id.HasValue)
return context.Employees return context.Employees
.Include(x => x.Position)
.FirstOrDefault(x => x.Id == model.Id)? .FirstOrDefault(x => x.Id == model.Id)?
.GetViewModel; .GetViewModel;
if (!string.IsNullOrEmpty(model.Phone)) if (!string.IsNullOrEmpty(model.Phone))
return context.Employees return context.Employees
.Include(x => x.Position)
.FirstOrDefault(x => x.Phone.Equals(model.Phone))? .FirstOrDefault(x => x.Phone.Equals(model.Phone))?
.GetViewModel; .GetViewModel;
return null; return null;
@ -37,12 +41,19 @@ namespace BeautySaloonDatabaseImplement.Implements
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model) public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{ {
if (string.IsNullOrEmpty(model.Surname)) using var context = new NewdbContext();
if (string.IsNullOrEmpty(model.Surname) && !model.Id.HasValue)
{ {
return new(); return new();
} }
using var context = new NewdbContext(); if (model.Id.HasValue)
return context.Employees return context.Employees
.Include(x => x.Position)
.Where(x => x.Id.Equals(model.Id))
.Select(x => x.GetViewModel)
.ToList();
return context.Employees
.Include(x => x.Position)
.Where(x => x.Surname.Contains(model.Surname)) .Where(x => x.Surname.Contains(model.Surname))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
@ -52,27 +63,33 @@ namespace BeautySaloonDatabaseImplement.Implements
{ {
using var context = new NewdbContext(); using var context = new NewdbContext();
return context.Employees return context.Employees
.Include(x => x.Position)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
public EmployeeViewModel? Insert(EmployeeBindingModel model) public EmployeeViewModel? Insert(EmployeeBindingModel model)
{ {
using var context = new NewdbContext();
model.Id = context.Employees.Count() > 0 ? context.Employees.Max(x => x.Id) + 1 : 1;
var newEmployee = Employee.Create(model); var newEmployee = Employee.Create(model);
if (newEmployee == null) if (newEmployee == null)
{ {
return null; return null;
} }
using var context = new NewdbContext();
context.Employees.Add(newEmployee); context.Employees.Add(newEmployee);
context.SaveChanges(); context.SaveChanges();
return newEmployee.GetViewModel; return context.Employees
.Include(x => x.Position)
.FirstOrDefault(x => x.Id == newEmployee.Id)?
.GetViewModel;
} }
public EmployeeViewModel? Update(EmployeeBindingModel model) public EmployeeViewModel? Update(EmployeeBindingModel model)
{ {
using var context = new NewdbContext(); using var context = new NewdbContext();
var client = context.Employees var client = context.Employees
.Include(x => x.Position)
.FirstOrDefault(x => x.Id == model.Id); .FirstOrDefault(x => x.Id == model.Id);
if (client == null) if (client == null)
{ {
@ -80,7 +97,10 @@ namespace BeautySaloonDatabaseImplement.Implements
} }
client.Update(model); client.Update(model);
context.SaveChanges(); context.SaveChanges();
return client.GetViewModel; return context.Employees
.Include(x => x.Position)
.FirstOrDefault(x => x.Id == client.Id)?
.GetViewModel;
} }
} }
} }

View File

@ -62,15 +62,41 @@ namespace BeautySaloonDatabaseImplement.Implements
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)
{ {
var newOrder = Order.Create(model); using var context = new NewdbContext();
model.Id = context.Orders
.Count() > 0 ? context.Orders.Max(x => x.Id) + 1 : 1;
var newOrder = Order.Create(context, model);
if (newOrder == null) if (newOrder == null)
{ {
return null; return null;
} }
using var context = new NewdbContext();
context.Orders.Add(newOrder); context.Orders.Add(newOrder);
context.SaveChanges(); context.SaveChanges();
return newOrder.GetViewModel; return newOrder.GetViewModel;
} }
public OrderViewModel? Update(OrderBindingModel model)
{
using var context = new NewdbContext();
using var transaction = context.Database.BeginTransaction();
try
{
var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
context.SaveChanges();
order.UpdateServices(context, model);
transaction.Commit();
return order.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
} }
} }

View File

@ -58,12 +58,14 @@ namespace BeautySaloonDatabaseImplement.Implements
public PositionViewModel? Insert(PositionBindingModel model) public PositionViewModel? Insert(PositionBindingModel model)
{ {
using var context = new NewdbContext();
model.Id = context.Positions
.Count() > 0 ? context.Positions.Max(x => x.Id) + 1 : 1;
var newPosition = Position.Create(model); var newPosition = Position.Create(model);
if (newPosition == null) if (newPosition == null)
{ {
return null; return null;
} }
using var context = new NewdbContext();
context.Positions.Add(newPosition); context.Positions.Add(newPosition);
context.SaveChanges(); context.SaveChanges();
return newPosition.GetViewModel; return newPosition.GetViewModel;

View File

@ -58,12 +58,14 @@ namespace BeautySaloonDatabaseImplement.Implements
public ServiceViewModel? Insert(ServiceBindingModel model) public ServiceViewModel? Insert(ServiceBindingModel model)
{ {
using var context = new NewdbContext();
model.Id = context.Services
.Count() > 0 ? context.Services.Max(x => x.Id) + 1 : 1;
var newService = Service.Create(model); var newService = Service.Create(model);
if (newService == null) if (newService == null)
{ {
return null; return null;
} }
using var context = new NewdbContext();
context.Services.Add(newService); context.Services.Add(newService);
context.SaveChanges(); context.SaveChanges();
return newService.GetViewModel; return newService.GetViewModel;

View File

@ -1,9 +1,6 @@
using BeautySaloonContracts.BindingModels; using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.ViewModels; using BeautySaloonContracts.ViewModels;
using BeautySaloonDataModels; using BeautySaloonDataModels;
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Numerics;
namespace BeautySaloonDatabaseImplement; namespace BeautySaloonDatabaseImplement;
@ -44,25 +41,26 @@ public partial class Order : IOrderModel
public virtual ServiceOrder? ServiceOrder { get; set; } public virtual ServiceOrder? ServiceOrder { get; set; }
public Dictionary<int, (TimeOnly, IServiceModel, IEmployeeModel)> _orderServices = null; public Dictionary<int, (TimeOnly, IServiceModel, int)> _orderServices = null;
public virtual List<ServiceOrder> Services { get; set; } = new(); public virtual List<ServiceOrder> Services { get; set; } = new();
public Dictionary<int, (TimeOnly, IServiceModel, IEmployeeModel)> OrderServices public Dictionary<int, (TimeOnly, IServiceModel, int)> OrderServices
{ {
get get
{ {
if (ServiceOrder != null) if (_orderServices == null)
{ {
_orderServices = Services _orderServices = Services
.ToDictionary(x => x.ServiceId, .ToDictionary(serviceOrd => serviceOrd.ServiceId,
x => (x.Date, x.Service as IServiceModel, x.Employee as IEmployeeModel)); serviceOrd => (serviceOrd.Date, serviceOrd.Service as IServiceModel,
serviceOrd.EmployeeId));
} }
return _orderServices; return _orderServices;
} }
} }
public static Order? Create(OrderBindingModel? model) public static Order? Create(NewdbContext context, OrderBindingModel? model)
{ {
if (model == null) if (model == null)
{ {
@ -74,10 +72,24 @@ public partial class Order : IOrderModel
Date = model.Date, Date = model.Date,
Sum = model.Sum, Sum = model.Sum,
ClientId = model.ClientId, ClientId = model.ClientId,
EmployeeId = model.EmployeeId EmployeeId = model.EmployeeId,
Services = model.OrderServices.Select(x => new ServiceOrder
{
Service = context.Services.First(y => y.Id == x.Key),
Date = x.Value.Item1,
EmployeeId = x.Value.Item3,
}).ToList()
}; };
} }
public void Update(OrderBindingModel model)
{
Date = model.Date;
Sum = model.Sum;
EmployeeId = model.EmployeeId;
ClientId = model.ClientId;
}
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
@ -85,9 +97,45 @@ public partial class Order : IOrderModel
Sum = Sum, Sum = Sum,
ClientId = ClientId, ClientId = ClientId,
EmployeeId = EmployeeId, EmployeeId = EmployeeId,
ClientName = Client.Name, ClientName = Client.Name + " " + Client.Surname + " " + Client.Patronymic,
EmployeeName = Employee.Name, EmployeeName = Employee.Name + " " + Employee.Surname + " " + Employee.Patronymic,
ClientPhone = Client.Phone, ClientPhone = Client.Phone,
EmployeePhone = Employee.Phone EmployeePhone = Employee.Phone
}; };
public void UpdateServices(NewdbContext context, OrderBindingModel model)
{
var orderServices = context.ServiceOrders
.Where(rec => rec.OrderId == model.Id).ToList();
if (orderServices != null && orderServices.Count > 0)
{ // удалили те, которых нет в модели
context.ServiceOrders
.RemoveRange(orderServices
.Where(rec => !model.OrderServices.ContainsKey(rec.ServiceId)));
context.SaveChanges();
// обновили данные у существующих записей
foreach (var updateService in orderServices)
{
updateService.Date = model.OrderServices[updateService.ServiceId].Item1;
updateService.EmployeeId =
model.OrderServices[updateService.ServiceId].Item3;
model.OrderServices.Remove(updateService.ServiceId);
}
context.SaveChanges();
}
var order = context.Orders.First(x => x.Id == Id);
foreach (var os in model.OrderServices)
{
context.ServiceOrders.Add(new ServiceOrder
{
Order = order,
Service = context.Services.First(x => x.Id == os.Key),
Date = os.Value.Item1,
EmployeeId = os.Value.Item3
});
context.SaveChanges();
}
_orderServices = null;
}
} }

View File

@ -0,0 +1,166 @@
namespace BeautySaloonView
{
partial class FormClient
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxSurname = new System.Windows.Forms.TextBox();
this.textBoxPatronymic = new System.Windows.Forms.TextBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.labelName = new System.Windows.Forms.Label();
this.labelSurname = new System.Windows.Forms.Label();
this.labelPatronymic = new System.Windows.Forms.Label();
this.labelPhone = new System.Windows.Forms.Label();
this.maskedTextBox = new System.Windows.Forms.MaskedTextBox();
this.SuspendLayout();
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(125, 12);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(244, 23);
this.textBoxName.TabIndex = 0;
//
// textBoxSurname
//
this.textBoxSurname.Location = new System.Drawing.Point(125, 41);
this.textBoxSurname.Name = "textBoxSurname";
this.textBoxSurname.Size = new System.Drawing.Size(244, 23);
this.textBoxSurname.TabIndex = 1;
//
// textBoxPatronymic
//
this.textBoxPatronymic.Location = new System.Drawing.Point(125, 70);
this.textBoxPatronymic.Name = "textBoxPatronymic";
this.textBoxPatronymic.Size = new System.Drawing.Size(244, 23);
this.textBoxPatronymic.TabIndex = 2;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(288, 127);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(200, 127);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
this.buttonSave.TabIndex = 14;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(12, 15);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(31, 15);
this.labelName.TabIndex = 16;
this.labelName.Text = "Имя";
//
// labelSurname
//
this.labelSurname.AutoSize = true;
this.labelSurname.Location = new System.Drawing.Point(12, 44);
this.labelSurname.Name = "labelSurname";
this.labelSurname.Size = new System.Drawing.Size(58, 15);
this.labelSurname.TabIndex = 17;
this.labelSurname.Text = "Фамилия";
//
// labelPatronymic
//
this.labelPatronymic.AutoSize = true;
this.labelPatronymic.Location = new System.Drawing.Point(12, 73);
this.labelPatronymic.Name = "labelPatronymic";
this.labelPatronymic.Size = new System.Drawing.Size(58, 15);
this.labelPatronymic.TabIndex = 18;
this.labelPatronymic.Text = "Отчество";
//
// labelPhone
//
this.labelPhone.AutoSize = true;
this.labelPhone.Location = new System.Drawing.Point(12, 102);
this.labelPhone.Name = "labelPhone";
this.labelPhone.Size = new System.Drawing.Size(101, 15);
this.labelPhone.TabIndex = 19;
this.labelPhone.Text = "Номер телефона";
//
// maskedTextBox
//
this.maskedTextBox.Location = new System.Drawing.Point(125, 99);
this.maskedTextBox.Mask = "00000000000";
this.maskedTextBox.Name = "maskedTextBox";
this.maskedTextBox.Size = new System.Drawing.Size(244, 23);
this.maskedTextBox.TabIndex = 21;
//
// FormClient
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(390, 157);
this.Controls.Add(this.maskedTextBox);
this.Controls.Add(this.labelPhone);
this.Controls.Add(this.labelPatronymic);
this.Controls.Add(this.labelSurname);
this.Controls.Add(this.labelName);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxPatronymic);
this.Controls.Add(this.textBoxSurname);
this.Controls.Add(this.textBoxName);
this.Name = "FormClient";
this.Text = "Создание клиента";
this.Load += new System.EventHandler(this.FormClient_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxName;
private TextBox textBoxSurname;
private TextBox textBoxPatronymic;
private Button buttonCancel;
private Button buttonSave;
private Label labelName;
private Label labelSurname;
private Label labelPatronymic;
private Label labelPhone;
private MaskedTextBox maskedTextBox;
}
}

View File

@ -0,0 +1,92 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.SearchModels;
namespace BeautySaloonView
{
public partial class FormClient : Form
{
private readonly IClientLogic _logicC;
private readonly IOrderLogic _logicO;
private int? _id;
public int Id { set { _id = value; } }
public FormClient(IClientLogic logicС, IOrderLogic logicO)
{
InitializeComponent();
_logicC = logicС;
_logicO = logicO;
}
private void FormClient_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logicC.ReadElement(new ClientSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
textBoxSurname.Text = view.Surname;
textBoxPatronymic.Text = view.Patronymic;
maskedTextBox.Text = view.Phone;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxSurname.Text))
{
MessageBox.Show("Заполните фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!maskedTextBox.MaskFull)
{
MessageBox.Show("Заполните номер телефона", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new ClientBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
Surname = textBoxSurname.Text,
Patronymic = textBoxPatronymic.Text,
Phone = maskedTextBox.Text
};
var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,108 @@
namespace BeautySaloonView
{
partial class FormClientOrders
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.GridColor = System.Drawing.Color.White;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(921, 337);
this.dataGridView.TabIndex = 10;
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(927, 156);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(927, 130);
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(130, 22);
this.buttonEdit.TabIndex = 12;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(927, 104);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(130, 22);
this.buttonAdd.TabIndex = 11;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// FormClientOrders
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1065, 337);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd);
this.Name = "FormClientOrders";
this.Text = "Заказы клиента";
this.Load += new System.EventHandler(this.FormClientOrders_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonUpdate;
private Button buttonEdit;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,77 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.SearchModels;
namespace BeautySaloonView
{
public partial class FormClientOrders : Form
{
private readonly IOrderLogic _logic;
private int? _idClient;
public int IdClient { set { _idClient = value; } }
public FormClientOrders(IOrderLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormClientOrders_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(new OrderSearchModel
{
ClientId = _idClient
});
if (list != null)
{
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["EmployeeId"].Visible = false;
dataGridView.Columns["OrderServices"].Visible = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.IdClient = _idClient.Value;
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(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
form.IdClient = _idClient.Value;
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,136 @@
namespace BeautySaloonView
{
partial class FormClients
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonOrders = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.GridColor = System.Drawing.Color.White;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(652, 337);
this.dataGridView.TabIndex = 10;
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(658, 194);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(658, 168);
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(130, 22);
this.buttonDelete.TabIndex = 13;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(658, 142);
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(130, 22);
this.buttonEdit.TabIndex = 12;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(658, 116);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(130, 22);
this.buttonAdd.TabIndex = 11;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// buttonOrders
//
this.buttonOrders.Location = new System.Drawing.Point(658, 220);
this.buttonOrders.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonOrders.Name = "buttonOrders";
this.buttonOrders.Size = new System.Drawing.Size(130, 22);
this.buttonOrders.TabIndex = 15;
this.buttonOrders.Text = "Посмотреть заказы";
this.buttonOrders.UseVisualStyleBackColor = true;
this.buttonOrders.Click += new System.EventHandler(this.ButtonOrders_Click);
//
// FormClients
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(796, 337);
this.Controls.Add(this.buttonOrders);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd);
this.Name = "FormClients";
this.Text = "Клиенты";
this.Load += new System.EventHandler(this.FormClients_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonEdit;
private Button buttonAdd;
private Button buttonOrders;
}
}

View File

@ -0,0 +1,109 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
namespace BeautySaloonView
{
public partial class FormClients : Form
{
private readonly IClientLogic _logic;
public FormClients(IClientLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormClients_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
if (service is FormClient form)
{
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(FormClient));
if (service is FormClient form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonOrders_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClientOrders));
if (service is FormClientOrders form)
{
form.IdClient = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
else
MessageBox.Show("Выберите пользователя для отображения заказов", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new ClientBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,275 @@
namespace BeautySaloonView
{
partial class FormCreateOrder
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.comboBoxEmployee = new System.Windows.Forms.ComboBox();
this.textBox = new System.Windows.Forms.TextBox();
this.labelDate = new System.Windows.Forms.Label();
this.labelCashier = new System.Windows.Forms.Label();
this.labelSum = new System.Windows.Forms.Label();
this.groupBoxServices = new System.Windows.Forms.GroupBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnServiceName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnDate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnEmployeeName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBoxServices.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dateTimePicker
//
this.dateTimePicker.Location = new System.Drawing.Point(109, 18);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(525, 23);
this.dateTimePicker.TabIndex = 0;
//
// comboBoxEmployee
//
this.comboBoxEmployee.FormattingEnabled = true;
this.comboBoxEmployee.Location = new System.Drawing.Point(109, 47);
this.comboBoxEmployee.Name = "comboBoxEmployee";
this.comboBoxEmployee.Size = new System.Drawing.Size(525, 23);
this.comboBoxEmployee.TabIndex = 2;
//
// textBox
//
this.textBox.Location = new System.Drawing.Point(109, 76);
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(525, 23);
this.textBox.TabIndex = 3;
//
// labelDate
//
this.labelDate.AutoSize = true;
this.labelDate.Location = new System.Drawing.Point(12, 24);
this.labelDate.Name = "labelDate";
this.labelDate.Size = new System.Drawing.Size(69, 15);
this.labelDate.TabIndex = 4;
this.labelDate.Text = "Дата заказа";
//
// labelCashier
//
this.labelCashier.AutoSize = true;
this.labelCashier.Location = new System.Drawing.Point(12, 50);
this.labelCashier.Name = "labelCashier";
this.labelCashier.Size = new System.Drawing.Size(61, 15);
this.labelCashier.TabIndex = 5;
this.labelCashier.Text = "Продавец";
//
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(12, 79);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(82, 15);
this.labelSum.TabIndex = 6;
this.labelSum.Text = "Сумма заказа";
//
// groupBoxServices
//
this.groupBoxServices.Controls.Add(this.buttonCancel);
this.groupBoxServices.Controls.Add(this.buttonSave);
this.groupBoxServices.Controls.Add(this.buttonUpdate);
this.groupBoxServices.Controls.Add(this.buttonDelete);
this.groupBoxServices.Controls.Add(this.buttonEdit);
this.groupBoxServices.Controls.Add(this.buttonAdd);
this.groupBoxServices.Controls.Add(this.dataGridView);
this.groupBoxServices.Dock = System.Windows.Forms.DockStyle.Bottom;
this.groupBoxServices.Location = new System.Drawing.Point(0, 105);
this.groupBoxServices.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxServices.Name = "groupBoxServices";
this.groupBoxServices.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxServices.Size = new System.Drawing.Size(737, 206);
this.groupBoxServices.TabIndex = 18;
this.groupBoxServices.TabStop = false;
this.groupBoxServices.Text = "Услуги";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(646, 176);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(79, 22);
this.buttonCancel.TabIndex = 6;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(646, 150);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(79, 22);
this.buttonSave.TabIndex = 5;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(646, 98);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(79, 22);
this.buttonUpdate.TabIndex = 4;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(646, 72);
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(79, 22);
this.buttonDelete.TabIndex = 3;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(646, 46);
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(79, 22);
this.buttonEdit.TabIndex = 2;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(646, 20);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(79, 22);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ID,
this.ColumnServiceName,
this.ColumnDate,
this.ColumnEmployeeName});
this.dataGridView.Location = new System.Drawing.Point(5, 20);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(629, 182);
this.dataGridView.TabIndex = 0;
//
// ID
//
this.ID.HeaderText = "ID";
this.ID.MinimumWidth = 6;
this.ID.Name = "ID";
this.ID.Visible = false;
this.ID.Width = 125;
//
// ColumnServiceName
//
this.ColumnServiceName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ColumnServiceName.HeaderText = "Услуга";
this.ColumnServiceName.MinimumWidth = 6;
this.ColumnServiceName.Name = "ColumnServiceName";
this.ColumnServiceName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
//
// ColumnDate
//
this.ColumnDate.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ColumnDate.HeaderText = "Время";
this.ColumnDate.MinimumWidth = 6;
this.ColumnDate.Name = "ColumnDate";
//
// ColumnEmployeeName
//
this.ColumnEmployeeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ColumnEmployeeName.HeaderText = "Сотрудник";
this.ColumnEmployeeName.Name = "ColumnEmployeeName";
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(737, 311);
this.Controls.Add(this.groupBoxServices);
this.Controls.Add(this.labelSum);
this.Controls.Add(this.labelCashier);
this.Controls.Add(this.labelDate);
this.Controls.Add(this.textBox);
this.Controls.Add(this.comboBoxEmployee);
this.Controls.Add(this.dateTimePicker);
this.Name = "FormCreateOrder";
this.Text = "Форма создания заказа";
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
this.groupBoxServices.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private DateTimePicker dateTimePicker;
private ComboBox comboBoxEmployee;
private TextBox textBox;
private Label labelDate;
private Label labelCashier;
private Label labelSum;
private GroupBox groupBoxServices;
private Button buttonCancel;
private Button buttonSave;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonEdit;
private Button buttonAdd;
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ID;
private DataGridViewTextBoxColumn ColumnServiceName;
private DataGridViewTextBoxColumn ColumnDate;
private DataGridViewTextBoxColumn ColumnEmployeeName;
}
}

View File

@ -0,0 +1,221 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.SearchModels;
using BeautySaloonDataModels;
namespace BeautySaloonView
{
public partial class FormCreateOrder : Form
{
private readonly IOrderLogic _logicO;
private readonly IEmployeeLogic _logicE;
private int? _idClient;
private int? _id;
private Dictionary<int, (TimeOnly, IServiceModel, int)> _orderServices;
public int IdClient { set { _idClient = value; } }
public int Id { set { _id = value; } }
public FormCreateOrder(IOrderLogic logic, IEmployeeLogic logicE)
{
InitializeComponent();
_logicO = logic;
_logicE = logicE;
_orderServices = new();
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
try
{
// продавцы
var list = _logicE.ReadList(new EmployeeSearchModel
{
Id = 1
});
if (list != null)
{
comboBoxEmployee.DisplayMember = "FIO";
comboBoxEmployee.ValueMember = "Id";
comboBoxEmployee.DataSource = list;
comboBoxEmployee.SelectedItem = null;
}
// загружаем заказ для изменения
if (_id.HasValue)
{
var view = _logicO.ReadElement(new OrderSearchModel
{
Id = _idClient.Value
});
if (view != null)
{
textBox.Text = view.Sum.ToString();
dateTimePicker.Text = view.Date.ToString();
comboBoxEmployee.SelectedValue = view.EmployeeId;
_orderServices = view.OrderServices ?? new();
LoadData();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadData()
{
// заполняем datagridview
try
{
if (_orderServices != null)
{
dataGridView.Rows.Clear();
foreach (var os in _orderServices)
{
var empl = _logicE.ReadElement(new EmployeeSearchModel
{
Id = os.Value.Item3
});
if (empl == null)
{
throw new ArgumentNullException("Не найден указанный сотрудник");
}
dataGridView.Rows.Add(new object[]
{
os.Key,
os.Value.Item2.Name,
os.Value.Item1,
empl.FIO,
});
}
textBox.Text = CalcPrice().ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrderServices));
if (service is FormOrderServices form)
{
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ServiceModel == null)
{
return;
}
if (_orderServices.ContainsKey(form.IdService))
{
_orderServices[form.IdService] = (form.Date,
form.ServiceModel, form.IdEmployee);
}
else
{
_orderServices.Add(form.IdService,
(form.Date, form.ServiceModel, form.IdEmployee));
}
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrderServices));
if (service is FormOrderServices form)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.IdService = id;
form.Date = _orderServices[id].Item1;
form.IdEmployee = _orderServices[id].Item3;
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ServiceModel == null)
{
return;
}
_orderServices[form.IdService] = (form.Date,
form.ServiceModel, form.IdEmployee);
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
_orderServices?.Remove(Convert.ToInt32(dataGridView
.SelectedRows[0].Cells[0].Value));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (comboBoxEmployee.SelectedValue == null)
{
MessageBox.Show("Выберите продавца", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (_orderServices == null || _orderServices.Count == 0)
{
MessageBox.Show("Заполните услуги", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new OrderBindingModel
{
Id = _id ?? 0,
Date = DateOnly.FromDateTime(dateTimePicker.Value),
Sum = Convert.ToDecimal(textBox.Text),
ClientId = _idClient.Value,
EmployeeId = Convert.ToInt32(comboBoxEmployee.SelectedValue),
OrderServices = _orderServices
};
var operationResult = _id.HasValue ? _logicO.Update(model) : _logicO.CreateOrder(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private decimal CalcPrice()
{
decimal price = 0;
foreach (var elem in _orderServices)
{
price += elem.Value.Item2?.Price ?? 0;
}
return Math.Round(price, 2);
}
}
}

View File

@ -0,0 +1,72 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnServiceName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnEmployeeName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,189 @@
namespace BeautySaloonView
{
partial class FormEmployee
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxSurname = new System.Windows.Forms.TextBox();
this.textBoxPatronymic = new System.Windows.Forms.TextBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.labelName = new System.Windows.Forms.Label();
this.labelSurname = new System.Windows.Forms.Label();
this.labelPatronymic = new System.Windows.Forms.Label();
this.labelPhone = new System.Windows.Forms.Label();
this.labelPosition = new System.Windows.Forms.Label();
this.maskedTextBox = new System.Windows.Forms.MaskedTextBox();
this.comboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(125, 12);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(244, 23);
this.textBoxName.TabIndex = 0;
//
// textBoxSurname
//
this.textBoxSurname.Location = new System.Drawing.Point(125, 41);
this.textBoxSurname.Name = "textBoxSurname";
this.textBoxSurname.Size = new System.Drawing.Size(244, 23);
this.textBoxSurname.TabIndex = 1;
//
// textBoxPatronymic
//
this.textBoxPatronymic.Location = new System.Drawing.Point(125, 70);
this.textBoxPatronymic.Name = "textBoxPatronymic";
this.textBoxPatronymic.Size = new System.Drawing.Size(244, 23);
this.textBoxPatronymic.TabIndex = 2;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(287, 156);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(199, 156);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
this.buttonSave.TabIndex = 14;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(12, 15);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(31, 15);
this.labelName.TabIndex = 16;
this.labelName.Text = "Имя";
//
// labelSurname
//
this.labelSurname.AutoSize = true;
this.labelSurname.Location = new System.Drawing.Point(12, 44);
this.labelSurname.Name = "labelSurname";
this.labelSurname.Size = new System.Drawing.Size(58, 15);
this.labelSurname.TabIndex = 17;
this.labelSurname.Text = "Фамилия";
//
// labelPatronymic
//
this.labelPatronymic.AutoSize = true;
this.labelPatronymic.Location = new System.Drawing.Point(12, 73);
this.labelPatronymic.Name = "labelPatronymic";
this.labelPatronymic.Size = new System.Drawing.Size(58, 15);
this.labelPatronymic.TabIndex = 18;
this.labelPatronymic.Text = "Отчество";
//
// labelPhone
//
this.labelPhone.AutoSize = true;
this.labelPhone.Location = new System.Drawing.Point(12, 102);
this.labelPhone.Name = "labelPhone";
this.labelPhone.Size = new System.Drawing.Size(101, 15);
this.labelPhone.TabIndex = 19;
this.labelPhone.Text = "Номер телефона";
//
// labelPosition
//
this.labelPosition.AutoSize = true;
this.labelPosition.Location = new System.Drawing.Point(12, 131);
this.labelPosition.Name = "labelPosition";
this.labelPosition.Size = new System.Drawing.Size(69, 15);
this.labelPosition.TabIndex = 20;
this.labelPosition.Text = "Должность";
//
// maskedTextBox
//
this.maskedTextBox.Location = new System.Drawing.Point(125, 99);
this.maskedTextBox.Mask = "00000000000";
this.maskedTextBox.Name = "maskedTextBox";
this.maskedTextBox.Size = new System.Drawing.Size(244, 23);
this.maskedTextBox.TabIndex = 21;
//
// comboBox
//
this.comboBox.FormattingEnabled = true;
this.comboBox.Location = new System.Drawing.Point(125, 128);
this.comboBox.Name = "comboBox";
this.comboBox.Size = new System.Drawing.Size(244, 23);
this.comboBox.TabIndex = 22;
//
// FormEmployee
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(390, 188);
this.Controls.Add(this.comboBox);
this.Controls.Add(this.maskedTextBox);
this.Controls.Add(this.labelPosition);
this.Controls.Add(this.labelPhone);
this.Controls.Add(this.labelPatronymic);
this.Controls.Add(this.labelSurname);
this.Controls.Add(this.labelName);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxPatronymic);
this.Controls.Add(this.textBoxSurname);
this.Controls.Add(this.textBoxName);
this.Name = "FormEmployee";
this.Text = "Создание сотрудника";
this.Load += new System.EventHandler(this.FormEmployee_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxName;
private TextBox textBoxSurname;
private TextBox textBoxPatronymic;
private Button buttonCancel;
private Button buttonSave;
private Label labelName;
private Label labelSurname;
private Label labelPatronymic;
private Label labelPhone;
private Label labelPosition;
private MaskedTextBox maskedTextBox;
private ComboBox comboBox;
}
}

View File

@ -0,0 +1,127 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.SearchModels;
using Microsoft.IdentityModel.Tokens;
namespace BeautySaloonView
{
public partial class FormEmployee : Form
{
private readonly IEmployeeLogic _logicE;
private readonly IPositionLogic _logicP;
private int? _id;
public int Id { set { _id = value; } }
public FormEmployee(IEmployeeLogic logicE, IPositionLogic logicP)
{
InitializeComponent();
_logicE = logicE;
_logicP = logicP;
}
private void FormEmployee_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logicE.ReadElement(new EmployeeSearchModel
{
Id = _id.Value
});
var list = _logicP.ReadList(null);
if (list != null)
{
comboBox.DisplayMember = "Name";
comboBox.ValueMember = "Id";
comboBox.DataSource = list;
comboBox.SelectedItem = null;
}
if (view != null)
{
textBoxName.Text = view.Name;
textBoxSurname.Text = view.Surname;
textBoxPatronymic.Text = view.Patronymic;
maskedTextBox.Text = view.Phone;
comboBox.SelectedValue = view.PositionId;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
else
{
try
{
var list = _logicP.ReadList(null);
if (list != null)
{
comboBox.DisplayMember = "Name";
comboBox.ValueMember = "Id";
comboBox.DataSource = list;
comboBox.SelectedItem = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxSurname.Text))
{
MessageBox.Show("Заполните фамилию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!maskedTextBox.MaskFull)
{
MessageBox.Show("Заполните номер телефона", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBox.SelectedValue == null)
{
MessageBox.Show("Выберите должность", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new EmployeeBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
Surname = textBoxSurname.Text,
Patronymic = textBoxPatronymic.Text,
Phone = maskedTextBox.Text,
PositionId = Convert.ToInt32(comboBox.SelectedValue)
};
var operationResult = _id.HasValue ? _logicE.Update(model) : _logicE.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,122 @@
namespace BeautySaloonView
{
partial class FormEmployees
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.GridColor = System.Drawing.Color.White;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(652, 337);
this.dataGridView.TabIndex = 10;
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(658, 194);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(658, 168);
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(130, 22);
this.buttonDelete.TabIndex = 13;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(658, 142);
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(130, 22);
this.buttonEdit.TabIndex = 12;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(658, 116);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(130, 22);
this.buttonAdd.TabIndex = 11;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// FormEmployees
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(796, 337);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd);
this.Name = "FormEmployees";
this.Text = "Сотрудники";
this.Load += new System.EventHandler(this.FormEmployees_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonEdit;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,93 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
namespace BeautySaloonView
{
public partial class FormEmployees : Form
{
private readonly IEmployeeLogic _logic;
public FormEmployees(IEmployeeLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormEmployees_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["PositionId"].Visible = false;
dataGridView.Columns["FIO"].Visible = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
if (service is FormEmployee form)
{
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(FormEmployee));
if (service is FormEmployee form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new EmployeeBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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

@ -36,7 +36,6 @@
this.сотрудникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.сотрудникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonCreateOrder = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -50,7 +49,7 @@
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29; this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(854, 515); this.dataGridView.Size = new System.Drawing.Size(911, 515);
this.dataGridView.TabIndex = 8; this.dataGridView.TabIndex = 8;
// //
// menuStrip1 // menuStrip1
@ -77,46 +76,41 @@
// должностиToolStripMenuItem // должностиToolStripMenuItem
// //
this.должностиToolStripMenuItem.Name = олжностиToolStripMenuItem"; this.должностиToolStripMenuItem.Name = олжностиToolStripMenuItem";
this.должностиToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.должностиToolStripMenuItem.Size = new System.Drawing.Size(140, 22);
this.должностиToolStripMenuItem.Text = "Должности"; this.должностиToolStripMenuItem.Text = "Должности";
this.должностиToolStripMenuItem.Click += new System.EventHandler(this.PositionsToolStripMenuItem_Click);
// //
// услугиToolStripMenuItem // услугиToolStripMenuItem
// //
this.услугиToolStripMenuItem.Name = "услугиToolStripMenuItem"; this.услугиToolStripMenuItem.Name = "услугиToolStripMenuItem";
this.услугиToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.услугиToolStripMenuItem.Size = new System.Drawing.Size(140, 22);
this.услугиToolStripMenuItem.Text = "Услуги"; this.услугиToolStripMenuItem.Text = "Услуги";
this.услугиToolStripMenuItem.Click += new System.EventHandler(this.ServicesToolStripMenuItem_Click);
// //
// сотрудникиToolStripMenuItem // сотрудникиToolStripMenuItem
// //
this.сотрудникиToolStripMenuItem.Name = "сотрудникиToolStripMenuItem"; this.сотрудникиToolStripMenuItem.Name = "сотрудникиToolStripMenuItem";
this.сотрудникиToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.сотрудникиToolStripMenuItem.Size = new System.Drawing.Size(140, 22);
this.сотрудникиToolStripMenuItem.Text = "Сотрудники"; this.сотрудникиToolStripMenuItem.Text = "Сотрудники";
this.сотрудникиToolStripMenuItem.Click += new System.EventHandler(this.EmployeesToolStripMenuItem_Click);
// //
// клиентыToolStripMenuItem // клиентыToolStripMenuItem
// //
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(140, 22);
this.клиентыToolStripMenuItem.Text = "Клиенты"; this.клиентыToolStripMenuItem.Text = "Клиенты";
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
// //
// buttonUpdate // buttonUpdate
// //
this.buttonUpdate.Location = new System.Drawing.Point(885, 270); this.buttonUpdate.Location = new System.Drawing.Point(917, 241);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate"; this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(116, 58); this.buttonUpdate.Size = new System.Drawing.Size(116, 58);
this.buttonUpdate.TabIndex = 17; this.buttonUpdate.TabIndex = 17;
this.buttonUpdate.Text = "Обновить"; this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true; this.buttonUpdate.UseVisualStyleBackColor = true;
// this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
// buttonCreateOrder
//
this.buttonCreateOrder.Location = new System.Drawing.Point(885, 208);
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(116, 58);
this.buttonCreateOrder.TabIndex = 13;
this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true;
// //
// FormMain // FormMain
// //
@ -124,12 +118,12 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1037, 539); this.ClientSize = new System.Drawing.Size(1037, 539);
this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
this.Name = "FormMain"; this.Name = "FormMain";
this.Text = "Салон красоты"; this.Text = "Салон красоты";
this.Load += new System.EventHandler(this.FormMain_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout(); this.menuStrip1.PerformLayout();

View File

@ -1,10 +1,76 @@
using BeautySaloonContracts.BusinessLogicsContracts;
namespace BeautySaloonView namespace BeautySaloonView
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
public FormMain() private readonly IOrderLogic _orderLogic;
public FormMain(IOrderLogic orderLogic)
{ {
InitializeComponent(); InitializeComponent();
_orderLogic = orderLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["EmployeeId"].Visible = false;
dataGridView.Columns["OrderServices"].Visible = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private void PositionsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPositions));
if (service is FormPositions form)
{
form.ShowDialog();
}
}
private void ServicesToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormServices));
if (service is FormServices form)
{
form.ShowDialog();
}
}
private void EmployeesToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployees));
if (service is FormEmployees form)
{
form.ShowDialog();
}
}
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
} }
} }
} }

View File

@ -0,0 +1,149 @@
namespace BeautySaloonView
{
partial class FormOrderServices
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.comboBoxService = new System.Windows.Forms.ComboBox();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.comboBoxEmployee = new System.Windows.Forms.ComboBox();
this.labelService = new System.Windows.Forms.Label();
this.labelEmployee = new System.Windows.Forms.Label();
this.labelDate = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// comboBoxService
//
this.comboBoxService.FormattingEnabled = true;
this.comboBoxService.Location = new System.Drawing.Point(133, 11);
this.comboBoxService.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxService.Name = "comboBoxService";
this.comboBoxService.Size = new System.Drawing.Size(311, 23);
this.comboBoxService.TabIndex = 9;
//
// dateTimePicker
//
this.dateTimePicker.CustomFormat = "HH:mm";
this.dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker.Location = new System.Drawing.Point(133, 68);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.ShowUpDown = true;
this.dateTimePicker.Size = new System.Drawing.Size(311, 23);
this.dateTimePicker.TabIndex = 10;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(365, 96);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(80, 22);
this.buttonCancel.TabIndex = 13;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(279, 96);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(80, 22);
this.buttonSave.TabIndex = 12;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// comboBoxEmployee
//
this.comboBoxEmployee.FormattingEnabled = true;
this.comboBoxEmployee.Location = new System.Drawing.Point(133, 40);
this.comboBoxEmployee.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxEmployee.Name = "comboBoxEmployee";
this.comboBoxEmployee.Size = new System.Drawing.Size(311, 23);
this.comboBoxEmployee.TabIndex = 14;
//
// labelService
//
this.labelService.AutoSize = true;
this.labelService.Location = new System.Drawing.Point(12, 14);
this.labelService.Name = "labelService";
this.labelService.Size = new System.Drawing.Size(44, 15);
this.labelService.TabIndex = 15;
this.labelService.Text = "Услуга";
//
// labelEmployee
//
this.labelEmployee.AutoSize = true;
this.labelEmployee.Location = new System.Drawing.Point(12, 43);
this.labelEmployee.Name = "labelEmployee";
this.labelEmployee.Size = new System.Drawing.Size(59, 15);
this.labelEmployee.TabIndex = 16;
this.labelEmployee.Text = "Работник";
//
// labelDate
//
this.labelDate.AutoSize = true;
this.labelDate.Location = new System.Drawing.Point(12, 74);
this.labelDate.Name = "labelDate";
this.labelDate.Size = new System.Drawing.Size(82, 15);
this.labelDate.TabIndex = 17;
this.labelDate.Text = "Время услуги";
//
// FormOrderServices
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(456, 126);
this.Controls.Add(this.labelDate);
this.Controls.Add(this.labelEmployee);
this.Controls.Add(this.labelService);
this.Controls.Add(this.comboBoxEmployee);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.dateTimePicker);
this.Controls.Add(this.comboBoxService);
this.Name = "FormOrderServices";
this.Text = "Услуга заказа";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ComboBox comboBoxService;
private DateTimePicker dateTimePicker;
private Button buttonCancel;
private Button buttonSave;
private ComboBox comboBoxEmployee;
private Label labelService;
private Label labelEmployee;
private Label labelDate;
}
}

View File

@ -0,0 +1,99 @@
using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.ViewModels;
using BeautySaloonDataModels;
namespace BeautySaloonView
{
public partial class FormOrderServices : Form
{
private readonly List<ServiceViewModel>? _listS;
private readonly List<EmployeeViewModel>? _listE;
public int IdService
{
get
{
return Convert.ToInt32(comboBoxService.SelectedValue);
}
set
{
comboBoxService.SelectedValue = value;
}
}
public int IdEmployee
{
get
{
return Convert.ToInt32(comboBoxEmployee.SelectedValue);
}
set
{
comboBoxEmployee.SelectedValue = value;
}
}
public IServiceModel? ServiceModel
{
get
{
if (_listS == null)
{
return null;
}
foreach (var elem in _listS)
{
if (elem.Id == IdService)
{
return elem;
}
}
return null;
}
}
public TimeOnly Date
{
get { return TimeOnly.FromDateTime(dateTimePicker.Value); }
set { dateTimePicker.Text = value.ToString(); }
}
public FormOrderServices(IServiceLogic logicS, IEmployeeLogic logicE)
{
InitializeComponent();
_listS = logicS.ReadList(null);
_listE = logicE.ReadList(null);
if (_listS != null)
{
comboBoxService.DisplayMember = "Name";
comboBoxService.ValueMember = "Id";
comboBoxService.DataSource = _listS;
comboBoxService.SelectedItem = null;
}
if (_listE != null)
{
comboBoxEmployee.DisplayMember = "FIO";
comboBoxEmployee.ValueMember = "Id";
comboBoxEmployee.DataSource = _listE;
comboBoxEmployee.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (comboBoxService.SelectedValue == null)
{
MessageBox.Show("Выберите услугу", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxEmployee.SelectedValue == null)
{
MessageBox.Show("Выберите работника", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DialogResult = DialogResult.OK;
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,99 @@
namespace BeautySaloonView
{
partial class FormPosition
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelPosition = new System.Windows.Forms.Label();
this.textBox = new System.Windows.Forms.TextBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelPosition
//
this.labelPosition.AutoSize = true;
this.labelPosition.Location = new System.Drawing.Point(12, 9);
this.labelPosition.Name = "labelPosition";
this.labelPosition.Size = new System.Drawing.Size(123, 15);
this.labelPosition.TabIndex = 0;
this.labelPosition.Text = "Название должности";
//
// textBox
//
this.textBox.Location = new System.Drawing.Point(141, 6);
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(223, 23);
this.textBox.TabIndex = 1;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(282, 34);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 13;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(194, 34);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
this.buttonSave.TabIndex = 12;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// FormPosition
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(376, 60);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBox);
this.Controls.Add(this.labelPosition);
this.Name = "FormPosition";
this.Text = "Создание должности";
this.Load += new System.EventHandler(this.FormPosition_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelPosition;
private TextBox textBox;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,75 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.SearchModels;
using System.Windows.Forms;
namespace BeautySaloonView
{
public partial class FormPosition : Form
{
private readonly IPositionLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormPosition(IPositionLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormPosition_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new PositionSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBox.Text = view.Name;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox.Text))
{
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new PositionBindingModel
{
Id = _id ?? 0,
Name = textBox.Text
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,122 @@
namespace BeautySaloonView
{
partial class FormPositions
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.GridColor = System.Drawing.Color.White;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(426, 337);
this.dataGridView.TabIndex = 10;
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(435, 195);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(435, 169);
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(130, 22);
this.buttonDelete.TabIndex = 13;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(435, 143);
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(130, 22);
this.buttonEdit.TabIndex = 12;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(435, 117);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(130, 22);
this.buttonAdd.TabIndex = 11;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// FormPositions
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(577, 337);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd);
this.Name = "FormPositions";
this.Text = "Должности";
this.Load += new System.EventHandler(this.FormPositions_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonEdit;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,92 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
namespace BeautySaloonView
{
public partial class FormPositions : Form
{
private readonly IPositionLogic _logic;
public FormPositions(IPositionLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormPositions_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPosition));
if (service is FormPosition form)
{
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(FormPosition));
if (service is FormPosition form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new PositionBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,124 @@
namespace BeautySaloonView
{
partial class FormService
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelService = new System.Windows.Forms.Label();
this.textBox = new System.Windows.Forms.TextBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.labelPrice = new System.Windows.Forms.Label();
this.numericUpDown = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).BeginInit();
this.SuspendLayout();
//
// labelService
//
this.labelService.AutoSize = true;
this.labelService.Location = new System.Drawing.Point(12, 9);
this.labelService.Name = "labelService";
this.labelService.Size = new System.Drawing.Size(99, 15);
this.labelService.TabIndex = 0;
this.labelService.Text = "Название услуги";
//
// textBox
//
this.textBox.Location = new System.Drawing.Point(141, 6);
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(223, 23);
this.textBox.TabIndex = 1;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(282, 63);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 13;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(194, 63);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(82, 22);
this.buttonSave.TabIndex = 12;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// labelPrice
//
this.labelPrice.AutoSize = true;
this.labelPrice.Location = new System.Drawing.Point(12, 37);
this.labelPrice.Name = "labelPrice";
this.labelPrice.Size = new System.Drawing.Size(35, 15);
this.labelPrice.TabIndex = 14;
this.labelPrice.Text = "Цена";
//
// numericUpDown
//
this.numericUpDown.Location = new System.Drawing.Point(141, 35);
this.numericUpDown.Name = "numericUpDown";
this.numericUpDown.Size = new System.Drawing.Size(223, 23);
this.numericUpDown.TabIndex = 15;
this.numericUpDown.Maximum = 20000;
//
// FormService
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(376, 91);
this.Controls.Add(this.numericUpDown);
this.Controls.Add(this.labelPrice);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBox);
this.Controls.Add(this.labelService);
this.Name = "FormService";
this.Text = "Создание услуги";
this.Load += new System.EventHandler(this.FormService_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelService;
private TextBox textBox;
private Button buttonCancel;
private Button buttonSave;
private Label labelPrice;
private NumericUpDown numericUpDown;
}
}

View File

@ -0,0 +1,81 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.SearchModels;
namespace BeautySaloonView
{
public partial class FormService : Form
{
private readonly IServiceLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormService(IServiceLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormService_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new ServiceSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBox.Text = view.Name;
numericUpDown.Value = view.Price;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox.Text) || numericUpDown.Value <= 0)
{
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (numericUpDown.Value <= 0)
{
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new ServiceBindingModel
{
Id = _id ?? 0,
Name = textBox.Text,
Price = numericUpDown.Value,
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,122 @@
namespace BeautySaloonView
{
partial class FormServices
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.GridColor = System.Drawing.Color.White;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(426, 337);
this.dataGridView.TabIndex = 10;
//
// buttonUpdate
//
this.buttonUpdate.Location = new System.Drawing.Point(435, 195);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(130, 22);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Обновить";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDelete
//
this.buttonDelete.Location = new System.Drawing.Point(435, 169);
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(130, 22);
this.buttonDelete.TabIndex = 13;
this.buttonDelete.Text = "Удалить";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonEdit
//
this.buttonEdit.Location = new System.Drawing.Point(435, 143);
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(130, 22);
this.buttonEdit.TabIndex = 12;
this.buttonEdit.Text = "Изменить";
this.buttonEdit.UseVisualStyleBackColor = true;
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(435, 117);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(130, 22);
this.buttonAdd.TabIndex = 11;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// FormServices
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(577, 337);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonDelete);
this.Controls.Add(this.buttonEdit);
this.Controls.Add(this.buttonAdd);
this.Name = "FormServices";
this.Text = "Услуги";
this.Load += new System.EventHandler(this.FormServices_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonEdit;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,91 @@
using BeautySaloonContracts.BindingModels;
using BeautySaloonContracts.BusinessLogicsContracts;
namespace BeautySaloonView
{
public partial class FormServices : Form
{
private readonly IServiceLogic _logic;
public FormServices(IServiceLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormServices_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormService));
if (service is FormService form)
{
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(FormService));
if (service is FormService form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new ServiceBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,6 +1,7 @@
using BeautySaloonBusinessLogic; using BeautySaloonBusinessLogic;
using BeautySaloonContracts.BusinessLogicsContracts; using BeautySaloonContracts.BusinessLogicsContracts;
using BeautySaloonContracts.StoragesContracts; using BeautySaloonContracts.StoragesContracts;
using BeautySaloonDatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace BeautySaloonView namespace BeautySaloonView
@ -28,11 +29,11 @@ namespace BeautySaloonView
private static void ConfigureServices(ServiceCollection services) private static void ConfigureServices(ServiceCollection services)
{ {
/*services.AddTransient<IClientStorage, ClientStorage>(); services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IEmployeeStorage, IngredientStorage>(); services.AddTransient<IEmployeeStorage, EmployeeStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPositionStorage, SushiStorage>(); services.AddTransient<IPositionStorage, PositionStorage>();
services.AddTransient<IServiceStorage, SushiStorage>();*/ services.AddTransient<IServiceStorage, ServiceStorage>();
services.AddTransient<IClientLogic, ClientLogic>(); services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IEmployeeLogic, EmployeeLogic>(); services.AddTransient<IEmployeeLogic, EmployeeLogic>();
@ -40,7 +41,18 @@ namespace BeautySaloonView
services.AddTransient<IPositionLogic, PositionLogic>(); services.AddTransient<IPositionLogic, PositionLogic>();
services.AddTransient<IServiceLogic, ServiceLogic>(); services.AddTransient<IServiceLogic, ServiceLogic>();
services.AddTransient<FormClient>();
services.AddTransient<FormClientOrders>();
services.AddTransient<FormClients>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormEmployee>();
services.AddTransient<FormEmployees>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormOrderServices>();
services.AddTransient<FormPosition>();
services.AddTransient<FormPositions>();
services.AddTransient<FormService>();
services.AddTransient<FormServices>();
} }
} }
} }