Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            int userId = Int32.Parse(context.Request["user.id"]);

            UserService userService = new UserService();

            User user = userService.GetModel(userId);

            //判断是否输入新的密码,输入则更新密码,否则使用原密码
            string passWord = context.Request["user.password"];

            if (passWord != "")
            {
                user.password = MyMd5.GetMd5String(MyMd5.GetMd5String(passWord));
            }

            user.nickname = context.Request["user.nickName"];
            user.truename = context.Request["user.trueName"];
            user.sex      = context.Request["user.sex"];
            user.email    = context.Request["user.email"];
            user.mobile   = context.Request["user.mobile"];

            bool b = userService.Update(user);

            context.Response.Write(b);
            context.Response.End();
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                nickName = Request["user.nickName"];
                string passWord = MyMd5.GetMd5String(MyMd5.GetMd5String(Request["user.password"]));

                UserService userService = new UserService();

                List<User> user = userService.GetModelList("type = '3' and nickName='" + nickName + "'and passWord='******'");

                int i = user.Count();

                if (i > 0)
                {
                    Session["adminuser"] = user[0];

                    Response.Redirect("/admin/Main.aspx");

                }
                else
                {
                    error = "登录失败!";
                }
            }
        }
Пример #3
0
        //登录方法
        protected void login()
        {
            string username = Request["username"];
            string userpass = MyMd5.GetMd5String(Request["userpass"]);  //Md5加密

            UserService userService = new UserService();

            List <User> userList = userService.GetModelList("unickname= '" + username + "' and upassword= '******'");

            if (userList.Count > 0)
            {
                Session["userInfo"] = userList[0];   //存入Session

                if (!string.IsNullOrEmpty(Request["remember"]))
                {
                    //创建cookie
                    HttpCookie cookie1 = new HttpCookie("username", username);
                    HttpCookie cookie2 = new HttpCookie("userpass", userpass);

                    //设置cookie过期时间
                    cookie1.Expires = DateTime.Now.AddDays(3);
                    cookie2.Expires = DateTime.Now.AddDays(3);

                    //将cookie保存到电脑硬盘
                    Response.Cookies.Add(cookie1);
                    Response.Cookies.Add(cookie2);
                }

                Response.Redirect(prePage);
            }
            else
            {
                ErrorMsg = "登录失败,请检查用户名及密码.";
            }
        }
Пример #4
0
        //修改后更新用户信息
        protected void updateuser()
        {
            int  uid  = Int32.Parse(Request["uid"]);
            User user = userService.GetModel(uid);

            string pass = Request["pass"];

            if (pass != null && !"".Equals(pass))
            {
                user.upassword = MyMd5.GetMd5String(pass);
            }

            HttpPostedFile file = Request.Files["photo1"];  //获取上传的图片

            string photo = user.uphoto;

            if (file != null && !file.FileName.Equals(""))                                             //判断文件是否为空
            {
                string fileName = file.FileName;                                                       //获取上传文件的文件名
                string ext      = Path.GetExtension(fileName);                                         //得到上传的文件的扩展名

                if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == "jpeg" || ext == ".JPG") //判断文件类型是否符合要求
                {
                    string newFileNames = Guid.NewGuid().ToString() + ext;                             //随机产生一个新的文件名

                    photo = "/Images/face/" + newFileNames;                                            //photo存储路径+新文件名

                    string fileSavePath = Request.MapPath("/Images/face/" + newFileNames);             //请求文件的相对路径

                    file.SaveAs(fileSavePath);                                                         //将文件保存
                }
            }
            user.uphoto    = photo;
            user.unickname = Request["nickname"];
            user.uname     = Request["name"];
            user.ucard     = Request["card"];
            user.usex      = Request["sex"];
            user.uemail    = Request["email"];
            user.uqq       = Request["qq"];
            user.utel      = Request["tel"];
            user.utype     = Request["type"];

            if (userService.Update(user))
            {
                Response.Write(true);
                Response.End();
            }
            else
            {
                Response.Write(false);
                Response.End();
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string name = Request["name"];
                string pass = MyMd5.GetMd5String(MyMd5.GetMd5String(Request["pass"]));   //MD5加密两次

                WorkerService workerService = new WorkerService();

                List <Worker> workerList = workerService.GetModelList("wname='" + name + "' and wpassword = '******'");

                if (workerList.Count > 0)
                {
                    Session["adminInfo"] = workerList[0];

                    Response.Redirect("/MyAdmin/Default.aspx");
                }
                else
                {
                    ErrorMsg = "登录失败";
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                HttpPostedFile file = Request.Files["face"];      //获取上传的图片

                if (file != null && !file.FileName.Equals(""))
                {                                                                                           //判断文件是否为空
                    string fileName = file.FileName;                                                        //得到上传图片的文件名字

                    string ext = Path.GetExtension(fileName);                                               //得到上传图片的文件扩展名

                    if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == ".jpeg" || ext == ".JPG") //设定文件的类型
                    {
                        string newFileNames = Guid.NewGuid().ToString() + ext;

                        //Directory.CreateDirectory(Path.GetDirectoryName(Request.MapPath("/face/" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "/")));

                        string fileSavePath = Request.MapPath("/face/" + newFileNames);

                        face = "/face/" + newFileNames;

                        file.SaveAs(fileSavePath);       //保存图片到服务器指定的目录中去
                    }
                    else
                    {
                        face = "/images/timg.jpg";
                    }
                }
                else
                {
                    face = "/images/timg.jpg";
                }

                nickname = Request.Form["user.nickName"];
                truename = Request.Form["user.trueName"];
                sex      = Request.Form["user.sex"];
                //face = "/face/" + newFileNames;
                string password = MyMd5.GetMd5String(MyMd5.GetMd5String(Request.Form["user.password"]));
                regtime = DateTime.Now;
                mobile  = Request.Form["user.mobile"];
                email   = Request.Form["user.email"];
                type    = Request.Form["type"];

                //创建业务层,且调用业务层的方法进行用户信息添加
                UserService userService = new UserService();
                User        userInfo    = new User();

                userInfo.nickname = nickname;
                userInfo.truename = truename;
                userInfo.sex      = sex;
                userInfo.face     = face;
                userInfo.password = password;
                userInfo.regtime  = regtime;
                userInfo.mobile   = mobile;
                userInfo.email    = email;
                userInfo.type     = type;

                int i = userService.Add(userInfo);       //user表的id值

                if (i > 0)
                {
                    userInfo.id         = i; //用户主键ID
                    Session["userInfo"] = userInfo;
                    Response.Redirect("Index.aspx");
                }
                else
                {
                    msg = "注册失败,请重新注册!";
                }
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                UserService userService = new UserService();

                HttpPostedFile file = Request.Files["photo"];  //获取上传的图片

                string photo = ((User)Session["userInfo"]).uphoto;

                if (file != null && !file.FileName.Equals(""))
                {                                                                                                            //判断文件是否为空
                    string fileName = file.FileName;                                                                         //得到上传图片的文件名字

                    string ext = Path.GetExtension(fileName);                                                                //得到上传图片的文件扩展名

                    if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == ".jpeg" || ext == ".JPG" || ext == ".bmp") //设定文件的类型
                    {
                        string newFileNames = Guid.NewGuid().ToString() + ext;

                        string fileSavePath = Request.MapPath("/Images/face/" + newFileNames);

                        photo = "/Images/face/" + newFileNames;

                        file.SaveAs(fileSavePath);   //保存图片到服务器指定的目录中去
                    }
                }

                int  uid  = ((User)Session["userInfo"]).uid;
                User user = new User();
                user = userService.GetModel(uid);

                user.unickname = ((User)Session["userInfo"]).unickname;
                user.uname     = Request["name"];
                user.utype     = Request["type"];
                user.usex      = Request["sex"];
                user.uphoto    = photo;
                user.ucard     = Request["card"];
                user.utel      = Request["tel"];
                user.uqq       = Request["qq"];
                user.uemail    = Request["email"];

                //判断是否更改密码
                if (!"".Equals(Request["password1"]) && Request["password1"] != null)
                {
                    user.upassword = MyMd5.GetMd5String(Request["password1"]);
                }
                else
                {
                    user.upassword = ((User)Session["userInfo"]).upassword;
                }

                //更新方法
                if (userService.Update(user))
                {
                    Session["userInfo"] = user;

                    Response.Redirect("/Index.aspx");
                }
                else
                {
                    ErrorMsg = "修改失败!";
                }
            }
            else
            {
                if (Session["userInfo"] != null)
                {
                    //页面选择显示用户类别,性别
                    utype = ((User)Session["userInfo"]).utype;
                    sex   = ((User)Session["userInfo"]).usex;
                }
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //调用业务层的方法进行用户信息添加
            UserService userService = new UserService();
            User        userInfo    = new User();

            sex = ((User)Session["userInfo"]).sex;  //下拉菜单默认显示

            if (IsPostBack)
            {
                HttpPostedFile file = Request.Files["face"];  //获取上传的图片

                if (file != null && !file.FileName.Equals(""))
                {                                                                                           //判断文件是否为空
                    string fileName = file.FileName;                                                        //得到上传图片的文件名字

                    string ext = Path.GetExtension(fileName);                                               //得到上传图片的文件扩展名

                    if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == ".jpeg" || ext == ".JPG") //设定文件的类型
                    {
                        string newFileNames = Guid.NewGuid().ToString() + ext;

                        //Directory.CreateDirectory(Path.GetDirectoryName(Request.MapPath("/face/" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "/")));

                        string fileSavePath = Request.MapPath("/face/" + newFileNames);

                        userInfo.face = "/face/" + newFileNames;

                        file.SaveAs(fileSavePath);   //保存图片到服务器指定的目录中去
                    }
                    else
                    {
                        userInfo.face = ((bbs.Model.User)Session["userInfo"]).face;
                    }
                }
                else
                {
                    userInfo.face = ((bbs.Model.User)Session["userInfo"]).face;
                }

                userInfo.nickname = Request.Form["user.nickName"];
                userInfo.truename = Request.Form["user.trueName"];
                userInfo.sex      = Request.Form["user.sex"];
                //face = "/face/" + newFileNames;
                userInfo.password = MyMd5.GetMd5String(MyMd5.GetMd5String(Request.Form["user.password"]));
                userInfo.regtime  = DateTime.Parse(Request.Form["user.regTime"]);
                userInfo.mobile   = Request.Form["user.mobile"];
                userInfo.email    = Request.Form["user.email"];
                userInfo.type     = Request.Form["user.type"];
                userInfo.id       = Int32.Parse(Request.Form["user.id"]);

                var i = userService.Update(userInfo);   //true or false

                if (i == true)
                {
                    Session["userInfo"] = userInfo;
                    Response.Redirect("/userCenter/UserInfo.aspx");
                }
                else
                {
                    msg = "个人信息修改失败,请重新修改!";
                }
            }
        }
