protected void gvComments_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int commentID = Convert.ToInt32(e.CommandArgument);

            CarrierComment comment = null;

            if (e.CommandName == "DoEdit")
            {
                ViewState["CarrierCommentID"] = e.CommandArgument.ToString();

                comment = CarrierCommentManager.Get(commentID);

                if (comment != null)
                {
                    showEditPanel();

                    txtComment.Text = comment.CommentText;
                }
            }
            else if (e.CommandName == "DoDelete")
            {
                CarrierCommentManager.Delete(commentID);

                showGridPanel();

                bindComments();
            }
        }
Пример #2
0
        public static CarrierComment Get(int id)
        {
            CarrierComment comment = null;

            comment = (from x in DbContextHelper.DbContext.CarrierComment
                       where x.CommentId == id
                       select x).First <CarrierComment>();

            return(comment);
        }
Пример #3
0
        public static CarrierComment Save(CarrierComment comment)
        {
            if (comment.CommentId == 0)
            {
                DbContextHelper.DbContext.Add(comment);
            }

            DbContextHelper.DbContext.SaveChanges();

            return(comment);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int commentID = 0;

            Page.Validate("Comment");
            if (!Page.IsValid)
            {
                return;
            }

            CarrierComment comment = null;

            // carrier being edited
            commentID = Convert.ToInt32(ViewState["CarrierCommentID"]);

            if (commentID == 0)
            {
                comment = new CarrierComment();

                comment.CarrierID = carrierID;

                comment.CommentDate = DateTime.Now;

                comment.Status = true;
            }

            comment.CommentText = txtComment.Text.Trim();

            comment.UserId = Core.SessionHelper.getUserId();



            try {
                CarrierCommentManager.Save(comment);

                bindComments();

                showGridPanel();

                lblMessage.Text     = "Comment saved successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text     = "Comment not saved successfully.";
                lblMessage.CssClass = "error";

                Core.EmailHelper.emailError(ex);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int commentID = 0;

            Page.Validate("Comment");
            if (!Page.IsValid)
                return;

            CarrierComment comment = null;

            // carrier being edited
            commentID = Convert.ToInt32(ViewState["CarrierCommentID"]);

            if (commentID == 0) {
                comment = new CarrierComment();

                comment.CarrierID = carrierID;

                comment.CommentDate = DateTime.Now;

                comment.Status = true;
            }

            comment.CommentText = txtComment.Text.Trim();

            comment.UserId = Core.SessionHelper.getUserId();

            try {
                CarrierCommentManager.Save(comment);

                bindComments();

                showGridPanel();

                lblMessage.Text = "Comment saved successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text = "Comment not saved successfully.";
                lblMessage.CssClass = "error";

                Core.EmailHelper.emailError(ex);
            }
        }
Пример #6
0
        public static void Delete(int id)
        {
            // Create an entity to represent the Entity you wish to delete
            // Notice you don't need to know all the properties, in this
            // case just the ID will do.
            CarrierComment comment = new CarrierComment {
                CommentId = id
            };

            // Now attach the category stub object to the "Categories" set.
            // This puts the Entity into the context in the unchanged state,
            // This is same state it would have had if you made the query
            DbContextHelper.DbContext.AttachTo("CarrierComments", comment);


            // Do the delete the category
            DbContextHelper.DbContext.DeleteObject(comment);

            // Apply the delete to the database
            DbContextHelper.DbContext.SaveChanges();
        }