46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
|
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)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|