|
Hello wise people; I am really close to ending a project but am running out of ideas as to how to implement the closing part. Okay, I have two .jsp files. In my first .jsp(printinvoice.jsp), I query the iSeries and bring up all the invoices to be printed and in my second .jsp(produceinvoice.jsp) I create the invoice and the user can hit the print button and print that invoice. Now, the user wants to print multiple invoices at the same time. Something along the lines of having check boxes by the invoices on printinvoice.jsp. I am thinking it is almost impossible to do this and want to go to something using Swing components and install that app on the users workstation. I just did not want to start up on a whole new solution from scratch if somebody had run into something like this before. I am posting the code for printinvoice.jspand produceinvoice.jsp below. Any help would be much appreciated. Just looking for some direction and I can take it from there. Thanks in advance. printinvoice.jsp ***************** <html> <head> <%@ page language="java" import = "org.apache.commons.lang.StringUtils,java.util.*,java.lang.*, java.sql.*,java.io.*" %> <title>Database Querying</title> </head> <h1 align="center"><FONT color="#0000ff">Muckboots Package Slip Printing</FONT><BR> <FONT size="4" color="#000000"><U>Customer Number</U></FONT><FONT color="#b72828"></FONT></h1> <form action="printinvoice.jsp" method=get> <DIV align="center"><INPUT type="text" name="customernumber"> <BR> <BR> </DIV> <DIV align="center"><INPUT type="submit" value="Produce Invoice"><BR> </DIV> </form> <% //// String customernumber; Connection dbconn; ResultSet results; Statement stat; String sql; try { Class.forName("com.ibm.as400.access.AS400JDBCDriver"); try { boolean doneheading = false; dbconn = DriverManager.getConnection( "jdbc:as400://xxx.xxx.xxx.xxx", "xxx", "xxx"); customernumber = request.getParameter("customernumber"); sql = ("SELECT DISTINCT OER100FHST.\"BIPO#\", OER100FHST.BIADR1, OER100FHST.BIADR2, OER100FHST.BIZIP, OER100FHST.BIADR3, OER100FHST.BIADR4, OER100FHST.BIADR5, OER100FHST.BIADR6, OER100FHST.BIZIP, OER100FHST.\"BICST#\", OER100FHST.\"BIORD#\" FROM EC30DATA.OER100FHST AS OER100FHST WHERE OER100FHST.\"BICST#\" LIKE '%" + customernumber + "%'"); stat = dbconn.createStatement(); results = stat.executeQuery(sql); String shippingname, shippingaddress, shippingbusiness, cityandstate, zipcode, phone, imagestring, urlfixing, poinfo, shippinginfo, itemdescription; String itemnumber, quantity, invoicenumber; String ordernumber; out.println("<html>"); out.println("<body>"); while (results.next()) { if (!doneheading) { out.println( "<center><table border=2 width=600><TR><TD width=50>PRINT</TD><TD width=150>Order Number</TD><TD width=250>Shipping Info</TD>"); doneheading = true; } shippingname = results.getString("BIADR1"); shippingbusiness = results.getString("BIADR2"); shippingaddress = results.getString("BIADR3"); cityandstate = results.getString("BIADR4"); zipcode = results.getString("BIZIP"); invoicenumber = results.getString("BIPO#"); StringUtils su = new StringUtils(); String linknumber = invoicenumber; linknumber = su.trim(linknumber); linknumber = su.removeStart(linknumber, " "); linknumber = su.replace(linknumber," ","%20"); // out.println(invoicenumber); out.println( "<TR><TD><a href=produceinvoice.jsp?ordernum=" + linknumber + "&custno=" + customernumber + ">Print</a></TD>"); String temp = ""; int index = invoicenumber.lastIndexOf("-"); if (index > 0) temp = invoicenumber.substring(0, index); out.println("<TD>" + temp + "</td>"); out.println( "<TD>" + shippingname + "<BR>" + shippingaddress + "<BR>" + cityandstate + " " + zipcode + "</TD></TR>"); } if (doneheading) { out.println("</table>"); out.println("</form>"); out.println("</body>"); out.println("</html>"); } else { //out.println("No matches for " + place); } } catch (SQLException s) { out.println("SQL Error<br>" + s.getMessage()); } } catch (ClassNotFoundException err) { out.println("Class loading error"); out.println("The error is : " + err.getMessage()); } %> <p align="center"><b>Please visit: </b> <a </body> </html> *************************** produceinvoice.jsp ********************* <html> <head> <title>Packing Slip</title> <%@ page language="java" import="java.sql.*" import= "java.io.IOException" import= "org.apache.commons.lang.StringUtils" import= "java.util.*" import= "java.lang.*" %> </head> <HEAD> </HEAD> <body> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <TBODY> <tr> <td width="150" rowspan="2"><%Connection dbconn; ResultSet results; Statement stat; StringUtils su = new StringUtils(); try { Class.forName("com.ibm.as400.access.AS400JDBCDriver"); try { String sql; String ordernumber; String custno = "", shippingcompany = "", shippingpref = "N/A"; String shippingnameforinvoice = "N/A", shippingaddressforinvoice = "N/A", shippingcityandstateforinvoice = "N/A", shippingzipcodeforinvoice = ""; String shippingphoneforinvoice = "N/A", imagestring = "N/A", shippingcustomernumberforinvoice = "N/A", shippingitemdescriptionforinvoice = ""; String shippingitemnumberforinvoice = "N/A", shippingquantityforinvoice = "N/A", shippinginvoicenumber = "N/A", ownername = "N/A"; String invoiceitems = ""; String owneraddress = null; String exchangepolicy = null; String returnpolicy = null; String qty = "", item = "", dsc = ""; dbconn = DriverManager.getConnection("jdbc:as400://xxx.xxx.xxx.xxx", "xxx", "xxx"); ordernumber = request.getParameter("ordernum"); custno = request.getParameter("custno"); ordernumber = su.replace(ordernumber, "%20"," "); //customernumber = request.getParameter("customernumber"); //sql = ("SELECT ITMMST.ITMDSC, MUCKBOOTS_MINE.NCORD#, MUCKBOOTS_MINE.NCORCS, MUCKBOOTS_MINE.NCORQT, MUCKBOOTS_MINE.NCORIT, MUCKBOOTS_MINE.NCORA1, MUCKBOOTS_MINE.NCORA4, MUCKBOOTS_MINE.NCORA5, MUCKBOOTS_MINE.NCORA6, MUCKBOOTS_MINE.NCORA7, MUCKBOOTS_MINE.NCORPO FROM TESTING.MUCKBOOTS_MINE AS MUCKBOOTS_MINE, EC30DATA.ITMMST AS ITMMST WHERE ITMMST.ITMNUM = MUCKBOOTS_MINE.NCORIT AND MUCKBOOTS_MINE.NCORD# =" + ordernumber ); sql = ("SELECT ITMMST.ITMDSC,OER100FHST.\"BICST#\", OER100FHST.\"BIPO#\", OER100FHST.BIADR1, " + "OER100FHST.BIADR2, OER100FHST.BIADR3, OER100FHST.BIADR4, OER100FHST.BIADR5, OER100FHST.BIADR6, OER100FHST.BIZIP, " + "OER100FHST.\"BIITM#\", OER100FHST.BIQTY, OER100FHST.BISPIN, MUCKBOOTSLOGIN.EXCHANGEPOLICY, MUCKBOOTSLOGIN.RETURNPOLICY, MUCKBOOTSLOGIN.ADDRESS, " + "MUCKBOOTSLOGIN.COMPANYNAME FROM EC30DATA.ITMMST AS ITMMST, TESTING.MUCKBOOTSLOGIN AS MUCKBOOTSLOGIN, EC30DATA.OER100FHST AS OER100FHST " + "WHERE OER100FHST.\"BICST#\" LIKE '%" + custno + "' AND ITMMST.ITMNUM = OER100FHST.\"BIITM#\" AND MUCKBOOTSLOGIN.CUSTOMERNO LIKE '%" + custno + "%' AND OER100FHST.\"BIPO#\" LIKE '%" + ordernumber + "%'"); stat = dbconn.createStatement(); // out.print(sql); results = stat.executeQuery(sql); while (results.next()) { shippingnameforinvoice = results.getString("BIADR1"); shippingaddressforinvoice = results.getString("BIADR3"); shippingzipcodeforinvoice = results.getString("BIZIP"); shippingcityandstateforinvoice = results.getString("BIADR4") + " " + shippingzipcodeforinvoice; shippingphoneforinvoice = results.getString("BIADR5"); shippingcustomernumberforinvoice = custno; shippingitemdescriptionforinvoice = results.getString("ITMDSC").trim(); shippingitemnumberforinvoice = results.getString ("BIITM#").trim(); shippingquantityforinvoice = results.getString("BIQTY").trim(); int index = ordernumber.lastIndexOf("-"); System.out.println("132"); shippinginvoicenumber = ordernumber.substring(0, index); owneraddress = results.getString("ADDRESS").trim(); exchangepolicy = results.getString("EXCHANGEPOLICY"); System.out.println("test"); if (exchangepolicy == null) exchangepolicy = " "; else exchangepolicy = exchangepolicy.trim(); returnpolicy = results.getString("RETURNPOLICY"); if (returnpolicy == null) returnpolicy = " "; else returnpolicy = returnpolicy.trim(); ownername = results.getString("CompanyName").trim(); shippingcompany = results.getString("BIADR2").trim(); shippingpref = results.getString("BISPIN").trim(); qty = qty + shippingquantityforinvoice + "<BR>"; item = item + shippingitemnumberforinvoice + "<BR>"; dsc = dsc + shippingitemdescriptionforinvoice + "<BR>"; } if (shippingcustomernumberforinvoice.length() > 3) { out.println( "<img border='0' src='images/" + shippingcustomernumberforinvoice + ".jpg' width=150></td>"); } else { out.println("<br><BR>"); } out.println( "<td width=300 align=left valign=bottom rowspan=2><b><font size=6>"); out.println( ownername + "</font></b><p> </p><p>" + owneraddress + "</td>"); java.util.Date today = new java.util.Date(); String onlydate = today.toString().substring(0, 10); //Calendar cal = new GregorianCalendar(); //String year = String.valueOf(cal.get(Calendar.YEAR)); //String month = String.valueOf((cal.get(Calendar.MONTH) + 1)); //, 1=Feb, ... //String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); // 1... //String date = month + "/" + day + "/" + year; out.println( "<td width=150 align=right valign=top>Date: " + onlydate + "</td>"); out.println( "</tr> <tr> <td width=150 align=right valign=bottom>Invoice No. " + shippinginvoicenumber + "</td></tr></table>"); out.println( "<hr color=#000000 align=left size=4><table width=722><TR><TD width=716><b>Shipping Information: <br> </b>"); out.println( "<table width=600 border=0 cellpadding=0 cellspacing=0 style=border-collapse: collapse bordercolor=#111111>"); out.println("<tr> <td width=225>Name:</td>"); out.println( "<td width=375>" + shippingnameforinvoice + "</td></tr><tr><td width=25>Address:</td><td width=375>"); if (shippingcompany.equals("")) out.println(shippingaddressforinvoice); else out.println(shippingcompany + "<BR>" + shippingaddressforinvoice); out.println("</td></tr>"); out.println( "<tr><td width=225> </td><td width=375>" + shippingcityandstateforinvoice + "</td></tr><tr><td width=225>Phone:</td> <td width=375>"); out.println(shippingphoneforinvoice + "</td></tr>"); out.println("<tr> <td width=225> Shipping Preference:</td>"); out.println( "<td width=375>" + shippingpref.trim() + "</TD></TR></TABLE>"); out.println("<div align=left><br><BR><b>Shipping Invoice:<br></b><BR>"); out.println( "<table border=1 cellpadding=0 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=600>"); out.println( "<tr><td width=75>Quantity </td><td width=150>Item No.</td><td width=375>Description</td></tr><tr>"); out.println( "<td width=75 align=left valign=top>" + qty + "</td><td width=150 align=left valign=top>" + item); out.println("</td><td width=375 align=left valign=top>"); out.println(dsc + "</td></tr></table></div>"); out.println( "<p> </p><p><font size=2>" + exchangepolicy + "</font></p><p><font size=2>" + returnpolicy + "</font></p><BR><BR><p align=center>Thank you for shopping with "); out.println(ownername + "!</p></body></html>"); } catch (SQLException s) { out.println("SQL Error<br>" + s.getMessage()); } } catch (ClassNotFoundException err) { out.println("Class loading error"); out.println("The error is : " + err.getMessage()); } %> **************** Happy Friday.. cheers, Jake.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.