Exemple #1
0
        public JsonResult AddUser(Info_User model)
        {
            Result        result      = new Result();
            JsonResult    jsonResult  = new JsonResult();
            Info_User_BLL infoUserBll = new Info_User_BLL();
            bool          isOkAdd;

            model.IsDelete = false;
            if (model.ID == 0)
            {
                isOkAdd = infoUserBll.Insert(model);
                if (isOkAdd)
                {
                    result.message = "添加成功";
                }
            }
            else
            {
                isOkAdd = infoUserBll.Update(model);
                if (isOkAdd)
                {
                    result.message = "更新成功";
                }
            }

            jsonResult.Data = result;
            return(jsonResult);
        }
Exemple #2
0
        public JsonResult Pagination(int pageNumber, int pageSize, string sortOrder)
        {
            Result                  result      = new Result();
            JsonResult              jsonResult  = new JsonResult();
            Info_User_BLL           infoUserBll = new Info_User_BLL();
            int                     count       = infoUserBll.GetEntitiesCount();
            IEnumerable <Info_User> infoUsers   = infoUserBll.GetEntitiesForPaging(pageNumber, pageSize, sortOrder);

            result.data     = new { infoUsers, count };
            jsonResult.Data = result;
            return(jsonResult);
        }
Exemple #3
0
        public JsonResult Search(string _search)
        {
            Result           result      = new Result();
            JsonResult       jsonResult  = new JsonResult();
            Info_User_BLL    infoUserBll = new Info_User_BLL();
            List <Info_User> infoUsers   = infoUserBll.GetList()
                                           .FindAll(x => x.UserName.Contains(_search) || x.Phone.Contains(_search));

            result.data     = infoUsers;
            jsonResult.Data = result;
            return(jsonResult);
        }
Exemple #4
0
        /// <summary>
        /// 获取数据库用户信息
        /// </summary>
        private void GetUserInfo()
        {
            Info_User_BLL   infoUserBll   = new Info_User_BLL();
            Info_User_Model infoUserModel = infoUserBll.GetModel(new Guid(UserID));

            TextBox1.Text     = infoUserModel.UserName;
            TextBox2.Text     = infoUserModel.UserSex.ToString();
            TextBox3.Text     = infoUserModel.UserPhone;
            TextBox4.Text     = infoUserModel.AccountNum;
            TextBox4.ReadOnly = true;
            TextBox5.Text     = infoUserModel.Pwd;
        }
Exemple #5
0
        public JsonResult GetUserInfo(int userId)
        {
            Result        result      = new Result();
            JsonResult    jsonResult  = new JsonResult();
            Info_User_BLL infoUserBll = new Info_User_BLL();
            Info_User     infoUser    = infoUserBll.GetModelByID(userId);

            if (infoUser != null)
            {
                result.data = infoUser;
            }

            jsonResult.Data = result;
            return(jsonResult);
        }
        protected void Button1_OnClick(object sender, EventArgs e)
        {
            Info_User_BLL   infoUserBll   = new Info_User_BLL();
            Info_User_Model infoUserModel = new Info_User_Model();
            string          AccountNum    = TextBox1.Text.Trim();
            string          Pwd           = TextBox2.Text.Trim();

            List <Info_User_Model> infoUserModels = infoUserBll.GetModelList("AccountNum='" + AccountNum + "'");

            // lambda表达式 .tolist转换为list列表
            if (infoUserModels.Where(x => x.AccountNum == AccountNum).ToList().Count > 0)
            {
                Response.Write("用户账户已经重复,请输入其他的");
                return;
            }


            infoUserModel.UserID     = Guid.NewGuid();
            infoUserModel.AccountNum = AccountNum;
            infoUserModel.Pwd        = Pwd;
            infoUserModel.CreateUser = Guid.NewGuid();
            infoUserModel.CreateTime = DateTime.Now;
            // 添加日志
            Sys_ProcessLog_Model sysProcessLogModel = new Sys_ProcessLog_Model();

            sysProcessLogModel.ID             = Guid.NewGuid();
            sysProcessLogModel.LogType        = (int)SystemLogType.UserRegister;
            sysProcessLogModel.LogDescription = "插入了一个用户";
            sysProcessLogModel.CreateUser     = new Guid("CB693BE8-D36C-4B27-8E6B-892987DC5D9E");
            sysProcessLogModel.CreateTime     = DateTime.Now;
            // 修改成使用事务
            bool result = infoUserBll.Add(infoUserModel, sysProcessLogModel);

            if (result)
            {
                Response.Write("添加成功");
                Response.Redirect("Login.aspx");
            }
            else
            {
                Response.Write("添加失败,请联系管理员");
            }
        }
