예제 #1
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                User              login     = new User();
                UsersValidations  userObj   = new UsersValidations();
                SellerValidations sellerObj = new SellerValidations();
                BuyerValidations  buyerObj  = new BuyerValidations();

                login.UserName = txtUserName.Text;
                login.Password = txtPass.Password;



                login = userObj.LoginUser(login);

                if (login != null)
                {
                    if (login.UserType.ToLower() == "admin")
                    {
                        Admin sp = new Admin();
                        this.NavigationService.Navigate(sp);
                    }
                    else if (login.UserType.ToLower() == "seller")
                    {
                        int        sellerId = sellerObj.SellerId(login.UserName);
                        SellerPage sp       = new SellerPage(sellerId);
                        this.NavigationService.Navigate(sp);
                    }
                    else if (login.UserType.ToLower() == "buyer")
                    {
                        int buyerId = buyerObj.BuyerId(login.UserName);
                        ShowAllProperties_Buyer sp = new ShowAllProperties_Buyer(buyerId);
                        this.NavigationService.Navigate(sp);
                    }
                    MessageBox.Show("Login Successful!!");
                }
                else
                {
                    txtUserName.Text = "";
                    txtPass.Password = "";
                    throw new UserException("UserName/Password is required");
                }
            }
            catch (UserException ex)
            {
                MessageBox.Show(ex.Message, "Alert");
            }
        }
예제 #2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            User              login     = new User();
            UsersValidations  userObj   = new UsersValidations();
            SellerValidations sellerObj = new SellerValidations();
            BuyerValidations  buyerObj  = new BuyerValidations();

            login.UserName = txtUserName.Text;
            login.Password = txtPassword.Text;

            login = userObj.LoginUser(login);

            if (login != null)
            {
                if (login.UserType.ToLower() == "admin")
                {
                    Session["userName"] = login.UserName;
                    Response.Redirect("Admin.aspx");
                }
                else if (login.UserType.ToLower() == "seller")
                {
                    int sellerId = sellerObj.GetSellerId(login.UserName);
                    Session["userId"]   = sellerId;
                    Session["userName"] = login.UserName;
                    Response.Redirect("SellerHome.aspx");
                }
                else if (login.UserType.ToLower() == "buyer")
                {
                    int buyerId = buyerObj.BuyerId(login.UserName);
                    Session["userId"]   = buyerId;
                    Session["userName"] = login.UserName;
                    Response.Redirect("DisplayResults.aspx");
                }

                Response.Write("<script type='text/javascript'>alert( '" + login.UserName + "');</script>");
            }
            //else
            //{

            //    throw new UserException("UserName/Password is invalid");


            //}
        }