Пример #1
0
        public ActionResult Login(FashionShop.Models.EF.Admin admin)
        {
            if (ModelState.IsValid)
            {
                var dao    = new UserDao();
                var result = dao.Login(admin.UserName, admin.Password);

                if (result)
                {
                    var user        = dao.getByID(admin.UserName);
                    var userSession = new adminLogin();

                    userSession.ID       = user.ID;
                    userSession.username = user.UserName;
                    Session.Add(commonstants.User_Session, userSession);

                    return(RedirectToAction("Index", "Default"));
                }
                else
                {
                    ModelState.AddModelError("", "Đăng nhập không đúng");
                }
            }

            return(View("Index"));
        }
Пример #2
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Hide();
            adminLogin adminLogin = new adminLogin();

            adminLogin.Show();
        }
Пример #3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (TextBox1.Text == "" || TextBox2.Text == "")
     {
         ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('用户名和密码不能为空');</script>");
     }
     else if (TextBox1.Text.Length < 2 || TextBox1.Text.Length > 10)
     {
         ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('用户名为2-10之间!');</script>");
     }
     else if (TextBox2.Text.Length < 4 || TextBox2.Text.Length > 18)
     {
         ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('密码为4-18位之间!');</script>");
     }
     else
     {
         DataClassesDataContext db = new DataClassesDataContext();
         var bb = from r in db.adminLogin where  r.userName == TextBox1.Text select r;
         if (bb.Count() > 0)
         {
             //Response.Write("<script language='javascript'> alert('用户名已存在!');</script>");
             ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('用户名已存在!');</script>");
         }
         else
         {
             adminLogin aa = new adminLogin();
             aa.userName = TextBox1.Text;
             aa.userPwd  = TextBox2.Text;
             aa.userType = "管理员";
             db.adminLogin.InsertOnSubmit(aa);
             db.SubmitChanges();
             ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('添加成功!');</script>");
         }
     }
 }
Пример #4
0
        public ActionResult Login(adminLogin adminLogin)
        {
            if (!ModelState.IsValid)
            {
                return(View(adminLogin));
            }

            var dbadmin = _context.AdminSettings.FirstOrDefault(m => m.Email.Trim() == adminLogin.Email.Trim());

            if (dbadmin == null || !Crypto.VerifyHashedPassword(dbadmin.Password, adminLogin.Password))
            {
                ModelState.AddModelError("loginError", "Email və ya Parol Yanlışdır!");
                return(View(adminLogin));
            }

            Session["lgadmin"] = dbadmin;

            return(RedirectToAction("Index", "Dashboard"));
        }