%@ include file="globalPaths.jsp" %><%@ include file="globalDefinitions.jsp" %><%
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
String query = "";
int discount=0;
double price=0.0;
String printartwork = null;
printartwork = request.getParameter("printartwork");
String artwork=request.getParameter("artwork");
if (((artwork==null)||(artwork.equals("")))&&((printartwork==null)||(printartwork.equals(""))))
{
sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("Missing artwork or printartwork"));
return;
}
try
{
connection = openConnection();
statement = connection.createStatement();
query = "SELECT price,discount FROM galleryArtwork WHERE id=" + quoteString(artwork);
resultSet = statement.executeQuery(query);
if (resultSet.next())
{
price = resultSet.getDouble("price");
discount = resultSet.getInt("discount");
resultSet.close();
}
else
{
resultSet.close();
sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("RecordSet is empty. May be an artwork was not found"));
return;
}
}
catch(Exception e)
{
errorLog(e, query);
sendRedirect(globalErrorPage + "?errorDescription="
+ URLEncoder.encode(e.getMessage() + "."));
return;
}
finally
{
if (resultSet != null) resultSet.close();
if (connection != null && !connection.isClosed()) connection.close();
}
if (request.getParameter("submit")!=null)
{
String offer=request.getParameter("offer");
if (!"".equals(offer.trim()))
{
try
{
offer=offer.trim()+" ";
while (offer.startsWith("$"))
{
offer=offer.substring(offer.indexOf("$")+1);
}
offer=" "+offer.trim();
while (offer.endsWith("$"))
{
offer=offer.substring(0,offer.length()-1);
}
offer=offer.trim();
offer=substituteTokens(offer,",","");
double doffer=Double.parseDouble(offer);
doffer=Math.round(doffer*100)/100.0;
if (doffer>=price*(1.00-discount/100.00))
{
Vector cart=new Vector();
cart.addElement(artwork);
Vector offeredprice=new Vector();
offeredprice.addElement(new Double(doffer));
session.putValue("offereditems",cart);
session.putValue("offeredprices",offeredprice);
sendRedirect("norder02ship.jsp?artwork="+artwork+"&printartwork="+printartwork);
return;
}
}
catch (Exception e)
{
sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("Please enter correct price." ));
return;
}
}
else
{
sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("Please enter correct price." ));
return;
}
}
%>
Customer's offer
<%@ include file="inc/head.txt" %>
<%@ include file="inc/top.txt" %>
<%@ include file="inc/bottom.txt" %>
<%@ include file="globalFinally.jsp" %>