Пример #1
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        public static string ModifyPwd(string pwd, string oldpwd)
        {
            using (dbDataContext db = new HsBusiness.dbDataContext())
            {
                //string currentpwd = HttpContext.Current.Session["CurrentPwd"].ToString();//获取当前用户登陆密码
                //var newpwditem = db.Users.FirstOrDefault(x => x.Pwd == currentpwd);
                var user   = db.Users.FirstOrDefault(x => x.ID.Equals(int.Parse(Common.TCContext.Current.OnlineUserID)));
                var result = "";

                if (user != null)
                {
                    if (Interface.Comm.MD5.Encrypt(oldpwd, 32) != user.Pwd)
                    {
                        result = JsonConvert.SerializeObject(new { msg = "旧密码输入错误", state = 2 });
                    }
                    else
                    {
                        user.Pwd = Interface.Comm.MD5.Encrypt(pwd, 32);//md5加密
                        db.SubmitChanges();
                        result = JsonConvert.SerializeObject(new { msg = "修改成功", state = 1 });
                        //HttpContext.Current.Session["CurrentPwd"] = newpwditem.Pwd;//修改完存session
                    }
                }

                else
                {
                    result = JsonConvert.SerializeObject(new { msg = "修改失败", state = 0 });
                }
                return(result);
            }
        }
Пример #2
0
        public static string Read(int SmBaID)
        {
            using (dbDataContext db = new HsBusiness.dbDataContext())
            {
                if (Common.TCContext.Current.OnlineUserID != "")
                {
                    var UserID = Convert.ToInt32(Common.TCContext.Current.OnlineUserID);//用户ID
                    var list   = db.SmaBaRead.Where(x => x.SmBaID == SmBaID && x.UserID == UserID).FirstOrDefault();
                    if (list == null)
                    {
                        SmaBaRead read = new SmaBaRead();
                        read.UserID = UserID;
                        read.SmBaID = SmBaID;
                        read.IsRead = 1;

                        db.SmaBaRead.InsertOnSubmit(read);
                    }
                    else
                    {
                        list.IsRead = 1;
                    }
                    db.SubmitChanges();
                    return(JsonConvert.SerializeObject(new { state = 1, msg = "请求成功" }));
                }
                return(JsonConvert.SerializeObject(new { state = 0, msg = "已读出错,请重新登录" }));
            }
        }
Пример #3
0
        /// <summary>
        /// 登陆
        /// </summary>
        /// <returns></returns>
        public static string Login1(string UserName, string Password, string code)
        {
            using (dbDataContext db = new HsBusiness.dbDataContext())
            {
                var result = "";
                //var pwd = Interface.Comm.MD5.Encrypt(Password, 32);
                var loginuser = db.Users.FirstOrDefault(x => x.Mobile == UserName && x.Pwd == Password);
                var exitlogin = db.Users.FirstOrDefault(x => x.Mobile == UserName);
                if (!code.ToUpper().Equals(HttpContext.Current.Request.Cookies["yzm"].Value))
                {
                    result = JsonConvert.SerializeObject(new { msg = "验证码错误", state = 4 });
                    //return;
                    return(result);
                }
                if (loginuser != null)
                {
                    result = JsonConvert.SerializeObject(new { msg = "登陆成功", state = 1 });
                    OperateLog opermodel = new OperateLog();                                                          //日志记录
                    opermodel.Operator     = loginuser.Name;                                                          //操作人
                    opermodel.OperTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");                            //操作时间
                    opermodel.OperType     = "登陆";                                                                    //操作类型
                    opermodel.Operdescribe = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + loginuser.Name + "登陆该系统"; //操作描述
                    db.OperateLog.InsertOnSubmit(opermodel);
                    db.SubmitChanges();
                    //HttpContext.Current.Session["CurrentUerName"] = loginuser.Name;
                    //HttpContext.Current.Session["CurrentPwd"] = loginuser.Pwd;
                    //HttpContext.Current.Session["CurrentUer"] = loginuser;//登陆信息存入session
                    FormsAuthentication.SetAuthCookie(loginuser.ID.ToString(), false);
                    Common.TCContext.Current.OnlineUserNickName = loginuser.Mobile;
                    Common.TCContext.Current.OnlineRealName     = loginuser.Name;
                    Common.TCContext.Current.OnlineUserID       = loginuser.ID.ToString();
                    Common.TCContext.Current.OnlineUserType     = loginuser.Roles.RoleName.ToString();
                    Common.TCContext.Current.OnlineArea         = loginuser.Areas.ToString();
                    if (loginuser.Pwd == "123456")
                    {
                        result = JsonConvert.SerializeObject(new { msg = "请修改密码", state = 2 });
                    }
                }
                else
                {
                    if (exitlogin == null)
                    {
                        result = JsonConvert.SerializeObject(new { msg = "用户名不存在", state = 3 });
                    }

                    else
                    {
                        result = JsonConvert.SerializeObject(new { msg = "用户名或密码错误", state = 0 });
                    }
                }
                return(result);
            }
        }
