Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public with sharing class AddBasketGasQuoteFromMonitor{
- @TestVisible Public List<WrapperClassEx> WrapperList{get;set;}
- public AddBasketGasQuoteFromMonitor(ApexPages.StandardSetController controller) {
- mycon = controller;
- Selectedmeters = mycon.getSelected();
- }
- public AddBasketGasQuoteFromMonitor(ApexPages.StandardController controller) {
- mycon2 = controller;
- }
- public List<sobject> Selectedmeters {get; set;}
- ApexPages.StandardSetController mycon;
- ApexPages.StandardController mycon2;
- @TestVisible Public List<WrapperClassEx> getwrapperObj(){
- id lineId = mycon2.getId();
- //List<Account> accList = [Select id,name from account limit 5];
- //List<Line_del__c> SelectedLines = [select Linked_Monitor_Line__r.id from Line_del__c where id in: SelectedMeters];
- List<electricity_meter__c> MeterList = [Select id,name,AQ__c,meter_details__c from electricity_meter__c where (Linked_Monitor_Line__c =: lineId)];
- WrapperList = New List<WrapperClassEx>();
- for(electricity_meter__c met: MeterList){
- String meterNameInner = String.valueOf( met.get('Name') );
- String meterAQ = String.valueOf( met.get('AQ__c') );
- String meterID = String.valueOf( met.get('meter_details__c') );
- WrapperList.add(New WrapperClassEx(met,meterNameInner,meterAQ,meterID ));
- }
- return WrapperList;
- }
- Public String options{get;set;}
- // Get the list of suppliers
- public List<SelectOption> getSuppliers(){
- List<SelectOption> options = new List<SelectOption>();
- Schema.DescribeFieldResult fieldResult =
- Electricity_Meter__c.Current_Supplier__c.getDescribe();
- List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
- for( Schema.PicklistEntry f : ple)
- {
- options.add(new SelectOption(f.getLabel(), f.getValue()));
- }
- return options;
- }
- @TestVisible Public Class WrapperClassEx{
- Public Account accObj {get;set;}
- Public Sobject elecObj {get;set;}
- Public Boolean checkBox{get;set;}
- Public string meterName{get;set;}
- Public double dayrate {get;set;}
- Public string meterID {get;set;}
- Public double standing{get;set;}
- Public string supplier{get;set;}
- Public string AQ {get;set;}
- Public string AQQ {get;set;}
- Public WrapperClassEx(sobject accRec, string meterNameMethodVar, string meterAQ, string meterIDs ){
- elecObj = accRec;
- meterName = meterNameMethodVar;
- AQ=meterAQ;
- meterID=meterIDs;
- }
- }
- public List<Quote__C> newQuotes {get; set;}
- public void save(){
- newQuotes = new list<Quote__c>();
- for (WrapperClassEx wrap : WrapperList){
- newQuotes.add(new Quote__c(
- consumption__c=decimal.valueOf(wrap.AQQ),
- Day_rate__c=decimal.valueOf(wrap.dayrate),
- Standing_Charge__c=decimal.valueOf(wrap.standing),
- Supplier__c=wrap.supplier,
- All_Products__c=wrap.elecObj.id
- ));
- }
- try {
- insert newQuotes;
- } catch (DmlException ex){
- ApexPages.addMessages(ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement