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 { /// /// Interaction logic for AddUser.xaml /// 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 + " добавлен!"); } } } }