ProjectLib/ProjectLibrary/Forms/FReader.cs

50 lines
1.5 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 System.Xml.Linq;
using ProjectLibrary.Entities;
namespace ProjectLibrary.Forms
{
public partial class FReader : Form
{
private Reader _reader;
public FReader(Reader reader)
{
InitializeComponent();
_reader = reader;
LoadReaderData();
}
private void LoadReaderData()
{
txtId.Text = _reader.Id.ToString();
txtName.Text = _reader.Name;
txtReaderTicket.Text = _reader.ReaderTicket.ToString();
txtRegistrationDate.Text = _reader.RegistrationDateRT.ToShortDateString();
}
private void btnSave_Click(object sender, EventArgs e)
{
// Создание новой сущности с обновленными данными
var updatedReader = Reader.CreateEntity(
int.Parse(txtId.Text),
txtName.Text,
int.Parse(txtReaderTicket.Text),
DateTime.Parse(txtRegistrationDate.Text)
);
// Обновление внутренней переменной
_reader = updatedReader;
MessageBox.Show("Данные успешно сохранены!");
}
private void buttonCancel_Click_Click(object sender, EventArgs e)
{
// Закрытие формы без сохранения
this.Close();
}
}
}