public static void CreateOrUpdatePostalAddress(FinancialEntities context, PostalAddress currentPostalAddress, PostalAddress newPostalAddress, DateTime now)
        {
            //check if is equal;
            bool equal = true;
            equal &= currentPostalAddress.Barangay == newPostalAddress.Barangay;
            equal &= currentPostalAddress.StreetAddress == newPostalAddress.StreetAddress;
            equal &= currentPostalAddress.Country == newPostalAddress.Country;
            equal &= currentPostalAddress.City == newPostalAddress.City;
            equal &= currentPostalAddress.Municipality == newPostalAddress.Municipality;
            equal &= currentPostalAddress.PostalCode == newPostalAddress.PostalCode;
            equal &= currentPostalAddress.Province == newPostalAddress.Province;
            equal &= currentPostalAddress.State == newPostalAddress.State;

            if (equal == false)
            {
                currentPostalAddress.Address.EndDate = now;

                Address address = new Address();
                address.Party = currentPostalAddress.Address.Party;
                address.AddressType = currentPostalAddress.Address.AddressType;
                address.EffectiveDate = now;

                newPostalAddress.Address = address;
                newPostalAddress.PostalAddressType = currentPostalAddress.PostalAddressType;
                context.PostalAddresses.AddObject(newPostalAddress);
            }
        }
예제 #2
0
        public static PostalAddress AddPostal(Address address, PostalAddressType type, bool isPrimary)
        {
            PostalAddress postalAddress = new PostalAddress();
            postalAddress.Address = address;
            postalAddress.PostalAddressType = type;
            postalAddress.IsPrimary = isPrimary;

            return postalAddress;
        }
 public void FillPostalAddress(PostalAddress postalAddress)
 {
     lblStreetAddress.Text = postalAddress.StreetAddress;
     lblBarangay.Text = postalAddress.Barangay;
     lblCity.Text = postalAddress.City;
     lblMunicipality.Text = postalAddress.Municipality;
     lblProvince.Text = postalAddress.Province;
     lblCountry.Text = postalAddress.Country.Name;
     lblPostalCode.Text = postalAddress.PostalCode;
 }
        public static PostalAddress CreatePostalAddress(FinancialEntities context, Party party, PostalAddressType type, DateTime now)
        {
            Address address = new Address();
            address.Party = party;
            address.AddressType = AddressTypeEnums.GetPostalAddressType(context);
            address.EffectiveDate = now;

            PostalAddress postalAddress = new PostalAddress();
            postalAddress.Address = address;
            postalAddress.PostalAddressType = type;
            return postalAddress;
        }
예제 #5
0
        public static string GetPrimaryPhoneNumber(Party party, PostalAddress postalAddress)
        {
            string primPhoneNumber = null;
            //Primary Business Phone Number
            var addressTypTelecom = ObjectContext.AddressTypes.First(entity => entity.Name == AddressType.TelecommunicationNumberType.Name);

            var primaryNumber = party.Addresses.FirstOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == addressTypTelecom.Id
                && entity.TelecommunicationsNumber.TypeId.Value ==  TelecommunicationsNumberType.BusinessPhoneNumberType.Id && entity.TelecommunicationsNumber != null
                && entity.TelecommunicationsNumber.IsPrimary);

            if (primaryNumber != null)
            {
                var pN = primaryNumber.TelecommunicationsNumber;
                primPhoneNumber = postalAddress.Country.CountryTelephoneCode + " " + "(" + pN.AreaCode + ") " + pN.PhoneNumber;
            }

            return primPhoneNumber;
        }
예제 #6
0
        public static string GetFaxNumber(Party party, PostalAddress postalAddress)
        {
            string faxPhoneNUmber = string.Empty;
            var telecomNumberTypeFax = ObjectContext.TelecommunicationsNumberTypes.SingleOrDefault(entity => entity.Name == TelecommunicationsNumberType.BusinessFaxNumberType.Name);
            InitialDatabaseValueChecker.ThrowIfNull<TelecommunicationsNumberType>(telecomNumberTypeFax);
            var addressTypTelecom = ObjectContext.AddressTypes.First(entity => entity.Name == AddressType.TelecommunicationNumberType.Name);

            var faxNumber = party.Addresses.FirstOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == addressTypTelecom.Id
                && entity.TelecommunicationsNumber.TypeId.Value == telecomNumberTypeFax.Id && entity.TelecommunicationsNumber.IsPrimary);

            if (faxNumber != null)
            {
                var fN = faxNumber.TelecommunicationsNumber;
                faxPhoneNUmber = postalAddress.Country.CountryTelephoneCode + " " + "(" + fN.AreaCode + ") " + fN.PhoneNumber;

            }
            return faxPhoneNUmber;
        }
예제 #7
0
        public static void CreateOrUpdatePostalAddress(PostalAddress currentPostalAddress, PostalAddress newPostalAddress, DateTime now)
        {
            newPostalAddress.Barangay = string.IsNullOrWhiteSpace(newPostalAddress.Barangay) ? null : newPostalAddress.Barangay;
            newPostalAddress.StreetAddress = string.IsNullOrWhiteSpace(newPostalAddress.StreetAddress) ? null : newPostalAddress.StreetAddress;
            newPostalAddress.City = string.IsNullOrWhiteSpace(newPostalAddress.City) ? null : newPostalAddress.City;
            newPostalAddress.Municipality = string.IsNullOrWhiteSpace(newPostalAddress.Municipality) ? null : newPostalAddress.Municipality;
            newPostalAddress.PostalCode = string.IsNullOrWhiteSpace(newPostalAddress.PostalCode) ? null : newPostalAddress.PostalCode;
            newPostalAddress.Province = string.IsNullOrWhiteSpace(newPostalAddress.Province) ? null : newPostalAddress.Province;
            newPostalAddress.State = string.IsNullOrWhiteSpace(newPostalAddress.State) ? null : newPostalAddress.State;

            //check if is equal;
            bool isEqual = true;
            isEqual = currentPostalAddress.Barangay == newPostalAddress.Barangay;
            isEqual = isEqual && currentPostalAddress.StreetAddress == newPostalAddress.StreetAddress;
            isEqual = isEqual && currentPostalAddress.CountryId == newPostalAddress.CountryId;
            isEqual = isEqual && currentPostalAddress.City == newPostalAddress.City;
            isEqual = isEqual && currentPostalAddress.Municipality == newPostalAddress.Municipality;
            isEqual = isEqual && currentPostalAddress.PostalCode == newPostalAddress.PostalCode;
            isEqual = isEqual && currentPostalAddress.Province == newPostalAddress.Province;
            isEqual = isEqual && currentPostalAddress.State == newPostalAddress.State;

            if (isEqual == false)
            {
                currentPostalAddress.Address.EndDate = now;

                Address address = new Address();
                address.Party = currentPostalAddress.Address.Party;
                address.AddressType = currentPostalAddress.Address.AddressType;
                address.EffectiveDate = now;

                newPostalAddress.Address = address;
                newPostalAddress.PostalAddressType = currentPostalAddress.PostalAddressType;
                Context.PostalAddresses.AddObject(newPostalAddress);
            }
            else
            {
                if (newPostalAddress.EntityState == System.Data.EntityState.Added)
                    Context.Detach(newPostalAddress);
            }
        }
예제 #8
0
        public static string GetSecondaryPhoneNumber(Party party, PostalAddress postalAddress)
        {
            string secPhoneNUmber = string.Empty;
            //Secondary Business Phone Number
            var addressTypTelecom = ObjectContext.AddressTypes.First(entity => entity.Name == AddressType.TelecommunicationNumberType.Name);
            var telecomNumberTypeBusinessPhoneNumber = ObjectContext.TelecommunicationsNumberTypes.SingleOrDefault(entity => entity.Name == TelecommunicationsNumberType.BusinessPhoneNumberType.Name);

            var secondaryNumber = party.Addresses.FirstOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == addressTypTelecom.Id
                && entity.TelecommunicationsNumber.TypeId.Value == telecomNumberTypeBusinessPhoneNumber.Id && entity.TelecommunicationsNumber != null
                && entity.TelecommunicationsNumber.IsPrimary == false);

            if (secondaryNumber != null)
            {
                var sN = secondaryNumber.TelecommunicationsNumber;
                secPhoneNUmber = postalAddress.Country.CountryTelephoneCode + " " + "(" + sN.AreaCode + ") " + sN.PhoneNumber + secPhoneNUmber;
            }

            return secPhoneNUmber;
        }
예제 #9
0
        public static void CreateOrUpdatePostalAddress(Party party, PostalAddress newPostalAddress, PostalAddressType addressType, DateTime now, bool isPrimary)
        {
            var address = party.Addresses.SingleOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == AddressType.PostalAddressType.Id
                                                            && entity.PostalAddress.PostalAddressTypeId == addressType.Id
                                                            && entity.PartyId == party.Id
                                                            && entity.PostalAddress.IsPrimary == isPrimary);

            newPostalAddress.Barangay = string.IsNullOrWhiteSpace(newPostalAddress.Barangay) ? null : newPostalAddress.Barangay;
            newPostalAddress.StreetAddress = string.IsNullOrWhiteSpace(newPostalAddress.StreetAddress) ? null : newPostalAddress.StreetAddress;
            newPostalAddress.City = string.IsNullOrWhiteSpace(newPostalAddress.City) ? null : newPostalAddress.City;
            newPostalAddress.Municipality = string.IsNullOrWhiteSpace(newPostalAddress.Municipality) ? null : newPostalAddress.Municipality;
            newPostalAddress.PostalCode = string.IsNullOrWhiteSpace(newPostalAddress.PostalCode) ? null : newPostalAddress.PostalCode;
            newPostalAddress.Province = string.IsNullOrWhiteSpace(newPostalAddress.Province) ? null : newPostalAddress.Province;
            newPostalAddress.State = string.IsNullOrWhiteSpace(newPostalAddress.State) ? null : newPostalAddress.State;

            bool isNull = true;

            isNull &= newPostalAddress.Barangay == null;
            isNull &= newPostalAddress.City == null;
            isNull &= newPostalAddress.Municipality == null;
            isNull &= newPostalAddress.PostalCode == null;
            isNull &= newPostalAddress.Province == null;
            isNull &= (newPostalAddress.CountryId == null || newPostalAddress.CountryId == 0);

            if (isNull)
            {
                if (newPostalAddress.EntityState == System.Data.EntityState.Added)
                    Context.Detach(newPostalAddress);
                return;
            }

            bool isEqual = false;
            if (address != null)
            {
                isEqual = true;

                var currentPostalAddress = address.PostalAddress;
                isEqual = isEqual && currentPostalAddress.Barangay == newPostalAddress.Barangay;
                isEqual = isEqual && currentPostalAddress.StreetAddress == newPostalAddress.StreetAddress;
                isEqual = isEqual && currentPostalAddress.CountryId == newPostalAddress.CountryId;
                isEqual = isEqual && currentPostalAddress.City == newPostalAddress.City;
                isEqual = isEqual && currentPostalAddress.Municipality == newPostalAddress.Municipality;
                isEqual = isEqual && currentPostalAddress.PostalCode == newPostalAddress.PostalCode;
                isEqual = isEqual && currentPostalAddress.Province == newPostalAddress.Province;
                isEqual = isEqual && currentPostalAddress.State == newPostalAddress.State;

                if (isEqual == false)
                    address.EndDate = now;
            }

            if (isEqual == false)
            {
                Address newAddress = new Address();
                newAddress.Party = party;
                newAddress.AddressType = AddressType.PostalAddressType;
                newAddress.EffectiveDate = now;

                newPostalAddress.Address = newAddress;
                newPostalAddress.PostalAddressType = addressType;
                Context.PostalAddresses.AddObject(newPostalAddress);
            }
            else
            {
                if (newPostalAddress.EntityState == System.Data.EntityState.Added)
                    Context.Detach(newPostalAddress);
            }
        }
예제 #10
0
        public static PostalAddress CreatePostalAddress(Party party, PostalAddressType type, DateTime now)
        {
            Address address = new Address();
            address.Party = party;
            address.AddressType = AddressType.PostalAddressType;
            address.EffectiveDate = now;

            PostalAddress postalAddress = new PostalAddress();
            postalAddress.Address = address;
            postalAddress.PostalAddressType = type;
            return postalAddress;
        }
