Esempio n. 1
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        String spt   = Session["personId"].ToString();
        int    supid = Convert.ToInt32(spt);
        string nameSurname;

        string[]         values;
        string           name;
        string           surname;
        BOOKGRAMEntities db           = new BOOKGRAMEntities();
        MessageList      sendMesseage = new MessageList();

        sendMesseage.IsActive     = true;
        sendMesseage.IsRead       = false;
        sendMesseage.MessageText  = txtMesseage.Text;
        sendMesseage.senderUserId = supid;
        nameSurname = ddlReceiver.Text;
        values      = nameSurname.Split(' ');
        name        = values[0];
        surname     = values[1];
        Person t = (from x in db.Person where x.FirstName == name && x.LastName == surname select x).SingleOrDefault();

        sendMesseage.receiverUserId = t.PersonId;
        db.MessageList.Add(sendMesseage);
        db.SaveChanges();
        Response.Redirect("Messeage.aspx");
    }
Esempio n. 2
0
    protected void grdTeamOp_RowsCanceling(object sender, GridViewCancelEditEventArgs e)
    {
        grdTeamOp.EditIndex = -1;
        BOOKGRAMEntities db  = new BOOKGRAMEntities();
        String           spt = Session["personId"].ToString();
        int supid            = Convert.ToInt32(spt);

        Friend[] friendList = (from x in db.Friend where x.isActive == true && (x.Friend1Id == supid || x.Friend2Id == supid) select x).ToArray();

        db.SaveChanges();


        grdTeamOp.DataSource = friendList;
        grdTeamOp.DataBind();
    }
Esempio n. 3
0
    protected void grdSupUpdate_editingRow(object sender, GridViewEditEventArgs e)
    {
        String spt   = Session["personId"].ToString();
        int    supid = Convert.ToInt32(spt);

        grdSupUpdate.EditIndex = e.NewEditIndex;
        BOOKGRAMEntities db = new BOOKGRAMEntities();

        Person[] teamList = (from x in db.Person where x.IsActive == true && x.PersonId == supid select x).ToArray();


        grdSupUpdate.DataSource = teamList;
        db.SaveChanges();


        grdSupUpdate.DataBind();
    }
Esempio n. 4
0
    protected void grdTeamOp_RowsDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow      row         = (GridViewRow)grdTeamOp.Rows[e.RowIndex];
        Label            lbldeleteid = (Label)row.FindControl("lblId");
        BOOKGRAMEntities db          = new BOOKGRAMEntities();
        int    id = Convert.ToInt32(lbldeleteid.Text);
        Friend c  = (from x in db.Friend where x.FriendId == id && x.isActive == true select x).SingleOrDefault();

        if (c != null)
        {
            c.isActive = false;
        }

        db.SaveChanges();


        grdTeamOp.DataBind();
    }
Esempio n. 5
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        String spt   = Session["postId"].ToString();
        int    supid = Convert.ToInt32(spt);
        String sspt  = Session["personId"].ToString();
        int    perid = Convert.ToInt32(sspt);
        //lblPostId.Text = spt;
        BOOKGRAMEntities db         = new BOOKGRAMEntities();
        Comment          newComment = new Comment();

        newComment.CommentText = txtPost.Text;
        newComment.IsActive    = true;
        newComment.PostId      = supid;
        newComment.PersonId    = perid;
        db.Comment.Add(newComment);
        db.SaveChanges();
        Response.Redirect("CommentPage.aspx");
    }
