Пример #1
0
        protected void SaveRecord(bool newRecord)
        {
            // new record / exiting record //

            object oldEntity  = null;
            object oldAddress = null;

            if (newRecord)
            {
                PersonPersonal              = new CRM_PersonPersonal();
                PersonPersonal.CRM_Address  = new CRM_Address();
                PersonPersonal.IsArchived   = false;
                PersonPersonal.CRM_PersonID = Entity.ID;
                db.CRM_PersonPersonals.InsertOnSubmit(PersonPersonal);
            }
            else
            {
                oldEntity  = PersonPersonal.ShallowCopy();
                oldAddress = PersonPersonal.CRM_Address.ShallowCopy();
            }

            PersonPersonal.Description = txtDescription.Text;
            PersonPersonal.Telephone   = txtTelephone.Text;
            PersonPersonal.Email       = txtEmail.Text;
            PersonPersonal.IsPrimary   = chkMakePrimary.Checked;

            ucAddress.Save(PersonPersonal.CRM_Address);
            db.SubmitChanges();

            PersonPersonal.CRM_Address.ParentID = PersonPersonal.ID;
            if (oldEntity != null)
            {
                CRM.Code.History.History.RecordLinqUpdate(db, AdminUser, oldEntity, PersonPersonal);
                CRM.Code.History.History.RecordLinqUpdate(db, AdminUser, oldAddress, PersonPersonal.CRM_Address);
                db.SubmitChanges();
            }
            else
            {
                CRM.Code.History.History.RecordLinqInsert(AdminUser, PersonPersonal);
                CRM.Code.History.History.RecordLinqInsert(AdminUser, PersonPersonal.CRM_Address);
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.NotSet);
            PersonPersonal = db.CRM_PersonPersonals.SingleOrDefault(c => c.ID.ToString() == Request.QueryString["pid"]);

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

            ucNavPerson.Entity = Entity;
            ucLogNotes.INotes  = PersonPersonal;
            // buttons //

            btnSubmit.EventHandler        = btnSubmit_Click;
            btnSubmitChanges.EventHandler = btnSubmitChanges_Click;
            btnDelete.EventHandler        = btnDelete_Click;
            btnReinstate.EventHandler     = btnReinstate_Click;
            // Security //

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;
            btnDelete.Visible        = PermissionManager.CanDelete;
            if (!PermissionManager.CanAdd && Entity == null)
            {
                Response.Redirect("list.aspx");
            }

            // confirmations //

            confirmationDelete.StandardDeleteHidden("personal record", btnRealDelete_Click);

            // process //
            CRMContext = PersonPersonal;
            if (!IsPostBack)
            {
                if (PersonPersonal != null)
                {
                    PopulateFields();
                }
            }
        }