예제 #11
0
        public void UpdateOrNot(PartyRole partyRole)
        {
            DateTime today = DateTime.Now;
            var lenderPartyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.RoleTypeId == RoleType.LendingInstitutionType.Id);//Lending Institution
            var EmployeeView = ObjectContext.EmployeeViewLists.SingleOrDefault(entity => entity.EmployeeId == partyRole.Id);
            var party = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.Id == partyRole.Id && entity.EndDate == null).Party;
            var person = party.Person;
            var employee = ObjectContext.Employees.SingleOrDefault(entity => entity.PartyRoleId == partyRole.Id);
            var partyRelationShip = ObjectContext.PartyRelationships.SingleOrDefault(entity => entity.FirstPartyRoleId == partyRole.Id && entity.SecondPartyRoleId == lenderPartyRole.Id                                                  && entity.EndDate == null);
            var employment = ObjectContext.Employments.SingleOrDefault(entity => entity.PartyRelationshipId == partyRelationShip.Id);
            string concatinatedTIN = ConcatinateTIN(txtTIN.Text, txtTIN1.Text, txtTIN2.Text, txtTIN3.Text);

            Person.CreateOrUpdatePersonNames(person, PersonNameType.TitleType, hdnTitle.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.FirstNameType, hdnFirstName.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.MiddleNameType, hdnMiddleName.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.LastNameType, hdnLastName.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.NameSuffixType, hdnSuffix.Text, today);
            Person.CreateOrUpdatePersonNames(person, PersonNameType.NickNameType, hdnNickName.Text, today);

            /*------------------------------------------------------------------------------------------------------------------*/
            GenderType genderType;
            if(radioFemale.Checked) genderType = GenderType.FemaleType;
            else genderType = GenderType.MaleType;

            if(person.GenderType != genderType) person.GenderType = genderType;//gender
            if(person.Birthdate != dtBirthDate.SelectedDate) person.Birthdate = dtBirthDate.SelectedDate;//birthdate

            string stringPersinPictureFile  = hdnPersonPicture.Value.ToString();
            if (person.ImageFilename != stringPersinPictureFile) person.ImageFilename = hdnPersonPicture.Value.ToString();//imagepicture

            if (employee.EmployeeIdNumber != txtEmployeeIdNumber.Text)
            {
                if (string.IsNullOrWhiteSpace(txtEmployeeIdNumber.Text))
                {
                    employee.EmployeeIdNumber = null;
                }
                else
                {
                    employee.EmployeeIdNumber = txtEmployeeIdNumber.Text;//employeeidnumber
                }
            }
            if (employee.Position != cmbPosition.SelectedItem.Text) employee.Position = cmbPosition.SelectedItem.Text;//position
            if(employment.EmploymentStatus != cmbEmploymentStatus.SelectedItem.Text) employment.EmploymentStatus = cmbEmploymentStatus.SelectedItem.Text;//employmentstatus
            if(employment.Salary != txtSalary.Text) employment.Salary = txtSalary.Text;//salary

            Taxpayer.CreateOrUpdateTaxPayer(partyRole, concatinatedTIN);//tin

            if(employee.SssNumber != txtSSSNumber.Text) employee.SssNumber = txtSSSNumber.Text;//sssnumber
            if(employee.PhicNumber != txtPHICNumber.Text) employee.PhicNumber = txtPHICNumber.Text;//phicnumber
            /*------------------------------------------------------------------------------------------------------------------*/

            /**  CONTACT INFO DETAILS  **/

            /*------------------------------------------------------------------------------------------------------------------*/
            //Primary Home Address
            PostalAddress newPostalAddress = new PostalAddress();
            newPostalAddress.StreetAddress = hdnStreetAddress.Text;
            newPostalAddress.Barangay = hdnBarangay.Text;
            newPostalAddress.City = hdnCity.Text;
            newPostalAddress.Municipality = hdnMunicipality.Text;
            newPostalAddress.Province = hdnProvince.Text;
            newPostalAddress.State = hdnState.Text;
            newPostalAddress.PostalCode = hdnPostalCode.Text;
            newPostalAddress.CountryId = int.Parse(hdnCountryId.Text);
            newPostalAddress.IsPrimary = true;
            PostalAddress.CreateOrUpdatePostalAddress(party, newPostalAddress, PostalAddressType.HomeAddressType, today, true);

            //Home Phone
            TelecommunicationsNumber newTelePhoneNumber = new TelecommunicationsNumber();
            newTelePhoneNumber.AreaCode = txtTeleAreaCode.Text;
            newTelePhoneNumber.PhoneNumber = txtTelePhoneNumber.Text;
            newTelePhoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.HomePhoneNumberType;
            newTelePhoneNumber.IsPrimary = true;
            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newTelePhoneNumber, TelecommunicationsNumberType.HomePhoneNumberType, today, true);

            //Personal Mobile
            TelecommunicationsNumber newCellPhoneNumber = new TelecommunicationsNumber();
            newCellPhoneNumber.AreaCode = txtCellAreaCode.Text;
            newCellPhoneNumber.PhoneNumber = txtCellPhoneNumber.Text;
            newCellPhoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.PersonalMobileNumberType;
            newCellPhoneNumber.IsPrimary = true;
            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newCellPhoneNumber, TelecommunicationsNumberType.PersonalMobileNumberType, today, true);

            //Electronic Address
            ElectronicAddress newEmailAddress = new ElectronicAddress();
            newEmailAddress.ElectronicAddressString = txtPrimaryEmailAddress.Text;
            newEmailAddress.ElectronicAddressType = ElectronicAddressType.PersonalEmailAddressType;
            newEmailAddress.IsPrimary = true;
            ElectronicAddress.CreateOrUpdateElectronicAddress(party, newEmailAddress, ElectronicAddressType.PersonalEmailAddressType, entity => entity.ElectronicAddress.IsPrimary == true, today);
        }
        private void CreateOrUpdatePostalAddress(Party party, Country country, DateTime today)
        {
            AddressType addressType = AddressType.PostalAddressType;
            PostalAddressType postalAddressType = PostalAddressType.BusinessAddressType;

            //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);
        }
        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);

            }
        }
        private void SaveBasicOrganizationContactInformation()
        {
            var today = DateTime.Now;

            //insert partyTypeId to Party
            PartyType partyType = ObjectContext.PartyTypes.SingleOrDefault(entity => entity.Name == PartyTypeEnums.Organization);
            Party party = new Party();
            party.PartyType = partyType;

            //insert organizationType, organizationName and dateEstablished to Organization
            OrganizationType internalOrganization = ObjectContext.OrganizationTypes.SingleOrDefault(entity => entity.Name == OrganizationTypeEnums.Internal);
            OrganizationType externalOrganization = ObjectContext.OrganizationTypes.SingleOrDefault(entity => entity.Name == OrganizationTypeEnums.External);
            Organization organization = new Organization();
            organization.OrganizationName = txtName.Text;
            if (!string.IsNullOrWhiteSpace(cmbOrganizationType.SelectedItem.Text))
            {
                int organizationTypeId = int.Parse(cmbOrganizationType.Value.ToString());
                var organizationType = ObjectContext.OrganizationTypes.SingleOrDefault(entity => entity.Id == organizationTypeId);
                organization.OrganizationType = organizationType;
            }
            else
            {
                organization.OrganizationTypeId = null;
            }
            if (dtDateEstablished.SelectedValue != null)
                organization.DateEstablished = dtDateEstablished.SelectedDate;
            else
                organization.DateEstablished = null;

            //retirieve contactRoleType from Role Type where name = "Contact"
            var contactRoleType = ObjectContext.RoleTypes.SingleOrDefault(entity => entity.Name == RoleTypeEnums.Contact);

            //insert partyId, contactRoleType and effectiveDate to Party Role
            PartyRole partyRole = new PartyRole();
            partyRole.Party = party;
            partyRole.PartyRoleType = contactRoleType.PartyRoleType;
            partyRole.EffectiveDate = today;

            //insert firstPartyRoleId, secondPartyRoleId and EffectiveDate to PartyRelationship
            var contactRelationshipType = ObjectContext.PartyRelTypes.SingleOrDefault(entity => entity.Name == PartyRelationTypesEnums.ContactRelationship);
            RoleType lendingInstitution = ObjectContext.RoleTypes.SingleOrDefault(entity => entity.Name == RoleTypeEnums.LendingInstitution);
            PartyRole lendingInstitutionPartyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.RoleTypeId == lendingInstitution.Id);
            PartyRelationship partyRelationship = new PartyRelationship();
            partyRelationship.PartyRole = partyRole;
            partyRelationship.PartyRole1 = lendingInstitutionPartyRole;
            partyRelationship.PartyRelType = contactRelationshipType;
            partyRelationship.EffectiveDate = today;

            //retrieve postalAddressCategoryType from AddressType where name = "Postal Address"
            var postalAddressCategoryType = ObjectContext.AddressTypes.SingleOrDefault(entity => entity.Name == AddressTypeEnums.PostalAddress);

            //retrieve businessAddressCategory from Address where addressType = postalAddressCategoryType and name = "Business Address"
            var primaryBusinessAddress = ObjectContext.PostalAddressTypes.SingleOrDefault(entity => entity.Name == PostalAddressTypeEnums.BusinessAddress);

            //insert address
            int countryId = int.Parse(cmbCountry.Value.ToString());
            var country = ObjectContext.Countries.SingleOrDefault(entity => entity.Id == countryId);

            AddressType addressType = AddressType.PostalAddressType;
            PostalAddressType postalAddressType = PostalAddressType.BusinessAddressType;

            //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);
            //retrieve telecommunicationNumberType

            if (!string.IsNullOrWhiteSpace(txtFaxNumber.Text))
            {
                TelecommunicationsNumber specificCellphoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.BusinessFaxNumberType, today);
                specificCellphoneNumber.AreaCode = txtFaxAreaCode.Text;
                specificCellphoneNumber.PhoneNumber = txtFaxNumber.Text;
                specificCellphoneNumber.IsPrimary = true;
            }

            if (!string.IsNullOrWhiteSpace(txtTelephoneNumber.Text))
            {
                TelecommunicationsNumber specificTelephoneNumber = TelecommunicationsNumber.CreateTelecommNumberAddress(party, TelecommunicationsNumberType.BusinessPhoneNumberType, today);
                specificTelephoneNumber.AreaCode = txtTelephoneAreaCode.Text;
                specificTelephoneNumber.PhoneNumber = txtTelephoneNumber.Text;
                specificTelephoneNumber.IsPrimary = true;
            }

            if (!string.IsNullOrWhiteSpace(txtEmailAddress.Text))
            {
                ElectronicAddress specificEmailAddress = ElectronicAddress.CreateElectronicAddress(party, ElectronicAddressType.BusinessEmailAddressType, today);
                specificEmailAddress.ElectronicAddressString = txtEmailAddress.Text;
                specificEmailAddress.IsPrimary = true;
            }

            ObjectContext.Parties.AddObject(party);
        }