Пример #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                WorkerService workerService = new WorkerService();

                Worker worker = new Worker();

                HttpPostedFile file = Request.Files["photo"];  //获取上传的图片

                string photo = ((Worker)Session["adminInfo"]).wphoto;

                if (file != null && !file.FileName.Equals(""))                                             //判断文件是否为空
                {
                    string fileName = file.FileName;                                                       //获取上传文件的文件名
                    string ext      = Path.GetExtension(fileName);                                         //得到上传的文件的扩展名

                    if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == "jpeg" || ext == ".JPG") //判断文件类型是否符合要求
                    {
                        string newFileNames = Guid.NewGuid().ToString() + ext;                             //随机产生一个新的文件名

                        photo = "/Images/face/" + newFileNames;                                            //photo存储路径+新文件名

                        string fileSavePath = Request.MapPath("/Images/face/" + newFileNames);             //请求文件的相对路径

                        file.SaveAs(fileSavePath);                                                         //将文件保存
                    }
                    else
                    {
                    }
                }
                else
                {
                }

                int wid = ((Worker)Session["adminInfo"]).wid;

                worker = workerService.GetModel(wid);

                worker.wphoto  = photo;
                worker.wsex    = Request["sex"];
                worker.wcard   = Request["card"];
                worker.wtel    = Request["tel"];
                worker.wemail  = Request["email"];
                worker.wadress = Request["adress"];

                string pass = Request["newpass2"];

                if (pass != "")
                {
                    worker.wpassword = MyMd5.GetMd5String(MyMd5.GetMd5String(pass));
                }

                //修改成功返回true,否则返回false
                if (workerService.Update(worker))
                {
                    Session["adminInfo"] = worker;
                    Response.Write(true);
                    Response.End();
                }
                else
                {
                    Response.Write(false);
                    Response.End();
                }
            }
            else

            if (Session["adminInfo"] == null)
            {
                Response.Redirect("/MyAdmin/AdminLogin.aspx");
            }
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                HttpPostedFile file = Request.Files["photo"];  //获取上传的图片

                string photo = "";

                if (file != null && !file.FileName.Equals(""))
                {                                                                                                            //判断文件是否为空
                    string fileName = file.FileName;                                                                         //得到上传图片的文件名字

                    string ext = Path.GetExtension(fileName);                                                                //得到上传图片的文件扩展名

                    if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == ".jpeg" || ext == ".JPG" || ext == ".bmp") //设定文件的类型
                    {
                        string newFileNames = Guid.NewGuid().ToString() + ext;

                        string fileSavePath = Request.MapPath("/Images/face/" + newFileNames);

                        photo = "/Images/face/" + newFileNames;

                        file.SaveAs(fileSavePath);   //保存图片到服务器指定的目录中去
                    }
                    else
                    {
                        photo = "/Images/face/lbxx.jpg";  //默认头像
                    }
                }
                else
                {
                    photo = "/Images/face/lbxx.jpg";
                }

                nickname = Request["nickname"];
                name     = Request["name"];
                type     = Request["type"];
                sex      = Request["sex"];
                card     = Request["card"];
                tel      = Request["tel"];
                qq       = Request["qq"];
                email    = Request["email"];

                User user = new User();

                user.unickname = nickname;
                user.uname     = name;
                user.utype     = type;
                user.usex      = sex;
                user.uphoto    = photo;
                user.ucard     = card;
                user.utel      = tel;
                user.uqq       = qq;
                user.uemail    = email;
                user.upassword = MyMd5.GetMd5String(Request["password1"]);   //密码加密
                user.uregtime  = DateTime.Now;
                user.ucredit   = 10.ToString();

                UserService userService = new UserService();

                //调用Add方法
                if (userService.Add(user) > 0)
                {
                    Session["userInfo"] = user;
                    Response.Redirect("/Index.aspx");
                }
                else
                {
                    Response.Write("<script>alert(注册失败!)</script>");
                }
            }
        }
