Advertisement
srijitb

Untitled

Sep 18th, 2014
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. package com.srijit.finasoft.customer;
  2. import javax.servlet.http.HttpServletRequest;
  3. import javax.servlet.http.HttpSession;
  4.  
  5. import org.apache.struts2.interceptor.ServletRequestAware;
  6.  
  7. import com.opensymphony.xwork2.ActionSupport;
  8. import com.srijit.finasoft.dao.*;
  9.  
  10. import java.sql.*;
  11. import java.util.ArrayList;
  12. import java.util.ListIterator;
  13.  
  14. public class ACSummary extends ActionSupport implements ServletRequestAware{
  15. Connection con;
  16. int cid;   
  17. ArrayList<ACModel> al=new ArrayList();
  18.  
  19.  
  20. public ArrayList getAl() {
  21.     return al;
  22. }
  23. public void setAl(ArrayList al) {
  24.     this.al = al;
  25. }
  26.  
  27. public int getCid() {
  28.     return cid;
  29. }
  30.  
  31. public void setCid(int cid) {
  32.     this.cid = cid;
  33. }
  34.  
  35.  
  36.  
  37.     public void setServletRequest(HttpServletRequest request)
  38.     {
  39.         HttpSession session=request.getSession();
  40.         if (session.getAttribute("custid")!=null)
  41.         {
  42.             cid=(int) session.getAttribute("custid");  
  43.         }
  44.        
  45.        
  46.     }  
  47.     public String execute()
  48.     {
  49.         if(cid!=0)
  50.         {
  51.             try {              
  52.             con=DBCon.getCon();        
  53.             PreparedStatement ps=con.prepareStatement("select a.acno,cd.fname,cd.lname,b.bname,a.acbal from custdetails cd,custac a,custacdetails d,branch_details b where d.custid=? and a.acno=d.acno and d.custid=cd.custid and a.branchid=b.bid");
  54.             ps.setInt(1, cid);
  55.             ResultSet rs=ps.executeQuery();
  56.             while(rs.next()){                  
  57.                 ACModel obj = new ACModel();
  58.                 obj.setAcno(rs.getLong(1));
  59.                 obj.setAcname(rs.getString(2)+" "+rs.getString(3) );
  60.                 obj.setBranch(rs.getString(4));
  61.                 obj.setAcbal(rs.getDouble(5));             
  62.                 al.add(obj);
  63.               }
  64.            
  65.             }
  66.             catch(Exception e){e.printStackTrace();}    
  67.            
  68.             return "success";
  69.         }
  70.         else
  71.             {
  72.                 return LOGIN;
  73.             }
  74.            
  75.                
  76.     }  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement