Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public class MyCustomController {
  2. public Merchandise__C merchandise { get; set; }
  3.  
  4. public MyCustomController() {
  5. Id id = ApexPages.currentPage().getParameters().get('id');
  6. merchandise= (id == null) ? new Merchandise__C() :
  7. [SELECT Name, Description__C, Price__C,Total_Inventory__C FROM Merchandise__C WHERE Id = :id];
  8. }
  9.  
  10. public PageReference save() {
  11. try{
  12. insert merchandise; //Database.insert
  13. return (new ApexPages.StandardController(Merchandise)).view();
  14. }catch(Exception ex){
  15. System.debug('Exception : ' + ex);
  16. }
  17. return null;
  18. }
  19.  
  20. }
  21.  
  22. <apex:page controller="MyCustomController" tabstyle="Merchandise__c">
  23. <apex:form >
  24. <apex:pageBlock mode="edit">
  25. <apex:pageMessages />
  26. <apex:pageBlockSection >
  27. <apex:inputField value="{!Merchandise.name}"/>
  28. <apex:inputField value="{!Merchandise.Description__c}"/>
  29. <apex:inputField value="{!Merchandise.Price__c}"/>
  30. <apex:inputField value="{!Merchandise.Total_Inventory__c}"/>
  31. </apex:pageBlockSection>
  32. <apex:pageBlockButtons location="bottom">
  33. <apex:commandButton value="Save" action="{!save}"/>
  34. </apex:pageBlockButtons>
  35. </apex:pageBlock>
  36. </apex:form>
  37. </apex:page>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement