private void Logout(Window obj)
        {
            StateLogin.AccountLogin = null;
            StateLogin.WrireJson();
            LoginWindow view = new LoginWindow();

            obj.Hide();
            view.Show();
            obj.Close();
        }
Example #2
0
        private async void SignIn(Window obj)
        {
            try
            {
                var result = await acc_repo.GetFilterAsync(t => t.NameLogin.Equals(Namelogin) && t.PassWord.Equals(Password));

                if (result.Count() < 1)
                {
                    dc.Content = "Sai Tài Khoản Hoặc Mật Khẩu";
                    dc.Tilte   = "Thông Báo";
                    dialog     = new DialogOk()
                    {
                        DataContext = dc
                    };
                    DialogHost.CloseDialogCommand.Execute(null, null);
                    await DialogHost.Show(dialog, DialogHostId);
                }
                else
                {
                    if (IsRememberLogin)
                    {
                        StateLogin.AccountLogin.NameLogin = Namelogin;
                        StateLogin.AccountLogin.Password  = Password;
                        StateLogin.AccountLogin.Id        = result.First().Employee.EmpID;
                        StateLogin.AccountLogin.Username  = result.First().Employee.Name;
                        StateLogin.AccountLogin.Image     = result.First().Avatar;
                        StateLogin.WrireJson();
                    }

                    dc.Content = "Đăng Nhập Thành Công";
                    dc.Tilte   = "Thông Báo";
                    dialog     = new DialogOk()
                    {
                        DataContext = dc
                    };
                    DialogHost.CloseDialogCommand.Execute(null, null);
                    await DialogHost.Show(dialog, DialogHostId);

                    obj.Hide();
                    var view = new MainWindow();
                    view.Show();
                    obj.Close();
                }
            }
            catch (Exception ex)
            {
                //Raiserror();
                MessageBox.Show(ex.ToString());
            }
        }
Example #3
0
 private void Chip_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Bạn Muốn Đăng Xuất ?",
                         "Thông Báo",
                         MessageBoxButton.YesNo,
                         MessageBoxImage.Warning)
         == MessageBoxResult.Yes)
     {
         StateLogin.AccountLogin = null;
         StateLogin.WrireJson();
         LoginWindow view = new LoginWindow();
         this.Hide();
         view.Show();
         this.Close();
     }
 }