Compare commits

..

2 Commits

Author SHA1 Message Date
Алина
bb8fb6782a готовая 6 лаба 2024-04-16 23:12:15 +04:00
Алина
dca942c65d formclienteorder сделал своё дело 2024-04-16 23:10:53 +04:00
7 changed files with 391 additions and 235 deletions

View File

@ -12,7 +12,7 @@ using TypographyDatabaseImplement;
namespace TypographyDatabaseImplement.Migrations
{
[DbContext(typeof(TypographyDatabase))]
[Migration("20240416091109_InitialCreate")]
[Migration("20240416174343_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
@ -70,6 +70,33 @@ namespace TypographyDatabaseImplement.Migrations
b.ToTable("Components");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
@ -90,6 +117,9 @@ namespace TypographyDatabaseImplement.Migrations
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PrintedId")
.HasColumnType("int");
@ -103,6 +133,8 @@ namespace TypographyDatabaseImplement.Migrations
b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("PrintedId");
b.ToTable("Orders");
@ -162,6 +194,10 @@ namespace TypographyDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TypographyDatabaseImplement.Models.Implementer", "Implementer")
.WithMany("ImplementerOrders")
.HasForeignKey("ImplementerId");
b.HasOne("TypographyDatabaseImplement.Models.Printed", "Printed")
.WithMany("Orders")
.HasForeignKey("PrintedId")
@ -170,6 +206,8 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Printed");
});
@ -202,6 +240,11 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("PrintedComponents");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
{
b.Navigation("ImplementerOrders");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Printed", b =>
{
b.Navigation("Components");

View File

@ -40,6 +40,22 @@ namespace TypographyDatabaseImplement.Migrations
table.PrimaryKey("PK_Components", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Implementers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
WorkExperience = table.Column<int>(type: "int", nullable: false),
Qualification = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Implementers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Printeds",
columns: table => new
@ -61,6 +77,7 @@ namespace TypographyDatabaseImplement.Migrations
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientId = table.Column<int>(type: "int", nullable: false),
ImplementerId = table.Column<int>(type: "int", nullable: true),
PrintedId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
@ -77,6 +94,11 @@ namespace TypographyDatabaseImplement.Migrations
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Implementers_ImplementerId",
column: x => x.ImplementerId,
principalTable: "Implementers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Orders_Printeds_PrintedId",
column: x => x.PrintedId,
@ -117,6 +139,11 @@ namespace TypographyDatabaseImplement.Migrations
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ImplementerId",
table: "Orders",
column: "ImplementerId");
migrationBuilder.CreateIndex(
name: "IX_Orders_PrintedId",
table: "Orders",
@ -145,6 +172,9 @@ namespace TypographyDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Implementers");
migrationBuilder.DropTable(
name: "Components");

View File

@ -67,6 +67,33 @@ namespace TypographyDatabaseImplement.Migrations
b.ToTable("Components");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
@ -87,6 +114,9 @@ namespace TypographyDatabaseImplement.Migrations
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PrintedId")
.HasColumnType("int");
@ -100,6 +130,8 @@ namespace TypographyDatabaseImplement.Migrations
b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("PrintedId");
b.ToTable("Orders");
@ -159,6 +191,10 @@ namespace TypographyDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TypographyDatabaseImplement.Models.Implementer", "Implementer")
.WithMany("ImplementerOrders")
.HasForeignKey("ImplementerId");
b.HasOne("TypographyDatabaseImplement.Models.Printed", "Printed")
.WithMany("Orders")
.HasForeignKey("PrintedId")
@ -167,6 +203,8 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Printed");
});
@ -199,6 +237,11 @@ namespace TypographyDatabaseImplement.Migrations
b.Navigation("PrintedComponents");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Implementer", b =>
{
b.Navigation("ImplementerOrders");
});
modelBuilder.Entity("TypographyDatabaseImplement.Models.Printed", b =>
{
b.Navigation("Components");

View File

@ -7,6 +7,7 @@ using TypographyListImplement.Models;
namespace TypographyListImplement
{
public class DataListSingleton
{
private static DataListSingleton? _instance;

View File

@ -44,4 +44,3 @@ app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -1,146 +1,168 @@
namespace TypographyView
{
partial class FormCreateOrder
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
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);
}
/// <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
#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.labelPrinted = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.labelSum = new System.Windows.Forms.Label();
this.comboBoxPrinted = new System.Windows.Forms.ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.textBoxSum = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelPrinted
//
this.labelPrinted.AutoSize = true;
this.labelPrinted.Location = new System.Drawing.Point(12, 15);
this.labelPrinted.Name = "labelPrinted";
this.labelPrinted.Size = new System.Drawing.Size(154, 20);
this.labelPrinted.TabIndex = 0;
this.labelPrinted.Text = "Печатная продукция";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(12, 49);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(90, 20);
this.labelCount.TabIndex = 1;
this.labelCount.Text = "Количество";
//
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(12, 82);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(55, 20);
this.labelSum.TabIndex = 2;
this.labelSum.Text = "Сумма";
//
// comboBoxPrinted
//
this.comboBoxPrinted.FormattingEnabled = true;
this.comboBoxPrinted.Location = new System.Drawing.Point(172, 12);
this.comboBoxPrinted.Name = "comboBoxPrinted";
this.comboBoxPrinted.Size = new System.Drawing.Size(240, 28);
this.comboBoxPrinted.TabIndex = 3;
this.comboBoxPrinted.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPrinted_SelectedIndexChanged);
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(172, 46);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(240, 27);
this.textBoxCount.TabIndex = 4;
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(172, 79);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.ReadOnly = true;
this.textBoxSum.Size = new System.Drawing.Size(240, 27);
this.textBoxSum.TabIndex = 5;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(202, 112);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(102, 29);
this.buttonSave.TabIndex = 6;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(310, 112);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(102, 29);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(427, 153);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxSum);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.comboBoxPrinted);
this.Controls.Add(this.labelSum);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.labelPrinted);
this.Name = "FormCreateOrder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Заказ";
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
this.ResumeLayout(false);
this.PerformLayout();
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
labelPrinted = new Label();
labelCount = new Label();
labelSum = new Label();
comboBoxPrinted = new ComboBox();
textBoxCount = new TextBox();
textBoxSum = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
labelClient = new Label();
comboBoxClient = new ComboBox();
SuspendLayout();
//
// labelPrinted
//
labelPrinted.AutoSize = true;
labelPrinted.Location = new Point(15, 50);
labelPrinted.Name = "labelPrinted";
labelPrinted.Size = new Size(154, 20);
labelPrinted.TabIndex = 0;
labelPrinted.Text = "Печатная продукция";
//
// labelCount
//
labelCount.AutoSize = true;
labelCount.Location = new Point(15, 84);
labelCount.Name = "labelCount";
labelCount.Size = new Size(90, 20);
labelCount.TabIndex = 1;
labelCount.Text = "Количество";
//
// labelSum
//
labelSum.AutoSize = true;
labelSum.Location = new Point(15, 117);
labelSum.Name = "labelSum";
labelSum.Size = new Size(55, 20);
labelSum.TabIndex = 2;
labelSum.Text = "Сумма";
//
// comboBoxPrinted
//
comboBoxPrinted.FormattingEnabled = true;
comboBoxPrinted.Location = new Point(175, 47);
comboBoxPrinted.Name = "comboBoxPrinted";
comboBoxPrinted.Size = new Size(240, 28);
comboBoxPrinted.TabIndex = 3;
comboBoxPrinted.SelectedIndexChanged += ComboBoxPrinted_SelectedIndexChanged;
//
// textBoxCount
//
textBoxCount.Location = new Point(175, 81);
textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(240, 27);
textBoxCount.TabIndex = 4;
textBoxCount.TextChanged += TextBoxCount_TextChanged;
//
// textBoxSum
//
textBoxSum.Location = new Point(175, 114);
textBoxSum.Name = "textBoxSum";
textBoxSum.ReadOnly = true;
textBoxSum.Size = new Size(240, 27);
textBoxSum.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(205, 147);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(102, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(313, 147);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(102, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(15, 15);
labelClient.Name = "labelClient";
labelClient.Size = new Size(58, 20);
labelClient.TabIndex = 8;
labelClient.Text = "Клиент";
//
// comboBoxClient
//
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(175, 12);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(240, 28);
comboBoxClient.TabIndex = 9;
//
// FormCreateOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(427, 183);
Controls.Add(comboBoxClient);
Controls.Add(labelClient);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxSum);
Controls.Add(textBoxCount);
Controls.Add(comboBoxPrinted);
Controls.Add(labelSum);
Controls.Add(labelCount);
Controls.Add(labelPrinted);
Name = "FormCreateOrder";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказ";
Load += FormCreateOrder_Load;
ResumeLayout(false);
PerformLayout();
}
}
#endregion
#endregion
private Label labelPrinted;
private Label labelCount;
private Label labelSum;
private ComboBox comboBoxPrinted;
private TextBox textBoxCount;
private TextBox textBoxSum;
private Button buttonSave;
private Button buttonCancel;
}
private Label labelPrinted;
private Label labelCount;
private Label labelSum;
private ComboBox comboBoxPrinted;
private TextBox textBoxCount;
private TextBox textBoxSum;
private Button buttonSave;
private Button buttonCancel;
private Label labelClient;
private ComboBox comboBoxClient;
}
}

View File

@ -5,106 +5,124 @@ using Microsoft.Extensions.Logging;
namespace TypographyView
{
public partial class FormCreateOrder : Form
{
private readonly ILogger _logger;
private readonly IPrintedLogic _logicP;
private readonly IOrderLogic _logicO;
public partial class FormCreateOrder : Form
{
private readonly ILogger _logger;
private readonly IClientLogic _logicC;
private readonly IPrintedLogic _logicP;
private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IPrintedLogic logicP, IOrderLogic logicO)
{
InitializeComponent();
_logger = logger;
_logicP = logicP;
_logicO = logicO;
}
public FormCreateOrder(ILogger<FormCreateOrder> logger, IClientLogic logicC, IPrintedLogic logicP, IOrderLogic logicO)
{
InitializeComponent();
_logicC = logicC;
_logger = logger;
_logicP = logicP;
_logicO = logicO;
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка изделий для заказа");
var _list = _logicP.ReadList(null);
if (_list != null)
{
comboBoxPrinted.DisplayMember = "PrintedName";
comboBoxPrinted.ValueMember = "Id";
comboBoxPrinted.DataSource = _list;
comboBoxPrinted.SelectedItem = null;
}
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка клиентов для заказа");
var _listC = _logicC.ReadList(null);
if (_listC != null)
{
comboBoxClient.DisplayMember = "ClientFIO";
comboBoxClient.ValueMember = "Id";
comboBoxClient.DataSource = _listC;
comboBoxClient.SelectedItem = null;
}
private void CalcSum()
{
if (comboBoxPrinted.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
{
try
{
int id = Convert.ToInt32(comboBoxPrinted.SelectedValue);
var product = _logicP.ReadElement(new PrintedSearchModel
{
Id = id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка расчета суммы заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
_logger.LogInformation("Загрузка изделий для заказа");
var _list = _logicP.ReadList(null);
if (_list != null)
{
comboBoxPrinted.DisplayMember = "PrintedName";
comboBoxPrinted.ValueMember = "Id";
comboBoxPrinted.DataSource = _list;
comboBoxPrinted.SelectedItem = null;
}
}
private void ComboBoxPrinted_SelectedIndexChanged(object sender, EventArgs e)
{
CalcSum();
}
private void CalcSum()
{
if (comboBoxPrinted.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
{
try
{
int id = Convert.ToInt32(comboBoxPrinted.SelectedValue);
var product = _logicP.ReadElement(new PrintedSearchModel
{
Id = id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка расчета суммы заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void TextBoxCount_TextChanged(object sender, EventArgs e)
{
CalcSum();
}
private void ComboBoxPrinted_SelectedIndexChanged(object sender, EventArgs e)
{
CalcSum();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxPrinted.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
PrintedId = Convert.ToInt32(comboBoxPrinted.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
});
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TextBoxCount_TextChanged(object sender, EventArgs e)
{
CalcSum();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxClient.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxPrinted.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
PrintedId = Convert.ToInt32(comboBoxPrinted.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
});
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}