ProjectLib/ProjectLibrary/Forms/FOrders.cs

57 lines
1.6 KiB
C#

using System;
using System.Windows.Forms;
using ProjectLibrary.Entites;
namespace ProjectLibrary.Forms
{
public partial class FOrders : Form
{
private Orders _order;
private Book_Orders _bookOrder;
public FOrders(Orders order, Book_Orders bookOrder)
{
InitializeComponent();
_order = order;
_bookOrder = bookOrder;
LoadOrderData();
}
private void LoadOrderData()
{
txtOrderID.Text = _order.Id.ToString();
txtOrderDate.Text = _order.OrderDate.ToString();
txtReturnDate.Text = _order.ReturnDate.ToString();
txtReaderID.Text = _order.ReaderID.ToString();
txtBookID.Text = _bookOrder.BookID.ToString();
}
private void btnSave_Click(object sender, EventArgs e)
{
// Создание обновленных данных
var updatedOrder = Orders.CreateEntity(
int.Parse(txtOrderID.Text),
int.Parse(txtOrderDate.Text),
int.Parse(txtReturnDate.Text),
int.Parse(txtReaderID.Text)
);
var updatedBookOrder = Book_Orders.CreateEntity(
int.Parse(txtBookID.Text),
int.Parse(txtOrderID.Text)
);
// Обновление объектов
_order = updatedOrder;
_bookOrder = updatedBookOrder;
MessageBox.Show("Данные успешно сохранены!");
}
private void buttonCancel_Click_Click(object sender, EventArgs e)
{
}
}
}