Exemplo n.º 1
0
        public void LoadReply()
        {
            if (Request.QueryString["DynamicID"] == null)
            {
                return;
            }
            Model.Dynamic dynamic = BLL.DynamicBll.GetDynamicByID(Request.QueryString["DynamicID"]);
            var           list    = from r in BLL.ReplyBll.GetReplyByDynamicID(dynamic.DynamicID)
                                    join u in BLL.UserBll.GetUserList()
                                    on r.UserNum equals u.UserNum
                                    join p in BLL.PictureBll.GetPictureList()
                                    on u.UserNum equals p.PictureNum
                                    select new
            {
                UserNum      = u.UserNum,
                UserName     = u.UserName,
                Remark       = u.Remark,
                PicturesPath = p.PicturesPath,
                ReplyContent = r.ReplyContent,
                PublishDate  = r.PublishDate
            };

            dgReplyList.DataSource = list.ToList();
            dgReplyList.DataBind();
        }
Exemplo n.º 2
0
 protected void imgPublishUserHead_Click(object sender, ImageClickEventArgs e)
 {
     Model.Dynamic dynamic = BLL.DynamicBll.GetDynamicByID(Request.QueryString["DynamicID"]);
     if (Session["LoginUser"] != null && dynamic.UserNum == (Session["LoginUser"] as Model.User).UserNum)
     {
         Response.Redirect("UserInfo.aspx");
     }
     else
     {
         Response.Redirect("OtherUserInfo.html?" + dynamic.UserNum);
     }
 }
Exemplo n.º 3
0
        public static int InsertDynamicAndPic(Model.Dynamic dynamic, List <Model.Picture> picList)
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConn"].ConnectionString))
            {
                conn.Open();
                SqlTransaction transaction = conn.BeginTransaction();
                try
                {
                    string         strSql = "insert into [Dynamic] values(@DynamicID,@DynamicTitle,@DynamicContent,@SectionID,@PublishDate,@UserNum,@ReadCount,@State)";
                    SqlParameter[] p      = { new SqlParameter("@DynamicID", dynamic.DynamicID),
                                              new SqlParameter("@DynamicTitle",   dynamic.DynamicTitle),
                                              new SqlParameter("@DynamicContent", dynamic.DynamicContent),
                                              new SqlParameter("@SectionID",      dynamic.SectionID),
                                              new SqlParameter("@PublishDate",    dynamic.PublishDate),
                                              new SqlParameter("@UserNum",        dynamic.UserNum),
                                              new SqlParameter("@ReadCount",      dynamic.ReadCount),
                                              new SqlParameter("@State",          dynamic.State) };

                    SqlCommand cmd = new SqlCommand(strSql, conn);
                    cmd.Parameters.AddRange(p);
                    cmd.Transaction = transaction;
                    cmd.ExecuteNonQuery();



                    foreach (Model.Picture item in picList)
                    {
                        strSql = "insert into [Picture] values(@PicturesPath,@PictureNum,@State)";
                        SqlParameter[] parameter = { new SqlParameter("@PictureNum",   item.PictureNum),
                                                     new SqlParameter("@PicturesPath", item.PicturesPath),
                                                     new SqlParameter("@State",        item.State) };
                        cmd.CommandText = strSql;
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddRange(parameter);
                        cmd.Transaction = transaction;
                        cmd.ExecuteNonQuery();
                    }

                    transaction.Commit();
                    return(1);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    return(0);
                }
                finally
                { conn.Close(); }
            }
        }
Exemplo n.º 4
0
        public void LoadDynamicInfo()
        {
            if (Request.QueryString["DynamicID"] == null)
            {
                return;
            }
            Model.Dynamic dynamic = BLL.DynamicBll.GetDynamicByID(Request.QueryString["DynamicID"] as string);
            if (dynamic == null)
            {
                return;
            }
            Model.User user = BLL.UserBll.GetUserByUserNum(dynamic.UserNum);
            if (Session["LoginUser"] != null && BLL.FollowBll.CheckIsFollow((Session["LoginUser"] as Model.User).UserNum, dynamic.UserNum))
            {
                btnFollow.Text = "已关注";
            }
            if (Session["LoginUser"] != null && BLL.CollectionBll.CheckIsCollect((Session["LoginUser"] as Model.User).UserNum, dynamic.DynamicID))
            {
                btnCollect.Text = "已收藏";
            }
            if (Session["LoginUser"] != null && (Session["LoginUser"] as Model.User).UserNum == user.UserNum)
            {
                btnFollow.Visible = false;
            }
            Model.Picture        userPic    = BLL.PictureBll.GetUserHeadByPicNum(user.UserNum);
            List <Model.Picture> dynamicPic = BLL.PictureBll.GetPictureByDynamicID(dynamic.DynamicID);

            lblPublisherName.Text       = user.UserName;
            imgPublishUserHead.ImageUrl = BLL.PictureBll.GetUserHeadByPicNum(user.UserNum).PicturesPath;
            lblUserRemark.Text          = user.Remark;
            lblPublishDate.Text         = dynamic.PublishDate.ToString();
            lblDynamicTitle.Text        = dynamic.DynamicTitle;
            lblDynamicContent.Text      = "   " + dynamic.DynamicContent;
            foreach (Model.Picture item in dynamicPic)
            {
                item.PicturesPath = "Image/UploadImg/watermark/" + item.PicturesPath;
            }
            dgPics.DataSource = dynamicPic;
            dgPics.DataBind();
            BLL.DynamicBll.UpdateReadCount(dynamic);
        }
Exemplo n.º 5
0
 public static int UpdateReadCount(Model.Dynamic dynamic)
 {
     dynamic.ReadCount = dynamic.ReadCount + 1;
     return(DAL.DBHelper.DataUpdateMethod <Model.Dynamic>(dynamic));
 }
Exemplo n.º 6
0
 public static int InsertDynamicAndPic(Model.Dynamic dynamic, List <Model.Picture> picList)
 {
     return(DAL.DynamicDal.InsertDynamicAndPic(dynamic, picList));
 }
Exemplo n.º 7
0
        protected void btnAddNewDynamic_Click1(object sender, EventArgs e)
        {
            if (lblGG.Text == "选择话题")
            {
                Response.Write("<script>alert('请选择话题!')</script>");
                return;
            }
            if (string.IsNullOrEmpty(textDynamicTitle.Text))
            {
                Response.Write("<script>alert('请输入帖子标题!')</script>");
                textDynamicTitle.Focus();
                return;
            }
            if (string.IsNullOrEmpty(textDynamicContent.Text))
            {
                Response.Write("<script>alert('请输入帖子内容!')</script>");
                textDynamicContent.Focus();
                return;
            }
            else if (textDynamicContent.Text.Length <= 6)
            {
                Response.Write("<script>alert('帖子内容不能少于6位!')</script>");
                textDynamicContent.Focus();
                return;
            }
            string     code  = textVerCode.Text;
            HttpCookie htco  = Request.Cookies["ImageV"];
            string     scode = htco.Value.ToString();

            if (string.IsNullOrEmpty(code) || textVerCode.Text.Length < 4 || code.ToLower() != scode.ToLower())
            {
                Response.Write("<script>alert('验证码输入不正确!')</script>");
                textVerCode.Text = "";
                textVerCode.Focus();
                return;
            }
            Model.Dynamic dynamic = new Model.Dynamic();
            dynamic.DynamicID      = "dynamic" + DateTime.Now.ToFileTime();
            dynamic.DynamicTitle   = textDynamicTitle.Text;
            dynamic.DynamicContent = textDynamicContent.Text;
            dynamic.PublishDate    = DateTime.Now;
            dynamic.SectionID      = BLL.SectionBll.GetSectionByName(lblGG.Text).SectionID;
            dynamic.UserNum        = (Session["LoginUser"] as Model.User).UserNum;
            List <Model.Picture>  picList  = new List <Model.Picture>();
            List <HttpPostedFile> fileList = Session["DynamicPicFiles"] as List <HttpPostedFile>;

            if (Session["DynamicPicFiles"] != null)
            {
                foreach (HttpPostedFile item in fileList)
                {
                    Model.Picture pic = new Model.Picture();
                    pic.PictureNum   = dynamic.DynamicID;
                    pic.PicturesPath = DateTime.Now.ToFileTime() + item.FileName.Substring(item.FileName.LastIndexOf("."));
                    picList.Add(pic);
                }
            }
            if (BLL.DynamicBll.InsertDynamicAndPic(dynamic, picList) > 0)
            {
                Response.Write("<script>alert('发表成功!')</script>");
                for (int i = 0; i < fileList.Count; i++)
                {
                    fileList[i].SaveAs(Server.MapPath("Image/UploadImg/") + picList[i].PicturesPath);
                    System.Drawing.Image img   = System.Drawing.Image.FromFile(Server.MapPath("Image/UploadImg/") + picList[i].PicturesPath);
                    Graphics             g     = Graphics.FromImage(img);
                    SolidBrush           brush = new SolidBrush(Color.Blue);
                    g.DrawString("@" + (Session["LoginUser"] as Model.User).UserName, new Font("宋体", 13f), brush, 0, 0);
                    img.Save(Server.MapPath("Image/UploadImg/watermark/") + picList[i].PicturesPath);
                    g.Dispose();
                    img.Dispose();
                    File.Delete(Server.MapPath("Image/UploadImg/") + picList[i].PicturesPath);
                }
                Session["DynamicPicFiles"] = null;
            }
            else
            {
                Response.Write("<script>alert('发表失败,数据操作错误,请联系管理员!')</script>");
            }
        }