You are on page 1of 4

APEX COADING

public opportunity opp{get;set;}


public Opportunity_Line_Item__c opli {get;set;}
public list<Opportunity_Line_Item__c> oplt {get;set;}
public list<Opportunity_Line_Item__c> oplitm {get;set;}
public integer numberofrowremove {get;set;}
public string Rid {get;set;}

public newpage(){
Rid = apexpages.currentpage().getparameters().get ('id');
opp = new opportunity();
opli = new Opportunity_Line_Item__c ();

oplt = new list<Opportunity_Line_Item__c>();


oplt.add(opli);
oplitm = [ select
Account__c,Description__c,Probability__c,opportunities__c,product__c ,GST__c,HSN_Co
de__c,IGST__c from Opportunity_Line_Item__c ];
}
public PageReference Save(){
Insert opp;
PageReference prf= new PageReference ('/'+opp.id);
return prf ;
}

public PageReference Cancel(){


return new PageReference ('/'+Rid);
}
public PageReference AddRow(){
Opportunity_Line_Item__c opli2 = new Opportunity_Line_Item__c();
opli2.opportunities__c = Rid;
oplt.add(opli2);
return null;

}
VF PAGE
<apex:page controller="newpage" >
<apex:sectionHeader title="Add Custom Product" subtitle="new custom product"/>
<apex:form >
<apex:pageBlock title="Add custom Product" >
<apex:pageBlockButtons / >
<apex:commandButton value="save" action="{!Save}" />
<apex:commandButton value="Cancel" action="{!Cancel}"/>
<apex:commandButton value="add row" action="{!AddRow}"/>

<apex:pageBlockTable value="{!opli}" var="pa">

<apex:column headerValue="Account name">


<apex:inputField value="{!pa.Account__c}" required="false"/>
</apex:column>
<apex:column headerValue="opportunity name">
<apex:inputField value="{!pa.opportunities__c}" required="false"/>
</apex:column>
<apex:column headerValue="Probablity%">
<apex:inputField value="{!pa.Probability__c}" required="false"/>
</apex:column>
<apex:column headerValue="product name">
<apex:inputField value="{!pa.product__c}"/>
</apex:column>
<apex:column headerValue="SGST%">
<apex:inputField value="{!pa.SGST__c}" required="false"/>
</apex:column>
<apex:column headerValue="IGST%">
<apex:inputField value="{!pa.IGST__c}" required="false"/>
</apex:column>
<apex:column headerValue="GST%">
<apex:inputField value="{!pa.GST__c}" required="false"/>
</apex:column>
<apex:column headerValue="HSN Code">
<apex:inputField value="{!pa.HSN_Code__c}" required="false"/>
</apex:column>
</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>

EditALL
<apex:page controller="EditAll" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Update all" action="{!save}"/>
<apex:commandButton value="cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

public class newcustomrec {


public opportunity opp {get;set;}
public string rec{get;set;}
public Opportunity_Line_Item__c opli {get;set;}
public list<Opportunity_Line_Item__c> oplist {get;set;}

public newcustomrec(){
rec=Apexpages.currentpage().getparameters().get('id');
system.debug(rec);
opp= new opportunity();
opli= new Opportunity_Line_Item__c();
oplist= new list<Opportunity_Line_Item__c>();

opp=[select id,name,accountid from opportunity where id =: rec];


opli.opportunities__c =opp.id;

}
public pagereference addrow(){
Opportunity_Line_Item__c opli2 = new Opportunity_Line_Item__c();
opli2.opportunities__c=rec;
oplist.add(opli2);
return null;
}
public void saveit(){
insert oplist;

}
<apex:page controller="newcustomrec" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="addrow" action="{!addrow}"/>
<apex:commandButton value="save" action="{!saveit}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!oplist}" var="pp" >
<apex:column headerValue="GST"/>
<apex:inputField value="{!pp.GST__c}"/>
<apex:column />
<apex:column headerValue="GST"/>
<apex:inputField value="{!pp.HSN_Code__c}"/>
<apex:column />
<apex:column headerValue="GST"/>
<apex:inputField value="{!pp.GST__c}"/>
<apex:column />
<apex:column headerValue="GST"/>
<apex:inputField value="{!pp.GST__c}"/>
<apex:column />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>

</apex:page>
<apex:outputField value="{!opp.name}"/>
<apex:outputField value="{!opp.Contact__c}"/>
<apex:outputField value="{!opp.CloseDate__c}"/>
<apex:outputField value="{!opp.LeadSource__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Totals" collapsible="false">
<apex:inputField value="{!qt.Subtotal__c}" />
<apex:inputField value="{!qt.List_Price__c}" />
<apex:inputField value="{!qt.Discount__c}" />
<apex:inputField value="{!qt.Unit_Price__c}" />
<apex:inputField value="{!qt.Total_Amount__c}" />
</apex:pageBlockSection>
<apex:pageBlockSection title="Address Information" collapsible="false">
<apex:inputField value="{!qt.Shipping_Name__c}" />
<apex:inputField value="{!qt.Additional_Name__c}" />
<apex:inputField value="{!qt.Shiping_Address__c}" />
<apex:inputField value="{!qt.Billing_Address__c}" />
</apex:pageBlockSection>
<apex:pageBlockSection title="Product Details" collapsible="false">
<apex:pageBlockTable value="{!oplist}" var="a" border="1">
<apex:column value="{!a.x1Opportunity__c}"/>

<table>
<tr><th>Account Name:</th>
<td><apex:outputField value="{!opp.name}"/></td>
</tr>
<tr><th>Customer Requirement:</th>
<td><apex:outputField value="{!opp.Stage__c}"/></td>
</tr>
<tr><th>Date:</th>
<td><apex:outputField value="{!opp.CloseDate__c}"/>
<apex:param value="{!opp.Account__c}"/></td>
</tr>

You might also like