ProjectLib/ProjectLibrary/Forms/FLibrary.cs

46 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
{
}
}
}