/// <summary>
 /// 删除文章分区表中的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <returns></returns>
 public static Boolean deleteResourceAreaInfo(Expression <Func <resourceArea, bool> > whereLambda)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <resourceArea> infoList = db.resourceArea.Where(whereLambda) as DbQuery <resourceArea>;
             List <resourceArea>    listResourceInfoAreaId = infoList.ToList();
             db.resourceArea.RemoveRange(listResourceInfoAreaId);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #2
0
        public void QuestionReply(int quesId, string reply, int userId)
        {
            quesAnswReply qarInfo = new quesAnswReply
            {
                quesAnswId   = quesId,
                userId       = userId,
                replyTime    = DateTime.Now,
                replyContent = reply,
                isAgree      = 0
            };

            using (LazyfitnessEntities db = new LazyfitnessEntities())
            {
                db.quesAnswReply.Add(qarInfo);
                db.SaveChanges();
                Response.Redirect(Url.Action("QuestionDetail", "Home", new { num = quesId }));
            }
        }
 /// <summary>
 /// 删除用户安全表中符合的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <returns></returns>
 public static Boolean deleteUserSecurity(Expression <Func <userSecurity, bool> > whereLambda)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <userSecurity> dbDelete = db.userSecurity.Where(whereLambda) as DbQuery <userSecurity>;
             List <userSecurity>    obDelete = dbDelete.ToList();
             db.userSecurity.RemoveRange(obDelete);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>
 /// 往文章分区表修改数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static Boolean updateResourceArea(Expression <Func <resourceArea, bool> > whereLambda, resourceArea info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <resourceArea> dataObject = db.resourceArea.Where(whereLambda) as DbQuery <resourceArea>;
             resourceArea           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.areaName  = info.areaName;
             oldInfo.areaBrief = info.areaBrief;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #5
0
        /// <summary>
        /// 往用户安全表中插入数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns>插入数据后的对象</returns>
        public static userSecurity insertUserSecurity(userSecurity info)
        {
            try
            {
                using (LazyfitnessEntities db = new LazyfitnessEntities())
                {
                    db.userSecurity.Add(info);
                    db.SaveChanges();

                    DbQuery <userSecurity> data       = db.userSecurity.Where(u => u.loginId == info.loginId) as DbQuery <userSecurity>;
                    userSecurity           objectUser = data.FirstOrDefault();
                    return(objectUser);
                }
            }
            catch
            {
                return(null);
            }
        }
Пример #6
0
        public void QuestionSubmit(int areaId, int userId, string title, string editor, int money)
        {
            userInfo info = Tools.GetUserInfo(userId);

            if (info.userAccount == null)
            {
                info.userAccount = 0;
            }
            if (info.userAccount < money)
            {
                money = (int)info.userAccount;
            }
            else
            {
                using (LazyfitnessEntities db = new LazyfitnessEntities())
                {
                    DbQuery <userInfo> dbsearch  = db.userInfo.Where(u => u.userId == userId) as DbQuery <userInfo>;
                    userInfo           _userinfo = dbsearch.FirstOrDefault();
                    _userinfo.userAccount -= money;
                    db.SaveChanges();
                }
            }
            quesAnswInfo qaInfo = new quesAnswInfo
            {
                areaId          = areaId,
                quesAnswTitle   = title,
                userId          = userId,
                quesAnswTime    = DateTime.Now,
                pageView        = 0,
                isPost          = 0,
                quesAnswStatus  = 1,
                amount          = money,
                quesAnswContent = editor
            };

            using (LazyfitnessEntities db = new LazyfitnessEntities())
            {
                db.quesAnswInfo.Add(qaInfo);
                db.SaveChanges();
                Response.Redirect(Url.Action("QuestionPart", "Home", new { partId = areaId }));
            }
        }
