• Ian Lin 439
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 3
    Replies
vf page:

<apex:page standardController="order" extensions="OrderExtension">
    <apex:form >
     <apex:pageMessages />
    <apex:pageBlock title="New Order">
    <apex:pageBlockSection title="Order Details" collapsible="false">
        <apex:inputField value="{!Order.AccountId}" html-placeholder="Customer Name"/>
         <apex:inputField value="{!Order.Email__c}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.Phone__c}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.EffectiveDate}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.Status}"/>
        <apex:inputField value="{!Order.ContractId}" html-placeholder="Contract Id"/>
        <apex:inputField value="{!Order.AEG__Rep_Code__c}"/>
        <!--apex:inputField value="{!Order.AEG__AR_Terms__c}"/-->
        <!--apex:inputField value="{!Order.AEG__Ship_Via__c}"/-->
        <apex:inputField value="{!Order.Pricebook2Id}" html-placeholder="PriceBook Type"/>
    </apex:pageBlockSection>
     <apex:pageBlockSection title="Address">
         <apex:inputField value="{!Order.ShippingAddress__c}" style="width:800px;height:20px" html-placeholder="Enter Text"/><br/>
         <apex:inputField value="{!Order.BillingAddress__c}" style="width:800px;height:20px" html-placeholder="Enter Text"/>
     </apex:pageBlockSection>
        <apex:pageBlockSection >
            <div align="right">
        <apex:commandButton value="Add New Order Item" action="{!add}"/>
               </div> 
        </apex:pageBlockSection>
        
      <apex:pageBlockSection title="Order Details" id="pb">
      <apex:pageBlockTable value="{!orderList}" var="o"> 
          <apex:column headerValue="Product Name" width="50%">
         <apex:outputField value="{!o.Product2Id}"/>
            </apex:column>  
          <apex:column headerValue="Product Family" width="50%">
           <apex:outputField value="{!o.product2.Family}"/>
           </apex:column>  
          <apex:column headerValue="Ordered Quantity" width="50%" >
           <apex:inputField value="{!o.Quantity}"/>
           </apex:column> 
          <!--apex:column headerValue="Available Quantity" width="50%">
           <apex:outputField value="{!o.AvailableQuantity__c}"/>
           </apex:column--> 
          <apex:column headerValue="List Price" width="50%">
           <apex:outputField value="{!o.ListPrice}"/>
           </apex:column>
          <apex:column headerValue="Unit Price" width="50%">
           <apex:outputField value="{!o.UnitPrice}"/>
           </apex:column>
          <apex:column >                      
              <apex:facet name="header">Action</apex:facet>
                <apex:commandLink action="{!deleteRecord}" value="Delete" onclick="if(!confirm('Are you sure?')) return false;">
                 <apex:param name="rowId" assignTo="{!bkId}" value="{!o.Id}"/>                 
               </apex:commandLink>
               </apex:column>        
      </apex:pageBlockTable>
        </apex:pageBlockSection>
        
           
           <apex:pageBlock id="orderAdd" >                 
        <apex:pageblockSection>
            <!--apex:actionRegion -->  
            <apex:pageBlockTable value="{!OrderLi}" var="orders">
                
                <!--apex:column headerValue="Product Name">
                    <apex:inputField value="{!orders.Product2Id}">
                    </apex:inputField>
                </apex:column-->
               
                <apex:column headerValue="Product Name">
                    
                    <apex:inputField value="{!orders.Product2Id}" >
                        <apex:actionSupport event="onchange" action="{!autopop}" reRender="orderAdd">
                        <apex:param name="selectedR"  value="{!orders.Product2Id}"  assignTo="{!ordId}"/>
                        </apex:actionSupport>
                         </apex:inputField>
                        </apex:column>
                
                <apex:column headerValue="Product Family" id="p1">
                    <apex:inputField value="{!orders.product2.Family}">
                        <!--apex:actionSupport event="onchange" action="{!autopop}" reRender="pbt">
                        <apex:param name="selectedR"  value="{!orders.product2.Family}" assignTo="{!ordId}"/>
                        </apex:actionSupport-->
                         </apex:inputField>
                </apex:column>
                <!--apex:outputField value="{!orders.product2.Family}"/-->
                <apex:column headerValue="order Quantity" id="p2">
                <apex:inputField value="{!orders.Quantity}">
                    <!--apex:actionSupport event="onchange" action="{!autopop}" reRender="orderAdd">
                        <apex:param name="selectedR"  value="{!orders.Quantity}" assignTo="{!ordId}"/>
                        </apex:actionSupport-->
                    </apex:inputField>
                </apex:column>
                             
                <!--apex:column headerValue="Available Quantity" width="50%">
           <apex:outputField value="{!orders.AvailableQuantity__c}"/>
           </apex:column-->
                <apex:column headerValue="order ListPrice">
                    <apex:inputField value="{!orders.ListPrice}">
                    <!--apex:actionSupport event="onchange" action="{!autopop}">
                        <apex:param name="selectedR"  value="{!orders.ListPrice}" assignTo="{!ordId}"/>
                        </apex:actionSupport-->
                    </apex:inputField>
                </apex:column>
                <apex:column headerValue="orders UnitPrice">
                    <apex:inputField value="{!orders.UnitPrice}"/>
                </apex:column>
                      
                <!--apex:column headerValue="orders Pricebook">
                    <apex:inputField value="{!Order.Pricebook2Id}"/>
                </apex:column-->
               
            </apex:pageBlockTable>   
                   
                <!--/apex:actionRegion-->
        </apex:pageblockSection>  
            
    </apex:pageBlock>
               
        <apex:pageBlockSection >
             <apex:panelGrid columns="4">
              <apex:commandButton action="{!First}" value="First"/>
              <apex:commandButton action="{!Previous}" value="Previous"/>
              <apex:commandButton action="{!Next}" value="Next"/>
              <apex:commandButton action="{!Last}" value="Last"/>   
              </apex:panelGrid> 
          </apex:pageBlockSection>
        <apex:pageBlockSection >
          <div align="centre">  
         <apex:panelGrid columns="2" >   
        <apex:commandButton action="{!save}" value="Save"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
             </apex:panelGrid>
             </div> 
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
        