Пример #11
0
        //添加或更新员工信息
        protected void addorupdate()
        {
            int wid;

            if (!Int32.TryParse(Request["wid"], out wid))    //wid是否存在 wid>0修改,否则添加
            {
                wid = 0;
            }
            Worker worker = new Worker();

            if (wid > 0)
            {
                worker = workerService.GetModel(wid);
            }
            else
            {
                worker.wphoto = "/Images/face/xi.jpg";
            }

            HttpPostedFile file = Request.Files["photo"];  //获取上传的图片

            string photo = worker.wphoto;

            if (file != null && !file.FileName.Equals(""))                                             //判断文件是否为空
            {
                string fileName = file.FileName;                                                       //获取上传文件的文件名
                string ext      = Path.GetExtension(fileName);                                         //得到上传的文件的扩展名

                if (ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == "jpeg" || ext == ".JPG") //判断文件类型是否符合要求
                {
                    string newFileNames = Guid.NewGuid().ToString() + ext;                             //随机产生一个新的文件名

                    photo = "/Images/face/" + newFileNames;                                            //photo存储路径+新文件名

                    string fileSavePath = Request.MapPath("/Images/face/" + newFileNames);             //请求文件的相对路径

                    file.SaveAs(fileSavePath);                                                         //将文件保存
                }
            }

            string pass = Request["newpass2"];

            if (pass != "")
            {
                worker.wpassword = MyMd5.GetMd5String(MyMd5.GetMd5String(pass));
            }

            worker.wid     = wid;
            worker.wphoto  = photo;
            worker.wname   = Request["name"];
            worker.wsex    = Request["sex"];
            worker.wcard   = Request["card"];
            worker.wtel    = Request["tel"];
            worker.wemail  = Request["email"];
            worker.wadress = Request["adress"];
            worker.wtype   = Request["type"];

            if (workerService.addorupdate(worker))
            {
                Response.Write(true);
                Response.End();
            }
            else
            {
                Response.Write(false);
                Response.End();
            }
        }