Advertisement
Guest User

Untitled

a guest
Feb 24th, 2014
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. public with sharing class AddBasketGasQuoteFromMonitor{
  2. @TestVisible Public List<WrapperClassEx> WrapperList{get;set;}
  3. public AddBasketGasQuoteFromMonitor(ApexPages.StandardSetController controller) {
  4. mycon = controller;
  5. Selectedmeters = mycon.getSelected();
  6. }
  7. public AddBasketGasQuoteFromMonitor(ApexPages.StandardController controller) {
  8. mycon2 = controller;
  9.  
  10. }
  11. public List<sobject> Selectedmeters {get; set;}
  12. ApexPages.StandardSetController mycon;
  13. ApexPages.StandardController mycon2;
  14. @TestVisible Public List<WrapperClassEx> getwrapperObj(){
  15. id lineId = mycon2.getId();
  16. //List<Account> accList = [Select id,name from account limit 5];
  17. //List<Line_del__c> SelectedLines = [select Linked_Monitor_Line__r.id from Line_del__c where id in: SelectedMeters];
  18. List<electricity_meter__c> MeterList = [Select id,name,AQ__c,meter_details__c from electricity_meter__c where (Linked_Monitor_Line__c =: lineId)];
  19. WrapperList = New List<WrapperClassEx>();
  20. for(electricity_meter__c met: MeterList){
  21. String meterNameInner = String.valueOf( met.get('Name') );
  22. String meterAQ = String.valueOf( met.get('AQ__c') );
  23. String meterID = String.valueOf( met.get('meter_details__c') );
  24. WrapperList.add(New WrapperClassEx(met,meterNameInner,meterAQ,meterID ));
  25. }
  26. return WrapperList;
  27. }
  28. Public String options{get;set;}
  29. // Get the list of suppliers
  30. public List<SelectOption> getSuppliers(){
  31. List<SelectOption> options = new List<SelectOption>();
  32. Schema.DescribeFieldResult fieldResult =
  33. Electricity_Meter__c.Current_Supplier__c.getDescribe();
  34. List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
  35. for( Schema.PicklistEntry f : ple)
  36. {
  37. options.add(new SelectOption(f.getLabel(), f.getValue()));
  38. }
  39. return options;
  40. }
  41.  
  42. @TestVisible Public Class WrapperClassEx{
  43. Public Account accObj {get;set;}
  44. Public Sobject elecObj {get;set;}
  45. Public Boolean checkBox{get;set;}
  46. Public string meterName{get;set;}
  47. Public double dayrate {get;set;}
  48. Public string meterID {get;set;}
  49. Public double standing{get;set;}
  50. Public string supplier{get;set;}
  51. Public string AQ {get;set;}
  52. Public string AQQ {get;set;}
  53. Public WrapperClassEx(sobject accRec, string meterNameMethodVar, string meterAQ, string meterIDs ){
  54. elecObj = accRec;
  55. meterName = meterNameMethodVar;
  56. AQ=meterAQ;
  57. meterID=meterIDs;
  58. }
  59. }
  60.  
  61. public List<Quote__C> newQuotes {get; set;}
  62.  
  63. public void save(){
  64. newQuotes = new list<Quote__c>();
  65. for (WrapperClassEx wrap : WrapperList){
  66. newQuotes.add(new Quote__c(
  67. consumption__c=decimal.valueOf(wrap.AQQ),
  68. Day_rate__c=decimal.valueOf(wrap.dayrate),
  69. Standing_Charge__c=decimal.valueOf(wrap.standing),
  70. Supplier__c=wrap.supplier,
  71. All_Products__c=wrap.elecObj.id
  72. ));
  73. }
  74.  
  75. try {
  76. insert newQuotes;
  77. } catch (DmlException ex){
  78. ApexPages.addMessages(ex);
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement