|
@@ -20,18 +20,47 @@ namespace ProjectAnalogParus
|
|
|
/// </summary>
|
|
|
public partial class InfoUserPage : Page
|
|
|
{
|
|
|
- public int? UserID { get; set; }
|
|
|
+ gr672_bdaEntities db = new gr672_bdaEntities();
|
|
|
+ public int? IdUser { get; set; }
|
|
|
public InfoUserPage(int? UserID)
|
|
|
{
|
|
|
- gr672_bdaEntities db = new gr672_bdaEntities();
|
|
|
+
|
|
|
InitializeComponent();
|
|
|
+ IdUser = UserID;
|
|
|
+ cmbRole.ItemsSource = db.Role.ToList();
|
|
|
+ cmbRole.DisplayMemberPath = "NameRole";
|
|
|
+ cmbRole.SelectedValuePath = "IdRole";
|
|
|
|
|
|
User us = db.User.SingleOrDefault(item => item.IdUser == UserID);
|
|
|
txtName.Text = us.NameUser;
|
|
|
txtFullName.Text = us.FullNameUser;
|
|
|
txtPassword.Text = us.Password;
|
|
|
- txtRole.Text = us.Role.NameRole;
|
|
|
-
|
|
|
+ cmbRole.SelectedValue = $"{us.RoleId}";
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void EditUser_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (txtFullName.Text == string.Empty || txtName.Text == string.Empty || txtPassword.Text == string.Empty || cmbRole.Text == string.Empty)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Ключевые поля не заполнены");
|
|
|
+ }
|
|
|
+ else if (txtFullName.Text.All(char.IsLetter) == false || txtName.Text.All(char.IsLetter) == false || txtPassword.Text.All(char.IsLetter) == false)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Некорректные данные");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ User us = db.User.SingleOrDefault(item => item.IdUser == IdUser);
|
|
|
+ us.NameUser = txtName.Text;
|
|
|
+ us.FullNameUser = txtFullName.Text;
|
|
|
+ us.Password = txtPassword.Text;
|
|
|
+ us.RoleId = Convert.ToInt32((cmbRole.SelectedItem as Role).IdRole);
|
|
|
+ db.SaveChanges();
|
|
|
+ MessageBox.Show("Данные отредактированы!");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|