Ejemplo n.º 1
0
        protected void gvComments_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int commentID = 0;
            int leadID    = 0;

            if (e.CommandName == "DoDelete")
            {
                commentID = Convert.ToInt32(e.CommandArgument.ToString());

                try {
                    LeadCommentManager.Delete(commentID);

                    // refresh comments list
                    int.TryParse(Session["LeadIds"].ToString(), out leadID);

                    FillComments(leadID);
                }
                catch (Exception ex) {
                }
            }

            if (e.CommandName == "DoEdit")
            {
                dvEdit.Visible = true;

                commentID = Convert.ToInt32(e.CommandArgument.ToString());

                LeadComment comment = LeadCommentManager.GetLeadCommentById(commentID);

                txtComment.Text = comment.CommentText;

                hfCommentId.Value = commentID.ToString();
            }
        }
Ejemplo n.º 2
0
        protected void btnSaveContinue_Click(object sender, EventArgs e)
        {
            lblError.Text      = string.Empty;
            lblError.Visible   = false;
            lblMessage.Text    = string.Empty;
            lblMessage.Visible = false;
            lblSave.Text       = string.Empty;
            lblSave.Visible    = false;
            int commentID = 0;

            try {
                if (int.TryParse(hfCommentId.Value, out commentID) && commentID > 0)
                {
                    LeadComment comment = LeadCommentManager.GetLeadCommentById(commentID);
                    comment.CommentText = txtComment.Text.Trim();
                    comment.UserId      = Convert.ToInt32(Session["UserId"]);

                    LeadComment objld  = LeadCommentManager.Save(comment);
                    int         LeadID = Convert.ToInt32(hfLeadsId.Value);

                    lblSave.Text    = "Comment Saved Successfully";
                    lblSave.Visible = true;
                    txtComment.Text = string.Empty;
                    FillComments(LeadID);
                    dvEdit.Visible        = false;
                    btnNewComment.Visible = true;
                    btnCancelNew.Visible  = true;
                }
                else
                {
                    LeadComment objLeadComment = new LeadComment();
                    int         LeadID         = 0;
                    if (hfLeadsId.Value != null && Convert.ToInt32(hfLeadsId.Value) > 0)
                    {
                        LeadID = Convert.ToInt32(hfLeadsId.Value);
                    }
                    else
                    {
                        lblError.Text    = string.Empty;
                        lblError.Text    = "There is a problem to save.";
                        lblError.Visible = true;
                        return;
                    }
                    objLeadComment.LeadId      = LeadID;
                    objLeadComment.UserId      = Convert.ToInt32(Session["UserId"]);
                    objLeadComment.CommentText = txtComment.Text;
                    objLeadComment.Status      = 1;
                    LeadComment objld = LeadCommentManager.Save(objLeadComment);
                    if (objLeadComment.CommentId > 0)
                    {
                        lblSave.Text    = string.Empty;
                        lblSave.Text    = "Comment Saved Successfully";
                        lblSave.Visible = true;
                        txtComment.Text = string.Empty;
                        FillComments(LeadID);
                        dvEdit.Visible        = false;
                        btnNewComment.Visible = true;
                        btnCancelNew.Visible  = true;
                    }
                }
            }
            catch (Exception ex) {
                lblError.Text    = string.Empty;
                lblError.Text    = "There is a problem to save.";
                lblError.Visible = true;
            }
        }