Beispiel #1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text != txtPwdConfirm.Text)
            {
                LayerShow.Msg(this, "两次输入密码不同");
                return;
            }
            //定义一个userBLL
            UserBLL userBLL = new UserBLL();

            //判断是否被注册
            if (userBLL.IsExist(txtUsername.Text.Trim()) == true)
            {
                LayerShow.Msg(this, "该邮箱已经被注册了");
            }
            else
            {
                //获取填写的学生注册信息
                User user = new User();
                user.Email = txtUsername.Text.Trim();
                user.Pwd   = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "MD5");
                bool result = userBLL.Register(user);
                if (result == true)
                {
                    Session["userName"] = txtUsername.Text.Trim();
                    LayerShow.Alert(this, "注册成功,快去为自己更换一个头像吧!", "Index.aspx");
                }
                else
                {
                    LayerShow.Msg(this, "注册失败");
                }
            }
        }
        protected void btnLike_Click(object sender, EventArgs e)
        {
            string ip = "";

            if (Request.ServerVariables["HTTP_VIA"] != null)
            {
                ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
            }
            else
            {
                ip = Request.ServerVariables["REMOTE_ADDR"].ToString();
            }
            if (ip != "")
            {
                if (foodBLL.LikeFromAny(ip, food.ID))
                {
                    LayerShow.Msg(this, "赞+1");
                }
                else
                {
                    LayerShow.Msg(this, "一天只能赞一次");
                }
            }
            else
            {
                LayerShow.Msg(this, "IP获取失败");
            }
        }
 protected void btnFarvorite_Click(object sender, EventArgs e)
 {
     if (Session["userName"] != null)
     {
         User user = userBLL.QueryInfo(Session["userName"].ToString());
         if (user != null)
         {
             if (foodBLL.FarvoriteFromUser(user.ID, food.ID))
             {
                 LayerShow.Msg(this, "收藏成功");
             }
             else
             {
                 if (foodBLL.RemoveFarvorite(user.ID, food.ID))
                 {
                     LayerShow.Msg(this, "取消收藏");
                 }
                 else
                 {
                     LayerShow.Msg(this, "内部错误");
                 }
             }
         }
         else
         {
             LayerShow.Alert(this, "内部错误,无效的用户ID", "Index.aspx");
         }
     }
     else
     {
         LayerShow.Msg(this, "登陆才能收藏哟");
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["id"] != null)
     {
         string id = Request.QueryString["id"];
         food = foodBLL.Query(id);
         if (food != null)
         {
             author = userBLL.QueryInfoByID(food.UploaderID);
             if (author != null)
             {
                 this.titleFood.InnerHtml    = food.Title;
                 this.imgFood.Src            = "Static/Image/Cover/cover_" + food.Cover;
                 this.textFood.InnerHtml     = food.Contents;
                 this.imgFace.Src            = "Static/Image/Face/face_avatar1_" + author.FacePath + ".jpg";
                 this.textEmail.InnerHtml    = author.Email;
                 this.textNickName.InnerHtml = author.NickName;
             }
             else
             {
                 LayerShow.Alert(this, "内部错误,无效的上传者ID", "Index.aspx");
             }
         }
         else
         {
             E : \ web设计 \ FoodStory \ FoodStory \ Static \ CSS \ bootstrap - theme.min.css
             LayerShow.Alert(this, "无法找到该页面", "Index.aspx");
         }
     }
     else
     {
         Response.Redirect("~/Index.aspx");
     }
 }
Beispiel #5
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text.Length < 3 || txtUsername.Text.Length > 40)
            {
                LayerShow.Msg(this, "用户名长度不合法");
                return;
            }
            if (txtPassword.Text.Length < 6 || txtUsername.Text.Length > 32)
            {
                LayerShow.Msg(this, "密码长度不合法");
                return;
            }

            if (chkRember.Checked)
            {
                Response.Cookies["FoodPrevUser"].Value   = txtUsername.Text;
                Response.Cookies["FoodPrevUser"].Expires = DateTime.Now.AddDays(7);
            }

            UserBLL userBLL = new UserBLL();

            if (userBLL.VerifyPwd(txtUsername.Text, txtPassword.Text))
            {
                Session["userName"] = txtUsername.Text;
                Response.Redirect("~/Index.aspx");
            }
            else
            {
                LayerShow.Msg(this, "用户名或者密码错误");
            }
        }
Beispiel #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["userName"] == null)
         {
             LayerShow.Alert(this, "请先登录", "Login.aspx");
         }
     }
 }
Beispiel #7
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Session["userName"] != null)
            {
                UserBLL userBLL = new UserBLL();
                User    user    = userBLL.QueryInfo(Session["userName"].ToString());
                if (user == null)
                {
                    LayerShow.Alert(this, "请先登录", "Login.aspx");
                    return;
                }
                FoodBLL foodBLL = new FoodBLL();
                Food    food    = new Food();
                food.UploaderID = user.ID;
                if (txtTitle.Text.Length >= 4 && txtTitle.Text.Length <= 30)
                {
                    food.Title = txtTitle.Text;
                }
                else
                {
                    LayerShow.Msg(this, "标题的长度必须为4~30个字符");
                    return;
                }
                //简单的二次过滤(仍旧不安全),我相信ckeditor的过滤...
                food.Contents = CheckStr(txtCkeditor.Value);
                //读取POST进来的图片
                HttpPostedFile file        = Request.Files[Request.Files.AllKeys[0]];
                string         fileName    = DateTime.Now.ToString("yyyyMMddhhmmssff") + CreateRandomCode(8);
                int            pos         = file.FileName.LastIndexOf(".");
                string         extName     = file.FileName.Substring(pos, file.FileName.Length - pos);
                string         virtualPath = string.Format("~/Static/Image/Cover/cover_{0}{1}", fileName, extName);
                file.SaveAs(Server.MapPath(virtualPath));
                food.Cover = fileName + extName;

                if (foodBLL.Insert(food) == true)
                {
                    LayerShow.Alert(this, "美食分享成功", "Index.aspx");
                }
                else
                {
                    LayerShow.Alert(this, "分享出错", "Share.aspx");
                }
            }
            else
            {
                LayerShow.Alert(this, "请先登录", "Login.aspx");
            }
        }
 protected void btnModifyPwd_Click(object sender, EventArgs e)
 {
     if (Session["userName"] != null)
     {
         UserBLL userBLL = new UserBLL();
         User    user    = userBLL.QueryInfo(Session["userName"].ToString());
         if (userBLL.ModifyPwd(Session["userName"].ToString(), txtOldPwd.Text, txtNewPwdConfirm.Text))
         {
             LayerShow.Alert(this, "密码修改成功", "Information.aspx");
         }
         else
         {
             LayerShow.Alert(this, "密码修改失败", "Information.aspx");
         }
     }
     else
     {
         LayerShow.Alert(this, "请先登录", "Login.aspx");
     }
 }
Beispiel #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["userName"] == null)
         {
             LayerShow.Alert(this, "请先登录", "Login.aspx");
         }
         else
         {
             UserBLL userBLL = new UserBLL();
             User    user    = userBLL.QueryInfo(Session["userName"].ToString());
             txtUID.Text      = user.ID;
             txtUsername.Text = user.Email;
             txtNickName.Text = user.NickName;
             ddlSex.Value     = user.Sex;
             txtPhone.Text    = user.Phone;
             txtQQ.Text       = user.QQ;
         }
     }
 }
        protected void btnSubmitInfo_Click(object sender, EventArgs e)
        {
            if (Session["userName"] != null)
            {
                UserBLL userBLL = new UserBLL();
                User    user    = userBLL.QueryInfo(Session["userName"].ToString());
                if (user == null)
                {
                    LayerShow.Alert(this, "请先登录", "Login.aspx");
                    return;
                }
                user.NickName = txtNickName.Text.Replace(" ", "");
                if (ddlSex.Value == "保密" || ddlSex.Value == "男" || ddlSex.Value == "女")
                {
                    user.Sex = ddlSex.Value;
                }
                else
                {
                    LayerShow.Msg(this, "性别信息有误");
                    return;
                }
                user.Phone = txtPhone.Text;
                user.QQ    = txtQQ.Text;

                if (userBLL.ModifyInfo(user) == true)
                {
                    LayerShow.Alert(this, "用户资料修改成功", "Information.aspx");
                }
                else
                {
                    LayerShow.Alert(this, "用户资料修改失败", "Information.aspx");
                }
            }
            else
            {
                LayerShow.Alert(this, "请先登录", "Login.aspx");
            }
        }