2024-11-19 14:49:58 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using ProjectLibrary.Entites;
|
|
|
|
|
|
|
|
|
|
namespace ProjectLibrary.Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class FLibrary : Form
|
|
|
|
|
{
|
|
|
|
|
private Library _library;
|
|
|
|
|
|
|
|
|
|
public FLibrary(Library library)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_library = library;
|
|
|
|
|
LoadLibraryData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadLibraryData()
|
|
|
|
|
{
|
|
|
|
|
txtId.Text = _library.Id.ToString();
|
|
|
|
|
txtName.Text = _library.Name;
|
|
|
|
|
txtAddress.Text = _library.Address;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Создание новой сущности с обновленными данными
|
|
|
|
|
var updatedLibrary = Library.CreateEntity(
|
|
|
|
|
int.Parse(txtId.Text),
|
|
|
|
|
txtName.Text,
|
|
|
|
|
txtAddress.Text
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Обновление внутренней переменной
|
|
|
|
|
_library = updatedLibrary;
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("Данные успешно сохранены!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCancel_Click_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-11-19 15:04:19 +04:00
|
|
|
|
// Закрытие формы без сохранения
|
|
|
|
|
this.Close();
|
2024-11-19 14:49:58 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|