Current File : /home/obabain/anms_obaba_in/state.jsp
<%@page import="java.sql.*" %>
<%!
String typ=null;
String sid=null;
ResultSet rs=null;
String cid=null;
%>

<%
if(request.getParameter("count")!=null) 
{
    int id=Integer.parseInt(request.getParameter("count")); //get country_id from index.jsp page with function country_change() through ajax and store in id variable
        
    try
    {
        Class.forName("com.mysql.jdbc.Driver"); //load driver
        Connection con=DriverManager.getConnection("jdbc:mysql://localhost/obabain_anmspl","obabain_anms22","y8*8i9DU2"); //create connection
        Statement st=con.createStatement();
         rs=st.executeQuery("select * from account_ledger where l_id="+id+"");
        while(rs.next())
        {
        	typ=rs.getString("type");
        	sid=rs.getString("ref_id");
        	cid=rs.getString("under");
        	
        }
        String buffer="<input type='hidden' name='comm[]' value='0'> <input type='hidden' value='B' name='typ[]' class='bill'> <select name='state[]' class='selectType form-control' style='width:60%;' onchange='showCity(this.value);'><option value='-1'>Select</option>";   
       /*  PreparedStatement pstmt=null ; //create statement
                
        pstmt=con.prepareStatement("SELECT * FROM ip_puchase_invoice where supplier_id=? "); //sql select query
        pstmt.setInt(1,id);
        ResultSet rs=pstmt.executeQuery();  *///execute query and set in resultset object rs.
       Statement stmt = con.createStatement(); 
        
        if(typ.equals("2")){
  rs = stmt.executeQuery("select tb.*,(tb.total-tb.paid_amt)as tot From ip_puchase_invoice3 tb where supplier_id="+sid+" and (total-paid_amt)>0  "); 
  while(rs.next()){
	   buffer=buffer+"<option value='"+rs.getString("pinvoice_id")+"'>"+rs.getString("invoice_date_created")+"  |  "+rs.getString("purchase_invoice_no")+"  |"+rs.getString("tot")+"</option>";  
	   }  
        }
        else if(typ.equals("1"))
        {
        	rs = stmt.executeQuery("select tr.*,(tr.credit-tr.paid_amt)as tot from journalentry tr where particulars="+id+" and type=2 and (credit-paid_amt)>0 ");  
            
        
  while(rs.next()){
   buffer=buffer+"<option value='"+rs.getString("journal_id")+"'>"+rs.getString("created_date")+"  |  "+rs.getString("journal_no")+"  |"+rs.getString("tot")+"</option>";  
   }  
        }
        if(typ.equals("3")){
        	rs = stmt.executeQuery("select tb.*,(tb.total-tb.paid_amt)as tot From credit_note tb where supplier="+sid+" and (total-paid_amt)>0"); 
        	  while(rs.next()){
        		   buffer=buffer+"<option value='"+rs.getString("voucher_id")+"'>"+rs.getString("voucher_date")+"  |  "+rs.getString("voucher_no")+"  |"+rs.getString("tot")+"</option>";  
        		   } 
        	
        }
        /* else if(typ.equals("0") && cid.equals("26"))
        {
        	rs = stmt.executeQuery("select tr.*,(tr.credit-tr.paid_amt)as tot from journalentry tr where particulars="+id+" and type=2 and (credit-paid_amt)>0 ");  
            
            
        	  while(rs.next()){
        	   buffer=buffer+"<option value='"+rs.getString("journal_id")+"'>"+rs.getString("created_date")+"  |  "+rs.getString("journal_no")+"  |"+rs.getString("tot")+"</option>";  
        	  
        }
        } */
        
 buffer=buffer+"</select>";  
 response.getWriter().println(buffer); 
 }
 catch(Exception e){
     System.out.println(e);
 }
   
}
%>