예제 #1
0
        public int login(loginBO lBO)
        {
            string conectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\BCS DATA\Samester 6\C Sharp\Assingment 1\DAL\styloDatabase.mdf;Integrated Security=True";


            using (DataClassesDataContext dc = new DataClassesDataContext(conectionString))
            {
                User us = dc.Users.SingleOrDefault(x => x.Username == lBO.Username);
                if (us == null)
                {
                    return(3);
                }
                else
                {
                    if (us.Role.Equals("Admin"))
                    {
                        if (us.Username.Equals(lBO.Username) && us.Password.Equals(lBO.Password))
                        {
                            return(1);
                        }
                    }
                    else if (us.Role.Equals("Staff"))
                    {
                        if (us.Username.Equals(lBO.Username) && us.Password.Equals(lBO.Password))
                        {
                            return(2);
                        }
                    }
                }
                return(4);
            }
        }
예제 #2
0
        //this method is to take user input details and store them in database and verify
        //whether username is unique or not. Sending object to business layer and retrieving a string
        //from business layer
        protected void Button1_Click(object sender, EventArgs e)
        {
            string s = null;
            users  u = new users();

            if (firstname.Text == "" || lastname.Text == "" || username.Text == "" || password.Text == "")
            {
                s = "please enter your details";
            }

            else
            {
                u.Firstname = firstname.Text;
                u.Lastname  = lastname.Text;
                u.Username  = username.Text;
                u.Password  = password.Text;

                loginBO lb = new loginBO();
                s = lb.insertuser(u);
            }
            output.Visible = true;
            output.Text    = s;

            if (s == "Registered Successfully")
            {
                Response.Redirect("loginpage.aspx");
            }
        }
예제 #3
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");
            }
        }
예제 #4
0
        //this method is to verify login details by passing object to BL and getting string as output from the
        //respective method.if login successful user redirected to products page
        protected void Button1_Click(object sender, EventArgs e)
        {
            users u = new users();

            u.Username = TextBox1.Text;
            u.Password = TextBox2.Text;

            loginBO lb = new loginBO();
            string  o  = lb.checklogin(u.Username, u.Password);

            output.Visible = true;
            output.Text    = o;

            if (o == "login success")
            {
                Session["user"] = u.Username;
                Response.Redirect("WebForm1.aspx");
            }
        }
예제 #5
0
        public int login(loginBO lBO)
        {
            loginDAL lDAL = new loginDAL();

            return(lDAL.login(lBO));
        }