</apex:page>

extension:

public  with Sharing class OrderExtension {
        
    private order orders { get; set;}
    public String bkId {get; set;}
    public String  ordId {get; set;}
   //private orderItem addNew {get;set;}
    public integer startingFrom{get;set;}
    public List<OrderItem> orderList;
    public List<OrderItem> orderLi{get;set;}
    public List<PriceBookEntry> orderL;
   //public List<OrderItem> orderL{get;set;}
    private final integer MAX_RECORDS=5;
    private integer orderRecordCount;
    private integer lastRecords;
    private ID recordId;
    public OrderItem op{get;set;}
    List<Order> li=new List<Order>();
    //public List<orderItem> l{get;set;}
    private ApexPages.StandardController sc;   
    public OrderExtension(ApexPages.StandardController sc){
          //this.op = (OrderItem)sc.getRecord();
         this.sc=sc;
         recordId=ApexPages.currentPage().getParameters().get('id');
        if(startingFrom==null)
        {
            startingFrom=0;
         }
        
        if(recordId==null)
        {
            orders=new order();
        }
        else{
            
            orders=[select AccountId,status from order where id= : recordId];
        }
        
        orderRecordCount=[select count() from orderItem where orderid= :recordId];
        lastRecords=math.mod(orderRecordCount, 5);
        //system.debug(orderRecordCount);
       orderLi=new List<orderItem>();
        //orderL.add(o);
        //op=new OrderItem();
    }
    
    public PageReference autopop(){
        
        system.debug('rohit');

       // order cont=(order) sc.getRecord();
        //system.debug(cont);
       //cont.order=[select product2.family from orderitem where id=:cont.Product2Id];
        //ordId = apexpages.currentPage().getParameters().get('selectedR');
        system.debug(ordId);
        system.debug(ApexPages.currentPage().getParameters().get('selectedR'));
        system.debug(ApexPages.currentPage().getParameters());
         //OrderItem ord = [select product2.family from orderItem where id =: ordId limit 1];
         //system.debug(ordId);
                
        return null;
    }
    
    public PageReference deleteRecord(){
        OrderItem remBank = [select id from orderItem where id =: bkId limit 1];        
        if(remBank != null)
        {
            try{
                delete remBank;
            }
            catch(DmlException ex){
                ApexPages.addMessages(ex);
            }
        }
       return null;
   }  
    
 
     public List<orderItem> getorderList(){
        orderList=[select Product2Id,Quantity,product2.name,Product2.family,ListPrice,UnitPrice from orderItem where orderid= :recordId
                   limit: MAX_RECORDS 
                   offset: startingFrom];
        return orderList;
    }
    
    /*public List<priceBookEntry> getPriceBookList(){
        orderList=[select id from priceBookEntry];
        return orderList;
    }*/
    
    public PageReference save() {
        try {
             Order o=(order)sc.getRecord();
      upsert o;
           //Id Id1=orderLi.get(0);
           //Id Id2= orderLi.get(Pricebook2Id);
            system.debug(ordId);
            system.debug('rishi');
   List<OrderItem> orderLis=new List<OrderItem>();
      for(OrderItem p:orderLi)
      {
          Id Id1=(Id)p.get('Product2id');
          Id Id2=o.pricebook2id;
          Pricebookentry b=[select Product2id from pricebookentry where Product2id=:Id1 and pricebook2id= :ID2];
          p.PricebookEntryId=b.id;
          p.OrderId=o.Id;
          orderLis.add(p);
      }
       upsert orderLis; 
 
    System.debug('Statement after insert.');
} catch(DmlException e) {
    apexpages.addmessages(e);
}
        //PageReference pg=new 
        return ApexPages.currentPage();
        }
    
    public void add(){
       
        OrderItem m=new OrderItem();
        //Id i=m.Product2Id;
        //system.debug(i);
        //PriceBookEntry c=[SELECT Name, Product2.Family, Product2.Name, Product2Id,UnitPrice FROM PricebookEntry WHERE  Product2Id= :i];
        //m.PricebookEntryId=c.Id;
        orderLi.add(m);
        orderList.add(m);
    }
       
    public pageReference first(){
        startingFrom=0;
        return ApexPages.currentPage();
    }
    
    public pageReference previous(){
        
        if(startingFrom<=0)
        {
            startingFrom=0;
        }
        
        else if(startingFrom >= orderRecordCount)
        {
            startingFrom=startingFrom- MAX_RECORDS;
        }
        
        else if(startingFrom < orderRecordCount)
        {
            startingFrom=startingFrom-MAX_RECORDS;
        }
        return ApexPages.currentPage();
    }
    
    public pageReference next(){
        if((orderRecordCount-startingFrom)>MAX_RECORDS)
        {
            startingFrom=startingFrom+MAX_RECORDS;
        }
        return ApexPages.currentPage();
    }
    
    public pageReference last(){
        startingFrom=orderRecordCount-lastRecords;
        return ApexPages.currentPage();
    }
    
    

}
vf page:

