コード例 #1
0
        private void loginHandler_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txt_username.Text) || string.IsNullOrWhiteSpace(this.txt_password.Password.ToString()))
            {
                if (string.IsNullOrWhiteSpace(this.txt_username.Text))
                {
                    txt_username.Background = Brushes.Red;
                }
                if (string.IsNullOrWhiteSpace(this.txt_password.Password.ToString()))
                {
                    txt_password.Background = Brushes.Red;
                }
                MessageBox.Show("Validate");

                return;
            }
            loginBLL aBLL = new loginBLL();
            loginBO  lBO  = new loginBO();

            lBO.Username = this.txt_username.Text;
            lBO.Password = this.txt_password.Password.ToString();
            int rv;

            rv = aBLL.login(lBO);

            if (rv == 1)
            {
                //MessageBox.Show("Loged in");
                //this.Show(adminPanel.x);
                adminPanel a = new adminPanel();
                this.Hide();
                a.Show();
            }
            else if (rv == 2)
            {
                //MessageBox.Show("User Panael");
                global.user = this.txt_username.Text;
                userPanel u = new userPanel();
                this.Hide();
                u.Show();
            }
            else if (rv == 3)
            {
                MessageBox.Show("User Do Not Exist");
            }
            else if (rv == 4)
            {
                MessageBox.Show("Invalid Username/Password");
            }
        }
コード例 #2
0
        private void loginValid()
        {
            loginBLL  l = new loginBLL();
            DataTable dt;

            dt = l.login(txtUserName.Text, txtPassword.Text);
            //MessageBox.Show("" + dt.Rows.Count);

            if (dt.Rows.Count == 1)
            {
                string status = dt.Rows[0][4].ToString();
                if (status.Equals("valid"))
                {
                    string des  = dt.Rows[0][3].ToString();
                    long   id   = Convert.ToInt64(dt.Rows[0][0].ToString());
                    string name = dt.Rows[0][5].ToString();

                    if (des.Equals("admin"))
                    {
                        this.Hide();
                        frmAdmin adm = new frmAdmin(id, name);
                        adm.Show();
                    }
                    else if (des.Equals("salesman"))
                    {
                        this.Hide();
                        frmSalesman adm = new frmSalesman(id, name);
                        adm.Show();
                    }
                }
                else
                {
                    lblLogin.Text = "you are invalid";
                }
            }
            else
            {
                lblLogin.Text = "User name or Password not matched";
            }
        }