Мегадоделал

This commit is contained in:
Artyom_Yashin 2024-04-01 00:58:22 +04:00
parent f3dc40b9a5
commit 63cc7ab010
10 changed files with 154 additions and 105 deletions

View File

@ -55,7 +55,7 @@
labelName.AutoSize = true;
labelName.Location = new Point(16, 15);
labelName.Name = "labelName";
labelName.Size = new Size(77, 20);
labelName.Size = new Size(42, 20);
labelName.TabIndex = 2;
labelName.Text = "ФИО";
//
@ -64,7 +64,7 @@
labelPhone.AutoSize = true;
labelPhone.Location = new Point(16, 63);
labelPhone.Name = "labelPhone";
labelPhone.Size = new Size(45, 20);
labelPhone.Size = new Size(69, 20);
labelPhone.TabIndex = 3;
labelPhone.Text = "Телефон";
//
@ -88,7 +88,7 @@
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormComponent
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
@ -99,8 +99,8 @@
Controls.Add(labelName);
Controls.Add(textBoxPhone);
Controls.Add(textBoxName);
Name = "FormComponent";
Text = "Компонент";
Name = "FormClient";
Text = "Клиент";
Load += FormClient_Load;
ResumeLayout(false);
PerformLayout();

View File

@ -87,7 +87,7 @@
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRef_Click;
//
// FormComponents
// FormClients
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
@ -97,8 +97,8 @@
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormComponents";
Text = "Компоненты";
Name = "FormClients";
Text = "Клиенты";
Load += FormClients_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);

View File

@ -36,6 +36,8 @@
labelEmployee = new Label();
buttonSave = new Button();
buttonCancel = new Button();
textBoxDateTime = new TextBox();
label1 = new Label();
SuspendLayout();
//
// comboBoxService
@ -93,7 +95,7 @@
//
// buttonSave
//
buttonSave.Location = new Point(278, 157);
buttonSave.Location = new Point(278, 154);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(93, 26);
buttonSave.TabIndex = 6;
@ -103,7 +105,7 @@
//
// buttonCancel
//
buttonCancel.Location = new Point(386, 157);
buttonCancel.Location = new Point(386, 154);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(97, 26);
buttonCancel.TabIndex = 7;
@ -111,11 +113,29 @@
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += CancelButton_Click;
//
// textBoxDateTime
//
textBoxDateTime.Location = new Point(130, 121);
textBoxDateTime.Name = "textBoxDateTime";
textBoxDateTime.Size = new Size(353, 27);
textBoxDateTime.TabIndex = 9;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(21, 124);
label1.Name = "label1";
label1.Size = new Size(102, 20);
label1.TabIndex = 10;
label1.Text = "Дата и время";
//
// FormCreateAppointment
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(515, 202);
ClientSize = new Size(515, 192);
Controls.Add(label1);
Controls.Add(textBoxDateTime);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelService);
@ -125,7 +145,7 @@
Controls.Add(labelClient);
Controls.Add(comboBoxClient);
Name = "FormCreateAppointment";
Text = "Заказ";
Text = "Запись";
Load += AppointmentForm_Load;
ResumeLayout(false);
PerformLayout();
@ -141,5 +161,7 @@
private Label labelEmployee;
private Button buttonSave;
private Button buttonCancel;
private TextBox textBoxDateTime;
private Label label1;
}
}

View File

@ -1,5 +1,6 @@
using BarberShopContracts.BindingModels;
using BarberShopContracts.BusinessLogicContracts;
using BarberShopContracts.SearchModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -62,6 +63,30 @@ namespace BarberShop
comboBoxEmployee.DataSource = listE;
comboBoxEmployee.SelectedItem = null;
}
if (_id.HasValue)
{
try
{
var view = _logicA.ReadElement(new AppointmentSearchModel
{
Id = _id.Value
});
if (view != null)
{
comboBoxClient.Text = view.ClientName;
comboBoxEmployee.Text = view.EmployeeName;
comboBoxService.Text = view.ServiceName;
textBoxDateTime.Text = view.Time.ToString();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения записи");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
_logger.LogInformation("Компьютер загружен");
}
catch (Exception ex)
@ -82,13 +107,15 @@ namespace BarberShop
_logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicA.Create(new AppointmentBindingModel
var model = new AppointmentBindingModel
{
Id = _id ?? 0,
ServiceId = Convert.ToInt32(comboBoxService.SelectedValue),
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
EmployeeId = Convert.ToInt32(comboBoxEmployee.SelectedValue),
Time = DateTime.UtcNow
});
Time = Convert.ToDateTime(textBoxDateTime.Text)
};
var operationResult = _id.HasValue ? _logicA.Update(model) : _logicA.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");

View File

@ -87,7 +87,7 @@
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRef_Click;
//
// FormComponents
// FormEmployees
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
@ -97,8 +97,8 @@
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormComponents";
Text = "Компоненты";
Name = "FormEmployees";
Text = "Сотрудники";
Load += FormEmployees_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);

View File

@ -63,28 +63,28 @@
// компонентыToolStripMenuItem
//
компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
компонентыToolStripMenuItem.Size = new Size(184, 26);
компонентыToolStripMenuItem.Size = new Size(182, 26);
компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += ComponentsStripMenuItem_Click;
//
// услугиToolStripMenuItem
//
услугиToolStripMenuItem.Name = "услугиToolStripMenuItem";
услугиToolStripMenuItem.Size = new Size(184, 26);
услугиToolStripMenuItem.Size = new Size(182, 26);
услугиToolStripMenuItem.Text = "Услуги";
услугиToolStripMenuItem.Click += ServicesStripMenuItem_Click;
//
// клиентыToolStripMenuItem
//
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
клиентыToolStripMenuItem.Size = new Size(184, 26);
клиентыToolStripMenuItem.Size = new Size(182, 26);
клиентыToolStripMenuItem.Text = "Клиенты";
клиентыToolStripMenuItem.Click += ClientsStripMenuItem_Click;
//
// мастераToolStripMenuItem
//
мастераToolStripMenuItem.Name = астераToolStripMenuItem";
мастераToolStripMenuItem.Size = new Size(184, 26);
мастераToolStripMenuItem.Size = new Size(182, 26);
мастераToolStripMenuItem.Text = "Мастера";
мастераToolStripMenuItem.Click += EmployeesStripMenuItem_Click;
//
@ -104,7 +104,7 @@
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(187, 37);
buttonCreate.TabIndex = 2;
buttonCreate.Text = "Создать заказ";
buttonCreate.Text = "Создать запись";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += CreateAppointmentButton_Click;
//
@ -114,7 +114,7 @@
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(187, 37);
buttonUpdate.TabIndex = 3;
buttonUpdate.Text = "Отдать на выполнение";
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpd_Click;
//
@ -124,7 +124,7 @@
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(187, 37);
buttonDelete.TabIndex = 4;
buttonDelete.Text = "Заказ готов";
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
@ -151,7 +151,7 @@
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMain";
Text = "Магазин компьютеров";
Text = "Салон суеты";
Load += FormMain_Load;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();

View File

@ -97,10 +97,10 @@ namespace BarberShopBusinessLogic
{
return;
}
//if (model.Time < DateTime.Now)
//{
// throw new ArgumentNullException("Некорректная дата", nameof(model.Time));
//}
if (model.Time < DateTime.Now)
{
throw new ArgumentNullException("Некорректная дата", nameof(model.Time));
}
_logger.LogInformation("Time. Time:{Time}. Id: { Id}", model.Time, model.Id);
}
}