예제 #1
0
        // GET: student/PersonalCenter
        public ActionResult Index()
        {
            var result = new ChangePWD();

            result.Success = false;
            try
            {
                string oldPWD = Request.QueryString["oldPWD"];
                string newPWD = Request.QueryString["newPWD"];
                int    userID = Common.User.GetUserID(Session["Username"].ToString());
                //判断旧密码
                if (Common.Auth.CheckPwd(oldPWD, Common.User.GetUserName(userID)))
                {
                    //更新密码
                    var    bll   = new BLL.user();
                    var    model = bll.GetModel(p => p.id == userID);
                    string pwd   = Common.Auth.Encrypt(newPWD);
                    model.pwd = pwd;
                    bll.Update(model, new[] { "id", "pwd" });
                    result.Success = true;
                }
            }
            catch (Exception)
            {
                return(View());
            }

            return(View(result));
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = Convert.ToInt32(context.Request["id"]);

            BLL.blogs   bll_blog   = new BLL.blogs();
            Model.blogs model_blog = bll_blog.GetModel(id);
            //阅读排行榜
            List <Model.blogs> list_blog = bll_blog.GetModelList("Blog_delete = 0 and Blog_is = 1 order by Blog_read desc LIMIT 4");

            //评论
            BLL.tell          bll_tell  = new BLL.tell();
            List <Model.tell> list_tell = bll_tell.GetModelList("Tell_blogid=" + id + "");

            BLL.user bll_user = new BLL.user();
            for (int i = 0; i < list_tell.Count; i++)
            {
                Model.user model_user = bll_user.GetModel((int)list_tell[i].Tell_userid);
                list_tell[i].Tell_name = model_user.User_name;
            }


            Model.showblog model_show = new Model.showblog()
            {
                Show_blog = model_blog,
                Show_list = list_blog,
                Show_tell = list_tell
            };
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string is_show = js.Serialize(model_show);

            context.Response.Write(is_show);
        }