Пример #7
0
        public void ArticleSubmit(string title, string editor, int userId, int areaId)
        {
            resourceInfo rInfo = new resourceInfo
            {
                areaId          = 1,
                resourceTime    = DateTime.Now,
                pageView        = 0,
                isTop           = 0,
                resourceName    = title,
                resourceContent = editor,
                userId          = 1
            };

            using (LazyfitnessEntities db = new LazyfitnessEntities())
            {
                db.resourceInfo.Add(rInfo);
                db.SaveChanges();
                Response.Redirect(Url.Action("ArticlePart", "Home", new { partId = areaId }));
            }
        }
 /// <summary>
 /// 往充值卡表修改数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static Boolean updateRecharge(Expression <Func <recharge, bool> > whereLambda, recharge info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <recharge> dataObject = db.recharge.Where(whereLambda) as DbQuery <recharge>;
             recharge           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.rechargePwd = info.rechargePwd;
             oldInfo.amount      = info.amount;
             oldInfo.isAvailable = info.isAvailable;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #9
0
        public void forumSubmit(int areaId, int userId, string title, string editor)
        {
            postInfo pInfo = new postInfo
            {
                areaId      = areaId,
                postTitle   = title,
                userId      = userId,
                postTime    = DateTime.Now,
                pageView    = 0,
                isPost      = 0,
                postStatus  = 1,
                postContent = editor
            };

            using (LazyfitnessEntities db = new LazyfitnessEntities())
            {
                db.postInfo.Add(pInfo);
                db.SaveChanges();
                Response.Redirect(Url.Action("forumPart", "Home", new { partId = areaId }));
            }
        }
 /// <summary>
 /// 往展示表修改数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static Boolean updateServerShowInfo(Expression <Func <serverShowInfo, bool> > whereLambda, serverShowInfo info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <serverShowInfo> dataObject = db.serverShowInfo.Where(whereLambda) as DbQuery <serverShowInfo>;
             serverShowInfo           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.title      = info.title;
             oldInfo.pictureAdr = info.pictureAdr;
             oldInfo.url        = info.url;
             oldInfo.Infostatus = info.Infostatus;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #11
