private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            PersonalWindow pw = new PersonalWindow(DialogName.EditData);

            pw.BuffUser.LastName     = userBuff.LastName;
            pw.BuffUser.FirstName    = userBuff.FirstName;
            pw.BuffUser.Login        = userBuff.Login;
            pw.BuffUser.Password     = userBuff.Password;
            pw.BuffUser.PositionName = userBuff.PositionName;

            if (pw.ShowDialog() == true)
            {
                User user = new User()
                {
                    FirstName = pw.BuffUser.FirstName,
                    LastName  = pw.BuffUser.LastName,
                    Login     = pw.BuffUser.Login,
                    Password  = pw.BuffUser.Password,
                    Position  = this.SetPosition(pw.BuffUser.PositionName)
                };

                efUser.Edit(user);
                this.UpdateBuffer(user);
                this.UpdateRecord();
                userBuff = null;
            }
            dgEmployee.SelectedItem = SelectUser;
        }
 public AuthorizationWindow()
 {
     InitializeComponent();
     btnCancel.Click  += Cancel;
     btnOk.Click      += Ok;
     tbLogin.KeyUp    += LogInKey;
     pbPassword.KeyUp += LogInKey;
     userBuff          = (UserBuffer)App.Current.Resources["userBuff"];
 }
 public PersonalWindow(DialogName name)
 {
     InitializeComponent();
     this.name  = name;
     this.Title = this.Caption;
     BuffUser   = (UserBuffer)App.Current.Resources["userBuff"];
     this.LoadComboBoxes();
     this.SetterWnd();
     btnCancel.Click += Cancel;
     btnOk.Click     += Ok;
 }
 private void UpdateBuffer(User user)
 {
     foreach (var item in efUser.GetUsers)
     {
         if (item.Login == user.Login)
         {
             userBuff = new UserBuffer()
             {
                 FirstName    = user.FirstName,
                 LastName     = user.LastName,
                 Login        = user.Login,
                 Password     = user.Password,
                 Position     = user.Position.Id,
                 PositionName = user.Position.Name
             };
             break;
         }
     }
 }
 private void LoadBuffer()
 {
     foreach (var item in efUser.GetUsers)
     {
         if (item.Login == SelectUser.Login)
         {
             userBuff = new UserBuffer()
             {
                 FirstName    = item.FirstName,
                 LastName     = item.LastName,
                 Login        = item.Login,
                 Password     = item.Password,
                 Position     = item.Position.Id,
                 PositionName = item.Position.Name
             };
             break;
         }
     }
 }