예제 #1
0
        protected void SaveRecord(bool newRecord)
        {
            // new record / exiting record //

            object oldEntity = null;

            if (newRecord)
            {
                Entity = new CRM_Note();
                Entity.TargetReference = Request.QueryString["references"];
                Entity.OwnerAdminID    = AdminUser.ID;
                Entity.DateCreated     = UKTime.Now;
                db.CRM_Notes.InsertOnSubmit(Entity);
            }
            else
            {
                oldEntity = Entity.ShallowCopy();
            }

            Entity.Title = txtTitle.Text;
            Entity.Body  = txtBody.Text;

            db.SubmitChanges();

            if (oldEntity != null)
            {
                CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldEntity, Entity);
                db.SubmitChanges();
            }
            else
            {
                CRM.Code.History.History.RecordLinqInsert(AdminUser, Entity);
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Form.Action = Request.RawUrl;
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.NotSet);

            Entity = db.CRM_Notes.SingleOrDefault(c => c.ID.ToString() == Request.QueryString["id"]);


            // buttons //
            btnDelete.EventHandler        = btnDelete_Click;
            btnSubmit.EventHandler        = btnSubmit_Click;
            btnSubmitChanges.EventHandler = btnSubmitChanges_Click;

            // Security //

            if (!PermissionManager.CanAdd && Entity == null)
            {
                Response.Redirect("list.aspx");
            }

            // confirmations //

            confirmationDelete.StandardDeleteHidden("note", btnRealDelete_Click);

            // process //

            if (!IsPostBack)
            {
                if (Entity != null)
                {
                    if (AdminUser.ID != Entity.OwnerAdminID)
                    {
                        btnDelete.Visible        = false;
                        btnSubmitChanges.Visible = false;
                    }

                    PopulateFields();
                }
                else
                {
                    lblOwner.Text   = AdminUser.DisplayName;
                    lblCreated.Text = UKTime.Now.ToString(Constants.DefaultDateStringFormat);
                }
            }
        }