예제 #3
0
 private bool DoEdit(int _id)
 {
     try
     {
         BLL.user   bll   = new BLL.user();
         Model.user model = bll.GetModel(_id);
         model.nickname   = txtName.Text;
         model.status     = Convert.ToInt32(rblStatus.SelectedValue);
         model.sex        = Convert.ToInt32(rblSex.SelectedValue);
         model.point      = Convert.ToInt32(txtPoint.Text);
         model.parent_id  = Convert.ToInt32(txtParent.Text);
         model.phone      = txtPhone.Text;
         model.email      = txtEmail.Text;
         model.login_time = Convert.ToDateTime(txtLoginTime.Text);
         model.reg_time   = Convert.ToDateTime(txtRegTime.Text);
         if (bll.Update(model))
         {
             AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改产品经理信息"); //记录日志
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     return(false);
 }
예제 #4
0
파일: User.cs 프로젝트: leoparddne/SCMS
        public static string GetUserName(int id)
        {
            var bll  = new BLL.user();
            var name = bll.GetModel(p => p.id == id).name;

            return(name);
        }
예제 #5
0
파일: User.cs 프로젝트: leoparddne/SCMS
        public static int GetUserID(string username)
        {
            var bll = new BLL.user();
            var id  = bll.GetModel(p => p.name == username).id;

            return(id);
        }
예제 #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int userid = 0;

            #region 没有cookie
            if (int.TryParse(context.Request["username"], out userid))
            {
                #region 账号格式正确
                userid = Convert.ToInt32(context.Request["username"]);
                BLL.user   bll_user   = new BLL.user();
                Model.user model_user = bll_user.GetModel(userid);
                if (model_user != null)
                {
                    string pwd = context.Request["password"];
                    if (model_user.User_pwd == pwd)
                    {
                        #region 密码正确
                        context.Session["USER"] = model_user;
                        string loginkeeping = context.Request["loginkeeping"];
                        if (loginkeeping != null)
                        {
                            #region 记住我
                            HttpCookie cookie_id = new HttpCookie("userid");
                            cookie_id.Expires = DateTime.Now.AddDays(1);
                            cookie_id.Value   = userid.ToString();
                            context.Response.AppendCookie(cookie_id);
                            HttpCookie cookie_pwd = new HttpCookie("userpwd");
                            cookie_pwd.Expires = DateTime.Now.AddDays(1);
                            cookie_pwd.Value   = pwd.ToString();
                            context.Response.AppendCookie(cookie_pwd);
                            context.Response.Write(1);
                            #endregion
                        }
                        #endregion
                    }
                    else
                    {
                        context.Response.Write("密码输入错误");
                    }
                }
                else
                {
                    if (context.Request.Cookies["userid"] != null && context.Request.Cookies["userpwd"] != null)
                    {
                        int        id           = Convert.ToInt32(context.Request.Cookies["userid"].Value);
                        BLL.user   bll_userid   = new BLL.user();
                        Model.user model_userid = bll_userid.GetModel(userid);
                        context.Session["USER"] = model_user;
                        object a = context.Session["USER"].ToString();
                        context.Response.Write(1);
                    }
                    context.Response.Write("账号格式错误");
                }
                #endregion
            }
            #endregion }
        }
예제 #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //博客类别
            string session_user = null;

            //if (context.Session["USER"] != null){
            //    session_user = context.Session["USER"].ToString();
            //}
            BLL.blog_type          bll_type  = new BLL.blog_type();
            List <Model.blog_type> list_type = bll_type.GetModelList("");

            //热门博客
            BLL.blogs          bll_blogs     = new BLL.blogs();
            List <Model.blogs> list_hotblogs = bll_blogs.GetModelList(" Blog_delete = 0 and Blog_is = 1 order by Blog_read  desc");

            Model.blogs moblogs = list_hotblogs[0];
            //图片分享
            BLL.img          bll_img  = new BLL.img();
            List <Model.img> list_img = bll_img.GetModelList("Img_is=1");

            //评论
            BLL.tell          bll_tell  = new BLL.tell();
            BLL.user          bll_user  = new BLL.user();
            List <Model.tell> list_tell = bll_tell.GetModelList(" Tell_id>0 order by Tell_blogid  LIMIT 3");

            for (int i = 0; i < list_tell.Count; i++)
            {
                Model.user model_user = bll_user.GetModel((int)list_tell[i].Tell_userid);
                list_tell[i].Tell_img  = model_user.User_img;
                list_tell[i].Tell_name = model_user.User_name;
            }
            //推荐博客

            List <Model.blogs> list_tuiblogs = new List <Model.blogs> {
                list_hotblogs[1], list_hotblogs[2], list_hotblogs[3]
            };

            Model.Main main = new Model.Main()
            {
                Main_type     = list_type,
                Main_hotblogs = moblogs,
                Main_tuiblogs = list_tuiblogs,
                Main_tell     = list_tell,
                Main_img      = list_img,
                name          = session_user
            };
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string json = js.Serialize(main);

            context.Response.Write(json);
        }
예제 #8
0
        /// <summary>
        /// 判断密码是否正确
        /// </summary>
        /// <param name="enPwd">用户输入的密码</param>
        /// <param name="username">用户名</param>
        /// <returns></returns>
        public static bool CheckPwd(string pwd, string username)
        {
            bool result = false;

            BLL.user bll  = new BLL.user();
            var      user = bll.GetModel(p => p.name == username);

            if (user.pwd == Encrypt(pwd))
            {
                result = true;
            }
            return(result);
        }
예제 #9
0
        public BaseController()
        {
#if DEBUG
            ViewBag.Username = "******";
#endif
            //初始化页面数据,通过ViewBag传递给view
            //获取用户id
            BLL.user user      = new BLL.user();
            string   name      = ViewBag.Username;
            var      userModel = user.GetModel(p => p.name == name);
            //验证用户权限
            if (!new BLL.clubManager().Exist(p => p.userID == userModel.id))
            {
                //返回用户登录界面
                Response.Redirect("/manager/Login/Login");
            }

            ViewBag.Clubs = new BLL.ClubBLL().GetRecordCount();
            //获取我管理的所有社团的活动申请结果
            var clubList = new BLL.clubManager().GetModels(p => p.userID == userModel.id);
            //获取这些社团的活动信息
            var list = new List <Model.clubactivity>();
            foreach (var item in clubList)
            {
                var act = new BLL.clubActivity().GetModels(p => p.clubID == item.cludID & p.state != 0 & p.state != 3);
                foreach (var j in act)
                {
                    list.Add(j);
                }
            }
            //页面申请结果数量
            ViewBag.Result = list.Count;
            //页面入社申请结果数量
            var newMember      = new BLL.newMember();
            int newMemberCount = 0;
            foreach (var item in clubList)
            {
                var act = new BLL.clubActivity().GetModels(p => p.clubID == item.cludID & p.state != 0 & p.state != 3);
                newMemberCount += newMember.GetRecordCount(p => p.state == 0 & p.clubID == item.cludID);
            }
            ViewBag.NewMember = newMemberCount;
        }