Exemple #7
0
        public JsonResult GetLoginByPhone(Info_User_Model model)
        {
            JsonResult    jr          = new JsonResult();
            Result        result      = new Result();
            Info_User_BLL infoUserBll = new Info_User_BLL();
            Info_User     infoUser    = infoUserBll.Login(model.Phone, model.PassWord);

            if (infoUser != null)
            {
                result.message = "登录成功";
                result.type    = "success";
                result.data    = new { reutrnUrl = Url.Content("~/User/Index") };
            }
            else
            {
                result.message = "登录失败,请检查用户名和密码";
                result.type    = "error";
            }

            jr.Data = result;
            return(jr);
        }
Exemple #8
0
        protected void Button1_OnClick(object sender, EventArgs e)
        {
            Info_User_BLL   infoUserBll   = new Info_User_BLL();
            Info_User_Model infoUserModel = infoUserBll.GetModel(new Guid(UserID));

            infoUserModel.UserName   = TextBox1.Text;
            infoUserModel.UserSex    = Convert.ToInt32(TextBox2.Text);
            infoUserModel.UserPhone  = TextBox3.Text;
            infoUserModel.AccountNum = TextBox4.Text;
            infoUserModel.Pwd        = TextBox5.Text;
            bool result = infoUserBll.Update(infoUserModel);

            if (result)
            {
                Response.Write("更新成功");
                Response.Redirect("Login.aspx");
            }
            else
            {
                Response.Write("更新失败,请联系管理员");
            }
        }
Exemple #9
0
        protected void Button1_OnClick(object sender, EventArgs e)
        {
            string        AccountNum  = TextBox1.Text.Trim();
            string        Pwd         = TextBox2.Text.Trim();
            Info_User_BLL infoUserBll = new Info_User_BLL();


            /*
             * // 是否登录
             * List<Info_User_Model> ds =
             *  infoUserBll.GetModelList("AccountNum='" + AccountNum + "' and Pwd='" + Pwd + "'");
             * if (ds.Count > 0)
             * {
             *  Info_User_Model infoUserModel = ds.FirstOrDefault();
             *  Response.Write("<div class='alert alert-success' role='alert'>登录成功</div>");
             *  CookieHelper.SetCookie("UserID", infoUserModel.UserID.ToString(), DateTime.Now.AddMinutes(10));
             *  Response.Redirect("LogList.aspx?AccountNum=" + AccountNum + "&UserID=" + infoUserModel.UserID);
             * }
             * else
             * {
             *  Response.Write("<div class='alert alert-danger' role='alert'>登录失败</div>");
             * }
             */
            // 自定义登录
            Info_User_Model infoUserModel = infoUserBll.GetModel(AccountNum, Pwd);

            if (infoUserModel != null)
            {
                Response.Write("<div class='alert alert-success' role='alert'>登录成功</div>");
                CookieHelper.SetCookie("UserID", infoUserModel.UserID.ToString(), DateTime.Now.AddMinutes(10));
                Response.Redirect("LogList.aspx?AccountNum=" + AccountNum + "&UserID=" + infoUserModel.UserID);
            }
            else
            {
                Response.Write("<div class='alert alert-danger' role='alert'>登录失败</div>");
            }
        }