Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Ordered Items: <apex:commandButton value="{!Count}"/>
  2. Cancelled Items: <apex:commandButton value="{!Count}" />
  3. Reviewed Items: <apex:commandButton value="{!Count}"/>
  4.  
  5.  
  6. Public Integer Count(){
  7. List<Items__c> items = [SELECT Count(ID) FROM Items__c WHERE Status == 'Ordered' OR Status == 'Cancelled' OR Status == 'Reviewed'];
  8. return items.size();
  9. }
  10.  
  11. Ordered Items: <apex:commandButton value="{!statusCount['Ordered']}"/>
  12. Cancelled Items: <apex:commandButton value="{!statusCount['Cancelled']}" />
  13. Reviewed Items: <apex:commandButton value="{!statusCount['Reviewed']}"/>
  14.  
  15.  
  16. Public Map<String, Integer> statusCount {
  17. get {
  18. if (statusCount == null) {
  19. statusCount = new Map<String, Integer>();
  20. statusCount.put('Ordered', 0);
  21. statusCount.put('Cancelled', 0);
  22. statusCount.put('Reviewed', 0);
  23. for (Items__c i = [SELECT Status
  24. FROM Items__c
  25. WHERE Status in ('Ordered', 'Cancelled', 'Reviewed']) {
  26. Integer count = statusCount.get(i.Status) + 1;
  27. statusCount.put(i.Status, count);
  28. }
  29. }
  30. return statusCount;
  31.  
  32. }
  33. set;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement