Esempio n. 1
0
        [HttpPost]//保存SaveNewPassword
        public ActionResult SaveNewPassword(string newPassword, string old, decimal userid)
        {
            var result = new ResultInfo(false);

            try
            {
                using (var db = new KeyMouseEntities())
                {
                    var user = db.dl_basic_user.FirstOrDefault(s => s.userid == userid);
                    if (user.userpwd != old)
                    {
                        result.IsSucceed = false;
                        result.Message   = "原密码错误!";
                        return(Json(result));
                    }
                    user.userpwd = newPassword;
                    if (db.SaveChanges() > 0)
                    {
                        result.IsSucceed = true;
                    }
                    else
                    {
                        result.IsSucceed = false;
                    }
                }
            }
            catch (Exception e)
            {
                result.IsSucceed = false;
                result.Message   = e.Message;
            }
            return(Json(result));
        }
Esempio n. 2
0
        public ActionResult SaveNewPassage(string newPassage, DateTime starttime, decimal userid)
        {
            var result = new ResultInfo(false);

            System.DateTime endtime = new System.DateTime();
            endtime = DateTime.Now;
            try
            {
                using (var db = new KeyMouseEntities())
                {
                    var passage = new t_f_data()
                    {
                        userid    = userid,
                        content   = newPassage,
                        starttime = starttime,
                        endtime   = endtime,
                    };
                    db.t_f_data.Add(passage);
                    if (db.SaveChanges() > 0)
                    {
                        result.IsSucceed = true;
                    }
                    else
                    {
                        result.IsSucceed = false;
                    }
                }
            }
            catch (Exception ex)
            {
                result.IsSucceed = false;
            }
            return(Json(result));
        }
Esempio n. 3
0
        [HttpPost]//保存new user
        public string Save(string json)
        {
            JsonObject obj      = new JsonObject(json);
            var        phone    = decimal.Parse(obj["phone"].Value.ToString());
            string     username = obj["user"].Value.ToString();
            string     userpwd  = obj["passwd"].Value.ToString();

            System.DateTime com_starttime = new System.DateTime();
            com_starttime = DateTime.Now;
            try
            {
                using (var db = new KeyMouseEntities())
                {
                    var uuser = db.dl_basic_user.FirstOrDefault(x => x.userphone == phone && x.isDel == false);
                    if (uuser == null)
                    {
                        var user = new dl_basic_user()
                        {
                            userpwd   = userpwd,
                            jointime  = com_starttime,
                            userphone = phone,
                            username  = username,
                            isDel     = false
                        };
                        db.dl_basic_user.Add(user);
                        db.SaveChanges();

                        var nuser = new sys_user_role()
                        {
                            userid = user.userid,
                            rid    = 2
                        };
                        db.sys_user_role.Add(nuser);
                        db.SaveChanges();
                        return("success");
                    }
                    else
                    {
                        return("existed");
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Esempio n. 4
0
        [HttpPost]//保存新资料
        public string SaveM(string json)
        {
            JsonObject    obj       = new JsonObject(json);
            dl_basic_user user      = Session["user"] as dl_basic_user;
            decimal       userid    = user.userid;
            decimal       userphone = decimal.Parse(obj["userphone"].Value.ToString());
            string        username  = obj["username"].Value.ToString();
            string        comment   = obj["comment"].Value.ToString();
            string        option1   = obj["option1"].Value.ToString();

            try
            {
                using (var db = new KeyMouseEntities())
                {
                    var uuser = db.dl_basic_user.FirstOrDefault(x => x.userid == userid);
                    if (uuser != null)
                    {
                        uuser.userphone = userphone;
                        uuser.username  = username;
                        uuser.comment   = comment;
                        uuser.option1   = option1;
                    }
                    if (db.SaveChanges() > 0)
                    {
                        return("success");
                    }
                    else
                    {
                        return("existed");
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }