示例#1
0
    //用户外层repeater
    protected void rptMassage_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        if (e.CommandName == "Delete")
        {
            int massageid = Convert.ToInt32(e.CommandArgument.ToString());

            string sql = "delete from Massage where massageid='" + massageid + "'";

            int flag = myclass.DataSQL(sql);

            if (flag == 1)
            {
                Response.Write("<script>alert('删除成功!')</script>");
            }
            Server.Transfer("Message.aspx");
        }

        if (e.CommandName == "Anwser")
        {
            int id = Convert.ToInt32(Session["id"].ToString());

            int massageid = Convert.ToInt32(e.CommandArgument.ToString());

            string sql = "select * from Massage where massageid= '" + massageid + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);

            int massageuserid = Convert.ToInt32(dt.Rows[0][3].ToString());

            DateTime now = DateTime.Now;

            string txt = ((TextBox)e.Item.FindControl("txtAnwserCom")).Text;

            //sql = "insert into MassageComment (_massageid,_massageownerid,_massageuserid,massagecommendtext,_publishtime) values('" + massageid + "','" + massageuserid + "','" + id + "','" + txt + "','" + now + "')";
            string massageusername  = myclass.RerdName(id);
            string massageownername = myclass.RerdName(massageuserid);
            sql = "insert into MassageComment (_massageid,_massageownerid,_massageuserid,massagecommendtext,_publishtime,_massageownername,_massageusername) values('" + massageid + "','" + massageuserid + "','" + id + "','" + txt + "','" + now + "','" + massageownername + "','" + massageusername + "')";

            int flag = myclass.DataSQL(sql);

            if (flag == 1)
            {
                Response.Write("<script>alert('回复成功!')</script>");
            }
            Server.Transfer("Message.aspx");
        }

        if (e.CommandName == "Jump")
        {
            int friendid = Convert.ToInt32(e.CommandArgument.ToString());
            Session["Friendid"] = friendid.ToString();
            Response.Write("<script>window.location='../Person/Person.aspx'</script>");
        }
    }
    protected void btnReply_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Session["id"].ToString());
        int friendid;

        //判断是否在好友页面
        if (Session["Friendid"] == null)
        {
            friendid = id;
        }
        else
        {
            friendid = Convert.ToInt32(Session["Friendid"].ToString());
        }

        string reply = txtReply.Text;

        //验证空值
        if (reply.Length == 0)
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            int photoid = Convert.ToInt32(Request.QueryString["photoid"]);

            DateTime now = DateTime.Now;

            myClass myclass = new myClass();

            string replyername     = myclass.RerdName(id);
            string replyowenername = myclass.RerdName(friendid);
            string replyerscu      = myclass.RerdSculpture(id);
            string replyownerscu   = myclass.RerdSculpture(friendid);

            string replyclass = "photo";

            string sql = "insert into Reply (replytime,replyer,replyowner,replytext,replyername,replyownername,replyownerscu,replyerscu,replyclass,classid) values('" + now + "','" + id + "','" + friendid + "','" + reply + "','" + replyername + "','" + replyowenername + "','" + replyerscu + "','" + replyowenername + "','" + replyclass + "','" + photoid + "')";

            int flag = myclass.DataSQL(sql);

            //评论同时添加到个人中心
            DataTable dt = new DataTable();
            sql = "select * from State where photos = '" + photoid + "'";
            dt  = myclass.JudgeIor(sql);
            int stateid = Convert.ToInt32(dt.Rows[0][0].ToString());
            sql = "insert into StateComment (_stateid,_stater,_stateowner,_statetime,_statement,_photoid,_statername,_staterownername) values('" + stateid + "','" + id + "','" + friendid + "','" + now + "','" + reply + "','" + photoid + "','" + replyername + "','" + replyowenername + "')";
            int stateflag = myclass.DataSQL(sql);


            if (flag == 1)
            {
                Response.Write("<script>alert('发布成功!')</script>");
                Server.Transfer("ThePhoto.aspx");
            }
        }
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //验证登陆
        if (Session["id"] == null)
        {
            Response.Write("<script>alert('请先登录!');location='../Login.aspx'</script>");
        }
        else
        {
            myClass myclass = new myClass();
            int     id      = Convert.ToInt32(Session["id"].ToString());

            scup.ImageUrl = "../" + myclass.RerdSculpture(id);
            lbName.Text   = myclass.RerdName(id);

            string sql = "select * from LogClass where logowner='" + id + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);
            //动态绑定下拉框
            dropClass.DataSource = dt;

            dropClass.DataTextField = "classfyname";

            dropClass.DataBind();
        }
    }
示例#4
0
    protected void rptDraft_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        //发布日志
        if (e.CommandName == "Submit")
        {
            int       logid = Convert.ToInt32(e.CommandArgument.ToString());
            int       id    = Convert.ToInt32(Session["id"].ToString());
            DataTable dt    = new DataTable();
            string    sql   = "select * from Log where logid ='" + logid + "'";
            dt = myclass.JudgeIor(sql);
            string   title    = dt.Rows[0][1].ToString();
            string   simplify = dt.Rows[0][8].ToString();
            DateTime now      = DateTime.Now;
            //判断分类决定是否要同步动态到个人中心
            sql = "select * from Log where logid = '" + logid + "'";
            dt  = myclass.JudgeIor(sql);
            string compare = "所有人可见";
            if (string.Compare(compare, dt.Rows[0][5].ToString()) == 0)
            {
                sql = "update Log set draft = '1',logtime='" + now + "' where logid='" + logid + "'";
                int    flag      = myclass.DataSQL(sql);
                string name      = myclass.RerdName(id);
                string sculpture = myclass.RerdSculpture(id);
                string other     = name + "发表了日志" + title;
                string state     = "insert into State (stater,statetime,other,statelike,statername,staterscu,logs,lable) values('" + id + "','" + now + "','" + other + "',',','" + name + "','" + sculpture + "','" + logid + "','" + simplify + "')";
                int    stateflag = myclass.DataSQL(state);
            }

            Response.Write("<script>alert('发布成功!')</script>");
            Server.Transfer("Log.aspx");
        }
    }
示例#5
0
    protected void btnSub_Click(object sender, EventArgs e)
    {
        myClass myclass = new myClass();

        int      id    = Convert.ToInt32(Session["id"].ToString());
        string   state = txtState.Text;
        DateTime now   = DateTime.Now;

        //判断空值
        if (state.Length == 0)
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            //发表说说
            string name      = myclass.RerdName(id);
            string sculpture = myclass.RerdSculpture(id);
            string sql       = "insert into State (stater,statetime,statement,statelike,statername,staterscu) values('" + id + "','" + now + "','" + state + "',',','" + name + "','" + sculpture + "')";
            int    flag      = myclass.DataSQL(sql);
            if (flag == 1)
            {
                Response.Write("<script>alert('发布成功!');location='Myhistory.aspx'</script>");
            }
        }
    }
    protected void btnPub_Click(object sender, EventArgs e)
    {
        int      id      = Convert.ToInt16(Session["id"].ToString());
        int      logid   = Convert.ToInt32(Request.QueryString["logid"]);
        string   title   = txtTitle.Text;
        string   content = Request.Form["content1"];
        string   classr  = dropClass.SelectedValue;
        string   power   = dropPower.SelectedValue;
        DateTime now     = DateTime.Now;

        DataTable dt      = new DataTable();
        myClass   myclass = new myClass();

        if (title.Length == 0 || content.Length == 0)
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            string sql = "select * from LogClass where classfyname='" + classr + "'and logowner ='" + id + "'";

            dt = myclass.JudgeIor(sql);

            int classid = Convert.ToInt16(dt.Rows[0][0].ToString());
            //获取纯文本
            string simplify = System.Text.RegularExpressions.Regex.Replace(content, @"<[///!]*?[^<>]*?>", "").Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("&nbsp;", "");
            //判断是否截取
            if (simplify.Length >= 50)
            {
                simplify = simplify.Substring(0, 50) + "....";
            }
            //判断是否要发动态
            sql = "update Log set title='" + title + "',simplify='" + simplify + "',logtext='" + content + "',logtime='" + now + "',logpower='" + power + "', _classfyid='" + classid + "',draft='0' where logid = '" + logid + "'";

            int flag = myclass.DataSQL(sql);

            string name      = myclass.RerdName(id);
            string sculpture = myclass.RerdSculpture(id);
            string other     = name + "发表了日志" + title;
            string state     = "insert into State (stater,statetime,other,statelike,statername,staterscu,logs,lable) values('" + id + "','" + now + "','" + other + "',',','" + name + "','" + sculpture + "','" + logid + "','" + simplify + "')";
            int    stateflag = myclass.DataSQL(state);

            if (flag == 1)
            {
                Response.Write("<script>alert('发布成功!')</script>");
                Server.Transfer("Draft.aspx");
            }
            else
            {
                Response.Write("<script>alert('发布失败!')</script>");
                Server.Transfer("DraftEditor.aspx");
            }
        }
    }
示例#7
0
    protected void rptFriends_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        int id = Convert.ToInt32(Session["id"].ToString());

        if (e.CommandName == "Add")
        {
            int _id = Convert.ToInt32(e.CommandArgument.ToString());

            string sql1  = "select * from Friends where  me='" + id + "' and friends = '" + _id + "'";
            int    count = myclass.JudgeAcc(sql1);

            if (count > 0)
            {
                Response.Write("<script>alert('好友已存在!')</script>");
            }
            else
            {
                string name  = myclass.RerdName(id);
                string _name = myclass.RerdName(_id);

                string sql  = "insert into Friends (me,friends,myname,friendname) values('" + id + "','" + _id + "','" + name + "','" + _name + "')";
                string _sql = "insert into Friends (me,friends,myname,friendname) values('" + _id + "','" + id + "','" + _name + "','" + name + "')";

                int flag  = myclass.DataSQL(sql);
                int _flag = myclass.DataSQL(_sql);


                if (flag == 1 && _flag == 1)
                {
                    Response.Write("<script>alert('添加成功!')</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加失败!')</script>");
                }
            }
        }
    }
示例#8
0
    protected void rptAdd_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        //双向添加好友同时添加两条记录
        if (e.CommandName == "Add")
        {
            int _id = Convert.ToInt32(e.CommandArgument.ToString());
            int id  = Convert.ToInt32(Session["id"].ToString());

            string name  = myclass.RerdName(id);
            string _name = myclass.RerdName(_id);

            string sql  = "insert into Friends (me,friends,myname,friendname) values('" + id + "','" + _id + "','" + name + "','" + _name + "')";
            string _sql = "insert into Friends (me,friends,myname,friendname) values('" + _id + "','" + id + "','" + _name + "','" + name + "')";

            int flag  = myclass.DataSQL(sql);
            int _flag = myclass.DataSQL(_sql);


            if (flag == 1 && _flag == 1)
            {
                Response.Write("<script>alert('添加成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败!')</script>");
            }
        }

        //跳转至好友空间
        if (e.CommandName == "Jump")
        {
            int friendid = Convert.ToInt32(e.CommandArgument.ToString());
            Session["Friendid"] = friendid.ToString();
            Response.Write("<script>window.location='Person/Person.aspx'</script>");
        }
    }
示例#9
0
    protected void btnSub_Click(object sender, EventArgs e)
    {
        int     userid;
        myClass myclass = new myClass();

        if (Session["Friendid"] != null)
        {
            userid = Convert.ToInt32(Session["Friendid"].ToString());
        }
        else
        {
            userid = Convert.ToInt32(Session["id"].ToString());
        }
        int      id      = Convert.ToInt32(Session["id"].ToString());
        string   massage = txtMassage.Text;
        DateTime now     = DateTime.Now;

        if (massage.Length == 0)
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            string name = myclass.RerdName(id);

            string sculpture = "../" + myclass.RerdSculpture(userid);

            //string sql = "insert into Massage (massageowner,massageuser,publishtime,massagetext,ownername,ownersculpture) values ('" + id + "','" + userid + "','" + now + "','" + massage + "'.'" + name + "','" + sculpture + "')";
            string sql = "insert into Massage (massageowner,massageuser,publishtime,massagetext,ownername,ownersculpture) values('" + userid + "','" + id + "','" + now + "','" + massage + "','" + name + "','" + sculpture + "')";

            int flag = myclass.DataSQL(sql);

            if (flag == 1)
            {
                Response.Write("<script>alert('留言成功!');location='Message.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('留言失败!')</script>");
            }
        }
    }