Esempio n. 6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        RegService       rg = new RegService();
        BOOKGRAMEntities db = new BOOKGRAMEntities();

        Person newSupporter = new Person();

        newSupporter.FirstName = txtboxName.Text;
        newSupporter.LastName  = txtboxSurname.Text;
        newSupporter.Email     = txtboxEmail.Text;
        newSupporter.BirthDate = Convert.ToDateTime(txtboxDate.Text);
        newSupporter.City      = txtboxAddress.Text;

        newSupporter.Friend_num = 0;
        //HIDEYI SOR

        newSupporter.IsActive    = true;
        newSupporter.Post_num    = 0;
        newSupporter.Message_num = 0;
        newSupporter.Username    = txtboxUsername.Text;
        newSupporter.Friend_num  = 0;



        newSupporter.Password = rg.makePersonPassword(txtboxPass.Text);
        if (fuLogoUp.HasFile)
        {
            fuLogoUp.SaveAs(Server.MapPath("~/Logos/" + fuLogoUp.FileName));
        }
        newSupporter.Imagepath = "~/Logos/" + fuLogoUp.FileName;
        if (chcBox.Checked == true)
        {
            newSupporter.Hide = true;
        }
        else
        {
            newSupporter.Hide = false;
        }


        db.Person.Add(newSupporter);
        db.SaveChanges();
        Response.Redirect("Register.aspx");
    }
    protected void grdTeamOp_RowsDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow      row         = (GridViewRow)grdTeamOp.Rows[e.RowIndex];
        Label            lbldeleteid = (Label)row.FindControl("lblId");
        BOOKGRAMEntities db          = new BOOKGRAMEntities();
        int    id    = Convert.ToInt32(lbldeleteid.Text);
        String spt   = Session["personId"].ToString();
        int    supid = Convert.ToInt32(spt);

        Friend newFriend = new Friend();

        newFriend.Friend1Id = supid;
        newFriend.Friend2Id = id;
        newFriend.isActive  = false;
        db.Friend.Add(newFriend);

        db.SaveChanges();


        grdTeamOp.DataBind();

        Response.Redirect("FriendList.aspx");
    }
Esempio n. 8
0
    protected void rptCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName.ToString() == "like")
        {
            BOOKGRAMEntities db = new BOOKGRAMEntities();

            int    postId;
            String id;
            id     = e.CommandArgument.ToString();
            postId = Convert.ToInt32(id);
            Post te = (from x in db.Post where x.PostId == postId select x).SingleOrDefault();
            te.Like_num++;
            db.SaveChanges();

            Response.Redirect("Default.aspx");
        }
        else if (e.CommandName.ToString() == "dislike")
        {
            BOOKGRAMEntities db = new BOOKGRAMEntities();

            int    postId;
            String id;
            id     = e.CommandArgument.ToString();
            postId = Convert.ToInt32(id);
            Post te = (from x in db.Post where x.PostId == postId select x).SingleOrDefault();
            te.Dislike_num++;
            db.SaveChanges();
            Response.Redirect("Default.aspx");
        }
        else if (e.CommandName.ToString() == "comment")
        {
            Session["postId"] = e.CommandArgument.ToString();

            Response.Redirect("CommentPage.aspx");
        }
    }
Esempio n. 9
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        BOOKGRAMEntities db  = new BOOKGRAMEntities();
        String           spt = Session["personId"].ToString();
        int supid            = Convert.ToInt32(spt);

        Post newPost = new Post();

        newPost.PostText    = txtPost.Text;
        newPost.Dislike_num = 0;
        newPost.Like_num    = 0;
        newPost.IsActive    = true;
        newPost.PersonId    = supid;
        newPost.Comment_num = 0;


        if (fuLogoUp.Visible == true)
        {
            if (fuLogoUp.HasFile)
            {
                fuLogoUp.SaveAs(Server.MapPath("~/Logos/" + fuLogoUp.FileName));
            }
            newPost.ImagePath  = "~/Logos/" + fuLogoUp.FileName;
            newPost.PostTypeId = 2;
        }
        else
        {
            newPost.PostTypeId = 1;
        }



        db.Post.Add(newPost);
        db.SaveChanges();
        Response.Redirect("AddPost.aspx");
    }
    protected void rptCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName.ToString() == "delete")
        {
            string nameSurname;
            //string[] values;
            //string name;
            //string surname;
            BOOKGRAMEntities db = new BOOKGRAMEntities();
            //nameSurname = ddlReceiver.SelectedValue.ToString();
            //values = nameSurname.Split(' ');
            //name = values[0];
            //surname = values[1];
            int    messeageId;
            String id;
            id         = e.CommandArgument.ToString();
            messeageId = Convert.ToInt32(id);
            MessageList te = (from x in db.MessageList where x.MessageId == messeageId select x).SingleOrDefault();
            te.IsActive = false;
            db.SaveChanges();

            Response.Redirect("MesseageList.aspx");
        }
    }