private void Button_Click(object sender, RoutedEventArgs e) { if (surnametb.Text == "" || birthyeartb.Text == "") { return; } string surname = surnametb.Text; int year = Convert.ToInt32(birthyeartb.Text); authCheking authCheking = new authCheking(); resulttb.Text = authCheking.createPersonalNumber(surname, year); }
private void btnLabel_Click(object sender, RoutedEventArgs e) { authCheking authCheking = new authCheking(); if (authCheking.emptyornot(loginTb.Text, passwordTb.Text) != "") { MessageBox.Show((authCheking.emptyornot(loginTb.Text, passwordTb.Text)), "We have some problems", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } try { Tattoo_Studio_2Entities tattoo_Studio_2Entities = new Tattoo_Studio_2Entities(); using (var db = new Tattoo_Studio_2Entities()) { var user = db.User .AsNoTracking() .FirstOrDefault(u => u.Login == loginTb.Text && u.Password == passwordTb.Text); if (user == null) { MessageBox.Show("There's no users with this datas", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } userID = user.UserId; switch (user.Position) { case "Master": Master.MasterPage masterPage = new Master.MasterPage(); this.NavigationService.Navigate(masterPage); break; case "Admin": Admin.AdminPage adminPage = new Admin.AdminPage(); this.NavigationService.Navigate(adminPage); break; } } } catch { MessageBox.Show("Problems with authorisation", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } }