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

            object oldEntity = null;

            if (newRecord)
            {
                PersonOrganisation              = new CRM_PersonOrganisation();
                PersonOrganisation.IsArchived   = false;
                PersonOrganisation.CRM_PersonID = Entity.ID;
                db.CRM_PersonOrganisations.InsertOnSubmit(PersonOrganisation);
            }
            else
            {
                oldEntity = PersonOrganisation.ShallowCopy();
            }

            PersonOrganisation.Telephone        = txtTelephone.Text;
            PersonOrganisation.Email            = txtEmail.Text;
            PersonOrganisation.CRM_Organisation = db.CRM_Organisations.Single(o => o.Reference == ucACOrganisation.SelectedID);
            PersonOrganisation.CRM_Role         = db.CRM_Roles.Single(r => r.ID.ToString() == ddlRole.SelectedValue);

            db.SubmitChanges();

            if (oldEntity != null)
            {
                CRM.Code.History.History.RecordLinqUpdate(db, AdminUser, oldEntity, PersonOrganisation);
                db.SubmitChanges();
            }
            else
            {
                CRM.Code.History.History.RecordLinqInsert(AdminUser, PersonOrganisation);
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.NotSet);
            PersonOrganisation = db.CRM_PersonOrganisations.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  = PersonOrganisation;

            ucACOrganisation.EventHandler = lnkSelect_Click;
            ucACOrganisation.Config       = new AutoCompleteConfig(JSONSet.DataSets.organisation);

            // 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 organisation record", btnRealDelete_Click);

            // process //


            CRMContext = PersonOrganisation;

            if (!IsPostBack)
            {
                ddlRole.DataSource = CRM_Role.BaseSet(db);
                ddlRole.DataBind();

                if (PersonOrganisation != null)
                {
                    PopulateFields();
                }
            }
        }