protected void btnAdd_Click(object sender, EventArgs e)
    {
        string content = Server.HtmlDecode(myEditor11.InnerHtml);
        string op      = null;


        string       id    = Session["NowUserId"].ToString();
        string       title = txtTitle.Text.ToString();
        string       time  = DateTime.Now.ToString();
        SQLOperation sql   = new SQLOperation();
        DataTable    dtt   = sql.select(" id,amount ", " classes ", " userid = " + id + " and name = '所有日志'");
        string       allID = dtt.Rows[0][0].ToString();
        //title,content,0,0,time,classid,null
        string name = dplstClass.SelectedValue.ToString();

        if (name == null)
        {
            name = allID;
        }
        ;                                    //默认所有日志
        if (content == null)
        {
        }
        else if (Request.QueryString["op"] == null)
        {
            DataTable dt      = sql.select(" amount ", " classes ", " id=" + name);
            string    classId = name;                                                 //获得选中的类别ID

            string allAmount = (int.Parse(dtt.Rows[0][1].ToString()) + 1).ToString(); //所有日志类的内存数量要增加1

            string amount = (int.Parse(dt.Rows[0][0].ToString()) + 1).ToString();     //这个类的内存数量要增加1
            string limit  = dplstLimit.SelectedValue.ToString();
            if (sql.add(" a_diary ", " '" + title + "','" + content + "',0,0,'" + time + "'," + allID + ",'" + limit + "',null") && sql.update(" classes ", " amount = " + allAmount, " id=" + allID))
            {
                DataTable dtForAll = sql.select(" id ", " a_diary ", " time='" + time + "'");
                string    idForAll = dtForAll.Rows[0][0].ToString();
                sql.add(" a_diary ", " '" + title + "','" + content + "',0,0,'" + time + "'," + classId + ",'" + limit + "'," + idForAll);
                sql.update(" classes ", " amount = " + amount, " id=" + classId);
                Response.Write("<script> alert('添加日志成功!');location=  'DiaryPage.aspx'</script> ");
            }
        }
        else if (Request.QueryString["op"].ToString() == "edit")
        {
            DataTable dt      = sql.select(" idInAll ", " a_diary ", " id = " + Request.QueryString["articleId"].ToString());
            string    inAllId = dt.Rows[0][0].ToString(); //获得该文章在所有日志类别下的id
            string    classId = dplstClass.SelectedValue.ToString();

            if (sql.update(" a_diary ", " title ='" + title + "',Diarycontent='" + content + "',time='" + time + "',classId=" + classId + ",whocansee='" + dplstLimit.SelectedValue.ToString() + "'", " id=" + Request.QueryString["articleId"].ToString()))
            {
                sql.update(" a_diary ", " title ='" + title + "',Diarycontent='" + content + "',time='" + time + "',classId=" + allID + ",whocansee='" + dplstLimit.SelectedValue.ToString() + "'", " id=" + inAllId);
                Response.Write("<script> alert('修改日志成功!');location=  'DiaryPage.aspx'</script> ");
            }
        }
    } //保存日志按钮,包含新建和编辑的判断
示例#2
0
 protected void btnMessageAdd_Click(object sender, EventArgs e)
 {
     if (txtMessageContent == null)
     {
         helper.alertHelper(this, "留言不可以为空!");
     }
     else
     {
         string       message    = txtMessageContent.Text;
         SQLOperation sql        = new SQLOperation();
         string       messagerID = Session["NowUserId"].ToString();
         string       userId     = Request.QueryString["id"].ToString();
         string       time       = DateTime.Now.ToString();
         try
         {
             //userid,messagerid,messagecontent,time,whocansee
             sql.add(" a_message ", " " + userId + "," + messagerID + ",'" + txtMessageContent.Text + "','" + time + "','" + dplstLimit.SelectedValue.ToString() + "'");
             helper.alertHelper(this, "留言成功!", "MessagePage.aspx?id=" + userId);
         }
         catch (Exception exception)
         {
             helper.alertHelper(this, "留言失败!");
         }
     }
 }