示例#10
0
    protected void rptState_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        myClass myclass = new myClass();

        if (e.CommandName == "Anwser")
        {
            int id = Convert.ToInt32(Session["id"].ToString());

            int stateid = Convert.ToInt32(e.CommandArgument.ToString());

            string sql = "select * from State where stateid= '" + stateid + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);

            int staterid = Convert.ToInt32(dt.Rows[0][1].ToString());

            string statername = myclass.RerdName(staterid);

            string name = myclass.RerdName(id);

            DateTime now = DateTime.Now;

            string txt = ((TextBox)e.Item.FindControl("txtAnwserCom")).Text;

            if (txt.Length == 0)
            {
                Response.Write("<script>alert('输入不能为空!')</script>");
            }
            else
            {
                //判断是否要添加到相册/日志
                int flag, stateflag;

                string locks = "上传";

                if (dt.Rows[0][3].ToString().Length != 0)
                {
                    //发表说说不需要同步评论
                    stateflag = 1;
                    sql       = "insert into StateComment (_stateid,_stater,_stateowner,_statetime,_statement,_statername,_staterownername) values('" + stateid + "','" + id + "','" + staterid + "','" + now + "','" + txt + "','" + name + "','" + statername + "')";
                    flag      = myclass.DataSQL(sql);
                }
                else if (dt.Rows[0][8].ToString().Contains(locks))
                {
                    //上传相册同步评论到相册
                    int photoid = Convert.ToInt32(dt.Rows[0][11].ToString());

                    string sculpture = myclass.RerdSculpture(id);

                    sql = "insert into StateComment (_stateid,_stater,_stateowner,_statetime,_statement,_photoid,_statername,_staterownername) values('" + stateid + "','" + id + "','" + staterid + "','" + now + "','" + txt + "','" + photoid + "','" + name + "','" + statername + "')";

                    flag = myclass.DataSQL(sql);

                    string replyclass = "photo";

                    sql = "insert into Reply (replytime,replyer,replyowner,replytext,replyername,replyownername,replyownerscu,replyerscu,replyclass,classid) values('" + now + "','" + id + "','" + id + "','" + txt + "','" + name + "','" + name + "','" + sculpture + "','" + sculpture + "','" + replyclass + "','" + photoid + "')";

                    stateflag = myclass.DataSQL(sql);
                }
                else
                {
                    //上传相册同步评论到日志
                    int logid = Convert.ToInt32(dt.Rows[0][10].ToString());

                    string sculpture = myclass.RerdSculpture(id);

                    sql = "insert into StateComment (_stateid,_stater,_stateowner,_statetime,_statement,_logid,_statername,_staterownername) values('" + stateid + "','" + id + "','" + staterid + "','" + now + "','" + txt + "','" + logid + "','" + name + "','" + statername + "')";

                    flag = myclass.DataSQL(sql);

                    string replyclass = "log";

                    sql = "insert into Reply (replytime,replyer,replyowner,replytext,replyername,replyownername,replyownerscu,replyerscu,replyclass,classid) values('" + now + "','" + id + "','" + id + "','" + txt + "','" + name + "','" + name + "','" + sculpture + "','" + sculpture + "','" + replyclass + "','" + logid + "')";

                    stateflag = myclass.DataSQL(sql);
                }


                if (flag == 1)
                {
                    Response.Write("<script>alert('回复成功!');location='Home.aspx'</script>");
                }
            }
        }



        if (e.CommandName == "Like")
        {
            int id = Convert.ToInt32(Session["id"].ToString());

            int stateid = Convert.ToInt32(e.CommandArgument.ToString());

            string locks = ',' + Convert.ToString(id) + ',';

            string sql = "select * from State where stateid = '" + stateid + "'";

            DataTable dt = new DataTable();

            dt = myclass.JudgeIor(sql);

            string like = dt.Rows[0][6].ToString();

            if (like.Contains(locks))
            {
                Response.Write("<script>alert('已经点过赞了哟!');location='Home.aspx'</script>");
            }
            else
            {
                like = dt.Rows[0][6].ToString() + Convert.ToString(id) + ',';

                int count = Convert.ToInt32(dt.Rows[0][7].ToString()) + 1;

                sql = "update State set statelike ='" + like + "',statelikecount = '" + count + "' where stateid = '" + stateid + "'";

                int flag = myclass.DataSQL(sql);
                Server.Transfer("Home.aspx");
            }
        }

        if (e.CommandName == "Jump")
        {
            int friendid = Convert.ToInt32(e.CommandArgument.ToString());
            Session["Friendid"] = friendid.ToString();
            Response.Write("<script>window.location='Person/Person.aspx'</script>");
        }

        /* if (e.CommandName == "DetailLog")
         * {
         *   int friendid = Convert.ToInt32(e.CommandArgument.ToString());
         *   Session["Friendid"] = friendid.ToString();
         * }
         *
         * if (e.CommandName == "DetailPhoto")
         * {
         *   int friendid = Convert.ToInt32(e.CommandArgument.ToString());
         *   Session["Friendid"] = friendid.ToString();
         * }*/
    }
示例#11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        myClass myclass = new myClass();

        if (Session["id"] == null)
        {
            Response.Write("<script>alert('请先登录!');location='../Login.aspx'</script>");
        }
        else
        {
            int id;

            if (Session["Friendid"] != null)
            {
                id                = Convert.ToInt32(Session["Friendid"].ToString());
                divScu.Visible    = false;
                divEditor.Visible = false;
            }
            else
            {
                id = Convert.ToInt32(Session["id"].ToString());
            }

            string sql = "select * from Log where author= '" + id + "' and draft = '0'";

            DataTable dt = new DataTable();
            //绑定日志数量
            dt = myclass.JudgeIor(sql);

            lbtLog.Text = dt.Rows.Count.ToString() + "篇日志";

            sql = "select * from Album where owner='" + id + "' ";

            dt = myclass.JudgeIor(sql);
            //相册数量
            int i, sum = 0;

            int count = dt.Rows.Count;

            DataTable newdt = new DataTable();

            for (i = 0; i < count; i++)
            {
                sql   = "select * from Photo where album='" + Convert.ToInt32(dt.Rows[i][0].ToString()) + "'";
                newdt = myclass.JudgeIor(sql);
                sum   = sum + newdt.Rows.Count;
            }

            lbtAlbum.Text = Convert.ToString(sum) + "张照片";
            //留言数量
            sql             = "select * from Massage where massageowner ='" + id + "'";
            dt              = myclass.JudgeIor(sql);
            lbtMassage.Text = Convert.ToString(dt.Rows.Count) + "条留言";

            //访客记录
            if (Session["friendid"] != null)
            {
                int      freindid = Convert.ToInt32(Session["friendid"].ToString());
                int      theid    = Convert.ToInt32(Session["id"].ToString());
                DateTime now      = DateTime.Now;
                string   name     = myclass.RerdName(id);
                string   scu      = "../Album" + myclass.RerdSculpture(id);
                sql = "insert into Visitor(visitor,bevisitor,visitetime,visitorname,visitorscu) values('" + theid + "','" + freindid + "','" + now + "','" + name + "','" + scu + "')";
                myclass.DataSQL(sql);
            }

            sql          = "select * from UserList where id='" + id + "'";
            dt           = myclass.JudgeIor(sql);
            lbID.Text    = dt.Rows[0][0].ToString();
            lbName.Text  = dt.Rows[0][1].ToString();
            lbSex.Text   = dt.Rows[0][3].ToString();
            lbEmail.Text = dt.Rows[0][7].ToString();
            lbPhone.Text = dt.Rows[0][8].ToString();
        }
    }
示例#12
0
    //图片上传并将图片重命名
    protected void btnUp_Click(object sender, EventArgs e)
    {
        myClass myclass = new myClass();

        int albumid = Convert.ToInt32(Request.QueryString["albumid"]);

        try
        {
            if (fup.PostedFile.FileName == "")
            {
                lblInfo.Text = "请选择文件!";
            }
            else
            {
                //string filepath = fup.PostedFile.FileName;
                if (!IsAllowedExtension(fup))
                {
                    lblInfo.Text = "上传文件格式不正确!";
                }
                if (IsAllowedExtension(fup) == true)
                {
                    //获取文件名字上传并存储
                    string filepath   = fup.PostedFile.FileName;
                    string filename   = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                    string serverpath = Server.MapPath("picture/") + filename;
                    fup.PostedFile.SaveAs(serverpath);
                    //改绝对路径为相对路径
                    serverpath = "picture/" + filename;
                    DateTime now  = DateTime.Now;
                    string   sql  = "insert into Photo (photoname,uptime,path,album)values('" + filename + "','" + now + "','" + serverpath + "','" + albumid + "')";
                    int      flag = myclass.DataSQL(sql);
                    //判断相册权限决定是否发布动态到个人中心
                    sql = "select * from Album where albumid = '" + albumid + "'";
                    DataTable dt = new DataTable();
                    dt = myclass.JudgeIor(sql);
                    string compare = "所有人可见";
                    if (string.Compare(compare, dt.Rows[0][4].ToString()) == 0)
                    {
                        sql = "select * from Photo where uptime='" + now + "'and photoname = '" + filename + "'";

                        dt = myclass.JudgeIor(sql);
                        int    photoid   = Convert.ToInt32(dt.Rows[0][0].ToString());
                        int    id        = Convert.ToInt32(Session["id"].ToString());
                        string name      = myclass.RerdName(id);
                        string sculpture = myclass.RerdSculpture(id);
                        string other     = name + "上传了照片" + filename;
                        string state     = "insert into State (stater,statetime,other,statelike,statername,staterscu,photos) values('" + id + "','" + now + "','" + other + "',',','" + name + "','" + sculpture + "','" + photoid + "')";
                        int    stateflag = myclass.DataSQL(state);
                    }


                    if (flag == 1)
                    {
                        lblInfo.Text = "上传成功!";
                        Server.Transfer("Photo.aspx");
                    }
                    else
                    {
                        lblInfo.Text = "上传失败!";
                    }
                }
                else
                {
                    lblInfo.Text = "请上传图片!";
                }
            }
        }
        catch (Exception ex)
        {
            lblInfo.Text = "上传发生错误!原因是:" + ex.ToString();
        }
    }