예제 #10
0
        public BaseController()
        {
#if DEBUG
            ViewBag.Username = "******";
#endif
            //初始化页面数据,通过ViewBag传递给view
            //获取用户id
            BLL.user user      = new BLL.user();
            string   name      = ViewBag.Username;
            var      userModel = user.GetModel(p => p.name == name);

            //获取所有社团数
            DushBoard model = new DushBoard();
            model.Clubs = new BLL.ClubBLL().GetRecordCount();
            //获取我加入的社团数
            model.Mine = new BLL.clubMember().GetRecordCount(p => p.userid == userModel.id);
            //获取申请中的新社团
            model.NewClubs = new BLL.newMember().GetRecordCount(p => p.userID == userModel.id & p.state == 0);

            ViewBag.Clubs    = model.Clubs;
            ViewBag.Mine     = model.Mine;
            ViewBag.NewClubs = model.NewClubs;

            //获取通知与活动个数
            ViewBag.Message  = new BLL.messageBLL().GetRecordCount(p => p.to == userModel.id & p.state == 0);
            ViewBag.Activity = new BLL.clubActivity().GetRecordCount(p => p.state == 1);
            //获取我所有加入的社团,然后查询
            int count     = 0;
            var mineClubs = new BLL.clubMember().GetModels(p => p.userid == userModel.id);
            foreach (var item in mineClubs)
            {
                count += new BLL.clubActivity().GetRecordCount(p => p.clubID == item.clubid & p.state == 1);
            }
            ViewBag.mineActivity = count;
            //获取未读申请结果个数
            ViewBag.ApplyResult = new BLL.newMember().GetRecordCount(p => p.userID == userModel.id & p.state != 0 & p.state != 3);
            //未读的创办社团消息
            ViewBag.ClubApplyResult = new BLL.newClub().GetModels(p => p.userID == userModel.id & p.state != 0 & p.state != 3).ToList().Count;
            //申请中的社团
            ViewBag.ClubApply = new BLL.newClub().GetModels(p => p.userID == userModel.id & p.state == 0).ToList().Count;
        }
예제 #11
0
        public BaseController()
        {
#if DEBUG
            ViewBag.Username = "******";
#endif
            //初始化页面数据,通过ViewBag传递给view
            //获取用户id
            BLL.user user      = new BLL.user();
            string   name      = ViewBag.Username;
            var      userModel = user.GetModel(p => p.name == name);
            //验证用户权限
            if (!new BLL.teacher().Exist(p => p.userID == userModel.id))
            {
                //返回用户登录界面
                Response.Redirect("/teacher/Login/Login?errorMSG=2");
            }
            //获取社团个数
            ViewBag.Clubs = new BLL.ClubBLL().GetRecordCount();
            //获取申请中的活动
            ViewBag.ActivityApply = new BLL.clubActivity().GetRecordCount(p => p.state == 0);
            //获取申请中的新社团
            ViewBag.ClubApply = new BLL.newClub().GetRecordCount(p => p.userID == userModel.id & p.state == 0);
        }
예제 #12
0
        public ActionResult checkPwd()
        {
            string pwd      = Request.Params["pwd"];
            string username = Request.Params["username"];

            BLL.user bll = new BLL.user();
            try
            {
                var result = Common.Auth.CheckPwd(pwd, username);

                if (result)
                {
                    BLL.user    userBll    = new BLL.user();
                    var         model      = userBll.GetModel(p => p.name == username);
                    BLL.teacher teacherBll = new BLL.teacher();

                    var exist = teacherBll.Exist(p => p.userID == model.id);
                    if (exist)
                    {
                        Session["Username"] = username;
                        return(Redirect("/teacher/Home"));
                    }
                    else
                    {
                        return(Redirect("/teacher/Login/Login?errorMSG=2"));
                    }
                }
                else
                {
                    return(Redirect("/teacher/Login/Login?errorMSG=1"));
                }
            }
            catch (Exception)
            {
                return(Redirect("/teacher/Login/Login?errorMSG=1"));
            }
        }