示例#3
0
    } //创建相册按钮--点开之后使与创建有关的输入、按钮等内容可见

    protected void btnAddNew_Click(object sender, EventArgs e) //立刻创建相册按钮
    {
        if (divNewAlbum.Visible = true)
        {
            btnAddNew.Text = "立刻创建";

            string       newName = txtNewName.Text;
            string       newDes  = txtNewDescipt.Text;
            SQLOperation sql     = new SQLOperation();
            //id,userid,albumname,amount,des,null
            string id    = Session["NowUserId"].ToString();
            string limit = dplstLimit.SelectedValue.ToString();
            if (sql.add(" a_album ", " " + id + ",'" + newName + "',0,'" + newDes + "','" + limit + "'"))
            {
                divNewAlbum.Visible = false;
                btnNewAlbum.Visible = true;
                Response.Write("<script> alert('添加相册成功!');location=  'AlbumPage.aspx'</script> ");
            }
        }
        else
        {
            btnAddNew.Text      = "取消创建";
            btnNewAlbum.Visible = false;
            divNewAlbum.Visible = true;
        }
    }
    protected void rptApplications_ItemCommand(object source, RepeaterCommandEventArgs e) //所有加好友申请显示--按钮判断
    {
        SQLOperation sql    = new SQLOperation();
        string       userID = Session["NowUserId"].ToString();

        if (e.CommandName == "btnPass")
        {
            string    AppID    = e.CommandArgument.ToString();
            DataTable dt       = sql.select(" fromID ", " friendApplication ", " id=" + AppID);
            string    friendID = dt.Rows[0][0].ToString();
            if (sql.add(" friends ", " " + userID + "," + friendID))
            {
                sql.delete(" FriendApplication ", " id=" + AppID); //好友申请通过后删除申请
                Response.Write("<script> alert('添加好友成功!');</script> ");
            }
        }
        else if (e.CommandName == "btnIgnore")
        {
            string AppID = e.CommandArgument.ToString();
            if (sql.delete(" FriendApplication ", " id=" + AppID))
            {
                Response.Write("<script> alert('您已删除该申请!');</script> ");
            }
        }
    }
    protected void btnLike_Click(object sender, EventArgs e)
    {
        SQLOperation sql     = new SQLOperation();
        string       diaryId = Request.QueryString["articleId"].ToString();
        string       id      = Session["NowUserId"].ToString();

        if (btnLike.Text.StartsWith("取消赞"))
        {
            DataTable dt        = sql.select(" likeamount ", " a_diary ", " id=" + diaryId);
            int       midAmount = int.Parse(dt.Rows[0][0].ToString()) - 1;
            string    amount    = midAmount.ToString();
            if (sql.delete(" a_like ", " likedId=" + diaryId + " and userId=" + id + " and likekind='日志'") && sql.update(" a_diary ", " likeamount =" + amount + " ", " id=" + diaryId))
            {
                btnLike.Text = "赞(" + amount + ")";
            }
        }
        else
        {
            string    time      = DateTime.Now.ToString();
            DataTable dt        = sql.select(" likeamount ", " a_diary ", " id=" + diaryId);
            int       midAmount = int.Parse(dt.Rows[0][0].ToString()) + 1;
            string    amount    = midAmount.ToString();
            //userid,likedid,likekind,time
            if (sql.add(" a_like ", " " + id + "," + diaryId + ",'日志','" + time + "'") && sql.update(" a_diary ", " likeamount =" + amount + " ", " id=" + diaryId))
            {
                btnLike.Text = "取消赞(" + amount + ")";
            }
        }
    }
示例#6
0
    protected void rptPhotos_ItemCommand(object source, RepeaterCommandEventArgs e) //显示当前相册下所有照片 --- 按钮判断
    {
        SQLOperation sql      = new SQLOperation();
        string       id       = Session["NowUserId"].ToString();
        DataTable    dt       = new DataTable();
        string       rootPath = "E:/enid1/Documents/003IT/程序/QQZoneWebSite";

        if (e.CommandName == "btnDelPhoto")              //删除图片
        {
            string picID = e.CommandArgument.ToString(); //得到这张图片在数据库中的ID
            dt = sql.select(" picture ", " a_photo ", " id=" + picID);
            string path = rootPath + dt.Rows[0][0].ToString().Substring(1);
            dt = sql.select(" amount ", " a_album ", " id =" + Request.QueryString["albumId"].ToString());
            string amount = (int.Parse(dt.Rows[0][0].ToString()) - 1).ToString();
            if (File.Exists(path))
            {
                File.Delete(path);
                if (sql.delete(" a_photo ", " id=" + picID) && sql.update(" a_album ", " amount =" + amount, " id= " + Request.QueryString["albumId"].ToString()))
                {
                    Response.Write("<script> alert('删除照片成功!');location=  'AlbumPage.aspx'</script> ");
                }
            }
        }
        if (e.CommandName == "btnLikePhoto") //点赞
        {
            string time  = DateTime.Now.ToString();
            string picID = e.CommandArgument.ToString(); //得到这张图片在数据库中的ID
            Button btn   = (Button)e.Item.FindControl("btnLikePhoto");
            if (Request.QueryString["id"] != null)
            {
                id = Request.QueryString["id"].ToString();
            }

            if (btn.Text.StartsWith("赞"))
            {
                dt = sql.select(" likeamount ", " a_photo ", " id=" + picID);
                int    midAmount = int.Parse(dt.Rows[0][0].ToString()) + 1;
                string amount    = midAmount.ToString();
                //userid,likedid,likekind,time
                if (sql.add(" a_like ", " " + id + "," + picID + ",'图片','" + time + "'") && sql.update(" a_photo ", " likeamount =" + amount + " ", " id=" + picID))
                {
                    btn.Text = "取消赞(" + amount + ")";
                }
            }
            else
            {
                dt = sql.select(" likeamount ", " a_photo ", " id=" + picID);
                int    midAmount = int.Parse(dt.Rows[0][0].ToString()) - 1;
                string amount    = midAmount.ToString();
                if (sql.delete(" a_like ", " likedId=" + picID + " and userId=" + id + " and likekind='图片'") && sql.update(" a_photo ", " likeamount =" + amount + " ", " id=" + picID))
                {
                    btn.Text = "赞(" + amount + ")";
                }
            }
        }
    }
    protected void btnAddStatus_Click(object sender, EventArgs e) //添加动态按钮---DONE
    {
        string       content = txtNewStatus.Text;
        SQLOperation sqlOp   = new SQLOperation();
        string       id      = Session["NowUserId"].ToString();
        string       time    = DateTime.Now.ToShortTimeString();

        if (content != null)
        {
            //userid,time,statusContent,picture,likeAmount,SeenAmount,WhoCanSee
            sqlOp.add(" a_status ", id + ",'" + time + "','" + content + "', null, 0, 0, null");
            Response.Write("<script> alert('添加动态成功!');location=  'PersonalCenterPage.aspx'</script> ");
        }
    }
    protected void rptSearchResult_ItemCommand(object source, RepeaterCommandEventArgs e) //搜索结果的结果显示--按钮判断
    {
        if (e.CommandName == "btnAddFriend")                                              //添加好友
        {
            Button btn = (Button)e.Item.FindControl("btnAddFriend");
            if (e.Item.FindControl("txtApplication").Visible == false)
            {
                e.Item.FindControl("txtApplication").Visible     = true;
                e.Item.FindControl("btnSendApplication").Visible = true;
                btn.Text = "取消添加";
            }
            else
            {
                e.Item.FindControl("txtApplication").Visible     = false;
                e.Item.FindControl("btnSendApplication").Visible = false;
                btn.Text = "加为好友";
            }
        }
        else if (e.CommandName == "btnSendApplication") //发送请求
        {
            SQLOperation sql = new SQLOperation();

            TextBox textbox = (TextBox)e.Item.FindControl("txtApplication");
            string  note;
            if (textbox == null)
            {
                note = null;
            }
            else
            {
                note = "'" + textbox.Text + "'";
            }
            string id       = Session["NowUserId"].ToString();
            string friendID = e.CommandArgument.ToString();
            if (sql.add(" friendApplication ", " " + id + "," + friendID + "," + note + ""))
            {
                e.Item.FindControl("txtApplication").Visible     = false;
                e.Item.FindControl("btnSendApplication").Visible = false;
                Response.Write("<script> alert('您的申请已发送!');</script> ");
            }
            else
            {
                Response.Write("<script> alert('申请发送失败!');</script> ");
            }
        }
    }
示例#9
0
    protected void btnUploading_Click(object sender, EventArgs e) //上传图片在文件夹和数据库中的操作
    {
        SQLOperation   sql      = new SQLOperation();
        string         id       = Session["NowUserId"].ToString();
        HttpPostedFile hpf      = Request.Files[0];
        string         fileType = hpf.FileName.Substring(hpf.FileName.LastIndexOf(".") + 1).ToString(); //get the type
        string         albumID  = dplstAlbums.SelectedValue.ToString();                                 //获得储存照片的相册ID
        DataTable      dt       = sql.select(" amount ", " a_album ", " id=" + albumID);
        int            count    = int.Parse(dt.Rows[0][0].ToString()) + 1;

        dt = sql.select(" id ", " a_album ", " albumName='所有照片' ");// 获得默认相册的ID
        string albumDefaultID = dt.Rows[0][0].ToString();

        string time = DateTime.Now.ToShortDateString();

        if (fileType != "jpg" && fileType != "png")
        {
            Response.Write("<script>alert('上传图片类型错误!')</script>");
        }
        else if (hpf.ContentLength < 1024 || hpf.ContentLength > 1048576)
        {
            Response.Write("<script>alert('上传图片不得小于1K或不得大于1M!')</script>");
        }
        else
        {
            // 取得文件路径
            //string filePath = hpf.FileName;
            // 从路径中取出文件名用来作为保存的文件名
            string fileName = id + count.ToString() + "Pic." + fileType;
            // 取得服务器站点根目录的绝对路径
            string serverPath = Server.MapPath("~/images/");
            // 保存文件
            hpf.SaveAs(serverPath + fileName);
            //userid,picture,albumid,time,whocansee,likeAmount
            //这里添加的时候要在相册和所有照片中各加一张
            if (sql.add(" a_photo ", " " + id + ",'~/images/" + fileName + "'," + albumID + ",'" + time + "',null,0") && sql.add(" a_photo ", " " + id + ",'~/images/" + fileName + "'," + albumDefaultID + ",'" + time + "',null,0"))
            {
                Response.Write("<srcipt>alert('上传照片成功');location='AlbumPage.aspx';</script>");
            }
            else
            {
                Response.Write("<srcipt>alert('上传失败!');</script>");
            }
        }
    }
示例#10
0
    protected void btnAddClass_Click(object sender, EventArgs e)
    {
        string       className = txtAddClass.Text;
        string       id        = Session["NowUserId"].ToString();
        SQLOperation sql       = new SQLOperation();

        if (className == null)
        {
            txtAddClass.ForeColor = System.Drawing.Color.Red;
            txtAddClass.Text      = "分类名不可以为空!";
        }
        else
        {
            if (sql.add(" classes ", " " + id + " ,'" + className + "','日志',0,'T'"))
            {
                Response.Write("<script> alert('添加分类成功!');location=  'DiaryPage.aspx'</script> ");
            }
        }
    }
示例#11
0
    protected void btnAddComment_Click(object sender, EventArgs e)
    {
        string comText = txtNewComment.Text; //获得新评论的值

        if (txtNewComment == null)
        {
            txtNewComment.Text      = "评论不能为空!";
            txtNewComment.ForeColor = System.Drawing.Color.Red;
        }
        else
        {
            string id;
            if (Request.QueryString["id"] != null)
            {
                id = Request.QueryString["id"].ToString();
            }
            else
            {
                id = Session["NowUserId"].ToString();
            }

            string commentedId = Request.QueryString["articleId"].ToString();
            string time        = DateTime.Now.ToString();
            string kind        = "diary";

            SQLOperation sql = new SQLOperation();
            if (sql.add(" a_comment ", commentedId + "," + id + ",'" + comText + "','" + time + "','" + kind + "',null,null"))
            {
                txtNewComment.Visible    = false;
                btnAddComment.Visible    = false;
                btnCancelComment.Visible = false;
                Response.Write("<script> alert('添加评论成功!');location=  'DiaryWritingPage.aspx'</script> ");
            }
            else
            {
                txtNewComment.Text = "评论添加失败";
            }
        }
    }
