Skip to main content
added 38 characters in body
Source Link
//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
public List<Time__c> timeList{get;set;}
public List<Time__c> timeListAdmin;
public List<Time__c> timeListDeveloper;
Decimal adminHour=0;adminHour;
Decimal devHour=0;devHour;
public TimeTaskController() {
    timeList = new List<Time__c>();
    timeListAdmin = new List<Time__c>();
    timeListDeveloper = new List<Time__c>();
}


public void timeMergeRecords(){
    adminHour=0;
    devHour=0;
    for(Integer i=0; i<=10 ; i++){
        timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
        if(timeListAdmin.size()==1){
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i , Hour__c=timeListAdmin[0].Hour__c ));
        }
        else if(timeListAdmin.size()>1){
            for(Time__c t : timeListAdmin){
                adminHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
        }
       
            
        timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
        if(timeListDeveloper.size()==1){
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i , Hour__c=timeListDeveloper[0].Hour__c ));
        }
        else if(timeListDeveloper.size()>1){
            for(Time__c t : timeListDeveloper){
                devHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));  
        }   
    }
}
//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
public List<Time__c> timeList{get;set;}
public List<Time__c> timeListAdmin;
public List<Time__c> timeListDeveloper;
Decimal adminHour=0;
Decimal devHour=0;
public TimeTaskController() {
    timeList = new List<Time__c>();
    timeListAdmin = new List<Time__c>();
    timeListDeveloper = new List<Time__c>();
}


public void timeMergeRecords(){
    for(Integer i=0; i<=10 ; i++){
        timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
        if(timeListAdmin.size()==1){
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i , Hour__c=timeListAdmin[0].Hour__c ));
        }
        else if(timeListAdmin.size()>1){
            for(Time__c t : timeListAdmin){
                adminHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
        }
       
            
        timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
        if(timeListDeveloper.size()==1){
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i , Hour__c=timeListDeveloper[0].Hour__c ));
        }
        else if(timeListDeveloper.size()>1){
            for(Time__c t : timeListDeveloper){
                devHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));  
        }   
    }
}
//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
public List<Time__c> timeList{get;set;}
public List<Time__c> timeListAdmin;
public List<Time__c> timeListDeveloper;
Decimal adminHour;
Decimal devHour;
public TimeTaskController() {
    timeList = new List<Time__c>();
    timeListAdmin = new List<Time__c>();
    timeListDeveloper = new List<Time__c>();
}


public void timeMergeRecords(){
    adminHour=0;
    devHour=0;
    for(Integer i=0; i<=10 ; i++){
        timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
        if(timeListAdmin.size()==1){
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i , Hour__c=timeListAdmin[0].Hour__c ));
        }
        else if(timeListAdmin.size()>1){
            for(Time__c t : timeListAdmin){
                adminHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
        }
       
            
        timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
        if(timeListDeveloper.size()==1){
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i , Hour__c=timeListDeveloper[0].Hour__c ));
        }
        else if(timeListDeveloper.size()>1){
            for(Time__c t : timeListDeveloper){
                devHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));  
        }   
    }
}
added 236 characters in body
Source Link
//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
    public List<Time__c> timeList{get;set;}
    public List<Time__c> timeListAdmin;
    public List<Time__c> timeListDeveloper;
    Decimal adminHour=0;
    Decimal devHour=0;
    public TimeTaskController() {
        timeList = new List<Time__c>();
        timeListAdmin = new List<Time__c>();
        timeListDeveloper = new List<Time__c>();
    }

    
    public void timeMergeRecords(){
        for(Integer i=0; i<=10 ; i++){
            timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
            if(timeListAdmin.size()>0==1){
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i , Hour__c=timeListAdmin[0].Hour__c ));
        }
        else if(timeListAdmin.size()>1){
            for(Time__c t : timeListAdmin){
                    adminHour += t.hour__c;    
                }
                timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
            }   
         
        
      
        timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
            if(timeListDeveloper.size()>0==1){
             timeList.add(new Time__c(Role__c='Developer', Rate__c for(Time__c=i t, :Hour__c=timeListDeveloper[0].Hour__c timeListDeveloper){);
            }
        devHour +=else tif(timeListDeveloper.hour__c;    size()>1){
             for(Time__c t : }timeListDeveloper){
                timeList.add(newdevHour Time__c(Role__c='Developer',+= Rate__ct.hour__c; =i,Hour__c=devHour ));  
            }   
        }
    }
}
// It's nottimeList.add(new bestTime__c(Role__c='Developer', practiceRate__c but=i,Hour__c=devHour i)); have done 
 this task now you can also you map} and done SOQl 
 query without inside loop.}
}

} // It's not best practice but i have done this task now you can also you map and done SOQl query without inside loop.

//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
    public List<Time__c> timeList{get;set;}
    public List<Time__c> timeListAdmin;
    public List<Time__c> timeListDeveloper;
    Decimal adminHour=0;
    Decimal devHour=0;
    public TimeTaskController() {
        timeList = new List<Time__c>();
        timeListAdmin = new List<Time__c>();
        timeListDeveloper = new List<Time__c>();
    }

    
    public void timeMergeRecords(){
        for(Integer i=0; i<=10 ; i++){
            timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
            if(timeListAdmin.size()>0){
                for(Time__c t : timeListAdmin){
                    adminHour += t.hour__c;    
                }
                timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
            }   
                
             timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
            if(timeListDeveloper.size()>0){
                for(Time__c t : timeListDeveloper){
                    devHour += t.hour__c;    
                }
                timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));  
            }   
        }
    }
}
// It's not best practice but i have done this task now you can also you map and done SOQl query without inside loop.
//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
public List<Time__c> timeList{get;set;}
public List<Time__c> timeListAdmin;
public List<Time__c> timeListDeveloper;
Decimal adminHour=0;
Decimal devHour=0;
public TimeTaskController() {
    timeList = new List<Time__c>();
    timeListAdmin = new List<Time__c>();
    timeListDeveloper = new List<Time__c>();
}


public void timeMergeRecords(){
    for(Integer i=0; i<=10 ; i++){
        timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
        if(timeListAdmin.size()==1){
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i , Hour__c=timeListAdmin[0].Hour__c ));
        }
        else if(timeListAdmin.size()>1){
            for(Time__c t : timeListAdmin){
                adminHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
        }
        
             
        timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
        if(timeListDeveloper.size()==1){
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i , Hour__c=timeListDeveloper[0].Hour__c ));
        }
        else if(timeListDeveloper.size()>1){
            for(Time__c t : timeListDeveloper){
                devHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));   
        }    
    }
}

} // It's not best practice but i have done this task now you can also you map and done SOQl query without inside loop.

added 226 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

//This is Visualforce Page <apex:page Controller="TimeTaskController" sidebar="false" showHeader="false"> <apex:form > <apex:pageBlock title="Time Details"> <apex:pageblockSection > <apex:pageBlockTable value="{!timeList}" var="t"> <apex:column value="{!t.Role__c}"/> <apex:column value="{!t.Rate__c}"/> <apex:column value="{!t.Hour__c}"/>

<apex:page Controller="TimeTaskController" sidebar="false" showHeader="false">
  <apex:form >
      <apex:pageBlock title="Time Details">
          <apex:pageblockSection >
              <apex:pageBlockTable value="{!timeList}" var="t">
                  <apex:column value="{!t.Role__c}"/>
                  <apex:column value="{!t.Rate__c}"/>
                  <apex:column value="{!t.Hour__c}"/>
              
              </apex:pageBlockTable>
          </apex:pageblockSection>
          <apex:commandButton action="{!timeMergeRecords}" value="Merge"/>
      </apex:pageBlock>
  </apex:form>
</apex:page>

</apex:form> </apex:page>

//------------------------------------------------------------------------------ // This is Controller. public class TimeTaskController { public List<Time__c> timeList{get;set;} public List<Time__c> timeListAdmin; public List<Time__c> timeListDeveloper; Decimal adminHour=0; Decimal devHour=0; public TimeTaskController() { timeList = new List<Time__c>(); timeListAdmin = new List<Time__c>(); timeListDeveloper = new List<Time__c>(); }

 
//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
    public List<Time__c> timeList{get;set;}
    public List<Time__c> timeListAdmin;
    public List<Time__c> timeListDeveloper;
    Decimal adminHour=0;
    Decimal devHour=0;
    public TimeTaskController() {
        timeList = new List<Time__c>();
        timeListAdmin = new List<Time__c>();
        timeListDeveloper = new List<Time__c>();
    }

    
    public void timeMergeRecords(){
        for(Integer i=0; i<=10 ; i++){
            timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
            if(timeListAdmin.size()>0){
                for(Time__c t : timeListAdmin){
                    adminHour += t.hour__c;    
                }
                timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
            }   
                
            timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
            if(timeListDeveloper.size()>0){
                for(Time__c t : timeListDeveloper){
                    devHour += t.hour__c;    
                }
                timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));  
            }   
        }
    }
}
// It's not best practice but i have done this task now you can also you map and done SOQl query without inside loop.

} // It's not best practice but i have done this task now you can also you map and done SOQl query without inside loop.

//This is Visualforce Page <apex:page Controller="TimeTaskController" sidebar="false" showHeader="false"> <apex:form > <apex:pageBlock title="Time Details"> <apex:pageblockSection > <apex:pageBlockTable value="{!timeList}" var="t"> <apex:column value="{!t.Role__c}"/> <apex:column value="{!t.Rate__c}"/> <apex:column value="{!t.Hour__c}"/>

          </apex:pageBlockTable>
      </apex:pageblockSection>
      <apex:commandButton action="{!timeMergeRecords}" value="Merge"/>
  </apex:pageBlock>

</apex:form> </apex:page>

//------------------------------------------------------------------------------ // This is Controller. public class TimeTaskController { public List<Time__c> timeList{get;set;} public List<Time__c> timeListAdmin; public List<Time__c> timeListDeveloper; Decimal adminHour=0; Decimal devHour=0; public TimeTaskController() { timeList = new List<Time__c>(); timeListAdmin = new List<Time__c>(); timeListDeveloper = new List<Time__c>(); }

public void timeMergeRecords(){
    for(Integer i=0; i<=10 ; i++){
        timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
        if(timeListAdmin.size()>0){
            for(Time__c t : timeListAdmin){
                adminHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
        }   
            
        timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
        if(timeListDeveloper.size()>0){
            for(Time__c t : timeListDeveloper){
                devHour += t.hour__c;    
            }
            timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));  
        }   
    }
}

} // It's not best practice but i have done this task now you can also you map and done SOQl query without inside loop.

//This is Visualforce Page

<apex:page Controller="TimeTaskController" sidebar="false" showHeader="false">
  <apex:form >
      <apex:pageBlock title="Time Details">
          <apex:pageblockSection >
              <apex:pageBlockTable value="{!timeList}" var="t">
                  <apex:column value="{!t.Role__c}"/>
                  <apex:column value="{!t.Rate__c}"/>
                  <apex:column value="{!t.Hour__c}"/>
              
              </apex:pageBlockTable>
          </apex:pageblockSection>
          <apex:commandButton action="{!timeMergeRecords}" value="Merge"/>
      </apex:pageBlock>
  </apex:form>
</apex:page>
 
//------------------------------------------------------------------------------
// This is Controller.
public class TimeTaskController {
    public List<Time__c> timeList{get;set;}
    public List<Time__c> timeListAdmin;
    public List<Time__c> timeListDeveloper;
    Decimal adminHour=0;
    Decimal devHour=0;
    public TimeTaskController() {
        timeList = new List<Time__c>();
        timeListAdmin = new List<Time__c>();
        timeListDeveloper = new List<Time__c>();
    }

    
    public void timeMergeRecords(){
        for(Integer i=0; i<=10 ; i++){
            timeListAdmin = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Admin' AND Rate__c=:i ];
            if(timeListAdmin.size()>0){
                for(Time__c t : timeListAdmin){
                    adminHour += t.hour__c;    
                }
                timeList.add(new Time__c(Role__c='Admin', Rate__c =i,Hour__c=adminHour ));
            }   
                
            timeListDeveloper = [Select id , Name , Role__c , Hour__c From Time__c where Role__c='Developer' AND Rate__c=:i ];
            if(timeListDeveloper.size()>0){
                for(Time__c t : timeListDeveloper){
                    devHour += t.hour__c;    
                }
                timeList.add(new Time__c(Role__c='Developer', Rate__c =i,Hour__c=devHour ));  
            }   
        }
    }
}
// It's not best practice but i have done this task now you can also you map and done SOQl query without inside loop.
Source Link
Loading