diff --git a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostsLogic.cs b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs similarity index 96% rename from BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostsLogic.cs rename to BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs index 2540070..b48eeb8 100644 --- a/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostsLogic.cs +++ b/BeautyStudio/BeautyStudioBusinessLogic/BusinessLogic/LaborCostLogic.cs @@ -12,11 +12,11 @@ using System.Threading.Tasks; namespace BeautyStudioBusinessLogic.BusinessLogics { - public class LaborCostsLogic : ILaborCostLogic + public class LaborCostLogic : ILaborCostLogic { private readonly ILogger _logger; private readonly ILaborCostStorage _laborCostsStorage; - public LaborCostsLogic(ILogger logger, ILaborCostStorage laborCostsStorage) + public LaborCostLogic(ILogger logger, ILaborCostStorage laborCostsStorage) { _logger = logger; _laborCostsStorage = laborCostsStorage; diff --git a/BeautyStudio/BeautyStudioContracts/StoragesContracts/ILaborCostsStorage.cs b/BeautyStudio/BeautyStudioContracts/StoragesContracts/ILaborCostStorage.cs similarity index 100% rename from BeautyStudio/BeautyStudioContracts/StoragesContracts/ILaborCostsStorage.cs rename to BeautyStudio/BeautyStudioContracts/StoragesContracts/ILaborCostStorage.cs diff --git a/BeautyStudio/BeautyStudioView/FormLogin.Designer.cs b/BeautyStudio/BeautyStudioView/FormLogin.Designer.cs new file mode 100644 index 0000000..2852d59 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormLogin.Designer.cs @@ -0,0 +1,119 @@ +namespace BeautyStudioView +{ + partial class FormLogin + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelPassword = new Label(); + labelLogin = new Label(); + textBoxPassword = new TextBox(); + textBoxLogin = new TextBox(); + buttonReg = new Button(); + buttonLogin = new Button(); + SuspendLayout(); + // + // labelPassword + // + labelPassword.AutoSize = true; + labelPassword.Location = new Point(23, 51); + labelPassword.Name = "labelPassword"; + labelPassword.Size = new Size(52, 15); + labelPassword.TabIndex = 22; + labelPassword.Text = "Пароль:"; + // + // labelLogin + // + labelLogin.AutoSize = true; + labelLogin.Location = new Point(23, 15); + labelLogin.Name = "labelLogin"; + labelLogin.Size = new Size(44, 15); + labelLogin.TabIndex = 20; + labelLogin.Text = "Логин:"; + // + // textBoxPassword + // + textBoxPassword.Location = new Point(98, 48); + textBoxPassword.Name = "textBoxPassword"; + textBoxPassword.PasswordChar = '*'; + textBoxPassword.Size = new Size(301, 23); + textBoxPassword.TabIndex = 19; + // + // textBoxLogin + // + textBoxLogin.Location = new Point(98, 12); + textBoxLogin.Name = "textBoxLogin"; + textBoxLogin.Size = new Size(301, 23); + textBoxLogin.TabIndex = 17; + // + // buttonReg + // + buttonReg.Location = new Point(12, 131); + buttonReg.Name = "buttonReg"; + buttonReg.Size = new Size(129, 23); + buttonReg.TabIndex = 15; + buttonReg.Text = "Регистрация"; + buttonReg.UseVisualStyleBackColor = true; + buttonReg.Click += RegButt_Click; + // + // buttonLogin + // + buttonLogin.Location = new Point(324, 131); + buttonLogin.Name = "buttonLogin"; + buttonLogin.Size = new Size(75, 23); + buttonLogin.TabIndex = 1; + buttonLogin.Text = "Логин"; + buttonLogin.UseVisualStyleBackColor = true; + buttonLogin.Click += ButtonLogin_Click; + // + // FormLogin + // + AcceptButton = buttonLogin; + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(413, 168); + Controls.Add(buttonLogin); + Controls.Add(labelPassword); + Controls.Add(labelLogin); + Controls.Add(textBoxPassword); + Controls.Add(textBoxLogin); + Controls.Add(buttonReg); + Name = "FormLogin"; + Text = "Логин"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelPassword; + private Label labelLogin; + private TextBox textBoxPassword; + private TextBox textBoxLogin; + private Button buttonReg; + private Button buttonLogin; + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormLogin.cs b/BeautyStudio/BeautyStudioView/FormLogin.cs new file mode 100644 index 0000000..f0565ba --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormLogin.cs @@ -0,0 +1,57 @@ +using BeautyStudioContracts.BusinessLogicContracts; +using BeautyStudioContracts.SearchModels; +using BeautyStudioContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormLogin : Form + { + private readonly IStoreKeeperLogic _storekeeperLogic; + + public StoreKeeperViewModel? LoggedInStoreKeeper { get; private set; } + + public FormLogin(IStoreKeeperLogic storekeeperLogic) + { + InitializeComponent(); + _storekeeperLogic = storekeeperLogic; + } + + private void ButtonLogin_Click(object sender, EventArgs e) + { + var storekeeper = _storekeeperLogic.ReadElement(new StoreKeeperSearchModel + { + StoreKeeperLogin = textBoxLogin.Text, + StoreKeeperPassword = textBoxPassword.Text + }); + + if (storekeeper != null) + { + LoggedInStoreKeeper = storekeeper; + DialogResult = DialogResult.OK; + Close(); + } + else + { + MessageBox.Show("Неверный логин или пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void RegButt_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormRegister)); + if (service is FormRegister form) + { + form.ShowDialog(); + } + } + } +} diff --git a/BeautyStudio/BeautyStudioView/FormLogin.resx b/BeautyStudio/BeautyStudioView/FormLogin.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormLogin.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormRegister.Designer.cs b/BeautyStudio/BeautyStudioView/FormRegister.Designer.cs new file mode 100644 index 0000000..0b550e7 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormRegister.Designer.cs @@ -0,0 +1,184 @@ +namespace BeautyStudioView +{ + partial class FormRegister + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonReg = new Button(); + buttonBack = new Button(); + textBoxLogin = new TextBox(); + textBoxEmail = new TextBox(); + textBoxPassword = new TextBox(); + labelLogin = new Label(); + labelEmail = new Label(); + labelPassword = new Label(); + labelPhone = new Label(); + textBoxPhone = new TextBox(); + labelFIO = new Label(); + textBoxFIO = new TextBox(); + SuspendLayout(); + // + // buttonReg + // + buttonReg.Location = new Point(119, 176); + buttonReg.Name = "buttonReg"; + buttonReg.Size = new Size(129, 23); + buttonReg.TabIndex = 7; + buttonReg.Text = "Зарегистрироваться"; + buttonReg.UseVisualStyleBackColor = true; + buttonReg.Click += ButtonRegister_Click; + // + // buttonBack + // + buttonBack.Location = new Point(254, 176); + buttonBack.Name = "buttonBack"; + buttonBack.Size = new Size(75, 23); + buttonBack.TabIndex = 8; + buttonBack.Text = "Назад"; + buttonBack.UseVisualStyleBackColor = true; + buttonBack.Click += LoginButt_Click; + // + // textBoxLogin + // + textBoxLogin.Location = new Point(94, 74); + textBoxLogin.Name = "textBoxLogin"; + textBoxLogin.Size = new Size(235, 23); + textBoxLogin.TabIndex = 9; + // + // textBoxEmail + // + textBoxEmail.Location = new Point(94, 103); + textBoxEmail.Name = "textBoxEmail"; + textBoxEmail.Size = new Size(235, 23); + textBoxEmail.TabIndex = 10; + // + // textBoxPassword + // + textBoxPassword.Location = new Point(94, 132); + textBoxPassword.Name = "textBoxPassword"; + textBoxPassword.Size = new Size(235, 23); + textBoxPassword.TabIndex = 11; + // + // labelLogin + // + labelLogin.AutoSize = true; + labelLogin.Location = new Point(19, 77); + labelLogin.Name = "labelLogin"; + labelLogin.Size = new Size(44, 15); + labelLogin.TabIndex = 12; + labelLogin.Text = "Логин:"; + // + // labelEmail + // + labelEmail.AutoSize = true; + labelEmail.Location = new Point(19, 106); + labelEmail.Name = "labelEmail"; + labelEmail.Size = new Size(44, 15); + labelEmail.TabIndex = 13; + labelEmail.Text = "Почта:"; + // + // labelPassword + // + labelPassword.AutoSize = true; + labelPassword.Location = new Point(19, 135); + labelPassword.Name = "labelPassword"; + labelPassword.Size = new Size(52, 15); + labelPassword.TabIndex = 14; + labelPassword.Text = "Пароль:"; + // + // labelPhone + // + labelPhone.AutoSize = true; + labelPhone.Location = new Point(19, 48); + labelPhone.Name = "labelPhone"; + labelPhone.Size = new Size(104, 15); + labelPhone.TabIndex = 16; + labelPhone.Text = "Номер телефона:"; + // + // textBoxPhone + // + textBoxPhone.Location = new Point(129, 45); + textBoxPhone.Name = "textBoxPhone"; + textBoxPhone.Size = new Size(200, 23); + textBoxPhone.TabIndex = 15; + // + // labelFIO + // + labelFIO.AutoSize = true; + labelFIO.Location = new Point(19, 19); + labelFIO.Name = "labelFIO"; + labelFIO.Size = new Size(37, 15); + labelFIO.TabIndex = 18; + labelFIO.Text = "ФИО:"; + // + // textBoxFIO + // + textBoxFIO.Location = new Point(94, 16); + textBoxFIO.Name = "textBoxFIO"; + textBoxFIO.Size = new Size(235, 23); + textBoxFIO.TabIndex = 17; + // + // FormRegister + // + AcceptButton = buttonReg; + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(352, 209); + Controls.Add(labelFIO); + Controls.Add(textBoxFIO); + Controls.Add(labelPhone); + Controls.Add(textBoxPhone); + Controls.Add(labelPassword); + Controls.Add(labelEmail); + Controls.Add(labelLogin); + Controls.Add(textBoxPassword); + Controls.Add(textBoxEmail); + Controls.Add(textBoxLogin); + Controls.Add(buttonBack); + Controls.Add(buttonReg); + Name = "FormRegister"; + Text = "Регистрация"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonReg; + private Button buttonBack; + private TextBox textBoxLogin; + private TextBox textBoxEmail; + private TextBox textBoxPassword; + private Label labelLogin; + private Label labelEmail; + private Label labelPassword; + private Label labelPhone; + private TextBox textBoxPhone; + private Label labelFIO; + private TextBox textBoxFIO; + } +} \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/FormRegister.cs b/BeautyStudio/BeautyStudioView/FormRegister.cs new file mode 100644 index 0000000..96fdc81 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormRegister.cs @@ -0,0 +1,68 @@ +using BeautyStudioContracts.BindingModels; +using BeautyStudioContracts.BusinessLogicContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BeautyStudioView +{ + public partial class FormRegister : Form + { + private readonly IStoreKeeperLogic _storekeeperLogic; + private readonly ILogger _logger; + + public FormRegister(IStoreKeeperLogic storekeeperLogic, ILogger logger) + { + InitializeComponent(); + _storekeeperLogic = storekeeperLogic; + _logger = logger; + } + + private void ButtonRegister_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxFIO.Text) || string.IsNullOrEmpty(textBoxPhone.Text) || string.IsNullOrEmpty(textBoxLogin.Text) || string.IsNullOrEmpty(textBoxPassword.Text) || string.IsNullOrEmpty(textBoxEmail.Text)) + { + MessageBox.Show("Заполните все поля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + var model = new StoreKeeperBindingModel + { + StoreKeeperFIO = textBoxFIO.Text, + StoreKeeperPhone = textBoxPhone.Text, + StoreKeeperLogin = textBoxLogin.Text, + StoreKeeperPassword = textBoxPassword.Text, + StoreKeeperEmail = textBoxEmail.Text + }; + + try + { + if (_storekeeperLogic.Create(model)) + { + MessageBox.Show("Регистрация прошла успешно", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); + Close(); + } + else + { + MessageBox.Show("Ошибка при регистрации", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка регистрации"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoginButt_Click(object sender, EventArgs e) + { + Close(); + } + } +} diff --git a/BeautyStudio/BeautyStudioView/FormRegister.resx b/BeautyStudio/BeautyStudioView/FormRegister.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/BeautyStudio/BeautyStudioView/FormRegister.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeautyStudio/BeautyStudioView/Program.cs b/BeautyStudio/BeautyStudioView/Program.cs index f3250ef..11a5aa6 100644 --- a/BeautyStudio/BeautyStudioView/Program.cs +++ b/BeautyStudio/BeautyStudioView/Program.cs @@ -35,21 +35,28 @@ namespace BeautyStudioView option.SetMinimumLevel(LogLevel.Information); option.AddNLog("nlog.config"); }); - //services.AddTransient(); - //services.AddTransient(); - //services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); - //services.AddTransient(); - //services.AddTransient(); - //services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); //services.AddTransient(); - //services.AddTransient(); ////services.AddTransient(); ////services.AddTransient(); ////services.AddTransient(); - //services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); //services.AddTransient(); //services.AddTransient(); //services.AddTransient();