public async Task <bool> Login() { TaskCompletionSource <bool> loginTask = new TaskCompletionSource <bool>(); var loginWindow = new LoginWindow(); loginWindow.LoginFinished += (sender, login) => { if (login.IsError) { Properties.Settings.Default.AuthCode = ""; Properties.Settings.Default.Username = ""; Properties.Settings.Default.Save(); loginWindow.Close(); loginTask.SetResult(false); } else { Properties.Settings.Default.AuthCode = login.AccessToken; Properties.Settings.Default.Username = login.User.Identity.Name; Properties.Settings.Default.Save(); loginWindow.Close(); Username = login.User.Identity.Name; loginTask.SetResult(true); } }; loginWindow.ShowDialog(); return(await loginTask.Task); }
private void LoginWindow_FormCompleted(object sender, CustomEventArgs e) { BsonValue output; if (e.Document.TryGetValue("CloseApplication", out output)) { if (Boolean.Parse(output.AsString)) { _window.Close(); Close(); } } else { MainHandlers.WindowManager = new MainWindowManager(e.Document); _window.Close(); if ((bool)!studentRecordRadioButton.IsChecked) { studentRecordRadioButton.IsChecked = true; } else { studentRecordRadioButton_Checked(null, null); } } }
private void Login() { if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password)) { using (UnitOfWork uow = new UnitOfWork()) { var user = uow.GetRepository <UserModel>().GetAll().FirstOrDefault(x => x.Username.Equals(Username) && x.Password.Equals(Password)); if (user != null) { using (TodoMenuWindow todoMenuWindow = new TodoMenuWindow()) { LoginWindow.Close(); LoginWindow.Dispose(); todoMenuWindow.ShowDialog(); } } else { MessageBox.Show("This username has already taken. Select different one.", "Username has taken", System.Windows.MessageBoxButton.OK, MessageBoxImage.Information); } } } else { MessageBox.Show("Please fill in the required fields."); } }
/// <summary> /// Executes the add User command /// </summary> private void AddNewUserExecute(object obj) { string password = (obj as PasswordBox).Password; User.UserPassword = password; userData.AddUser(User); UserList = userData.GetAllUsers().ToList(); // Login LoggedInUser.CurrentUser = new tblUser { UserID = User.UserID, FirstName = User.FirstName, LastName = User.LastName, Email = User.Email, Gender = User.Gender, DateOfBirth = User.DateOfBirth, UserLocation = User.UserLocation, Username = User.Username, UserPassword = PasswordHasher.Hash(User.UserPassword) }; ViewRegistration = Visibility.Collapsed; UserWindow userWindow = new UserWindow(); view.Close(); userWindow.Show(); }
private void Valider() { //hash le mot de passe avec SHA512 pour le comparer à la bdd SHA512 shaM = new SHA512Managed(); byte[] passwordHashed = shaM.ComputeHash(stringToByte(Mot_De_Passe)); string passe = Encoding.UTF8.GetString(passwordHashed); //Verifier utilisateur MegaProductionBDDEntities MyDB = new MegaProductionBDDEntities(); if (MyDB.Employe.Any(x => x.Nom_Utilisateur == Nom_Utilisateur && x.Mot_De_Passe == passe)) { employeAConnecter = MyDB.Employe.First(x => x.Nom_Utilisateur == Nom_Utilisateur && x.Mot_De_Passe == passe); windowAssociee.Close(); } else { MessageBox.Show("Mauvaise combinaison utilisateur / mdp"); } }
public void LoginTask(LoginWindow window) { if (window == null) { return; } using (var userRepository = new UserRepository()) { var user = userRepository.GetUser(Login); if (user == null || !user.password.Equals(CypherPassword(Password))) { return; } switch (user.userInfo.UserType) { case "Admin": (new AdminWindow()).Show(); window.Close(); break; case "User": (new UserWindow()).Show(); window.Close(); break; } } }
public MainViewModel() { LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { //IsLoaded = true; if (p == null) { return; } // p.Hide(); LoginWindow loginWindow = new LoginWindow(); if (loginWindow.DataContext == null) { return; } var loginMV = loginWindow.DataContext as LoginViewModel; loginWindow.Close(); //if (loginMV.IsLogin == true) //{ //} }); }
private void Login() { _window.StatusText.Text = ""; string uname = _window.Username.Text; string pwd = _window.Password.Password; if (String.IsNullOrWhiteSpace(uname)) { ShowError("Please enter a username"); return; } if (String.IsNullOrWhiteSpace(pwd)) { ShowError("Please enter a password"); return; } try { User u = User.GetUser(uname, pwd); if (u == null) { ShowError("Wrong username/password."); return; } ShowSuccess("Login was successfull. Loading the Digital Voter List."); VoterListApp.RunApp(u); _window.Close(); } catch (Exception ex) { ShowError(ex.Message, 10); } }
private bool ShowLogin() { //Startup Login LoginWindow loginWindow = new LoginWindow(); DomainManager domainManager = new DomainManager(); ManufacturingContext context = new ManufacturingContext(this.optionsBuilder.Options); IUserSettingsService userSettingsService = new UserSettingsService(this._logger, context); IAuthenticationUseCase auth = new AuthenticationService(context, domainManager, this._logger, userSettingsService); var loginVM = new LoginViewModel(auth, userSettingsService); loginVM.LoginCompleted += (sender, args) => { if (loginVM.LoginResponce.Success) { this.userService = loginVM.LoginResponce.Service; DXSplashScreen.Show <SETSplashScreen>(); } loginWindow.Close(); }; loginWindow.DataContext = loginVM; if (DXSplashScreen.IsActive) { DXSplashScreen.Close(); } loginWindow.ShowDialog(); return(this.userService.IsValid()); }
private void Login(object parameter) { log.Debug("Login button"); PasswordBox pwBox = (PasswordBox)parameter; Password = pwBox.Password; if (!DatabaseConnection.TestConnection()) { NotificationProvider.Alert("Database connection error", "Please set the database connection, before login."); } else { try { UserLogin.Login(UserID, Password); NotificationProvider.Info(String.Format("Welcome, {0}!", UserID), "You have succesfully logged in."); LoginWindow.Close(); } catch (ArgumentException e) { NotificationProvider.Error("Login error", e.Message); } } }
public void OpenMainWindow() { MainWindow win = new MainWindow(); win.Show(); _loginPage.Close(); }
private bool ShowLogin() { //Startup Login LoginWindow loginWindow = new LoginWindow(); DomainManager domainManager = new DomainManager(); UserServiceProvider userServiceProvider = new UserServiceProvider(new InventoryContext(), domainManager); LogInService logInService = new LogInService(domainManager, userServiceProvider); var loginVM = new LoginViewModel(logInService); loginVM.LoginCompleted += (sender, args) => { if (loginVM.LoginResponce.Success) { this.userService = loginVM.LoginResponce.Service; DXSplashScreen.Show <SETSplashScreen>(); } loginWindow.Close(); }; loginWindow.DataContext = loginVM; if (DXSplashScreen.IsActive) { DXSplashScreen.Close(); } loginWindow.ShowDialog(); return(this.userService.IsValid()); }
public static void AfterLoginSuccessful() { LoginTicket = GetBrowserLoginTicket(); File.WriteAllText(LOGIN_TICKET_FILE, LoginTicket); LoginWindow.Close(); MainWindow.Visibility = Visibility.Visible; }
/// <summary> /// 登录淘宝 /// </summary> public void LoginTaoBao() { try { if (this.InvokeRequired) { this.Invoke(new Action(LoginTaoBao), new object[] { }); } else { loginSuccess = false; if (lw != null) { if (lw.browser != null) { lw.browser.Dispose(); } lw.Dispose(); lw.Close(); lw = null; } lw = new LoginWindow(); lw.LoadSuccessHandle += Lw_LoadSuccessHandle; lw.LoginSuccessHandle += Lw_LoginSuccessHandle; lw.CloseWindowHandle += Lw_CloseWindowHandle; lw.StartPosition = FormStartPosition.CenterScreen; lw.ShowDialog(this); } } catch (Exception ex) { log.Error(ex); } }
protected override void OnStartup(StartupEventArgs e) { Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); // now set the Green accent and dark theme ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("Red"), appStyle.Item1); // or appStyle.Item1 _synchronizationContext = DispatcherSynchronizationContext.Current; _bootstrapper.Initialize(); _loginWindow = _bootstrapper.IocManager.Resolve <LoginWindow>(); var isLogin = _loginWindow.ShowDialog(); if (isLogin.HasValue && isLogin.Value) { _mainWindow = _bootstrapper.IocManager.Resolve <MainWindow>(); _mainWindow.Show(); _loginWindow.Close(); } }
public MainWindow() { LoginWindow login = new LoginWindow(); login.ShowDialog(); if (login.DialogResult == true) { login.Close(); InitializeComponent(); this.DataContext = new MainViewModel(); } else { login.Close(); this.Close(); } }
private void ViewModel_LoginSuccess(object sender, EventArgs e) { _view = new MainWindow { DataContext = _mainViewModel }; _view.Loaded += _mainViewModel.OnLoaded; _view.Show(); _loginView.Close(); }
private void LoginSuccess(object sender, AuthorDTO author) { mainViewModel = new MainViewModel(persistence, author); mainViewModel.CreateArticle += MainViewModel_CreateArticle; mainViewModel.EditArticle += MainViewModel_EditArticle; mainViewModel.ExitApplication += ExitApplication; mainViewModel.MessageApplication += ViewModel_MessageApplication; mainWindow = new MainWindow(); mainWindow.DataContext = mainViewModel; mainWindow.Show(); loginWindow.Close(); }
private void LoginClick(object sender, RoutedEventArgs e) { User logged = _db.Get(textboxLogin.Text, textboxPassword.Password); if (logged != null) { _parent.LoggedUser = logged; _parent.Close(); } else { MessageBox.Show("Login and/or password is invalid"); } }
private void _Login() { string password = this.View.GetPassword(); if (string.IsNullOrWhiteSpace(this.FileName)) { MessageBox.Show("请先选择打开的文件", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (!File.Exists(this.FileName)) { MessageBox.Show("该文件在磁盘上不存在,请重新选择", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } GlobalVariables.DbFile = this.FileName; GlobalVariables.DbPassword = password; try { using (DbHelper db = new DbHelper()) { } if (this.AppConfig.IsRememberFile) { this.AppConfig.FileName = this.FileName; this.AppConfig.Save(); } else { this.AppConfig.FileName = ""; this.AppConfig.Save(); } MainWindow main = new MainWindow(); LoginWindow login = Application.Current.MainWindow as LoginWindow; Application.Current.MainWindow = main; login.Close(); main.Show(); } catch (Exception ex) { this.View.SetPasswordFocus(); if (ex.Message.StartsWith("File opened that is not a database file")) { MessageBox.Show("密码错误,请重新输入", "提示", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void ViewModel_LoginSuccess(object sender, EventArgs e) { _mainViewModel = new MainWindowViewModel(_service); _mainViewModel.MessageApplication += ViewModel_MessageApplication; _mainViewModel.NewItemOpen += ViewModel_OpenItem; _mainViewModel.LogoutEvent += App_Exit; _view = new MainWindow { DataContext = _mainViewModel }; _view.Show(); _loginView.Close(); }
public void ExecuteLoginCommand(object obj) { CurrentUser = serviceClient.LoginUser(mViewModel.Username, mViewModel.Password); if (CurrentUser != null) { mView.CurrentUser = CurrentUser; mView.DialogResult = true; mView.Close(); } else { mViewModel.Error = "Der Benutzername oder das eingegebene Passwort sind nicht korrekt!"; } }
public void ValidateCredentials(LoginWindow sender) { GebruikerVM tmp; if (dataServer.AuthenticateGebruiker(this.Naam, this.Wachtwoord, out tmp)) { this.StartupHome(); sender.Close(); } else { MessageBox.Show("Foutieve inloggegevens opgegeven!"); } }
public static void InitBase() { Configuracion.Carpetas = new Extenciones.Configuraciones.ConfiguracionDeCarpetas(Configuracion.NombreDelSistema, Extenciones.Configuraciones.ConfiguracionDeCarpetas.Configuracion.ProgramData); Application.Current.Resources["Version"] = Configuracion.Version.Codigo; Application.Current.Resources["Compilacion"] = Configuracion.Version.Compilacion; Application.Current.Resources["SistemaOperativo"] = Configuracion.Version.SistemaOperativo; Application.Current.Resources["Licencia"] = DateTime.Today.Month.ToMesMinuscula() + " " + DateTime.Today.Year; Application.Current.Resources["ProximoVencimiento"] = DateTime.Today.AddMonths(1).Month.ToMesMinuscula() + " " + DateTime.Today.AddMonths(1).Year; Application.Current.Resources["TituloDelSistema"] = Configuracion.NombreDelSistema; Application.Current.Resources["Empresa"] = Configuracion.Empresa; Configuracion.DebugMode = ConfiguracionDelSistema.DebugModes.File; if (!Misc.CheckMiMaquina()) { JarseConfig.Carpetas.ImagenesArticulos = @"F:\APLI\JARSE\FOTOS\"; } LibConfig.PrincipalAssembly = Assembly.GetExecutingAssembly(); LibConfig.Configuracion = App.Configuracion; LibConfig.Servers = Servers; LibConfig.LogController = LogController; LibConfig.MailController = App.MailController; LibConfig.ExceptionManager = ExceptionManager; //LibConfig.MessageController = App.MessageController; LibConfig.DefaultPrinter = App.DefaultPrinter; LoginWindow = new LoginWindow(); Timer.Start(); Timer.Tick += (s, e) => { App.InterfazPrincipal.Refresh(); }; LoginController.OnLogin += s => { App.Usuario = s; LibConfig.Usuario = s; Application.Current.Resources["Usuario"] = App.Usuario; LoginWindow.Close(); }; LoginController.OnLogout += () => { App.Usuario = null; LibConfig.Usuario = null; Application.Current.Resources["Usuario"] = null; LoginWindow = new LoginWindow(); LoginWindow.Show(); }; }
public void LoginButtonIsPressed(string SSN, string Password) { if (_validateLogin.CheckSSN(SSN)) { if (_loadDatabase.ValidateLogin(SSN, Password)) { //ALT HERFRA TIL _HOMEWINDOW TÆNKER VI ER GODT //Spørgsmålet er, hvorvidt det skal placeres her, eller i homewindow eller et andet sted, så det kommer //med videre rundt i forløbet i programmet. :) _patient = _loadDatabase.LoadPatientInfo(SSN); //foreach (var item in _patient.PackageList) //{ // _exercisePackage = _loadDatabase.LoadPackageInfo(item.ExercisePackageID); // _packageList.Add(_exercisePackage); //} //foreach (var item in _packageList) //{ // foreach (var exercise in item.ExerciseList) // { // _exercise = _loadDatabase.LoadExerciseInfo(exercise.ExerciseID); // _exerciseList.Add(_exercise); // } //} _homeWindow = new HomeWindow(_patient); _homeWindow.Show(); _loginWindow.Close(); } else { _loginWindow.LoginErrorMessage(); _loginWindow.cprTB.Clear(); _loginWindow.pwTB.Clear(); _loginWindow.cprTB.Focus(); } } else { _loginWindow.SSNErrorMessage(); _loginWindow.cprTB.Clear(); _loginWindow.pwTB.Clear(); _loginWindow.cprTB.Focus(); } }
private void ViewModel_LoginSuccess(object sender, EventArgs e) { _mainViewModel = new MainViewModel(_model); _mainViewModel.MessageApplication += new EventHandler <MessageEventArgs>(ViewModel_MessageApplication); //_mainViewModel.ExitApplication += new EventHandler(ViewModel_ExitApplication); _mainViewModel.Logout += new EventHandler(ViewModel_Logout); _mainViewModel.EditingStarted += new EventHandler(MainViewModel_EditingStarted); _mainViewModel.EditingFinished += new EventHandler(MainViewModel_EditingFinished); _mainView = new MainWindow(); _mainView.DataContext = _mainViewModel; _mainView.Show(); _loginView.Close(); }
private void ViewModel_LoginSuccess(object sender, EventArgs e) { _viewModel = new MainViewModel(_service); _viewModel.MessageApplication += new EventHandler <MessageEventArgs>(ViewModel_MessageApplication); _viewModel.ExitApplication += new EventHandler(ViewModel_ExitApplication); _viewModel.BookCreatingStarted += new EventHandler(MainViewModel_BookCreatingStarted); _viewModel.BookCreatingFinished += new EventHandler(MainViewModel_BookCreatingFinished); _viewModel.ImageEditingStarted += new EventHandler <BookEventArgs>(MainViewModel_ImageEditingStarted); _view = new MainWindow(); _view.DataContext = _viewModel; _view.Show(); _loginView.Close(); }
public static void Shutdown() { IsRunning = false; if (MainWindow != null) { MainWindow.Visible = false; } if (LoginWindow != null) { LoginWindow.Close(); } Network.NetworkManager.Shutdown(); Environment.Exit(0); }
private void BtnSubmit_Click() { SqlConnection Conn = new SqlConnection(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=LoginDB;Integrated Security=True"); try { if (Conn.State == ConnectionState.Closed) { Conn.Open(); string query = "SELECT COUNT(1) FROM LoginPasswordManager WHERE Email=@Email"; SqlCommand sqlcmd = new SqlCommand(query, Conn); sqlcmd.Parameters.AddWithValue("@Email", txtUsername); // sqlcmd.Parameters.AddWithValue("@Password",txtPassword); int count = Convert.ToInt32(sqlcmd.ExecuteScalar()); if (count == 1) { if (PasswordHash.ValidatePassword(txtPassword, getstoredhash()) == true) { MainWindow dashboard = new MainWindow(); dashboard.Show(); LoginWindow dash = new LoginWindow(); dash.Close(); } else { MessageBox.Show("Incorrect password"); } } else { MessageBox.Show("Username or Password is incorrect"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Conn.Close(); } }
private void Button_Click(object sender, RoutedEventArgs e) { string name = ""; string pass = ""; string region = ""; name = UserName.Text; pass = PassWord.Password; region = WareHouse.SelectedIndex.ToString(); DataSet ds = new DataSet(); string sql = ""; sql = "select * from T_Staff as t " + "where t.name_staff = '" + name + "' and t.pass_staff = '" + pass + "'"; ds = DBClass.execQuery(sql); if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("用户名或密码有误,请检查!"); } else { sql = "select t.Region_staff from T_Staff as t " + "where t.name_staff = '" + name + "' and t.pass_staff = '" + pass + "'"; ds = DBClass.execQuery(sql); if (region == "0") { MessageBox.Show("请选择要操作的仓库!"); } else if (ds.Tables[0].Rows[0][0].ToString() == region) { Application.Current.Properties["name"] = name; Application.Current.Properties["region"] = region; MainWindow mw = new MainWindow(); mw.Show(); mw.WindowState = WindowState.Maximized; LoginWindow lw = System.Windows.Window.GetWindow(this) as LoginWindow; lw.Close(); } else { MessageBox.Show("请选择正确的仓库!"); } } }
public void openMainWindowAndCloseLoginWindow(LoginWindow loginWindow) { MainWindow mainWindow = new MainWindow(); loginWindow.Close(); mainWindow.Show(); }