Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection <LoginTable> db = new ObservableCollection <LoginTable>();
            ReadAllLoginItem dbLogin             = new ReadAllLoginItem();
            //db = dbLogin.GetAllLoginItems();//Get all DB Login

            string user = txtUsername.Text.Trim();
            string pass = passwordBx.Password.Trim();

            LoginTable loginObj = new LoginTable();

            loginObj = dbLogin.GetExistUserLogin(user, pass);

            bool isLoginSuccess = this.validateLoginUser(user, pass);

            if (isLoginSuccess)
            {
                NavigationService.Navigate(new Uri("/Views/ReadContactList.xaml", UriKind.Relative));
            }

            /*if (loginObj != null)
             * {
             *  NavigationService.Navigate(new Uri("/Views/ReadContactList.xaml", UriKind.Relative));
             * }
             * else
             * {
             *  MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu");
             * }*/
        }
Ejemplo n.º 2
0
        private bool validateLoginUser(string user, string pass)
        {
            ReadAllLoginItem dbLogin  = new ReadAllLoginItem();
            LoginTable       loginObj = new LoginTable();

            if (user == "" || pass == "")
            {
                MessageBox.Show("Bạn chưa nhập tên đăng nhập hoặc mật khẩu");
                return(false);
            }

            loginObj = dbLogin.GetExistUserLogin(user, pass);

            if (loginObj == null)
            {
                MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu, vui lòng thử lại!");
                return(false);
            }
            else
            {
                return(true);
            }
        }