Пример #4
0
        public static string Edit(int ID, string StoreName, string Broadband, string Price, string OverTime, string ContactName, string ContactTel, string StoreAddress, string OtherNeeds)
        {
            using (dbDataContext db = new HsBusiness.dbDataContext())
            {
                var item   = db.Store.FirstOrDefault(x => x.ID == ID);
                var result = "";
                if (item != null)
                {
                    item.ID           = ID;
                    item.StoreName    = StoreName;
                    item.Broadband    = Broadband;
                    item.Price        = Price;
                    item.OverTime     = OverTime;
                    item.ContactName  = ContactName;
                    item.ContactTel   = ContactTel;
                    item.StoreAddress = StoreAddress;
                    item.OtherNeeds   = OtherNeeds;
                    item.LastTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                    #region 状态判断
                    if (item.State == 0)//正常
                    {
                        //正常修改不处理
                    }
                    else if (item.State == 1)//已派单
                    {
                        item.State = 0;
                        var sr = item.StoreRemind.Where(x => x.Type == 1).OrderByDescending(x => x.AddTime).FirstOrDefault();//最新提醒
                        if (sr != null)
                        {
                            sr.State = 2;//未处理
                        }
                    }
                    else if (item.State == 2) //已回执
                    {
                        item.State = 0;       //正常
                    }
                    #endregion

                    db.SubmitChanges();
                    result = JsonConvert.SerializeObject(new { msg = "修改成功", state = 1 });
                }
                else
                {
                    result = JsonConvert.SerializeObject(new { msg = "修改失败", state = 0 });
                }

                return(result);
            }
        }
Пример #5
0
 public static string DeleteAll()
 {
     using (dbDataContext db = new HsBusiness.dbDataContext())
     {
         string result = "";
         var    item   = db.SmallBalance.Where(x => true).ToList();
         db.SmallBalance.DeleteAllOnSubmit(item);
         OperateLog opermodel = new OperateLog();
         opermodel.Operator     = Common.TCContext.Current.OnlineRealName.ToString(); //操作人
         opermodel.OperTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");       //操作时间
         opermodel.OperType     = "全部删除";                                             //操作类型
         opermodel.Operdescribe = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Common.TCContext.Current.OnlineRealName + "进行了批量删除操作";
         db.SubmitChanges();
         result = JsonConvert.SerializeObject(new { msg = "删除成功", stste = 1 });
         return(result);
     }
 }
Пример #6
0
 public static string Add(string StoreName, string StoreAddress, string Broadband, string Price, string OverTime, string ContactName, string ContactTel, string OtherNeeds)
 {
     using (dbDataContext db = new HsBusiness.dbDataContext())
     {
         var item = new Store();
         item.StoreName    = StoreName;
         item.StoreAddress = StoreAddress;
         item.Broadband    = Broadband;
         item.Price        = Price;
         item.OtherNeeds   = OtherNeeds;
         item.State        = 0;
         item.OverTime     = OverTime;
         item.ContactName  = ContactName;
         item.ContactTel   = ContactTel;
         item.AddTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         item.LastTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         item.UserID       = int.Parse(Common.TCContext.Current.OnlineUserID);
         db.Store.InsertOnSubmit(item);
         db.SubmitChanges();
         var result = new { msg = "添加成功", state = 1 };
         return(new JavaScriptSerializer().Serialize(result));
     }
 }