public static PersonName GetPersonNameByTypeEntity(FinancialEntities context, Person person, string type) { var personNameType = context.PersonNameTypes.SingleOrDefault(entity => entity.Name == type); InitialDatabaseValueChecker.ThrowIfNull<PersonNameType>(personNameType); var personName = person.PersonNames.SingleOrDefault(entity => entity.PersonNameTypeId == personNameType.Id && entity.EndDate == null); return personName; }
public static void CreateOrUpdatePersonNames(FinancialEntities context, Person person, string type, string name, DateTime today) { PersonName personName = GetPersonNameByTypeEntity(context, person, type); if (personName == null || name != personName.Name) { if (personName != null) personName.EndDate = today; PersonName newPersonName = CreatePersonName(context, type, name, person); context.PersonNames.AddObject(newPersonName); } }
public static PersonName CreatePersonName(FinancialEntities context, string nameType, string name, Person person) { var personNameType = context.PersonNameTypes.SingleOrDefault(entity => entity.Name == nameType); InitialDatabaseValueChecker.ThrowIfNull<PersonNameType>(personNameType); PersonName personName = new PersonName(); personName.Name = name; personName.PersonNameType = personNameType; personName.Person = person; personName.EffectiveDate = DateTime.Now; return personName; }
protected void checkEmployerNames() { var today = DateTime.Now; var personName = txtPersonName.Text; //bool res = true; var sameName = ObjectContext.EmployersViewLists.SingleOrDefault(entity => entity.Name == personName); if (sameName != null) { int id = sameName.EmployerID; X.Msg.Confirm("Message", "An employer record with the same name already exists in the list. Do you want to create another employer record with the same name?", new JFunction("Employer.AddSameEmployer(result, id);", "result")).Show(); } else { Party party = new Party(); Person person = new Person(); Organization org = new Organization(); PersonName employerFName = new PersonName(); PersonName employerLName = new PersonName(); PersonName employerMName = new PersonName(); PersonName employerNiName = new PersonName(); PersonName employerNaName = new PersonName(); PersonName employerTName = new PersonName(); PersonName employerMMName = new PersonName(); if (this.txtEmployerPartyType.Text == "Person") { party.PartyType = PartyType.PersonType; person.Party = party; employerFName.Person = person; employerFName.PersonNameType = PersonNameType.FirstNameType; employerFName.Name = txtPersonFirstName.Text; employerFName.EffectiveDate = today; employerLName.Person = person; employerLName.PersonNameType = PersonNameType.LastNameType; employerLName.Name = txtPersonLastName.Text; employerLName.EffectiveDate = today; employerMMName.Person = person; employerMMName.PersonNameType = PersonNameType.MothersMaidenNameType; employerMMName.Name = txtPersonMothersMaidenName.Text; employerMMName.EffectiveDate = today; employerMName.Person = person; employerMName.PersonNameType = PersonNameType.MiddleNameType; employerMName.Name = txtPersonMiddleName.Text; employerMName.EffectiveDate = today; employerNaName.Person = person; employerNaName.PersonNameType = PersonNameType.NameSuffixType; employerNaName.Name = txtPersonNameSuffix.Text; employerNaName.EffectiveDate = today; employerNiName.Person = person; employerNiName.PersonNameType = PersonNameType.NickNameType; employerNiName.Name = txtPersonNickName.Text; employerNiName.EffectiveDate = today; } else { party.PartyType = PartyType.OrganizationType; org.OrganizationName = txtOrganizationName.Text; org.Party = party; } PartyRole partyRole = new PartyRole(); partyRole.Party = party; partyRole.PartyRoleType.RoleType = RoleType.EmployerType; var res = Person.CheckEmployerName(partyRole); if(res != null) X.Msg.Confirm("Message", "A party record with the same name already exists. Do you want to use this record to create the new employer record?", new JFunction("Employer.AddSameName(result, res);", "result")).Show(); } }
public int checkEmployerName() { var result = 0; var today = DateTime.Now; var personName = this.PersonName; Party party = new Party(); Person person = new Person(); Organization org = new Organization(); PersonName employerFName = new PersonName(); PersonName employerLName = new PersonName(); PersonName employerMName = new PersonName(); PersonName employerNiName = new PersonName(); PersonName employerNaName = new PersonName(); PersonName employerTName = new PersonName(); PersonName employerMMName = new PersonName(); party.PartyType = PartyType.PersonType; person.Party = party; if (this.txtEmployerPartyType.Text == "Person") { party.PartyType = PartyType.PersonType; person.Party = party; employerFName.Person = person; employerFName.PersonNameType = PersonNameType.FirstNameType; employerFName.Name = txtPersonFirstName.Text; employerFName.EffectiveDate = today; employerLName.Person = person; employerLName.PersonNameType = PersonNameType.LastNameType; employerLName.Name = txtPersonLastName.Text; employerLName.EffectiveDate = today; employerMMName.Person = person; employerMMName.PersonNameType = PersonNameType.MothersMaidenNameType; employerMMName.Name = txtPersonMothersMaidenName.Text; employerMMName.EffectiveDate = today; employerMName.Person = person; employerMName.PersonNameType = PersonNameType.MiddleNameType; employerMName.Name = txtPersonMiddleName.Text; employerMName.EffectiveDate = today; employerNaName.Person = person; employerNaName.PersonNameType = PersonNameType.NameSuffixType; employerNaName.Name = txtPersonNameSuffix.Text; employerNaName.EffectiveDate = today; employerNiName.Person = person; employerNiName.PersonNameType = PersonNameType.NickNameType; employerNiName.Name = txtPersonNickName.Text; employerNiName.EffectiveDate = today; employerTName.Person = person; employerTName.PersonNameType = PersonNameType.TitleType; employerTName.Name = txtPersonTitle.Text; employerTName.EffectiveDate = today; } else { party.PartyType = PartyType.OrganizationType; org.OrganizationName = txtOrganizationName.Text; org.Party = party; } PartyRole partyRole = new PartyRole(); partyRole.Party = party; partyRole.RoleTypeId = RoleType.EmployerType.Id; //bool res = true; var sameName = Person.CheckEmployerPersonName(partyRole); if (sameName != null) { int id = sameName.Id; //X.Msg.Confirm("Message", "An employer record with the same name already exists in the list. Do you want to create another employer record with the same name?", new JFunction("Employer.AddSameEmployer(result, id);", "result")).Show(); this.hiddenID.Value = id; result = 1; } else { var res = Person.CheckEmployerName(partyRole); if (res != null) { //X.Msg.Confirm("Message", "A party record with the same name already exists. Do you want to use this record to create the new employer record?", new JFunction("Employer.AddSameName(result, res);", "result")).Show(); result = 2; hiddenID.Value = res.Id; hiddenExistingParty.Value = res.PartyId; hiddenExistingPartyRole.Value = res.Id; } } return result; }
private PersonName GetPersonNameByTypeEntity(Person person, string type) { var personNameType = ObjectContext.PersonNameTypes.SingleOrDefault(entity => entity.Name == type); InitialDatabaseValueChecker.ThrowIfNull<PersonNameType>(personNameType); var personName = person.PersonNames.SingleOrDefault(entity => entity.PersonNameTypeId == personNameType.Id && entity.EndDate == null); return personName; }
public static MaritalStatu GetActive(Person person) { return person.MaritalStatus.SingleOrDefault(entity => entity.IsActive == true && entity.PartyId == person.PartyId); }
public int checkPersonName(string name) { int result = 0; var names = name; var today = DateTime.Now; Party party = new Party(); Person person = new Person(); PersonName customerFName = new PersonName(); PersonName customerLName = new PersonName(); PersonName customerMName = new PersonName(); PersonName customerNiName = new PersonName(); PersonName customerNaName = new PersonName(); PersonName customerTName = new PersonName(); PersonName customerMMName = new PersonName(); party.PartyType = PartyType.PersonType; person.Party = party; customerTName.Person = person; customerTName.PersonNameType = PersonNameType.TitleType; customerTName.Name = cmbTitle.SelectedItem.Text; customerTName.EffectiveDate = today; customerFName.Person = person; customerFName.PersonNameType = PersonNameType.FirstNameType; customerFName.Name = txtFirstName.Text; customerFName.EffectiveDate = today; customerLName.Person = person; customerLName.PersonNameType = PersonNameType.LastNameType; customerLName.Name = txtLastName.Text; customerLName.EffectiveDate = today; customerMMName.Person = person; customerMMName.PersonNameType = PersonNameType.MothersMaidenNameType; customerMMName.Name = txtMothersMaidenName.Text; customerMMName.EffectiveDate = today; customerMName.Person = person; customerMName.PersonNameType = PersonNameType.MiddleNameType; customerMName.Name = txtMiddleName.Text; customerMName.EffectiveDate = today; customerNaName.Person = person; customerNaName.PersonNameType = PersonNameType.NameSuffixType; customerNaName.Name = txtNameSuffix.Text; customerNaName.EffectiveDate = today; customerNiName.Person = person; customerNiName.PersonNameType = PersonNameType.NickNameType; customerNiName.Name = txtNickName.Text; customerNiName.EffectiveDate = today; PartyRole partyRole = new PartyRole(); partyRole.Party = party; partyRole.RoleTypeId = RoleType.ContactType.Id; //check if input name is equal to existing person name var sameName = Person.CheckPersonName(party); //InitialDatabaseValueChecker.ThrowIfNull<CustomersViewList>(sameName); if (sameName != null) { //X.Msg.Confirm("Message", "A customer record with the same name already exists. Do you want to create another customer record with the same name?", new JFunction("Customer.AddSameCustomer(result);", "result")).Show(); hiddenID.Value = sameName.Id; result = 1; } return result; }
public int CheckEmployeeName() { var today = DateTime.Now; Party party = new Party(); Person person = new Person(); PersonName employeeTitleName = new PersonName(); PersonName employeeFirstName = new PersonName(); PersonName employeeMiddleName = new PersonName(); PersonName employeeLastName = new PersonName(); PersonName employeeSuffixName = new PersonName(); PersonName employeeNickName = new PersonName(); party.PartyType = PartyType.PersonType; person.Party = party; employeeTitleName.Person = person; employeeTitleName.PersonNameType = PersonNameType.TitleType; employeeTitleName.Name = txtTitle.Text; employeeTitleName.EffectiveDate = today; employeeFirstName.Person = person; employeeFirstName.PersonNameType = PersonNameType.FirstNameType; employeeFirstName.Name = txtFirstName.Text; employeeFirstName.EffectiveDate = today; employeeMiddleName.Person = person; employeeMiddleName.PersonNameType = PersonNameType.MiddleNameType; employeeMiddleName.Name = txtMiddleName.Text; employeeMiddleName.EffectiveDate = today; employeeLastName.Person = person; employeeLastName.PersonNameType = PersonNameType.LastNameType; employeeLastName.Name = txtLastName.Text; employeeLastName.EffectiveDate = today; employeeSuffixName.Person = person; employeeSuffixName.PersonNameType = PersonNameType.NameSuffixType; employeeSuffixName.Name = txtSuffix.Text; employeeSuffixName.EffectiveDate = today; employeeNickName.Person = person; employeeNickName.PersonNameType = PersonNameType.NickNameType; employeeNickName.Name = txtNickName.Text; employeeNickName.EffectiveDate = today; PartyRole partyRole = new PartyRole(); partyRole.Party = party; partyRole.RoleTypeId = RoleType.EmployeeType.Id; var res = Person.CheckEmployeePersonName(partyRole); int result = 0; //var SameEmployeeName = ObjectContext.EmployeeViewLists.SingleOrDefault(entity => entity.Name.Contains(txtEmployeeName.Text)); if (res != null) //Exists in the Employee Record { int partyRoleId = res.Id; //var partyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.Id == partyRoleId); hdnEmployeeID.Value = partyRoleId; //hdnPickedPartyId.Text = partyRole.PartyId.ToString(); result = 1; } else { var SameAllowedEmployeeName = Person.CheckAllowedEmployeeName(partyRole); if (SameAllowedEmployeeName != null) { hdnPickedPartyId.Text = SameAllowedEmployeeName.PartyId.ToString(); result = 2; } } return result; }
private static PersonName GetPersonNameByTypeEntity(Person person, PersonNameType type) { var personName = person.PersonNames.SingleOrDefault(entity => entity.PersonNameTypeId == type.Id && entity.EndDate == null); return personName; }
private static PersonName CreatePersonName(Person person, PersonNameType nameType, string name, DateTime today) { if (string.IsNullOrWhiteSpace(name)) return null; PersonName personName = new PersonName(); personName.Name = name; personName.PersonNameType = nameType; personName.Person = person; personName.EffectiveDate = today; Context.PersonNames.AddObject(personName); return personName; }
public static bool ValidatePersonNameIfEqual(Person person1, Person person2) { bool isEqual = true; isEqual &= person1.TitleString.ToLower() == person2.TitleString.ToLower(); isEqual &= person1.FirstNameString.ToLower() == person2.FirstNameString.ToLower(); isEqual &= person1.LastNameString.ToLower() == person2.LastNameString.ToLower(); isEqual &= person1.MiddleNameString.ToLower() == person2.MiddleNameString.ToLower(); isEqual &= person1.NameSuffixString.ToLower() == person2.NameSuffixString.ToLower(); isEqual &= person1.NickNameString.ToLower() == person2.NickNameString.ToLower(); //isEqual &= person1.MothersMaidenNameString.ToLower() == person2.MothersMaidenNameString.ToLower(); return isEqual; }
public static string GetPersonFullName(Person person) { string title = person.TitleString; string firstName = person.FirstNameString; string lastName = person.LastNameString; string middleName = person.MiddleNameString; string suffix = person.NameSuffixString; string middleInitial = string.IsNullOrWhiteSpace(middleName) ? "" : middleName[0] + "."; string fullName = StringConcatUtility.Build(" ", title, lastName + ",", firstName, middleInitial, suffix); return fullName; }
public static void CreatePersonName(Person Person, DateTime Today, string title, string firstName, string middleName, string lastName, string suffix, string nickName) { Person.CreateOrUpdatePersonNames(Person, PersonNameType.TitleType, title, Today); Person.CreateOrUpdatePersonNames(Person, PersonNameType.FirstNameType, firstName, Today); Person.CreateOrUpdatePersonNames(Person, PersonNameType.MiddleNameType, middleName, Today); Person.CreateOrUpdatePersonNames(Person, PersonNameType.LastNameType, lastName, Today); Person.CreateOrUpdatePersonNames(Person, PersonNameType.NameSuffixType, suffix, Today); Person.CreateOrUpdatePersonNames(Person, PersonNameType.NickNameType, nickName, Today); }
public static void CreateOrUpdatePersonNames(Person person, PersonNameType type, string name, DateTime today) { PersonName personName = GetPersonNameByTypeEntity(person, type); if (personName == null || name != personName.Name) { if (personName != null) personName.EndDate = today; CreatePersonName(person, type, name, today); } }
protected void btnSave_Click(object sender, DirectEventArgs e) { using (UnitOfWorkScope scope = new UnitOfWorkScope(true)) { var today = DateTime.Now; /*_________________________________________________________QUERIES_________________________________________________________________________________________________________*/ //Gender Types GenderType genderType = radMale.Checked ? GenderType.MaleType : GenderType.FemaleType; PartyRole lendingInstitutionPartyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.RoleTypeId == RoleType.LendingInstitutionType.Id); //retrieve telephone country code int countryId = int.Parse(cmbCountry.Value.ToString()); var country = ObjectContext.Countries.SingleOrDefault(entity => entity.Id == countryId); //retreive personName by personNameType string personTitle = cmbTitle.Text; string personFirstName = txtFirstName.Text; string personMiddleName = txtMiddleName.Text; string personLastName = txtLastName.Text; string personNickName = txtNickName.Text; string personNameSuffix = txtNameSuffix.Text; string personMothersMaidenName = txtMothersMaidenName.Text; /*_________________________________________________________INSERTS______________________________________________________________________________________________________________________________________________________________*/ //insert partyTypeId to Party Party party = new Party(); party.PartyType = PartyType.PersonType; //insert genderTypeId, birthdate to Person Person person = new Person(); person.GenderType = genderType; person.Birthdate = dtBirthdate.SelectedDate; Person.CreatePersonName(person, today, personTitle, personFirstName, personMiddleName, personLastName, personNameSuffix, personNickName); Person.CreateOrUpdatePersonNames(person, PersonNameType.MothersMaidenNameType, personMothersMaidenName, today); //insert partyId, roleTypeId, effectiveDate to Party Role PartyRole partyRole = new PartyRole(); partyRole.Party = party; partyRole.PartyRoleType = RoleType.ContactType.PartyRoleType; partyRole.EffectiveDate = today; //insert firstPartyRoleId, secondPartyRoleId, partyRelationshipTypeId to Party Relationship PartyRelationship partyRelationshipType = new PartyRelationship(); partyRelationshipType.PartyRole = partyRole; partyRelationshipType.PartyRole1 = lendingInstitutionPartyRole; partyRelationshipType.PartyRelType = PartyRelType.ContactRelationshipType; partyRelationshipType.EffectiveDate = today; if (!string.IsNullOrWhiteSpace(txtCellphoneNumber.Text)) { TelecommunicationsNumber specificCellphoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.PersonalMobileNumberType, today); specificCellphoneNumber.AreaCode = txtCellphoneAreaCode.Text; specificCellphoneNumber.PhoneNumber = txtCellphoneNumber.Text; specificCellphoneNumber.IsPrimary = true; } if (!string.IsNullOrWhiteSpace(txtTelephoneNumber.Text)) { TelecommunicationsNumber specificTelephoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.HomePhoneNumberType, today); specificTelephoneNumber.AreaCode = txtTelephoneAreaCode.Text; specificTelephoneNumber.PhoneNumber = txtTelephoneNumber.Text; specificTelephoneNumber.IsPrimary = true; } if (!string.IsNullOrWhiteSpace(txtEmailAddress.Text)) { ElectronicAddress specificEmailAddress = ElectronicAddress.CreateElectronicAddress(party, ElectronicAddressType.PersonalEmailAddressType, today); specificEmailAddress.ElectronicAddressString = txtEmailAddress.Text; specificEmailAddress.IsPrimary = true; } AddressType addressType = AddressType.PostalAddressType; PostalAddressType postalAddressType = PostalAddressType.HomeAddressType; //Create an Address with AddressType as Postal Address PostalAddress newPostalAddress = new PostalAddress(); newPostalAddress.Country = country; newPostalAddress.Barangay = hiddenBarangay.Text; newPostalAddress.PostalCode = hiddenPostalCode.Text; newPostalAddress.Province = hiddenProvince.Text; newPostalAddress.City = hiddenCity.Text; newPostalAddress.Municipality = hiddenMunicipality.Text; newPostalAddress.StreetAddress = hiddenStreet.Text; newPostalAddress.IsPrimary = true; PostalAddress.CreateOrUpdatePostalAddress(party, newPostalAddress, postalAddressType, today, true); ObjectContext.Parties.AddObject(party); } }
//New Person protected Person CreatePerson(Party Party, DateTime BirthDate, GenderType GenderType, string ImageFileName) { Person NewPerson = new Person(); NewPerson.Party = Party; NewPerson.GenderType = GenderType; NewPerson.NationalityType = null; NewPerson.EducAttainmentType = EducAttainmentType.CollegeGraduateType; NewPerson.Birthdate = BirthDate; NewPerson.ImageFilename = ImageFileName; ObjectContext.People.AddObject(NewPerson); return NewPerson; }