Current File : /home/obabain/public_html/abc/city.jsp
<%@page import="java.sql.*" %>
<%!
String typ=null;
String sid=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/obaba_nfurnchi","obaba_nfurnchi","JikRvLk$0"); //create connection
        Statement st=con.createStatement();
        ResultSet rs1=st.executeQuery("select * from account_ledger where l_id="+id+"");
        while(rs1.next())
        {
        	typ=rs1.getString("type");
        	sid=rs1.getString("ref_id");
        	
        }
        String buffer="<input type='hidden' name='comm[]' value='0'> <input type='hidden' value='B' name='typ[]' class='bill'> <select name='city[]' class='selectType form-control' style='width:60%;'><option value='-1'>Select</option>";   
        PreparedStatement pstmt=null ; //create statement
                
        pstmt=con.prepareStatement("SELECT * FROM ip_sales_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("3")){
  rs = stmt.executeQuery("select tb.*,(tb.total-tb.received_amt)as tot From ip_sales_invoice tb where supplier_id="+sid+" and (total-received_amt)>0  "); 
  while(rs.next()){
	   buffer=buffer+"<option value='"+rs.getString("sinvoice_id")+"'>"+rs.getString("invoice_date_created")+"  |  "+rs.getString("sales_invoice_no")+"  |"+rs.getString("tot")+"</option>";  
	   }  
        }
        else if(typ.equals("0"))
        {
        	rs = stmt.executeQuery("select tr.*,(tr.debit-tr.paid_amt)as tot from journalentry tr where particulars="+id+" and type=1 and (debit-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);
 }
   
}
%>