protected void lnkUpdate_Click(object sender, EventArgs e) { CRM.Code.Models.CRM_Person person = db.CRM_Persons.Single(s => s.ID.ToString() == ((LinkButton)sender).CommandArgument); litBefore.Text = person.MergeCard.Replace(Environment.NewLine, "<br/>"); lblConstituentTypesBefore.Text = CRM.Code.Helpers.JSONSet.FlattenList(person.ConstituentTypes(db).ToList(), "<br/>"); litAfter.Text = TransformPerson(person).MergeCard.Replace(Environment.NewLine, "<br/>"); lblConstituentTypesAfter.Text = lblConstituentTypesBefore.Text + "<br/>"; foreach (RepeaterItem item in rptConstituent.Items) { CheckBox chk = (CheckBox)item.FindControl("chkOption"); HtmlGenericControl lbl = (HtmlGenericControl)item.FindControl("lblOption"); if (chk.Checked && !person.ConstituentTypes(db).Contains(lbl.InnerText)) { lblConstituentTypesAfter.Text += lbl.InnerText + "<br/>"; } } pnlMerge.Visible = true; hdnRecord.Value = person.ID.ToString(); }
protected void Page_Load(object sender, EventArgs e) { RunSecurity(CRM.Code.Models.Admin.AllowedSections.NotSet); Entity = db.CRM_Persons.SingleOrDefault(c => c.ID.ToString() == Request.QueryString["id"]); ucLogHistory.IHistory = Entity; ucLogNotes.INotes = Entity; ucCustomFields._DataTableID = db._DataTables.Single(c => c.TableReference == "CRM_Person").ID; // buttons // btnDelete.EventHandler = btnDelete_Click; btnSubmit.EventHandler = btnSubmit_Click; btnSubmitChanges.EventHandler = btnSubmitChanges_Click; btnReinstate.EventHandler = btnReinstate_Click; ucNavPerson.Entity = Entity; // Security // if (!PermissionManager.CanAdd && Entity == null) { Response.Redirect("list.aspx"); } // confirmations // confirmationDelete.StandardDeleteHidden("person", btnRealDelete_Click); // process // ucDuplicate.BaseObject = new CRM_Person(); txtFirstname.TextBox.Attributes[CRM_Person.DataKey] = ((byte)CRM_Person.SearchKeys.Firstname).ToString(); txtLastname.TextBox.Attributes[CRM_Person.DataKey] = ((byte)CRM_Person.SearchKeys.Lastname).ToString(); txtPrimaryEmail.TextBox.Attributes[CRM_Person.DataKey] = ((byte)CRM_Person.SearchKeys.PrimaryEmail).ToString(); txtTelephone.TextBox.Attributes[CRM_Person.DataKey] = ((byte)CRM_Person.SearchKeys.Telephone).ToString(); txtDateOfBirth.TextBox.Attributes[CRM_Person.DataKey] = ((byte)CRM_Person.SearchKeys.DoB).ToString(); ((UserControlTextBox)ucAddress.FindControl("txtPostcode")).TextBox.Attributes[CRM_Person.DataKey] = ((byte)CRM_Person.SearchKeys.Postcode).ToString(); ucDuplicate.OriginalID = Entity == null ? 0 : Entity.ID; CRMContext = Entity; ucAddress.TownRequired = false; if (!IsPostBack) { ddlTitles.DataSource = CRM_Title.SetDropDownWithString(db.CRM_Titles.Cast <IArchivable>(), Entity == null ? "" : Entity.Title); ddlTitles.DataBind(); if (Entity != null) { PopulateFields(); } else { ucCustomFields.Populate(String.Empty); } } pnlAdultInfo.Visible = !chkIsChild.Checked; pnlAdultLeft.Visible = !chkIsChild.Checked; }
public string ReplacePlaceholders(string output, CRM_Person person) { CRM_AnnualPass pass = this; output = output.Replace("@FIRSTNAME@", person.Firstname); output = output.Replace("@LASTNAME@", person.Lastname); output = output.Replace("@CARDNUMBER@", pass.CRM_AnnualPassCard.MembershipNumber.ToString()); output = output.Replace("@STARTDATE@", pass.StartDate.ToString("dd-MM-yyyy")); output = output.Replace("@EXPIRY@", pass.ExpiryDate.ToString("dd-MM-yyyy")); output = output.Replace("@CURRENTPASS@", pass.CRM_AnnualPassType.Name); return(output); }
public static string[] ConstituentTypes(this CRM_Person person, MainDataContext db) { IEnumerable <CRM_FormFieldResponse> answers = db.CRM_FormFieldResponses.Where(f => f.TargetReference == person.Reference && f.CRM_FormFieldID == 1); if (answers != null) { return(answers.Select(s => s.CRM_FormFieldItem.Label).ToArray()); } else { return new string[] { } }; } }
protected void btnSubmitChanges_Click(object sender, EventArgs e) { if (hdnRecord.Value != "") { object oldEntity = null; object oldAddress = null; CRM.Code.Models.CRM_Person person = db.CRM_Persons.Single(s => s.ID.ToString() == hdnRecord.Value); oldEntity = person.ShallowCopy(); oldAddress = person.CRM_Address.ShallowCopy(); TransformPerson(person); person.WebsiteAccountID = Entity.OriginAccountID; person.Password = Entity.Password; if (Entity.GroupNames.Length > 0) { var groupNames = Entity.GroupNames.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (var groupName in groupNames) { if (groupName.Trim().Length > 0) { } } } if (Entity.DoNotMail != null) { person.IsDoNotMail = (bool)Entity.DoNotMail; } if (Entity.DoNotEmail != null) { person.IsDoNotEmail = (bool)Entity.DoNotEmail; } /* * if (Entity.AlwaysSendPassInfo != null) * person.AlwaysSendPassInfo = (bool)Entity.AlwaysSendPassInfo; */ db.SubmitChanges(); CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldEntity, person); CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldAddress, person.PrimaryAddress); db.SubmitChanges(); ApplyCustomField(person, 2, 22); db.SubmitChanges(); ApplyConstituentsToSelected(person); /* * * CRM_FormFieldAnswer answer = db.CRM_FormFieldAnswers.FirstOrDefault(f => f.CRM_FormFieldID == 24 && f.TargetReference == person.Reference); * * if (answer == null) * { * answer = new CRM_FormFieldAnswer(); * answer.CRM_FormFieldID = 24; * answer.TargetReference = person.Reference; * db.CRM_FormFieldAnswers.InsertOnSubmit(answer); * } * * answer.Answer = ""; * foreach (ListItem chkBox in rptInterests.Items) * { * if (chkBox.Selected) * { * string id = chkBox.Value; * CRM_FormFieldItem item = db.CRM_FormFieldItems.Single(s => s.ID.ToString() == id); * answer.Answer += item.Label + "<br/>"; * } * } * */ AddRelationship(person); db.SubmitChanges(); NoticeManager.SetMessage("Record merged"); } }
public static IEnumerable <CRM_PersonOrganisation> BaseSet(MainDataContext db) { return(CRM_Person.BaseSet(db).SelectMany(c => c.CRM_PersonOrganisations)); }
public IEnumerable <IDuplicate> GetBaseSet(MainDataContext db) { return(CRM_Person.BaseSet(db).Select(l => (IDuplicate)l)); }
protected void SaveRecord(bool newRecord) { // new record / exiting record // object oldEntity = null; object oldAddress = null; if (newRecord) { Entity = new CRM_Person(); Entity.IsArchived = false; Entity.DateAdded = UKTime.Now; Entity.Password = ""; Entity.TempCode = ""; db.CRM_Persons.InsertOnSubmit(Entity); } else { oldEntity = Entity.ShallowCopy(); oldAddress = Entity.CRM_Address.ShallowCopy(); } Entity.DateModified = UKTime.Now; Entity.Title = ddlTitles.SelectedValue; Entity.Firstname = txtFirstname.Text; Entity.Lastname = txtLastname.Text; Entity.PreviousNames = txtPrevious.Text; Entity.PrimaryEmail = txtPrimaryEmail.Text; Entity.PrimaryTelephone = txtTelephone.Text; Entity.IsContactEmail = chkIsContactEmail.Checked; Entity.IsChild = chkIsChild.Checked; Entity.IsConcession = chkIsConcession.Checked; Entity.IsCarerMinder = chkIsCarerMinder.Checked; Entity.IsDeceased = chkIsDeceased.Checked; Entity.IsGiftAid = chkIsGiftAid.Checked; Entity.IsDoNotMail = chkIsDoNotMail.Checked; Entity.IsDoNotEmail = chkIsDoNotEmail.Checked; Entity.AddressType = (byte)CRM_Address.Types.Home; Entity.Telephone2 = txtTelephone2.Text; if (!String.IsNullOrEmpty(txtDateOfBirth.Text)) { Entity.DateOfBirth = txtDateOfBirth.Value; } if (newRecord) { CRM_Address address = new CRM_Address(); Entity.CRM_Address = (CRM_Address)((Address)ucAddress).Save(address); } else { Entity.CRM_Address = (CRM_Address)((Address)ucAddress).Save(Entity.CRM_Address); } db.SubmitChanges(); if (ddlPrimaryAddress.SelectedValue != "") { Entity.PrimaryAddressID = Convert.ToInt32(ddlPrimaryAddress.SelectedValue); } db.SubmitChanges(); Entity.CRM_Address.ParentID = Entity.ID; if (oldEntity != null) { CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldEntity, Entity); CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldAddress, Entity.CRM_Address); db.SubmitChanges(); } else { CRM.Code.History.History.RecordLinqInsert(AdminUser, Entity); CRM.Code.History.History.RecordLinqInsert(AdminUser, Entity.CRM_Address); } ucCustomFields.Save(Entity.Reference); if (hdnCaptured.Value == "1") { File.Copy(MapPath(AdminUser.TempPhotoFile), MapPath(Entity.PersonImageURL), true); } }
public static IEnumerable <CRM_PersonSchool> BaseSet(MainDataContext db) { return(CRM_Person.BaseSet(db).SelectMany(c => c.CRM_PersonSchools)); }