示例#12
0
    protected void rptMessageShow_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "btnMessageDel")
        {
            SQLOperation sql       = new SQLOperation();
            string       messageID = e.CommandArgument.ToString();
            try
            {
                sql.delete(" a_message ", " id=" + messageID); //删除该条动态
                DataTable dtComments = sql.select(" id ", " a_comment ", " commentedID=" + messageID + " and kind='message'");
                for (int i = 0; i < dtComments.Rows.Count; i++)
                {
                    string commentID = dtComments.Rows[i][0].ToString(); //删除该动态下面的评论
                    sql.delete(" a_comment ", " id=" + commentID);
                }
                helper.alertHelper(this, "删除回复成功!", "MessagePage.aspx");
            }
            catch (Exception exception)
            {
                helper.alertHelper(this, "删除失败!");
            }
        }
        if (e.CommandName == "btnComment")
        {
            e.Item.FindControl("txtNewComment").Visible    = true;
            e.Item.FindControl("btnAddComment").Visible    = true;
            e.Item.FindControl("btnCancelComment").Visible = true;
        }
        if (e.CommandName == "btnCancelComment")
        {
            e.Item.FindControl("txtNewComment").Visible    = false;
            e.Item.FindControl("btnAddComment").Visible    = false;
            e.Item.FindControl("btnCancelComment").Visible = false;
        }
        if (e.CommandName == "btnAddComment")
        {
            TextBox txtNewCom = (TextBox)e.Item.FindControl("txtNewComment");
            string  comText   = txtNewCom.Text; //获得新评论的值
            if (comText == null)
            {
                txtNewCom.Text      = "评论不能为空!";
                txtNewCom.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                string id;
                if (Request.QueryString["id"] != null)
                {
                    id = Request.QueryString["id"].ToString();
                }
                else
                {
                    id = Session["NowUserId"].ToString();
                }

                string commentedId = e.CommandArgument.ToString();
                string time        = DateTime.Now.ToString();
                string kind        = "message";

                SQLOperation sql = new SQLOperation();
                if (sql.add(" a_comment ", commentedId + "," + id + ",'" + comText + "','" + time + "','" + kind + "',null"))
                {
                    e.Item.FindControl("txtNewComment").Visible    = false;
                    e.Item.FindControl("btnAddComment").Visible    = false;
                    e.Item.FindControl("btnCancelComment").Visible = false;
                    Response.Write("<script> alert('添加评论成功!');location=  'MessagePage.aspx'</script> ");
                }
                else
                {
                    txtNewCom.Text = "评论添加失败";
                }
            }
        }
    } //所有留言的显示--按钮判断
    protected void rptInReply_ItemCommand(object source, RepeaterCommandEventArgs e) //评论区RPT---DONE
    {
        if (e.CommandName == "btnCommentDel")                                        //删除评论按钮
        {
            try
            {
                SQLOperation sql       = new SQLOperation();
                string       commentID = e.CommandArgument.ToString();
                DataTable    dtReply   = sql.select(" id ", " a_comment ", " commentedID= " + commentID + " and kind='comment'");
                for (int j = 0; j < dtReply.Rows.Count; j++) //删除评论下面的回复
                {
                    sql.delete(" a_comment ", " id=" + dtReply.Rows[j][0].ToString());
                }
                sql.delete(" a_comment ", " id=" + commentID);
                helperSpecial.alertHelper(this, "删除评论成功!", "PersonalCenterPage.aspx");
            }
            catch (Exception exception)
            {
                helperSpecial.alertHelper(this, "删除评论失败!");
            }
        }
        if (e.CommandName == "btnReply")
        {
            Button btn = (Button)e.Item.FindControl("btnReply");
            if (e.Item.FindControl("btnAddReply").Visible) //正在回复时点击
            {
                btn.Text = "回复";
                e.Item.FindControl("btnAddReply").Visible = false;
                e.Item.FindControl("txtReply").Visible    = false;
            }
            else
            {
                e.Item.FindControl("btnAddReply").Visible = true;
                e.Item.FindControl("txtReply").Visible    = true;
                btn.Text = "取消回复";
            }
        }
        else if (e.CommandName == "btnAddReply")
        {
            TextBox txt = (TextBox)e.Item.FindControl("txtReply");
            string  id;
            string  content = txt.Text;
            if (content == null || content == "")
            {
                txt.ForeColor = System.Drawing.Color.Red;
                txt.Text      = "回复不可以为空!";
            }
            else
            {
                id = Session["NowUserId"].ToString();
                SQLOperation sql = new SQLOperation();
                // if(sql.add(" a_comment ","  "))
                string commentedId = e.CommandArgument.ToString();
                string time        = DateTime.Now.ToString();
                string kind        = "comment";

                if (sql.add(" a_comment ", commentedId + "," + id + ",'" + content + "','" + time + "','" + kind + "'," + commentedId))
                {
                    e.Item.FindControl("txtReply").Visible    = false;
                    e.Item.FindControl("btnReply").Visible    = false;
                    e.Item.FindControl("btnAddReply").Visible = false;
                    Response.Write("<script> alert('回复成功!');location=  'PersonalCenterPage.aspx'</script> ");
                }
                else
                {
                    txt.Text = "回复失败";
                }
            }
        }
    }
    protected void rptInInReply_ItemCommand(object source, RepeaterCommandEventArgs e) //---DONE
    {
        if (e.CommandName == "btnReplyDel")                                            //删除说说按钮
        {
            SQLOperation sql     = new SQLOperation();
            string       replyID = e.CommandArgument.ToString();
            if (sql.delete(" a_comment ", " id= " + replyID + " or commentedID =" + replyID)) //这条回复本身以及他的回复都应该被删除
            {
                helperSpecial.alertHelper(this, "删除回复成功!", "PersonalCenterPage.aspx");
            }
        }
        if (e.CommandName == "btnInReply")
        {
            Button btn = (Button)e.Item.FindControl("btnInReply");
            if (e.Item.FindControl("btnInAddReply").Visible) //正在回复时点击
            {
                btn.Text = "回复";
                e.Item.FindControl("btnInAddReply").Visible = false;
                e.Item.FindControl("txtInReply").Visible    = false;
            }
            else
            {
                e.Item.FindControl("btnInAddReply").Visible = true;
                e.Item.FindControl("txtInReply").Visible    = true;
                btn.Text = "取消回复";
            }
        }
        else if (e.CommandName == "btnInAddReply")
        {
            TextBox txt = (TextBox)e.Item.FindControl("txtInReply");
            string  id;
            string  content = txt.Text;
            if (content == null || content == "")
            {
                txt.ForeColor = System.Drawing.Color.Red;
                txt.Text      = "回复不可以为空!";
            }
            else
            {
                id = Session["NowUserId"].ToString();
                SQLOperation sql = new SQLOperation();
                // if(sql.add(" a_comment ","  "))
                string commentedId = e.CommandArgument.ToString();
                string time        = DateTime.Now.ToString();
                string kind        = "comment";

                /*获得当前所属评论的ID*/

                /* DataRowView rowv = (DataRowView)e.Item.DataItem;
                 * string FatherCommentID = rowv["id"].ToString();*/
                TextBox txtFather       = (TextBox)e.Item.FindControl("txtFatherCommentID");
                string  FatherCommentID = txtFather.Text;

                if (sql.add(" a_comment ", commentedId + "," + id + ",'" + content + "','" + time + "','" + kind + "'," + FatherCommentID))
                {
                    e.Item.FindControl("txtInReply").Visible    = false;
                    e.Item.FindControl("btnInReply").Visible    = false;
                    e.Item.FindControl("btnInAddReply").Visible = false;
                    Response.Write("<script> alert('回复成功!');location=  'PersonalCenterPage.aspx'</script> ");
                }
                else
                {
                    txt.Text = "回复失败";
                }
            }
        }
    }
    protected void rptAllStatus_ItemCommand(object source, RepeaterCommandEventArgs e) //所有动态RPT---DONE
    {
        if (e.CommandName == "btnStatusDel")
        {
            SQLOperation sql      = new SQLOperation();
            string       statusID = e.CommandArgument.ToString();
            try
            {
                sql.delete(" a_status ", " id=" + statusID); //删除该条动态
                DataTable dtComments = sql.select(" id ", " a_comment ", " commentedID=" + statusID + " and kind='status'");
                for (int i = 0; i < dtComments.Rows.Count; i++)
                {
                    string    commentID = dtComments.Rows[i][0].ToString(); //删除该动态下面的评论
                    DataTable dtReply   = sql.select(" id ", " a_comment ", " commentedID= " + commentID + " and kind='comment'");
                    for (int j = 0; j < dtReply.Rows.Count; j++)            //删除评论下面的回复
                    {
                        sql.delete(" a_comment ", " id=" + dtReply.Rows[j][0].ToString());
                    }
                    sql.delete(" a_comment ", " id=" + commentID);
                }
                helperSpecial.alertHelper(this, "删除回复成功!", "PersonalCenterPage.aspx");
            }
            catch (Exception exception)
            {
                helperSpecial.alertHelper(this, "删除失败!");
            }
        }
        if (e.CommandName == "btnLike")
        {
            int index = e.Item.ItemIndex;

            SQLOperation sql      = new SQLOperation();
            string       StatusId = e.CommandArgument.ToString();
            string       id       = Session["NowUserId"].ToString();
            Button       btn      = (Button)rptAllStatus.Items[index].FindControl("btnLike");

            if (btn.Text.StartsWith("取消赞"))
            {
                DataTable dt        = sql.select(" likeamount ", " a_status ", " id=" + StatusId);
                int       midAmount = int.Parse(dt.Rows[0][0].ToString()) - 1;
                string    amount    = midAmount.ToString();
                if (sql.delete(" a_like ", " likedId=" + StatusId + " and userId=" + id + " and likekind='说说'") && sql.update(" a_status ", " likeamount =" + amount + " ", " id=" + StatusId))
                {
                    btn.Text = "赞(" + amount + ")";
                }
            }
            else
            {
                string    time      = DateTime.Now.ToString();
                DataTable dt        = sql.select(" likeamount ", " a_status ", " id=" + StatusId);
                int       midAmount = int.Parse(dt.Rows[0][0].ToString()) + 1;
                string    amount    = midAmount.ToString();
                //userid,likedid,likekind,time
                if (sql.add(" a_like ", " " + id + "," + StatusId + ",'说说','" + time + "'") && sql.update(" a_status ", " likeamount =" + amount + " ", " id=" + StatusId))
                {
                    btn.Text = "取消赞(" + amount + ")";
                }
            }
        }
        if (e.CommandName == "btnComment")
        {
            e.Item.FindControl("txtNewComment").Visible    = true;
            e.Item.FindControl("btnAddComment").Visible    = true;
            e.Item.FindControl("btnCancelComment").Visible = true;
        }
        if (e.CommandName == "btnCancelComment")
        {
            e.Item.FindControl("txtNewComment").Visible    = false;
            e.Item.FindControl("btnAddComment").Visible    = false;
            e.Item.FindControl("btnCancelComment").Visible = false;
        }
        if (e.CommandName == "btnAddComment")
        {
            TextBox txtNewCom = (TextBox)e.Item.FindControl("txtNewComment");
            string  comText   = txtNewCom.Text; //获得新评论的值
            if (comText == null)
            {
                txtNewCom.Text      = "评论不能为空!";
                txtNewCom.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                string id;
                if (Session["NowVisitedId"] != null)
                {
                    id = Session["NowVisitedId"].ToString();
                }
                else
                {
                    id = Session["NowUserId"].ToString();
                }

                string commentedId = e.CommandArgument.ToString();
                string time        = DateTime.Now.ToString();
                string kind        = "status";

                SQLOperation sql = new SQLOperation();
                if (sql.add(" a_comment ", commentedId + "," + id + ",'" + comText + "','" + time + "','" + kind + "',null"))
                {
                    e.Item.FindControl("txtNewComment").Visible    = false;
                    e.Item.FindControl("btnAddComment").Visible    = false;
                    e.Item.FindControl("btnCancelComment").Visible = false;
                    Response.Write("<script> alert('添加评论成功!');location=  'PersonalCenterPage.aspx'</script> ");
                }
                else
                {
                    txtNewCom.Text = "评论添加失败";
                }
            }
        }
    }
示例#16
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        SpecialOperations operate = new SpecialOperations();
        string            number  = operate.generateRandomNum(10);

        string sex;

        if (btnMan.Checked)
        {
            sex = btnMan.Text;
        }
        else if (btnWoman.Checked)
        {
            sex = btnWoman.Text;
        }
        else
        {
            sex = null;
        }

        string checkCode = Session["checkCode"].ToString();

        bool emptyJudge      = operate.nullString(txtName.Text) || operate.nullString(sex) || operate.nullString(txtEmail.Text) || operate.nullString(txtCode.Text) || operate.nullString(txtPwdSet.Text) || operate.nullString(txtPwdSure.Text);
        bool overLengthJudge = operate.overLength(txtName.Text, 20) || operate.overLength(txtEmail.Text, 20) || operate.overLength(txtCode.Text, 6) || operate.overLength(txtPwdSet.Text, 10);

        if (emptyJudge)
        {
            Response.Write("<script> alert('有内容尚未完成!');</script> ");
        }
        else if (overLengthJudge)
        {
            Response.Write("<script> alert('有内容超出限定长度!');</script> ");
        }
        else if (operate.not_equal(txtPwdSet.Text, txtPwdSure.Text))
        {
            Response.Write("<script> alert('两次输入的密码不一致');</script> ");
        }
        else if (operate.not_equal(checkCode, txtCode.Text))
        {
            Response.Write("<script> alert('验证码错误');</script> ");
        }
        else
        {
            SQLOperation sql = new SQLOperation();
            //    sql = new SQLOperation();
            string nickname    = txtName.Text;
            string password    = operate.MD5String(txtPwdSet.Text);
            string loginstatus = "下线";
            string email       = txtEmail.Text;
            //' nickname  ','number','password','loginstatus','name','sex','age','headpicture','email','birthday'
            string values = "N'" + nickname + "', " + "N'" + number + "','" + password + "',N'" + loginstatus + "','" + null + "',N'" + sex + "','" + null + "',' ~\\images\\default.png ','" + email + "','" + null + "'";

            if (sql.add(" users ", values))
            {
                DataTable dt = sql.select(" id ", " users ", " number = '" + number + "'");
                string    id = dt.Rows[0][0].ToString();
                string    zoneDefultValue = id + ",N'" + nickname + "的空间'"; //give a default name for zone
                //userid,name,classkind,amount
                sql.add(" classes ", " " + id + " ,'所有日志','日志',0,'F'");     //注册就得到一个存放所有日志的默认分类
                sql.add(" a_album ", " " + id + ",'所有照片',0,null,null,'F'"); //注册的到一个默认相册
                if (sql.add(" zoneInfo ", zoneDefultValue))
                {
                    Response.Write("<script> alert('注册成功你的账号是" + number + "');location=  'MainPage.aspx'</script> ");
                }
            }
            else
            {
                Response.Write("<script> alert('注册失败');</script>");
            }


            /*全部清空*/
            txtEmail.Text = null;
            txtCode.Text  = null;

            txtPwdSet.Text  = null;
            txtPwdSure.Text = null;
            txtName.Text    = null;
        }
    }