• kiran jain 14
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
apexclass:
public  class EnrollmentFormClass {
public Contact primarycontact{get;set;}
public Contact othercontact{get;set;}
public Contact childcontact{get;set;}
public List<Contact> concAddList{get;set;} 
public Account acc{get;set;}
    
public EnrollmentFormClass() {
     primarycontact  = new Contact();
     othercontact = new Contact();
     childcontact = new Contact(); 
     acc  = new Account();
     concAddList  = new List<Contact>();   
     concAddList.Add(new Contact());
     }
    
public void AddRow(){
     childcontact = new Contact();
     concAddList.Add(childcontact);
       
     }
public void save(){
     insert  primarycontact;   
     acc.name = primarycontact.lastName; 
     insert acc;     
     primarycontact.accountId = acc.id;
     upsert primarycontact;
     othercontact.accountId = acc.id;
     othercontact.Contact1__c = primarycontact.Id; 
     insert othercontact;    
     for(contact cc :concAddList){
     cc.accountId = acc.id;
     cc.Contact1__c = primarycontact.Id;
     
     }
     upsert concAddList;
     }
     }
visualforcepage:
<apex:page controller="EnrollmentFormClass" showHeader="false" sidebar="false">
    <apex:form >
    <apex:pageBlock title="Opportunitiy Zone Enrollment Form">
              <apex:pageBlockSection columns="3">
              <apex:inputField value="{!primarycontact.Student_Name__c}"/>
              <apex:inputField value="{!primarycontact.School__c}"/> 
              <apex:inputField value="{!primarycontact.Date__c}"/>    
            </apex:pageBlockSection>     
            <br/> 
            <br/>
                    SPARC programs are funded by United Way of Greater Atlanta. As such, we are required to report demographic, income, educational and health access information on every individual/family we serve. With the United Way belief that serving one family member serves them all, we collect general information on each member of your household. We appreciate your willingness to complete this form in its entirety so that we can continue providing free programs to the community. Thank you!
            <br/>  
            <br/> 
            <apex:pageBlockSection title="Head of Household Information:">
                <apex:inputField value="{!primarycontact.FirstName}"/>
                <apex:inputField value="{!primarycontact.LastName}"/>
                <apex:inputField value="{!primarycontact.Date_of_Birth__c}"/>
                <apex:inputField value="{!primarycontact.Gender__c}"/> 
                <apex:inputField value="{!primarycontact.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!primarycontact.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!primarycontact.Address__c}"/>
                <apex:inputField value="{!primarycontact.City__c}"/>
                <apex:inputField value="{!primarycontact.State__c}"/>
                <apex:inputField value="{!primarycontact.County__c}"/>
                <apex:inputField value="{!primarycontact.Phone__c}"/>
                <apex:inputField value="{!primarycontact.Email_Address__c}"/>
                <apex:inputField value="{!primarycontact.Preferred_Method_of_Contact_Circle_One__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlocksection title="Demographic Data: (All information is confidential and is used in applying for grants to fund this program.)" columns="3">
                 <apex:inputField value="{!primarycontact.Spanish_translation_Services_Needed__c}"/>
                 <apex:inputField value="{!primarycontact.Race_Check_One__c}"/>
                 <apex:inputField value="{!primarycontact.Marital_Status_check_one__c}"/>
                 <apex:inputField value="{!primarycontact.HIGHEST_LEVEL_OF_EDUCATION_Check_one__c}"/>
                 <apex:inputField value="{!primarycontact.Employment_check_one__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="Income:" columns="3">
                <apex:inputField value="{!primarycontact.Annual_Income__c}"/> 
                <apex:inputField value="{!primarycontact.Source_of_Income__c}"/> 
                <apex:inputField value="{!primarycontact.Primary_Method_of_Transportation__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="HOUSEHOLD Information:" columns="3">
                <apex:inputField value="{!othercontact.Other_Adult_First_Name__c}"/>
                <apex:inputField value="{!othercontact.LastName}"/>
                <apex:inputField value="{!othercontact.Date_of_Birth__c}"/>
                <apex:inputField value="{!othercontact.Gender__c}"/> 
                <apex:inputField value="{!othercontact.Relationship_Primary_Care_Provider__c}"/>
                <apex:inputField value="{!othercontact.Medical_Insurance__c    }"/>  
            </apex:pageBlocksection>
               
            <apex:pageBlocksection title="Children (all children currently in your household, INCLUDING those participating in this program):" columns="1">
             <apex:pageBlockTable value="{!concAddList}" var="c">
             <apex:column headerValue="Name">
                 <apex:commandButton value="Add Row" action="{!addRow}" />
             
             </apex:column>
             <apex:column headerValue="Name"> 
             <apex:inputfield value="{!c.lastName}"/>    
             </apex:column> 
                    
       </apex:pageBlockTable> 
       </apex:pageBlocksection>
         <apex:commandButton value="Save" action="{!save}"/>
       </apex:pageBlock>
    </apex:form>
</apex:page>
  • February 14, 2018
  • Like
  • 0