예제 #15
0
        //New Postal Address
        protected void CreatePostalAddress(Address Address, 
                                            PostalAddressType PostalAddressType, 
                                            Country Country, 
                                            string StreetAddress, 
                                            string Barangay, 
                                            string Municipality, 
                                            string City, 
                                            string Province, 
                                            string State, 
                                            string PostalCode)
        {
            PostalAddress NewPostalAddress = new PostalAddress();
            NewPostalAddress.Address = Address;
            NewPostalAddress.PostalAddressType = PostalAddressType;
            NewPostalAddress.Country = Country;

            if (string.IsNullOrWhiteSpace(StreetAddress)) NewPostalAddress.StreetAddress = null;
            else NewPostalAddress.StreetAddress = StreetAddress;

            NewPostalAddress.Barangay = Barangay;

            if (string.IsNullOrWhiteSpace(Municipality)) NewPostalAddress.Municipality = null;
            else NewPostalAddress.Municipality = Municipality;

            if (string.IsNullOrWhiteSpace(City)) NewPostalAddress.City = null;
            else NewPostalAddress.City = City;

            if (string.IsNullOrWhiteSpace(Province)) NewPostalAddress.Province = null;
            else NewPostalAddress.Province = Province;

            if (string.IsNullOrWhiteSpace(State)) NewPostalAddress.State = null;
            else NewPostalAddress.State = State;

            NewPostalAddress.PostalCode = PostalCode;
            NewPostalAddress.IsPrimary = true;

            ObjectContext.PostalAddresses.AddObject(NewPostalAddress);
        }
