Esempio n. 1
0
 public ActionResult Login(string username, string password, int isPersistent = 0)
 {
     using (BasicDB db = new BasicDB(false))
     {
         if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
         {
             ViewBag.Error = "The username and password can not be empty";
         }
         else
         {
             MldAdmin model = adminDal.Query("name=@1 and pwd=@2", username, Common.Encryption.GetAdminPwd(password));
             if (model != null)
             {
                 if (model.IsLock == 1)
                 {
                     ViewBag.Error = "Sorry, your account has been locked up";
                 }
                 else
                 {
                     WebSiteHelper.Login(model.Name, ((EnumAdminRole)model.Rid).ToString(), Convert.ToBoolean(isPersistent));
                     model.LastLoginTime = DateTime.Now;
                     model.LastLoginIP   = HttpHelper.Context.Request.UserHostAddress;
                     adminDal.Update(model);
                     return(Redirect("/WebAdmin/Home/Welcome"));
                 }
             }
             else
             {
                 ViewBag.Error = "The username or password is incorrect, please reenter it";
             }
         }
     }
     return(View());
 }
Esempio n. 2
0
        public ActionResult EditPwd(string oldpwd, string newpwd, string anewpwd)
        {
            ViewBag.Error = "none";
            using (BasicDB db = new BasicDB(false))
            {
                AMW.Model.Entity.MldAdmin model = CurrentAdmin;
                if (model.Pwd.Equals(Common.Encryption.GetAdminPwd(oldpwd)))
                {
                    if (newpwd.Equals(anewpwd) && !string.IsNullOrEmpty(newpwd))
                    {
                        model.Pwd = Common.Encryption.GetAdminPwd(newpwd);

                        if (adminDal.Update(model))
                        {
                            ViewBag.Success = "ok";
                        }
                        else
                        {
                            ViewBag.Error = "Edit Password Error";
                        }
                    }
                    else
                    {
                        ViewBag.Error = "The new password entered two times is inconsistent, and the password changes failed.";
                    }
                }
                else
                {
                    ViewBag.Error = "The old password you entered is incorrect, and the password is changed.";
                }
            }
            return(View());
        }
Esempio n. 3
0
        public ActionResult Edit(int id)
        {
            using (BasicDB db = new BasicDB(false))
            {
                ViewBag.Error = "none";

                return(View(adminDal.Query(id)));
            }
        }
Esempio n. 4
0
 public ActionResult List(int pageSize = 20, int pageIndex = 1)
 {
     if (pageIndex <= 0)
     {
         pageIndex = 1;
     }
     using (BasicDB db = new BasicDB(false))
     {
         int             count     = adminDal.QueryInt("id!=1");
         int             pageCount = (count + pageSize - 1) / pageSize;
         List <MldAdmin> list      = adminDal.QueryList(pageIndex, pageSize, "id", "id desc", "id!=1");
         ViewBag.Pager = new AMW.Model.Pager()
         {
             PageSize = pageSize, PageCount = pageCount, PageIndex = pageIndex, SubmitLink = "/WebAdmin/Admin/List"
         };
         return(View(list));
     }
 }
Esempio n. 5
0
        public ActionResult Index(string name, string pwd)
        {
            ViewBag.Error = "none";
            using (BasicDB db = new BasicDB(false))
            {
                if (string.IsNullOrEmpty(name))
                {
                    ViewBag.Error = "Account is not null";
                }
                else
                {
                    if (string.IsNullOrEmpty(pwd))
                    {
                        ViewBag.Error = "Pwd is not null";
                    }
                    else
                    {
                        if (adminDal.Exists("name=@1", name))
                        {
                            ViewBag.Error = "The account has already existed";
                        }
                        else
                        {
                            MldAdmin model = new MldAdmin()
                            {
                                Rid = (int)EnumAdminRole.Normal, Name = name, Pwd = Common.Encryption.GetAdminPwd(pwd), AddTime = DateTime.Now, IsLock = 0
                            };

                            if (adminDal.Add(model) > 0)
                            {
                                ViewBag.Success = "ok";
                            }
                            else
                            {
                                ViewBag.Error = "Error";
                            }
                        }
                    }
                }
            }
            return(View());
        }
Esempio n. 6
0
 public ActionResult Delete(int id)
 {
     using (BasicDB db = new BasicDB(false))
     {
         if (adminDal.Delete(id))
         {
             return(Json(new JsonResultModel()
             {
                 ok = true
             }));
         }
         else
         {
             return(Json(new JsonResultModel()
             {
                 ok = false, error = "Error"
             }));
         }
     }
 }
Esempio n. 7
0
        public ActionResult Edit(int id, string name, string pwd, int islock)
        {
            ViewBag.Error = "none";
            using (BasicDB db = new BasicDB(false))
            {
                if (adminDal.Exists("name=@1 and id!=@2", name, id))
                {
                    ViewBag.Error = "The account has already existed";
                }
                else
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        ViewBag.Error = "Account is not null";
                    }
                    else
                    {
                        MldAdmin model = new MldAdmin();
                        model.ID   = id;
                        model.Name = name;

                        model.IsLock = islock;
                        if (!string.IsNullOrEmpty(pwd))
                        {
                            model.Pwd = Common.Encryption.GetAdminPwd(pwd);
                        }
                        if (adminDal.Update(model))
                        {
                            ViewBag.Success = "ok";
                        }
                        else
                        {
                            ViewBag.Error = "Error";
                        }
                    }
                }
                return(View("Edit", adminDal.Query(id)));
            }
        }
Esempio n. 8
0
        public ActionResult Index(int id, string title, string keyword, string description, string content)
        {
            ViewBag.Error = "none";
            MldPage model = dal.Query(id);

            model.Title       = title;
            model.Content     = content;
            model.KeyWord     = keyword;
            model.Description = description;

            using (BasicDB db = new BasicDB(false))
            {
                if (dal.Update(model))
                {
                    ViewBag.Success = "ok";
                }
                else
                {
                    ViewBag.Error = "Error";
                }
            }
            return(View(model));
        }
Esempio n. 9
0
        public ActionResult Index(string title, HttpPostedFileBase logo, string keyword, string description, string pagedown)
        {
            ViewBag.Error = "none";
            MldWebSite model = Helper.ApplicationHelper.CurWebsite;

            if (logo != null && logo.ContentLength > 0)
            {
                UploadFileResult result = logo.FileUpLoad("img", 1024 * 1024 * 4, "images");
                if (!result.Ok)
                {
                    ViewBag.Error = result.Data;
                }
                else
                {
                    model.Logo = result.Data;
                }
            }

            model.Title       = title;
            model.KeyWord     = keyword;
            model.Description = description;
            model.Content     = pagedown;

            using (BasicDB db = new BasicDB(false))
            {
                if (websiteDal.Update(model))
                {
                    ViewBag.Success = "ok";
                    Helper.ApplicationHelper.CurWebsite = model;
                }
                else
                {
                    ViewBag.Error = "Error";
                }
            }
            return(View(Helper.ApplicationHelper.CurWebsite));
        }