<apex:actionRegion >
            <apex:pageBlockTable value="{!OrderLi}" var="orders" id="pbt">
               
                <apex:column headerValue="Product Name">
                    
                    <apex:inputField value="{!orders.Product2Id}" >
                        <apex:actionSupport event="onchange" action="{!autopop}" reRender="pbt">
                        <apex:param name="selectedR"  value="{!orders.Product2Id}" assignTo="{!ordId}"/>
                        </apex:actionSupport>
                         </apex:inputField>
                        </apex:column>
         
Extension method:

 public PageReference autopop(){
        
        system.debug('rohit');

       // order cont=(order) sc.getRecord();
        //system.debug(cont);
       //cont.order=[select product2.family from orderitem where id=:cont.Product2Id];
        //ordId = apexpages.currentPage().getParameters().get('selectedR');
        system.debug(ordId);
        system.debug('rohit');
         //OrderItem ord = [select product2.family from orderItem where id =: ordId limit 1];
         //system.debug(ordId);
                
        return null;
    }
 
vf page:
<apex:pageBlockTable value="{!OrderLi}" var="orders" id="pbt">
                
                <!--apex:column headerValue="Product Name">
                    <apex:inputField value="{!orders.Product2Id}">
                    </apex:inputField>
                </apex:column-->
               
                <apex:column headerValue="Product Name">
                    
                    <apex:inputField value="{!orders.Product2Id}" >
                         <apex:actionSupport event="onclick" action="{!autopop}" reRender="orderAdd"  immediate="true">
                        <apex:param name="selectedR"  value="{!orders.Product2Id}" assignTo="{!ordId}"/>
                        </apex:actionSupport>    
                         </apex:inputField>
                        </apex:column>

extension:
public void autopop(){
        
        system.debug('rohit');

       // order cont=(order) sc.getRecord();
        //system.debug(cont);
       //cont.order=[select product2.family from orderitem where id=:cont.Product2Id];
        ordId = apexpages.currentPage().getParameters().get('selectedR');
        system.debug(ordId);
        system.debug('rohit');
         //OrderItem ord = [select product2.family from orderItem where id =: ordId limit 1];
         //system.debug(ordId);
                
        //return null;
    }
vf page:
<apex:page standardController="order" extensions="OrderExtension">
    <apex:form >
     <apex:messages />
    <apex:pageBlock title="New Order">
    <apex:pageBlockSection title="Order Details" collapsible="false">
        <apex:inputField value="{!Order.AccountId}" html-placeholder="Customer Name"/>
         <apex:inputField value="{!Order.Email__c}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.Phone__c}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.EffectiveDate}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.Status}"/>
        <apex:inputField value="{!Order.ContractId}" html-placeholder="Contract Id"/>
        <apex:inputField value="{!Order.AEG__Rep_Code__c}"/>
        <!--apex:inputField value="{!Order.AEG__AR_Terms__c}"/-->
        <!--apex:inputField value="{!Order.AEG__Ship_Via__c}"/-->
        <apex:inputField value="{!Order.Pricebook2Id}" html-placeholder="PriceBook Type"/>
    </apex:pageBlockSection>
     <apex:pageBlockSection title="Address">
         <apex:inputField value="{!Order.ShippingAddress__c}" style="width:800px;height:20px" html-placeholder="Enter Text"/><br/>
         <apex:inputField value="{!Order.BillingAddress__c}" style="width:800px;height:20px" html-placeholder="Enter Text"/>
     </apex:pageBlockSection>
        <apex:pageBlockSection >
            <div align="right">
        <apex:commandButton value="Add New Order Item" action="{!add}"/>
               </div> 
        </apex:pageBlockSection>
        
      <apex:pageBlockSection title="Order Details">
      <apex:pageBlockTable value="{!orderList}" var="o"> 
          <apex:column headerValue="Product Name" width="50%">
         <apex:outputField value="{!o.Product2Id}"/>
            </apex:column>  
          <apex:column headerValue="Product Family" width="50%">
           <apex:outputField value="{!o.product2.Family}"/>
           </apex:column>  
          <apex:column headerValue="Ordered Quantity" width="50%" >
           <apex:inputField value="{!o.Quantity}"/>
           </apex:column> 
          <!--apex:column headerValue="Available Quantity" width="50%">
           <apex:outputField value="{!o.AvailableQuantity__c}"/>
           </apex:column--> 
          <apex:column headerValue="List Price" width="50%">
           <apex:outputField value="{!o.ListPrice}"/>
           </apex:column>
          <apex:column headerValue="Unit Price" width="50%">
           <apex:outputField value="{!o.UnitPrice}"/>
           </apex:column>
          <apex:column >                      
              <apex:facet name="header">Action</apex:facet>
                <apex:commandLink action="{!deleteRecord}" value="Delete" onclick="if(!confirm('Are you sure?')) return false;">
                 <apex:param name="rowId" assignTo="{!bkId}" value="{!o.Id}"/>                 
               </apex:commandLink>
               </apex:column>        
      </apex:pageBlockTable>
        </apex:pageBlockSection>
           <apex:pageBlock id="orderAdd" >                 
        <apex:pageblockSection >
            <apex:pageBlockTable value="{!OrderLi}" var="orders" id="pbt">
                <!--apex:column headerValue="Product Name">
                    <apex:inputField value="{!orders.Product2Id}">
                    </apex:inputField>
                </apex:column-->
                <apex:column headerValue="Product Name">
                    <apex:inputField value="{!orders.Product2Id}">
                         <apex:actionSupport event="onchange" action="{!autopop}">
                        <apex:param name="selectedR"  value="{!orders.Product2Id}" assignTo="{!ordId}"/>
                        </apex:actionSupport>    
                        </apex:inputField>
                        </apex:column>
                <apex:column headerValue="Product Family">
                    <apex:inputField value="{!orders.product2.Family}"/>
                </apex:column>
                <!--apex:outputField value="{!orders.product2.Family}"/-->
                <apex:column headerValue="order Quantity">
                <apex:inputField value="{!orders.Quantity}"/>
                </apex:column>
                <!--apex:column headerValue="Available Quantity" width="50%">
           <apex:outputField value="{!orders.AvailableQuantity__c}"/>
           </apex:column-->
                <apex:column headerValue="order ListPrice">
                    <apex:inputField value="{!orders.ListPrice}"/>
                </apex:column>
                <apex:column headerValue="orders UnitPrice">
                    <apex:inputField value="{!orders.UnitPrice}"/>
                </apex:column>
                <!--apex:column headerValue="orders Pricebook">
                    <apex:inputField value="{!Order.Pricebook2Id}"/>
                </apex:column-->
            </apex:pageBlockTable>       
        </apex:pageblockSection>       
    </apex:pageBlock>
        <apex:pageBlockSection >
             <apex:panelGrid columns="4">
              <apex:commandButton action="{!First}" value="First"/>
              <apex:commandButton action="{!Previous}" value="Previous"/>
              <apex:commandButton action="{!Next}" value="Next"/>
              <apex:commandButton action="{!Last}" value="Last"/>   
              </apex:panelGrid> 
          </apex:pageBlockSection>
        <apex:pageBlockSection >
          <div align="centre">  
         <apex:panelGrid columns="2" >   
        <apex:commandButton action="{!save}" value="Save"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
             </apex:panelGrid>
             </div> 
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

extension method:

public PageReference autopop(){
        
       // order cont=(order) sc.getRecord();
        //system.debug(cont);
       //cont.order=[select product2.family from orderitem where id=:cont.Product2Id];
        ordId = apexpages.currentPage().getParameters().get('selectedR');
        system.debug(ordId);
        system.debug('rishi');
         //OrderItem ord = [select product2.family from orderItem where id =: ordId limit 1];
         //system.debug(ordId);
                
        return null;
    }
trigger TaxCalaculation on OrderItem (before insert,before update) {
    
    product2 a;
    //List<orderItem> a=[select product2.family from orderItem where product2id IN :Trigger.newMap.keySet()];
    //List<OrderItem> li=new List<OrderItem>();
    for(OrderItem o:Trigger.new)
    {
         a=[select family from product2 where id= :o.Product2Id];
        //o=[select Product2.family from orderItem where product2id= :Trigger.new.product2id];
                  
        //o=[select product2.family from orderItem where product2Id IN :Trigger.new];
        
        if(a.family=='Electronics')
       {
           o.taxRate__c=0.02;
       }
        
        else if(a.family=='FootWear')
       {
           o.taxRate__c=0.05;
       }
        
        else if(a.family=='Clothing')
       {
           o.taxRate__c=0.07;
       }
        
        o.finalRate__c=o.UnitPrice*o.Quantity*o.taxRate__c;
        
         system.debug(o.taxRate__c);
         system.debug(a.Family);
        System.debug(o.finalRate__c);

    }

}
GST rate applicable as per product family /category. System should auto apply GST on the basis of product family. Unit price are exclusive of tax rate i.e. on the top of Unit price tax need to be applied. (e.g. – Myntra prices are exclusive of tax but Flip kart/Amazon price are inclusive of tax)
    1. Tax per line item – Tax rate are according to product family i.e. should be configurable in the system.
Line Tax = Unit price * Quantity * Tax Rate
Tax per order – sum of all line Tax of all order line items
vf page:
<apex:page standardController="order" extensions="OrderExtension">
    <apex:form >
     <apex:messages />
    <apex:pageBlock title="New Order">
    <apex:pageBlockSection title="Order Details" collapsible="false">
        <apex:inputField value="{!Order.AccountId}" html-placeholder="Customer Name"/>
         <apex:inputField value="{!Order.Email__c}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.Phone__c}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.EffectiveDate}" html-placeholder="Enter Text"/>
         <apex:inputField value="{!Order.Status}"/>
        <apex:inputField value="{!Order.ContractId}" html-placeholder="Contract Id"/>
        <apex:inputField value="{!Order.AEG__Rep_Code__c}"/>
        <!--apex:inputField value="{!Order.AEG__AR_Terms__c}"/-->
        <!--apex:inputField value="{!Order.AEG__Ship_Via__c}"/-->
        <apex:inputField value="{!Order.Pricebook2Id}" html-placeholder="PriceBook Type"/>
    </apex:pageBlockSection>
     <apex:pageBlockSection title="Address">
         <apex:inputField value="{!Order.ShippingAddress__c}" style="width:800px;height:20px" html-placeholder="Enter Text"/><br/>
         <apex:inputField value="{!Order.BillingAddress__c}" style="width:800px;height:20px" html-placeholder="Enter Text"/>
     </apex:pageBlockSection>
        <apex:pageBlockSection >
            <div align="right">
        <apex:commandButton value="Add New Order Item" action="{!add}"/>
               </div> 
        </apex:pageBlockSection>
        
      <apex:pageBlockSection title="Order Details">
      <apex:pageBlockTable value="{!orderList}" var="o"> 
          <apex:column headerValue="Product Name" width="50%">
         <apex:outputField value="{!o.Product2Id}"/>
            </apex:column>  
          <apex:column headerValue="Product Family" width="50%">
           <apex:outputField value="{!o.product2.Family}"/>
           </apex:column>  
          <apex:column headerValue="Ordered Quantity" width="50%" >
           <apex:inputField value="{!o.Quantity}"/>
           </apex:column> 
          <!--apex:column headerValue="Available Quantity" width="50%">
           <apex:outputField value="{!o.AvailableQuantity__c}"/>
           </apex:column--> 
          <apex:column headerValue="List Price" width="50%">
           <apex:outputField value="{!o.ListPrice}"/>
           </apex:column>
          <apex:column headerValue="Unit Price" width="50%">
           <apex:outputField value="{!o.UnitPrice}"/>
           </apex:column>
          <apex:column >                      
              <apex:facet name="header">Action</apex:facet>
                <apex:commandLink action="{!deleteRecord}" value="Delete" onclick="if(!confirm('Are you sure?')) return false;">
                 <apex:param name="rowId" assignTo="{!bkId}" value="{!o.Id}"/>                 
               </apex:commandLink>
               </apex:column>        
      </apex:pageBlockTable>
        </apex:pageBlockSection>
           <apex:pageBlock id="orderAdd" >                 
        <apex:pageblockSection >
            <apex:pageBlockTable value="{!OrderLi}" var="orders" id="pbt">
                <!--apex:column headerValue="Product Name">
                    <apex:inputField value="{!orders.Product2Id}">
                    </apex:inputField>
                </apex:column-->
                <apex:column headerValue="Product Name">
                    <apex:inputField value="{!orders.Product2Id}">
                         <apex:actionSupport event="onchange" action="{!autopop}">
                        <apex:param name="selectedR"  value="{!orders.Product2Id}" assignTo="{!ordId}"/>
                        </apex:actionSupport>    
                        </apex:inputField>
                        </apex:column>
                <apex:column headerValue="Product Family">
                    <apex:inputField value="{!orders.product2.Family}"/>
                </apex:column>
                <!--apex:outputField value="{!orders.product2.Family}"/-->
                <apex:column headerValue="order Quantity">
                <apex:inputField value="{!orders.Quantity}"/>
                </apex:column>
                <!--apex:column headerValue="Available Quantity" width="50%">
           <apex:outputField value="{!orders.AvailableQuantity__c}"/>
           </apex:column-->
                <apex:column headerValue="order ListPrice">
                    <apex:inputField value="{!orders.ListPrice}"/>
                </apex:column>
                <apex:column headerValue="orders UnitPrice">
                    <apex:inputField value="{!orders.UnitPrice}"/>
                </apex:column>
                <!--apex:column headerValue="orders Pricebook">
                    <apex:inputField value="{!Order.Pricebook2Id}"/>
                </apex:column-->
            </apex:pageBlockTable>       
        </apex:pageblockSection>       
    </apex:pageBlock>
        <apex:pageBlockSection >
             <apex:panelGrid columns="4">
              <apex:commandButton action="{!First}" value="First"/>
              <apex:commandButton action="{!Previous}" value="Previous"/>
              <apex:commandButton action="{!Next}" value="Next"/>
              <apex:commandButton action="{!Last}" value="Last"/>   
              </apex:panelGrid> 
          </apex:pageBlockSection>
        <apex:pageBlockSection >
          <div align="centre">  
         <apex:panelGrid columns="2" >   
        <apex:commandButton action="{!save}" value="Save"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
             </apex:panelGrid>
             </div> 
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

extension method:

public PageReference autopop(){
        
       // order cont=(order) sc.getRecord();
        //system.debug(cont);
       //cont.order=[select product2.family from orderitem where id=:cont.Product2Id];
        ordId = apexpages.currentPage().getParameters().get('selectedR');
        system.debug(ordId);
        system.debug('rishi');
         //OrderItem ord = [select product2.family from orderItem where id =: ordId limit 1];
         //system.debug(ordId);
                
        return null;
    }