예제 #16
0
        //MAIN BUTTONS
        protected void btnSave_Click(object sender, DirectEventArgs e)
        {
            DateTime today = DateTime.Now;
            var lenderPartyRole = ObjectContext.PartyRoles.SingleOrDefault(entity => entity.RoleTypeId == RoleType.LendingInstitutionType.Id);
            Party party;
            string concatinatedTIN = ConcatinateTIN(txtTIN.Text, txtTIN1.Text, txtTIN2.Text, txtTIN3.Text);

            if (!string.IsNullOrWhiteSpace(hdnPickedPartyId.Text))//if the Employee is in the allowed employees
            {
                int PickedPartyId = int.Parse(hdnPickedPartyId.Text);
                party = Party.GetById(PickedPartyId);
                //Check if the new person has an employment record with another employer && end it.
                CheckIfHasAnotherEmployer(party);
                var person = party.Person;
                PartyRole partyRole = CreateEmployeePartyRole(party, today);
                CreateEmployee(partyRole, txtEmployeeIdNumber.Text, cmbPosition.SelectedItem.Text, txtSSSNumber.Text, string.Empty, string.Empty, txtPHICNumber.Text);

                Person.CreateOrUpdatePersonNames(person, PersonNameType.TitleType, txtTitle.Text, today);
                Person.CreateOrUpdatePersonNames(person, PersonNameType.FirstNameType, txtFirstName.Text, today);
                Person.CreateOrUpdatePersonNames(person, PersonNameType.MiddleNameType, txtMiddleName.Text, today);
                Person.CreateOrUpdatePersonNames(person, PersonNameType.LastNameType, txtLastName.Text, today);
                Person.CreateOrUpdatePersonNames(person, PersonNameType.NameSuffixType, txtSuffix.Text, today);
                Person.CreateOrUpdatePersonNames(person, PersonNameType.NickNameType, txtNickName.Text, today);

                Taxpayer.CreateOrUpdateTaxPayer(partyRole, concatinatedTIN);

                PartyRelationship partyRelationship = CreatePartyRelationship(partyRole, lenderPartyRole, today);
                CreateEmployment(partyRelationship, cmbEmploymentStatus.SelectedItem.Text, txtSalary.Text);

                PostalAddress newPostalAddress = new PostalAddress();
                newPostalAddress.StreetAddress = txtStreetAddress.Text;
                newPostalAddress.Barangay = txtBarangay.Text;
                newPostalAddress.City = hdnCity.Text;
                newPostalAddress.Municipality = hdnMunicipality.Text;
                newPostalAddress.Province = txtProvince.Text;
                newPostalAddress.PostalCode = txtPostalCode.Text;
                newPostalAddress.CountryId = int.Parse(cmbCountry.SelectedItem.Value);
                newPostalAddress.IsPrimary = true;
                PostalAddress.CreateOrUpdatePostalAddress(party, newPostalAddress, PostalAddressType.HomeAddressType, today, true);

                TelecommunicationsNumber newCellNumber = new TelecommunicationsNumber();
                newCellNumber.AreaCode = txtCellAreaCode.Text;
                newCellNumber.PhoneNumber = txtCellPhoneNumber.Text;
                newCellNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.PersonalMobileNumberType;
                newCellNumber.IsPrimary = true;
                TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newCellNumber, TelecommunicationsNumberType.PersonalMobileNumberType, today, true);

                TelecommunicationsNumber newTelePhoneNumber = new TelecommunicationsNumber();
                newTelePhoneNumber.AreaCode = txtTeleAreaCode.Text;
                newTelePhoneNumber.PhoneNumber = txtTelePhoneNumber.Text;
                newTelePhoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.HomePhoneNumberType;
                newTelePhoneNumber.IsPrimary = true;
                TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newTelePhoneNumber, TelecommunicationsNumberType.HomePhoneNumberType, today, true);

                ElectronicAddress newEmailAddress = new ElectronicAddress();
                newEmailAddress.ElectronicAddressString = txtPrimaryEmailAddress.Text;
                newEmailAddress.ElectronicAddressType = ElectronicAddressType.PersonalEmailAddressType;
                newEmailAddress.IsPrimary = true;
                ElectronicAddress.CreateOrUpdateElectronicAddress(party, newEmailAddress, ElectronicAddressType.PersonalEmailAddressType, entity => entity.ElectronicAddress.IsPrimary == true, today);
            }
            else//if Employee to be added is a new Employee with no records
            {
                int selectedCountryId = int.Parse(cmbCountry.SelectedItem.Value);
                var country = ObjectContext.Countries.SingleOrDefault(entity => entity.Id == selectedCountryId);

                party = CreateParty();
                //get selected gender
                GenderType genderType;
                if(radioFemale.Checked) genderType = GenderType.FemaleType;
                else genderType = GenderType.MaleType;

                Person person = CreatePerson(party, dtBirthDate.SelectedDate, genderType, hdnPersonPicture.Value.ToString());
                Person.CreatePersonName(person, today, txtTitle.Text, txtFirstName.Text, txtMiddleName.Text, txtLastName.Text, txtSuffix.Text, txtNickName.Text);

                PartyRole partyRole = CreateEmployeePartyRole(party, today);
                CreateEmployee(partyRole, txtEmployeeIdNumber.Text, cmbPosition.SelectedItem.Text, txtSSSNumber.Text, string.Empty, string.Empty, txtPHICNumber.Text);
                Taxpayer.CreateOrUpdateTaxPayer(partyRole, concatinatedTIN);

                PartyRelationship partyRelationship = CreatePartyRelationship(partyRole, lenderPartyRole, today);
                CreateEmployment(partyRelationship, cmbEmploymentStatus.SelectedItem.Text, txtSalary.Text);

                PostalAddress newPostalAddress = new PostalAddress();
                newPostalAddress.StreetAddress = txtStreetAddress.Text;
                newPostalAddress.Barangay = txtBarangay.Text;
                newPostalAddress.City = hdnCity.Text;
                newPostalAddress.Municipality = hdnMunicipality.Text;
                newPostalAddress.Province = txtProvince.Text;
                newPostalAddress.PostalCode = txtPostalCode.Text;
                newPostalAddress.CountryId = int.Parse(cmbCountry.SelectedItem.Value);
                newPostalAddress.IsPrimary = true;
                PostalAddress.CreateOrUpdatePostalAddress(party, newPostalAddress, PostalAddressType.HomeAddressType, today, true);

                TelecommunicationsNumber newCellNumber = new TelecommunicationsNumber();
                newCellNumber.AreaCode = txtCellAreaCode.Text;
                newCellNumber.PhoneNumber = txtCellPhoneNumber.Text;
                newCellNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.PersonalMobileNumberType;
                newCellNumber.IsPrimary = true;
                TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newCellNumber, TelecommunicationsNumberType.PersonalMobileNumberType, today, true);

                TelecommunicationsNumber newTelePhoneNumber = new TelecommunicationsNumber();
                newTelePhoneNumber.AreaCode = txtTeleAreaCode.Text;
                newTelePhoneNumber.PhoneNumber = txtTelePhoneNumber.Text;
                newTelePhoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.HomePhoneNumberType;
                newTelePhoneNumber.IsPrimary = true;
                TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newTelePhoneNumber, TelecommunicationsNumberType.HomePhoneNumberType, today, true);

                ElectronicAddress newEmailAddress = new ElectronicAddress();
                newEmailAddress.ElectronicAddressString = txtPrimaryEmailAddress.Text;
                newEmailAddress.ElectronicAddressType = ElectronicAddressType.PersonalEmailAddressType;
                newEmailAddress.IsPrimary = true;
                ElectronicAddress.CreateOrUpdateElectronicAddress(party, newEmailAddress, ElectronicAddressType.PersonalEmailAddressType, entity => entity.ElectronicAddress.IsPrimary == true, today);
            }

            ObjectContext.SaveChanges();
        }