using System.Windows;

namespace WpfApp1
{
    public partial class EditDriverWindow : Window
    {
        public int DriverId { get; set; }
        public string LastName { get; set; }
        public string FullName { get; set; }
        public string TabNumber { get; set; }

        public EditDriverWindow()
        {
            InitializeComponent();
        }

        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtLastName.Text) || string.IsNullOrWhiteSpace(txtTabNumber.Text))
            {
                MessageBox.Show("Заполните обязательные поля");
                return;
            }

            LastName = txtLastName.Text.Trim();
            FullName = txtFullName.Text.Trim();
            TabNumber = txtTabNumber.Text.Trim();

            this.DialogResult = true;
            this.Close();
        }

        private void BtnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }

        protected override void OnContentRendered(System.EventArgs e)
        {
            base.OnContentRendered(e);
            if (!string.IsNullOrEmpty(LastName))
            {
                txtLastName.Text = LastName;
                txtFullName.Text = FullName;
                txtTabNumber.Text = TabNumber;
            }
        }
    }
}