예제 #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //图片
            if (context.Request["page"] == "img")
            {
                int    id     = Convert.ToInt32(context.Request["id"]);
                string text   = context.Request["text"];
                string img    = context.Request["img"];
                int    img_is = Convert.ToInt32(context.Request["is"]);

                Model.img model_img = new Model.img()
                {
                    Img_address = img,
                    Img_id      = id,
                    Img_is      = img_is,
                    Img_text    = text
                };
                BLL.img bll_img = new BLL.img();
                if (bll_img.Update(model_img) == true)
                {
                    context.Response.Write("修改成功");
                }
                else
                {
                    context.Response.Write("修改失败");
                }
            }
            //用户
            if (context.Request["page"] == "user")
            {
                int    id    = Convert.ToInt32(context.Request["id"]);
                string name  = context.Request["name"];
                string img   = context.Request["img"];
                int    qq    = Convert.ToInt32(context.Request["qq"]);
                int    phone = Convert.ToInt32(context.Request["phone"]);

                Model.user model_user = new Model.user()
                {
                    User_id    = id,
                    User_name  = name,
                    User_img   = img,
                    User_qq    = qq,
                    User_phone = phone,
                    User_pwd   = id.ToString()
                };
                BLL.user bll_user = new BLL.user();
                if (bll_user.Update(model_user) == true)
                {
                    context.Response.Write("修改成功");
                }
                else
                {
                    context.Response.Write("修改失败");
                }
            }
            //评论
            if (context.Request["page"] == "tell")
            {
                int               id        = Convert.ToInt32(context.Request["id"]);
                BLL.tell          bll_tell  = new BLL.tell();
                List <Model.tell> list_tell = bll_tell.GetModelList("Tell_blogid=" + id + "");
                BLL.user          bll_user  = new BLL.user();
                for (int i = 0; i < list_tell.Count; i++)
                {
                    Model.user model_user = bll_user.GetModel((double)list_tell[i].Tell_userid);
                    list_tell[i].Tell_username = model_user.User_name;
                }
                System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
                string a = js.Serialize(list_tell);
                context.Response.Write(a);
            }
            //博客
            if (context.Request["page"] == "blog")
            {
                int                    id         = Convert.ToInt32(context.Request["id"]);
                string                 title      = context.Request["title"];
                string                 img        = context.Request["img"];
                int                    showis     = Convert.ToInt32(context.Request["showis"]);
                string                 time       = context.Request["time"];
                string                 typename   = context.Request["typename"];
                string                 text       = context.Request["text"];
                string                 abs        = context.Request["abs"];
                BLL.blog_type          bll_type   = new BLL.blog_type();
                List <Model.blog_type> list_type  = bll_type.GetModelList("Type_name='" + typename + "'");
                Model.blogs            model_blog = new Model.blogs()
                {
                    Blog_id       = id,
                    Blog_title    = title,
                    Blog_img      = img,
                    Blog_is       = showis,
                    Blog_time     = time,
                    Blog_typeid   = list_type[0].Type_id,
                    Blog_text     = text,
                    Blog_delete   = 0,
                    Blog_abstract = abs
                };
                BLL.blogs blogs    = new BLL.blogs();
                bool      blog_add = blogs.Update(model_blog);
                if (blog_add == true)
                {
                    context.Response.Write("修改成功");
                }
                else
                {
                    context.Response.Write("修改失败");
                }
            }

            //博客类型
            if (context.Request["page"] == "type")
            {
                int             id         = Convert.ToInt32(context.Request["id"]);
                string          type       = context.Request["type"];
                int             bai        = Convert.ToInt32(context.Request["bai"]);
                Model.blog_type model_type = new Model.blog_type()
                {
                    Type_id         = id,
                    Type_name       = type,
                    Type_percentage = bai
                };
                BLL.blog_type bll_type = new BLL.blog_type();
                bool          a        = bll_type.Update(model_type);
                if (a == true)
                {
                    context.Response.Write("修改成功");
                }
                else
                {
                    context.Response.Write("修改失败");
                }
            }
        }