============VisualForce Page=======================
<apex:page controller="branchsearch" showHeader="false">
<apex:includeScript value="{!$Resource.kvalidations}"/>
<apex:form id="theform">
<center><apex:commandButton value="New" action="{!newtab}"/></center>
<apex:pageBlock >
<TD>
<TABLE WIDTH="50%">
<TR>
<TD><apex:outputLabel >Name:</apex:outputLabel>
<apex:inputText value="{!name}">
<apex:actionSupport event="onkeyup" action="{!searchMethod}" reRender="pbt" status="filter"/>
</apex:inputText></TD>
<TD> <apex:commandButton value="next" action="{!nextmethod}" reRender="pbt"/>
<apex:commandButton value="previous" action="{!previousmethod}" reRender="pbt"/> </TD>
</TR>
</TABLE>
</TD>
<apex:pageBlockSection >
<apex:panelGrid >
<apex:outputPanel >
<apex:pageBlockTable value="{!records}" var="r" id="pbt">
<apex:column value="{!r.name}"/>
<apex:column value="{!r.Code__c}"/>
<apex:column value="{!r.Organization__c}"/>
<apex:column value="{!r.Email__c}"/>
<apex:column value="{!r.Mobile1__c}"/>
<apex:column headerValue="Action" >
<apex:commandLink value="Edit" action="{!Editkk}" >
<apex:param name="id" value="{!r.id}" id="id" />
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
<!--
<apex:outputPanel rendered="{!kiran}">
<apex:pageBlockTable value="{!record}" var="r" >
<apex:column value="{!r.name}"/>
<apex:column value="{!r.Code__c}"/>
<apex:column value="{!r.Organization__c}"/>
<apex:column value="{!r.Email__c}"/>
<apex:column value="{!r.Mobile1__c}"/>
<apex:column headerValue="Action" >
<apex:commandButton value="Edit" action="{!Editkk}">
<apex:param name="id" value="{!r.id}"/>
</apex:commandButton>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>-->
</apex:panelGrid>
<!-- ==================================2================================ -->
<apex:panelGrid >
<!-- ==================================new ============================ -->
<apex:pageBlock rendered="{!newpage}" >
<apex:tabPanel switchType="client">
<apex:tab label="General" style="width:200px">
<apex:pageBlockSection title="Information" columns="1">
<apex:inputField value="{!branch.name}">
<font color="red" size="4" >l</font>
<apex:actionSupport event="onblur" action="{!codevalidate}" reRender="c" />
</apex:inputField>
<apex:inputField value="{!branch.Code__c}" id="c" >
<font color="red" size="4" >l</font>
</apex:inputField>
<apex:inputField value="{!branch.Abbr__c}"/>
<apex:outputPanel >
<apex:outputLabel ><b>Division</b> </apex:outputLabel>
<apex:selectList value="{!selectDivision}" size="1">
<apex:selectoptions value="{!selectdtype}" ></apex:selectoptions>
</apex:selectList> <font color="red" size="4" >l</font>
</apex:outputPanel>
<apex:inputField value="{!branch.Status__c}" >
<font color="red" size="4" >l</font>
</apex:inputField>
<apex:inputField value="{!branch.Currency_in_Decimal__c}"/>
<apex:inputField value="{!branch.Date_Type__c}"/>
<apex:outputPanel >
<apex:outputLabel ><b>TimeZone</b> </apex:outputLabel>
<apex:selectList value="{!selectTimezone}" size="1">
<apex:selectoptions value="{!selectLtype}" ></apex:selectoptions>
</apex:selectList> <font color="red" size="4" >l</font>
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageBlockSection title="Address" columns="1">
<apex:inputField value="{!branch.Address1__c}"/>
<apex:inputField value="{!branch.Address2__c}"/>
<apex:inputField value="{!branch.City__c}"/>
<apex:inputField value="{!branch.State__c}"/>
<apex:inputField value="{!branch.Country__c}"/>
<apex:inputField value="{!branch.Zip__c}" onkeyup="zipRule(this)"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contact" columns="1">
<apex:inputField value="{!branch.Contact__c}"/>
<apex:inputField value="{!branch.Mobile1__c}" onkeyup="allowNumber(this)">
</apex:inputField>
<apex:inputField value="{!branch.Email__c}"/>
</apex:pageBlockSection>
<apex:outputPanel >
<apex:commandButton value="save" action="{!mySavenew}"/>
<apex:commandButton value="Cancel" action="{!Cancelnew}"/>
</apex:outputPanel>
</apex:tab>
<apex:tab label="Registration" style="width:200px">
<apex:pageBlockSection title="Branches" columns="1">
<apex:inputField value="{!branch.Registration1__c}" />
<apex:inputField value="{!branch.RegDate1__c}" />
<apex:inputField value="{!branch.Registration2__c}" />
<apex:inputField value="{!branch.RegDate2__c}" />
<apex:inputField value="{!branch.Registration3__c}" />
<apex:inputField value="{!branch.RegDate3__c}" />
<apex:inputField value="{!branch.Registration4__c}" />
<apex:inputField value="{!branch.RegDate4__c}" />
<apex:inputField value="{!branch.Registration5__c}" />
<apex:inputField value="{!branch.RegDate5__c}" />
<apex:outputPanel >
<apex:commandButton value="save" action="{!mySavenew}"/>
<apex:commandButton value="Cancel" action="{!Cancelnew}"/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
<!-- ==================================new ============================ -->
<!-- ==================================edit============================ -->
<!--========================Input fields Block========================-->
<apex:pageBlock rendered="{!editinput}">
<apex:tabPanel switchType="client">
<apex:tab label="General" style="width:200px">
<apex:pageBlockSection title="Information" columns="1">
<apex:inputField value="{!branch.name}">
<font color="red" size="4" >l</font>
</apex:inputField>
<apex:outputField value="{!branch.Code__c}" />
<apex:inputField value="{!branch.Abbr__c}"/>
<apex:outputPanel >
<apex:outputLabel ><b>Division</b>
</apex:outputLabel>
<apex:selectList value="{!selectDivision}" size="1">
<apex:selectoptions value="{!selectdtype}" ></apex:selectoptions>
</apex:selectList> <font color="red" size="4" >l</font>
</apex:outputPanel>
<apex:inputField value="{!branch.Status__c}" >
<font color="red" size="4" >l</font>
</apex:inputField>
<apex:inputField value="{!branch.Currency_in_Decimal__c}"/>
<apex:inputField value="{!branch.Date_Type__c}"/>
<apex:outputPanel >
<apex:outputLabel ><b>TimeZone</b>
</apex:outputLabel>
<apex:selectList value="{!selectTimezone}" size="1">
<apex:selectoptions value="{!selectLtype}" ></apex:selectoptions>
</apex:selectList> <font color="red" size="4" >l</font>
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageBlockSection title="Address" columns="1">
<apex:inputField value="{!branch.Address1__c}"/>
<apex:inputField value="{!branch.Address2__c}"/>
<apex:inputField value="{!branch.City__c}"/>
<apex:inputField value="{!branch.State__c}"/>
<apex:inputField value="{!branch.Country__c}"/>
<apex:inputField value="{!branch.Zip__c}" onkeyup="zipRule(this)"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contact" columns="1">
<apex:inputField value="{!branch.Contact__c}"/>
<apex:inputField value="{!branch.Mobile1__c}" onkeydown="allowNumber(this)">
</apex:inputField>
<apex:inputField value="{!branch.Email__c}"/>
</apex:pageBlockSection>
<apex:outputPanel >
<apex:commandButton value="Update" action="{!mySaveedit}" />
<apex:commandButton value="Cancel" action="{!Canceledit}"/>
</apex:outputPanel>
</apex:tab>
<apex:tab label="Registration" style="width:200px">
<apex:pageBlockSection title="Branches" columns="1">
<apex:inputField value="{!branch.Registration1__c}" />
<apex:inputField value="{!branch.RegDate1__c}" />
<apex:inputField value="{!branch.Registration2__c}" />
<apex:inputField value="{!branch.RegDate2__c}" />
<apex:inputField value="{!branch.Registration3__c}" />
<apex:inputField value="{!branch.RegDate3__c}" />
<apex:inputField value="{!branch.Registration4__c}" />
<apex:inputField value="{!branch.RegDate4__c}" />
<apex:inputField value="{!branch.Registration5__c}" />
<apex:inputField value="{!branch.RegDate5__c}" />
<apex:outputPanel >
<apex:commandButton value="Update" action="{!mySaveedit}" />
<apex:commandButton value="Cancel" action="{!Canceledit}"/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
<!--========================output fields Block========================-->
<apex:pageBlock rendered="{!editoutput}" id="out">
<apex:tabPanel switchType="client">
<apex:tab label="General" style="width:200px">
<apex:pageBlockSection title="Information" columns="1">
<apex:outputField value="{!branch .name}"/>
<apex:outputField value="{!branch .Code__c}"/>
<apex:outputField value="{!branch.Abbr__c}"/>
<apex:outputField value="{!branch.Division__c}"/>
<apex:outputField value="{!branch.Status__c}" />
<apex:outputField value="{!branch.Currency_in_Decimal__c}"/>
<apex:outputField value="{!branch.Date_Type__c}"/>
<apex:outputField value="{!branch.TimeZone__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Address" columns="1">
<apex:outputField value="{!branch.Address1__c}"/>
<apex:outputField value="{!branch.Address2__c}"/>
<apex:outputField value="{!branch.City__c}"/>
<apex:outputField value="{!branch.State__c}"/>
<apex:outputField value="{!branch.Country__c}"/>
<apex:outputField value="{!branch.Zip__c}" />
</apex:pageBlockSection>
<apex:pageBlockSection title="Contact" columns="1">
<apex:outputField value="{!branch.Contact__c}"/>
<apex:outputField value="{!branch.Mobile1__c}" />
<apex:outputField value="{!branch.Email__c}"/>
</apex:pageBlockSection>
<apex:outputPanel >
<apex:commandButton value="Edit" action="{!myEditedit}"/>
<apex:commandButton value="Delete"
action="{!mydeleteedit}" onclick="return confirm('Are you sure?');"/>
<apex:commandButton value="Cancel" action="{!Cancelbl}"/>
</apex:outputPanel>
</apex:tab>
<apex:tab label="Registrations" style="width:200px" >
<apex:pageBlockSection title="Branch" columns="1">
<apex:outputField value="{!branch.Registration1__c}" />
<apex:outputField value="{!branch.RegDate1__c}" />
<apex:outputField value="{!branch.Registration2__c}" />
<apex:outputField value="{!branch.RegDate2__c}" />
<apex:outputField value="{!branch.Registration3__c}" />
<apex:outputField value="{!branch.RegDate3__c}" />
<apex:outputField value="{!branch.Registration4__c}" />
<apex:outputField value="{!branch.RegDate4__c}" />
<apex:outputField value="{!branch.Registration5__c}" />
<apex:outputField value="{!branch.RegDate5__c}" />
<apex:outputPanel >
<apex:commandButton value="Edit" action="{!myEditedit}"/>
<apex:commandButton value="Delete"
action="{!mydeleteedit}" onclick="return confirm('Are you sure?');"/>
<apex:commandButton value="Cancel" action="{!Cancelbl}"/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
<!-- ==================================edit============================ -->
</apex:panelGrid>
<!-- ===================================2=============================== -->
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
==================controller==============
public with sharing class branchsearch {
public void queryMethod(){
records=Database.query(soql);
}
public boolean editoutput { get; set; }
public boolean editinput { get; set; }
public boolean newpage { get; set; }
public string soql{set;get;}
public PageReference newtab() {
newpage = true;
editoutput = false;
editinput = false;
return null;
}
//-----------------------------------search-------------------------------------------------------------------------------
public list<branch__c> b{ get; set; }
public boolean kiran { get; set; }
public list<branch__c> records { get; set; }
public list<branch__c> record { get; set; }
public String name { get; set; }
public string soql1{set;get;}
id id;
string id1;
public boolean pagination {set; get;}
public boolean search {set; get;}
Integer recordLimit = 1;
Integer offSetLimit =0;
public branchsearch() {
branch = new branch__c();
soql='SELECT
code1__c,Code__c,Contact__c,Country__c,CreatedById,CreatedDate,Email__c,mobile1__c,Name,Organization__c,Id,Phone__c
FROM Branch__c limit 3 ';
queryMethod();
}
public PageReference Editkk() {
id1 =apexpages.currentpage().getparameters().get('id');
system.debug('the id:::::::6666666666666666666666666666666666666666666666666666666666666666666666'+id1);
branch = [SELECT
Abbr__c,Address1__c,Address2__c,Name,City__c,Code__c,Contact__c,Country__c,Email__c,Language__c,Division__c,Currency_in_Decimal__c,Date_Type__c
,
mobile1__c,Phone__c,Organization__c,RegDate1__c,RegDate2__c,RegDate3__c,RegDate4__c,RegDate5__c,Registration1__c,Registration2__c,Registration3__c,Registration4__c,Registration5__c,Remarks__c,State__c,Status__c,Timezone__c,Zip__c
FROM Branch__c where id =: id1];
editoutput = true;
newpage = false;
return null;
}
public PageReference previousmethod() {
offSetLimit=0;
queryMethod1();
return null;
}
public PageReference nextmethod() {
offSetLimit=+3;
//soql=+ 'OFFSET:offSetLimit ';
queryMethod1();
return null;
}
public void queryMethod1(){
system.debug(',,,,,,,,,,,,,,,,,,,,,,,,,,,'+offSetLimit);
records=Database.query(soql+ ' OFFSET ' + offSetLimit);
}
/*
public List<Branch__c> records { get{
records=[SELECT
code1__c,Code__c,Contact__c,Country__c,CreatedById,CreatedDate,Email__c,mobile1__c,Name,Organization__c,Id,Phone__c
FROM Branch__c where Name Like:('%'+name+'%') Limit :recordLimit OFFSET
:offSetLimit ];
return records;
} set; }
*/
public PageReference searchMethod() {
soql='SELECT
code1__c,Code__c,Contact__c,Country__c,CreatedById,CreatedDate,Email__c,mobile1__c,Name,Organization__c,Id,Phone__c
FROM Branch__c ' ;
if(!name.equals(''))
soql+='where name LIKE \''+String.escapeSingleQuotes(name)+'%\'';
soql1=soql;
queryMethod();
return null;
}
/* public list<Branch__c> getRecord() {
return record;
}*/
//-----------------------------------search-------------------------------------------------------------------------------
//-----------------------------------New page-------------------------------------------------------------------------------
public branch__c branch {set; get;}
public Boolean mandatoryerr { get; set; }
public String selectDivision{ get; set; }
public String selectTimezone{ get; set; }
public PageReference codevalidate() {
if(branch.Code__c == null){
branch.Code__c = branch.name;
}else{
}
return null;
}
public List<selectoption> getSelectdtype() {
List<selectoption> option = new List<selectoption>();
for(lookup__c lt : [select id,name from lookup__c where looktype__c = 'Division'] ){
option.add(new selectoption(lt.name,lt.name));
}
return option;
}
public List<selectoption> getSelectLtype() {
List<selectoption> option = new List<selectoption>();
for(lookup__c lt : [select id,name from lookup__c where looktype__c = 'Time Zone'] ){
option.add(new selectoption(lt.name,lt.name));
}
return option;
}
public PageReference mySavenew() {
if(branch.name == null){
mandatoryerr = true;
branch.name.addError(' You must enter a value');
}
if(branch.Code__c == null){
mandatoryerr = true;
branch.Code__c.addError(' You must enter a value');
}
if(branch.status__c == null){
mandatoryerr = true;
branch.status__c.addError(' You must enter a value');
}
/* if(branch.Organization__c == null){
mandatoryerr = true;
branch.Organization__c.addError(' You must enter a value');
}*/
if(branch.name != null && branch.status__c != null ){ //&& branch.Organization__c != null
if(branch.Code__c == null){
branch.Code__c = branch.name;
branch.division__c = selectDivision;
branch.TimeZone__c = selectTimezone;
insert branch;
newpage = false;
}else{
branch.division__c = selectDivision;
branch.TimeZone__c = selectTimezone;
insert branch;
newpage = false;
}
branch.clear();
}
return null;
}
public PageReference Cancelnew() {
newpage = false;
return null;
}
//-----------------------------------New page-------------------------------------------------------------------------------
//-----------------------------------Edit page-------------------------------------------------------------------------------
public PageReference myEditedit() {
editinput = true;
editoutput = false;
newpage = false;
return null;
}
public PageReference Cancelbl() {
editoutput = false;
return null;
}
public PageReference mydeleteedit() {
delete branch;
return null;
}
public PageReference mySaveedit() {
if(branch.name == null){
mandatoryerr = true;
branch.name.addError(' You must enter a value');
}
if(branch.Code__c == null){
mandatoryerr = true;
branch.Code__c.addError(' You must enter a value');
}
if(branch.status__c == null){
mandatoryerr = true;
branch.status__c.addError(' You must enter a value');
}
if(branch.name != null && branch.status__c != null ){ //&& branch.Organization__c != null
branch.division__c = selectDivision;
branch.TimeZone__c = selectTimezone;
update branch;
editoutput = false;
editinput = false;
}
return null;
}
public PageReference Canceledit() {
editinput = false;
return null;
}
//-----------------------------------Edit page-------------------------------------------------------------------------------
}