private void logIn() { var users = getUsers(); var user = users.SingleOrDefault(x => x.login == ((LogIn)Application.Current.MainWindow).txtLogIn.Text && x.password == ((LogIn)Application.Current.MainWindow).txtPass.Password); if (user != null) { MessageBox.Show ("Логин: " + user.login + "\nИмя: " + user.Users.family.Trim() + " " + user.Users.name.Trim() + " " + user.Users.patronymic.Trim() + " " + "\nДолжность: " + user.Users.Role.name); AdministratorWindow adm = new AdministratorWindow(user.id_user, user.login, user.Users.family, user.Users.name, user.Users.patronymic); Application.Current.MainWindow.Close(); adm.Show(); } else { MessageBox.Show("Неверный логин или пароль."); } }
private async void button_Click(object sender, RoutedEventArgs e) { MainWindowHelper vm = MainWindowHelper.Instance; string okMessage = "\"ok\""; string url = baseUrl + "LogIn"; var logInContent = new JObject(); logInContent.Add("Email", emailField.Text); logInContent.Add("Password", passwordField.Password); HttpContent content = new StringContent(logInContent.ToString(), Encoding.UTF8, "application/json"); var responseBody = client.PostAsJsonAsync(url, logInContent).Result; string response = await responseBody.Content.ReadAsStringAsync(); if (okMessage.Equals(response)) { string uri = baseUrl + "Info"; var email = new JObject(); email.Add("email", emailField.Text); HttpContent content2 = new StringContent(email.ToString(), Encoding.UTF8, "application/json"); var response2 = client.PostAsync(uri, content2).Result; if (response2.IsSuccessStatusCode) { var responseJsonString = await response2.Content.ReadAsStringAsync(); var deserialized = JsonConvert.DeserializeObject <AdministratorCast>(responseJsonString); AdminUserHelper adminHelper = AdminUserHelper.Instance; adminHelper.admin = deserialized; AdministratorWindow administratorWindow = new AdministratorWindow(); administratorWindow.Show(); vm.CloseAction(); } else { MessageBox.Show(response2.ReasonPhrase); } } else { responseBox.Content = response; } }
private void buttonEntrance_Click(object sender, RoutedEventArgs e) { if (ModelCheck()) { try { Users users = LibraryDBEntities.Users.FirstOrDefault(p => p.Login == textBoxLogin.Text && p.Password == passwordBox.Password); if (users.IsBlocked == true) { MessageBox.Show("Дешевка заблокирована"); return; } switch (users.Role.ToLower()) { case "читатель": ReaderWindow reader = new ReaderWindow(users.Id); reader.Show(); this.Close(); break; case "библиотекарь": LibrarianWindow librarian = new LibrarianWindow(users.Id); librarian.Show(); this.Close(); break; case "администратор": AdministratorWindow administrator = new AdministratorWindow(); administrator.Show(); this.Close(); break; } } catch { MessageBox.Show("Пойманы за руку как дешевка"); } } }
private void SubmitButton_OnClick(object sender, RoutedEventArgs e) { var loginResult = SessionService.GetInstance().Authorizate(LoginBox.Text, PasswordBox.Password); switch (loginResult) { case 0: TextBox.Text = "Wrong username or password."; TextBox.Foreground = Brushes.Red; break; case 1: var administratorWindow = new AdministratorWindow(); administratorWindow.Show(); Close(); break; case 2: var employeeWindow = new EmployeeWindow(); employeeWindow.Show(); Close(); break; } }
public static void ShowAdministratorWindow() { var view = new AdministratorWindow(); view.ShowDialog(); }
private void Admin_Click(object sender, RoutedEventArgs e) { AdministratorWindow aw = new AdministratorWindow(this.Administrator); aw.Show(); }
/*-------------------------------------------------------------- TASTI MENU --------------------------------------------------------------*/ private void AdministratorButton_Click(object sender, RoutedEventArgs e) { AdministratorWindow.IsOpened(); }