12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace olimp8
- {
- /// <summary>
- /// Interaction logic for AddUser.xaml
- /// </summary>
- public partial class AddUser : Window
- {
- olimp_8Entities entity = new olimp_8Entities();
- public AddUser()
- {
- InitializeComponent();
- RoleBox.ItemsSource = entity.Role.ToList();
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- if (string.IsNullOrWhiteSpace(LoginBox.Text) || string.IsNullOrWhiteSpace(PassBox.Text) || string.IsNullOrWhiteSpace(NameBox.Text) || string.IsNullOrWhiteSpace(SurnameBox.Text) || string.IsNullOrWhiteSpace(PatrBox.Text) || string.IsNullOrWhiteSpace(RoleBox.Text))
- {
- MessageBox.Show("Заполнены не все поля");
- return;
- }
- else
- {
- User user = new User
- {
- Login = LoginBox.Text,
- Password = PassBox.Text,
- Name = NameBox.Text,
- Surname = SurnameBox.Text,
- Patronymic = PatrBox.Text,
- RoleID = Convert.ToInt32(RoleBox.SelectedValue),
- UserStatusID = 1
- };
- entity.User.Add(user);
- entity.SaveChanges();
- MessageBox.Show("Пользователь " + NameBox.Text + " " + SurnameBox.Text + " добавлен!");
- }
- }
- }
- }
|