Example #1
0
        public static TelecommunicationsNumber AddTelNum(Address address, TelecommunicationsNumberType type, bool isPrimary)
        {
            TelecommunicationsNumber telNum = new TelecommunicationsNumber();

            telNum.Address = address;
            telNum.TelecommunicationsNumberType = type;
            telNum.IsPrimary = isPrimary;
            return telNum;
        }
        public bool IsEqual(TelecommunicationsNumber number, string areaCode, string phoneNumber)
        {
            bool isEqual = true;

            isEqual = isEqual && number.AreaCode == areaCode;
            isEqual = isEqual && number.PhoneNumber == phoneNumber;

            return isEqual;
        }
        public static void CreateOrUpdateTeleCommNumberAddress(Party party, TelecommunicationsNumber newTelecommNumberAddress, TelecommunicationsNumberType type, DateTime now, bool IsPrimary)
        {
            var address = party.Addresses.FirstOrDefault(entity => entity.EndDate == null && entity.AddressTypeId == AddressType.TelecommunicationNumberType.Id && entity.TelecommunicationsNumber.IsPrimary == IsPrimary
                && entity.TelecommunicationsNumber.TelecommunicationsNumberType.Id == type.Id);

            newTelecommNumberAddress.AreaCode = string.IsNullOrWhiteSpace(newTelecommNumberAddress.AreaCode) ? null : newTelecommNumberAddress.AreaCode;
            newTelecommNumberAddress.PhoneNumber = string.IsNullOrWhiteSpace(newTelecommNumberAddress.PhoneNumber) ? null : newTelecommNumberAddress.PhoneNumber;

            if (newTelecommNumberAddress.AreaCode == null && newTelecommNumberAddress.PhoneNumber == null)
            {
                if (address != null)
                    address.EndDate = now;
                Context.Detach(newTelecommNumberAddress);
                return;
            }

            bool isEqual = false;
            if (address != null)
            {
                isEqual = true;
                var currentTeleComm = address.TelecommunicationsNumber;
                isEqual = isEqual && currentTeleComm.AreaCode == newTelecommNumberAddress.AreaCode;
                isEqual = isEqual && currentTeleComm.PhoneNumber == newTelecommNumberAddress.PhoneNumber;
                if (isEqual == false)
                    address.EndDate = now;
            }

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

                newTelecommNumberAddress.Address = newAddress;
                newTelecommNumberAddress.TelecommunicationsNumberType = type;
                Context.TelecommunicationsNumbers.AddObject(newTelecommNumberAddress);
            }
            else
                Context.Detach(newTelecommNumberAddress);
        }
        public static void CreateOrUpdateTeleCommNumberAddress(TelecommunicationsNumber currentTelecommNumbercAddress, TelecommunicationsNumber newTelecommNumberAddress, DateTime now)
        {
            //check if is equal;
            bool equal = true;
            equal &= currentTelecommNumbercAddress.AreaCode == newTelecommNumberAddress.AreaCode;
            equal &= currentTelecommNumbercAddress.PhoneNumber == newTelecommNumberAddress.PhoneNumber;

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

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

                newTelecommNumberAddress.Address = address;
                newTelecommNumberAddress.TelecommunicationsNumberType = currentTelecommNumbercAddress.TelecommunicationsNumberType;
                Context.TelecommunicationsNumbers.AddObject(newTelecommNumberAddress);
            }
            else
                Context.Detach(newTelecommNumberAddress);
        }
        public static TelecommunicationsNumber CreateTelecommNumberAddress(Party party, TelecommunicationsNumberType type, DateTime now)
        {
            Address address = new Address();
            address.Party = party;
            address.AddressType = AddressType.TelecommunicationNumberType;
            address.EffectiveDate = now;

            TelecommunicationsNumber telecomAddress = new TelecommunicationsNumber();
            telecomAddress.Address = address;
            telecomAddress.TelecommunicationsNumberType = type;
            return telecomAddress;
        }
        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 CreateOrUpdateContactInfo(Party party, Country country, DateTime today)
        {
            TelecommunicationsNumber faxNumber = new TelecommunicationsNumber();
            faxNumber.AreaCode = this.txtFaxAreacode.Text;
            faxNumber.PhoneNumber = this.txtFaxNumber.Text;
            faxNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.BusinessFaxNumberType;
            faxNumber.IsPrimary = true;
            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, faxNumber,
                TelecommunicationsNumberType.BusinessFaxNumberType, today, true);

            TelecommunicationsNumber telephoneNumber = new TelecommunicationsNumber();
            telephoneNumber.AreaCode = this.txtTelephoneAreaCode.Text;
            telephoneNumber.PhoneNumber = this.txtTelephoneNumber.Text;
            telephoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.BusinessPhoneNumberType;
            telephoneNumber.IsPrimary = true;
            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, telephoneNumber,
                TelecommunicationsNumberType.BusinessPhoneNumberType, today, true);

            ElectronicAddress emailAddress = new ElectronicAddress();
            emailAddress.ElectronicAddressString = txtEmailAddress.Text;
            emailAddress.IsPrimary = true;

            ElectronicAddress.CreateOrUpdateElectronicAddress(party, emailAddress,
                ElectronicAddressType.BusinessEmailAddressType, entity => entity.ElectronicAddress.IsPrimary, today);
        }
Example #8
0
        private void CreateOrUpdateTelecommuncationNumber(FinancialEntities context, Party party, Country country, DateTime today)
        {
            var addressType = AddressType.TelecommunicationNumberType;
            var businessNumberAddressType = TelecommunicationsNumberType.BusinessPhoneNumberType;
            var faxNumberAddressType = TelecommunicationsNumberType.BusinessFaxNumberType;

                TelecommunicationsNumber newTelNum = new TelecommunicationsNumber();
                newTelNum.IsPrimary = true;
                newTelNum.AreaCode = txtAreaCode.Text;
                newTelNum.PhoneNumber = txtPhoneNum.Text;
                newTelNum.TelecommunicationsNumberType = businessNumberAddressType;
                TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newTelNum, businessNumberAddressType, today, true);

                TelecommunicationsNumber newFaxNum = new TelecommunicationsNumber();
                newFaxNum.IsPrimary = true;
                newFaxNum.AreaCode = txtFaxAreaCode.Text;
                newFaxNum.PhoneNumber = txtFaxNum.Text;
                newFaxNum.TelecommunicationsNumberType = faxNumberAddressType;
                TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, newFaxNum, faxNumberAddressType, today, true);
        }
        private void CreateOrUpdateContactInfo(Party party, Country country, DateTime today)
        {
            TelecommunicationsNumber cellNumber = new TelecommunicationsNumber();
            cellNumber.AreaCode = this.txtCellphoneAreaCode.Text;
            cellNumber.PhoneNumber = this.txtCellphoneNumber.Text;
            cellNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.PersonalMobileNumberType;
            cellNumber.IsPrimary = true;
            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, cellNumber,
                TelecommunicationsNumberType.PersonalMobileNumberType, today, true);

            TelecommunicationsNumber telephoneNumber = new TelecommunicationsNumber();
            telephoneNumber.AreaCode = this.txtTelephoneAreaCode.Text;
            telephoneNumber.PhoneNumber = this.txtTelephoneNumber.Text;
            telephoneNumber.TelecommunicationsNumberType = TelecommunicationsNumberType.HomePhoneNumberType;
            telephoneNumber.IsPrimary = true;

            TelecommunicationsNumber.CreateOrUpdateTeleCommNumberAddress(party, telephoneNumber,
                TelecommunicationsNumberType.HomePhoneNumberType, today, true);

            ElectronicAddress emailAddress = new ElectronicAddress();
            emailAddress.ElectronicAddressString = txtEmailAddress.Text;
            emailAddress.IsPrimary = true;

            ElectronicAddress.CreateOrUpdateElectronicAddress(party, emailAddress,
                ElectronicAddressType.PersonalEmailAddressType, entity => entity.ElectronicAddress.IsPrimary, today);
        }
        //New Cellphone Number
        protected void CreateTelecomeNumber(Address Address, 
                                            TelecommunicationsNumberType TelecomNumberType, 
                                            Country Country, 
                                            string AreaCode,
                                            string PhoneNumber)
        {
            if (string.IsNullOrWhiteSpace(AreaCode) && string.IsNullOrWhiteSpace(PhoneNumber))
            {
                ObjectContext.Detach(Address);
                return;
            }
            TelecommunicationsNumber NewTelecomNumber = new TelecommunicationsNumber();
            NewTelecomNumber.Address = Address;
            NewTelecomNumber.TelecommunicationsNumberType = TelecomNumberType;
            NewTelecomNumber.AreaCode = AreaCode;
            NewTelecomNumber.PhoneNumber = PhoneNumber;
            NewTelecomNumber.IsPrimary = true;

            ObjectContext.TelecommunicationsNumbers.AddObject(NewTelecomNumber);
        }
        //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();
        }