コード例 #1
0
        protected void SaveRecord(bool newRecord)
        {
            // new record / exiting record //

            object oldEntity = null;

            if (newRecord)
            {
                PersonRelationship = new CRM_PersonRelationship();
                db.CRM_PersonRelationships.InsertOnSubmit(PersonRelationship);
            }
            else
            {
                oldEntity = PersonRelationship.ShallowCopy();
            }

            PersonRelationship.PersonA = db.CRM_Persons.Single(s => s.Reference.ToString() == ucAcPerson.SelectedID);
            PersonRelationship.PersonB = db.CRM_Persons.Single(s => s.Reference.ToString() == ucAcPersonB.SelectedID);

            PersonRelationship.PersonACode = db.CRM_RelationCodes.Single(s => s.ID.ToString() == ddlRelationCodeToA.SelectedValue);
            PersonRelationship.PersonBCode = db.CRM_RelationCodes.Single(s => s.ID.ToString() == ddlRelationCodetoB.SelectedValue);

            PersonRelationship.CRM_PersonIDAddress = Convert.ToInt32(rbPersonAddress.SelectedValue);

            PersonRelationship.Salutation = txtSalutation.Text;

            db.SubmitChanges();

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

            ucAcPerson.EventHandler = lnkSelect_Click;
            ucAcPerson.Config       = new AutoCompleteConfig(JSONSet.DataSets.person);

            ucAcPersonB.EventHandler = lnkSelectB_Click;
            ucAcPersonB.Config       = new AutoCompleteConfig(JSONSet.DataSets.person);

            // buttons //

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

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

            // confirmations //

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

            // process //

            CRMContext = Entity;

            if (!IsPostBack)
            {
                ddlRelationCodeToA.DataSource = CRM_RelationCode.BaseSet(db);
                ddlRelationCodeToA.DataBind();

                ddlRelationCodetoB.DataSource = CRM_RelationCode.BaseSet(db);
                ddlRelationCodetoB.DataBind();

                if (PersonRelationship != null)
                {
                    PopulateFields();
                }
                else
                {
                    ucAcPerson.Populate(Entity);
                    RebindAddresses();
                }
            }
        }