Esempio n. 1
0
        public string UsersSaveChanges(string jsonString, string action)
        {
            try
            {
                UserInfoEntity  ue = JsonConvert.DeserializeObject <UserInfoEntity>(jsonString);
                UserInfoManager pm = new UserInfoManager();
                if (action == "add")
                {
                    pm.Insert(ue);
                }
                else
                {
                    UserInfoEntity ueOld = pm.GetUserByCode(ue.Code);
                    ueOld.Name    = ue.Name;
                    ueOld.Type    = ue.Type;
                    ueOld.Company = ue.Company;

                    ueOld.UpdateBy = SessionHelper.CurrentUser.Code;

                    pm.Update(ueOld);
                }
                return("success");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Esempio n. 2
0
 public ActionResult Login(LoginUserViewModel model, string returnUrl)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     if (model.Code == "sa" && model.Password == "password")
     {
         LoginUserViewModel sa = new LoginUserViewModel {
             Name = "超级管理员", Code = "sa", Type = "超级管理员", Company = "上海敏慧"
         };
         Session[SessionHelper.CurrentUserKey] = sa;
         return(RedirectToLocal(returnUrl));
     }
     else
     {
         string          code = model.Code;
         UserInfoManager um   = new UserInfoManager();
         UserInfoEntity  ui   = um.GetUserByCode(code);
         Session[SessionHelper.CurrentUserKey] = new LoginUserViewModel {
             Name = ui.Name, Code = ui.Code, Type = ui.Type, Company = ui.Company
         };
         if (ui == null)
         {
             ModelState.AddModelError("", "用户名不存在!");
             return(View(model));
         }
         else
         {
             if (ui.Password == model.Password)
             {
                 return(RedirectToLocal(returnUrl));
             }
             else
             {
                 ModelState.AddModelError("", "密码错误!");
                 return(View(model));
             }
         }
     }
 }
Esempio n. 3
0
        public string GetUserByCode(string code)
        {
            UserInfoManager manager = new UserInfoManager();

            return(new JavaScriptSerializer().Serialize(manager.GetUserByCode(code)));
        }