private void btn_showaddwindow_Click(object sender, RoutedEventArgs e) { tb_login.Text = ""; tb_pass.Text = ""; tb_name.Text = ""; ContentAddUser.ShowAsync(); }
private void btn_add_add_Click(object sender, RoutedEventArgs e) { ContentAddUser.Hide(); if (tb_login.Text != "") { try { using RegistrantCoreContext ef = new RegistrantCoreContext(); User user = new User { Name = tb_name.Text, Login = tb_login.Text, Password = tb_pass.Text }; user.LevelAccess = cb_access.SelectedIndex switch { 0 => "kpp", 1 => "reader", 2 => "warehouse", 3 => "shipment", 4 => "admin", _ => user.LevelAccess }; ef.Add(user); ef.SaveChanges(); LoadUser(); } catch (Exception ex) { ((MainWindow)Application.Current.MainWindow).ContentErrorText.ShowAsync(); ((MainWindow)Application.Current.MainWindow).text_debuger.Text = ex.ToString(); } ContentSave.ShowAsync(); } }
private void btn_add_add_Click(object sender, RoutedEventArgs e) { ContentAddUser.Hide(); if (tb_login.Text != "") { try { using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext()) { DB.User user = new DB.User(); user.Name = tb_name.Text; user.Login = tb_login.Text; user.Password = tb_pass.Text; if (cb_access.SelectedIndex == 0) { user.LevelAccess = "kpp"; } else if (cb_access.SelectedIndex == 1) { user.LevelAccess = "reader"; } else if (cb_access.SelectedIndex == 2) { user.LevelAccess = "warehouse"; } else if (cb_access.SelectedIndex == 3) { user.LevelAccess = "shipment"; } else if (cb_access.SelectedIndex == 4) { user.LevelAccess = "admin"; } ef.Add(user); ef.SaveChanges(); LoadUser(); } } catch (Exception ex) { ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync(); ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString(); } ContentSave.ShowAsync(); } }
private void btn_add_close_Click(object sender, RoutedEventArgs e) { ContentAddUser.Hide(); }