0
        public ActionResult SaveImage(int userId)
        {
            HttpPostedFileBase imageName = Request.Files["image"];// 从前台获取文件

            if (imageName == null)
            {
                return(Content("(error)未获取到文件"));
            }
            string file        = imageName.FileName;
            string fileFormat  = file.Split('.')[file.Split('.').Length - 1];   // 以“.”截取,获取“.”后面的文件后缀
            Regex  imageFormat = new Regex(@"^(bmp)|(png)|(gif)|(jpg)|(jpeg)"); // 验证文件后缀的表达式(自己写的,不规范别介意哈)

            if (string.IsNullOrEmpty(file) || !imageFormat.IsMatch(fileFormat)) // 验证后缀,判断文件是否是所要上传的格式
            {
                return(Content("(error)文件格式支持(bmp)|(png)|(gif)|(jpg)|(jpeg)"));
            }
            else
            {
                string timeStamp     = DateTime.Now.Ticks.ToString();                // 获取当前时间的string类型
                string firstFileName = timeStamp.Substring(0, timeStamp.Length - 4); // 通过截取获得文件名
                string imageStr      = "/upload/";                                   // 获取保存图片的项目文件夹
                string uploadPath    = Server.MapPath("~/" + imageStr);              // 将项目路径与文件夹合并
                string pictureFormat = file.Split('.')[file.Split('.').Length - 1];  // 设置文件格式
                string fileName      = firstFileName + "." + fileFormat;             // 设置完整(文件名+文件格式)
                string saveFile      = uploadPath + fileName;                        //文件路径
                imageName.SaveAs(saveFile);                                          // 保存文件
                // 如果单单是上传,不用保存路径的话,下面这行代码就不需要写了!
                string image = imageStr + fileName;                                  // 设置数据库保存的路径

                using (LazyfitnessEntities db = new LazyfitnessEntities())
                {
                    DbQuery <userInfo> dbsearch  = db.userInfo.Where(u => u.userId == userId) as DbQuery <userInfo>;
                    userInfo           _userInfo = dbsearch.FirstOrDefault();
                    _userInfo.userHeaderPic = image;
                    db.SaveChanges();
                }
            }
            Response.Redirect("/Home/PersonalData");
            return(Content("sueccess"));
        }
 /// <summary>
 /// 删除充值卡表中符合的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <returns></returns>
 public static Boolean deleteRecharge(Expression <Func <recharge, bool> > whereLambda)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <recharge> dbDelete = db.recharge.Where(whereLambda) as DbQuery <recharge>;
             List <recharge>    obDelete = dbDelete.ToList();
             if (obDelete.Count == 0)
             {
                 return(false);
             }
             db.recharge.RemoveRange(obDelete);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>
 /// 修改文章表中的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static Boolean updateResourceInfo(Expression <Func <resourceInfo, bool> > whereLambda, resourceInfo info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <resourceInfo> dataObject = db.resourceInfo.Where(whereLambda) as DbQuery <resourceInfo>;
             resourceInfo           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.areaId          = info.areaId;
             oldInfo.resourceName    = info.resourceName;
             oldInfo.pageView        = info.pageView;
             oldInfo.isTop           = info.isTop;
             oldInfo.resourceContent = info.resourceContent;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>
 /// 删除展示表中符合的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <returns></returns>
 public static Boolean deleteServerShowInfo(Expression <Func <serverShowInfo, bool> > whereLambda)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <serverShowInfo> dbDelete = db.serverShowInfo.Where(whereLambda) as DbQuery <serverShowInfo>;
             List <serverShowInfo>    obDelete = dbDelete.ToList();
             if (obDelete.Count == 0)
             {
                 return(false);
             }
             db.serverShowInfo.RemoveRange(obDelete);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>
 ///删除帖子回复表中符合的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <returns></returns>
 public static Boolean deletePostReply(Expression <Func <postReply, bool> > whereLambda)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <postReply> dbDelete = db.postReply.Where(whereLambda) as DbQuery <postReply>;
             List <postReply>    obDelete = dbDelete.ToList();
             if (obDelete.Count == 0)
             {
                 return(true);
             }
             db.postReply.RemoveRange(obDelete);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public string chagePassword(userSecurity security, string userNewPwd)
 {
     try
     {
         string MD5Pwd    = MD5Helper.MD5Helper.encrypt(security.userPwd.Trim());
         string MD5NewPwd = MD5Helper.MD5Helper.encrypt(userNewPwd.Trim());
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <userSecurity> dbSecurity = db.userSecurity.Where(u => u.loginId == security.loginId.Trim()).Where(u => u.userPwd == MD5Pwd) as DbQuery <userSecurity>;
             userSecurity           obSecurity = dbSecurity.FirstOrDefault();
             if (obSecurity == null)
             {
                 return("用户名或密码错误");
             }
             obSecurity.userPwd = MD5NewPwd;
             db.SaveChanges();
             return("修改成功");
         }
     }
     catch
     {
         return("修改失败");
     }
 }
 public string findPassword(userSecurity security, userInfo info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <userInfo> dbInfo = db.userInfo.Where(u => u.userName == info.userName.Trim()).Where(u => u.userTel == info.userTel.Trim()) as DbQuery <userInfo>;
             userInfo           obInfo = dbInfo.FirstOrDefault();
             if (obInfo == null)
             {
                 return("用户名或电话不正确");
             }
             //实例化一个要修改的对象
             userSecurity obSecurity = db.userSecurity.Where(u => u.loginId == info.userName.Trim()).FirstOrDefault();
             obSecurity.userPwd = MD5Helper.MD5Helper.encrypt(security.userPwd.Trim());
             db.SaveChanges();
             return("修改成功");
         }
     }
     catch
     {
         return("验证失败");
     }
 }
 /// <summary>
 /// 修改问答帖子表中的数据
 /// </summary>
 /// <param name="whereLambda"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static Boolean updateQuesAnswInfo(Expression <Func <quesAnswInfo, bool> > whereLambda, quesAnswInfo info)
 {
     try
     {
         using (LazyfitnessEntities db = new LazyfitnessEntities())
         {
             DbQuery <quesAnswInfo> dataObject = db.quesAnswInfo.Where(whereLambda) as DbQuery <quesAnswInfo>;
             quesAnswInfo           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.areaId          = info.areaId;
             oldInfo.quesAnswTitle   = info.quesAnswTitle;
             oldInfo.pageView        = info.pageView;
             oldInfo.isPost          = info.isPost;
             oldInfo.amount          = info.amount;
             oldInfo.quesAnswStatus  = info.quesAnswStatus;
             oldInfo.quesAnswContent = info.quesAnswContent;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }