Here is my Code
Expand|Select|Wrap|Line Numbers
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <%@ page import="java.sql.*" %>
- <%@page import="java.util.Date"%>
- <%@ page import="java.math.*" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Insert title here</title>
- </head><h3>Invoice Details</h3>
- <body>
- <%
- String name=request.getParameter("bname");
- //System.out.println("name"+name);
- String size=request.getParameter("bsize");
- //System.out.println("size"+size);
- String qty=request.getParameter("quantity");;
- Date date=new Date();
- String availablequantity=(String)request.getAttribute("quantity");
- //System.out.println("quantity"+availablequantity);
- String invoice=request.getParameter("invoice");
- String newqty=(String)request.getAttribute("up1");
- //System.out.println(invoice);
- try{
- Class.forName("org.postgresql.Driver");
- Connection con=DriverManager.getConnection("jdbc:postgresql://192.168.1.2:5432/tlsagencies","ihisblank","ihisblank");
- Statement s1=con.createStatement();
- Statement s2=con.createStatement();
- Statement s3=con.createStatement();
- Statement s4=con.createStatement();
- Statement s5=con.createStatement();
- Statement s6=con.createStatement();
- Statement s7=con.createStatement();
- Statement s8=con.createStatement();
- Statement s9=con.createStatement();
- Statement s10=con.createStatement();
- Statement s11=con.createStatement();
- String x="Select Size";
- //System.out.println("qwadsasdasd"+x);
- ResultSet r1=s1.executeQuery("select brandname from brandlist");
- %>
- <form action="Table.jsp" method="get"><table><div><tr><td>BrandName:</td><td><select name="bname" onchange="this.form.submit()" id="bname">
- <%if(name!=null)
- {
- %>
- <option value="<%=name %>"><%=name %></option>
- <%
- }
- %>
- <%if(name==null)
- {%>
- <option value="0">Select Brand</option>
- <%
- while(r1.next())
- {
- %>
- <option value="<%=r1.getString("brandname") %>"><%=r1.getString("brandname") %></option>
- <%
- }
- }
- %>
- </select></td></tr></div>
- <div><tr><td>BrandSize:</td><td><select name="bsize" onchange="this.form.submit()" id="bsize">
- <% if((size!=null)&&(name!=null))
- {
- %>
- <option value="<%=size %>"><%=size %></option>
- <%
- }
- if((size==null)||(name!=null))
- {
- ResultSet r2=s2.executeQuery("select brandlist_seq from brandlist where brandname='"+name+"'");
- if(size==null){
- %>
- <option name="0">Select Size</option>
- <%
- }
- while(r2.next())
- {
- request.setAttribute("bseq", r2.getString("brandlist_seq"));
- ResultSet r3=s3.executeQuery("select sizelist_seq from stockdtl where brandlist_seq='"+r2.getString("brandlist_seq")+"'");
- while(r3.next())
- {
- request.setAttribute("sizeseq", r3.getString("sizelist_seq"));
- ResultSet r4=s4.executeQuery("select brandsize from sizelist where sizelist_seq='"+r3.getString("sizelist_seq")+"'");
- while(r4.next())
- {
- String bsize=r4.getString("brandsize");
- // request.setAttribute("brandsize", bsize);
- %>
- <option value="<%=bsize %>"><%=bsize %></option>
- <%}
- }
- }
- }
- %>
- </select></td></tr></div>
- <%if((size==null)||(size.equals(x)))
- {
- %>
- <div><tr><td>Available Quantity:</td><td><input type="text" name="quantity" value="<%=qty%>" id="quantity" readonly></td></tr></div>
- <%
- }
- else
- {
- ResultSet r5=s5.executeQuery("select brandlist_seq from brandlist where brandname='"+name+"'");
- while(r5.next())
- {
- request.setAttribute("bseq", r5.getString("brandlist_seq"));
- }
- ResultSet r6=s6.executeQuery("select sizelist_seq from sizelist where brandsize='"+size+"'");
- while(r6.next())
- {
- request.setAttribute("sseq", r6.getString("sizelist_seq"));
- }
- String brandseq=(String)request.getAttribute("bseq");
- String sizeseq=(String)request.getAttribute("sseq");
- //System.out.println(brandseq);
- //System.out.println(sizeseq);
- ResultSet r7=s7.executeQuery("select quantity from stockdtl where brandlist_seq='"+brandseq+"' and sizelist_seq='"+sizeseq+"'");
- while(r7.next())
- {
- String availablequantity1=r7.getString("quantity");
- //System.out.println(availablequantity1);
- request.setAttribute("quantity", r7.getString("quantity"));
- %>
- <div><tr><td>Available Quantity:</td><td><input type="text" name="quantity" value="<%=availablequantity1%>" id="quantity" readonly></td></tr></div>
- <%}
- }
- %>
- <div><tr><td>Invoice Quantity:</td><td><input type="text" name="invoice"></td></tr></div>
- <tr><td></td><td><input type="submit" value="submit"></td></tr>
- </table></form>
- <%if((invoice!=null)&&(invoice!=""))
- {
- String brandseq=(String)request.getAttribute("bseq");
- String sizeseq=(String)request.getAttribute("sseq");
- //System.out.println(brandseq);
- //System.out.println(sizeseq);
- ResultSet r=s11.executeQuery("select quantity from stockdtl where brandlist_seq='"+brandseq+"' and sizelist_seq='"+sizeseq+"'");
- while(r.next())
- {
- String quant=r.getString("quantity");
- request.setAttribute("quantity", quant);
- }
- String qq=(String)request.getAttribute("quantity");
- //System.out.println("new"+qq);
- ResultSet r8=s8.executeQuery("select stock_seq from stockdtl where brandlist_seq='"+brandseq+"' and sizelist_seq='"+sizeseq+"'");
- while(r8.next())
- {
- int is=s9.executeUpdate("INSERT INTO invoicedtl(stock_seq, created_date, invoice_qty) VALUES ('"+r8.getString("stock_seq")+"','"+date+"','"+invoice+"');");
- }
- //int update=((Integer.parseInt)availablequantity)-((Integer.parseInt)invoice);
- // Integer.valueOf(availablequantity)-(Integer.valueOf(invoice));
- int qt=Integer.parseInt(qq);
- //System.out.println("qty"+availablequantity);
- int in=Integer.parseInt(invoice);
- int newqt=qt-in;
- //System.out.println(newqt);
- String updatedquantity=Integer.toString(newqt);
- request.setAttribute("up1", updatedquantity);
- //System.out.println(updatedquantity);
- // int iss=s10.executeUpdate("UPDATE stockdtl SET quantity='"+updatedquantity+"' WHERE brandlist_seq='"+brandseq+"' and sizelist_seq='"+sizeseq+"';");
- }
- %>
- <%
- }
- catch(Exception e)
- {
- }%>
- </body>
- </html>