%@ page import="ebiz.ist.sqlutil.*"%>
<%@ page import="ebiz.jsp.util.*"%>
<%@ page import="ebiz.jsp.system.*"%>
<%@ page import="ebiz.jsp.db.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.awt.Color"%>
<%@ page import="java.awt.Font"%>
<%@ page import="java.awt.Graphics2D"%>
<%@ page import="java.awt.geom.AffineTransform"%>
<%@ page import="java.awt.image.BufferedImage"%>
<%@ page import="java.io.IOException"%>
<%@ page import="java.io.FileOutputStream"%>
<%@ page import="javax.imageio.ImageIO"%>
<%
String value;
Random mynum=new Random(System.currentTimeMillis());
String validate = "false";
String validatefield = "false";
String msg = "";
String strDate = "";
java.util.Date utilDate = new java.util.Date();
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
String strTime = "";
String strVenue = "";
int intTel=0;
int k = -1; //the selected row in crs_2
String strCourseID = request.getParameter("courseID");
String strCourseName = request.getParameter("txtCourseName");
String strName = request.getParameter("txtName");
String strEmail = request.getParameter("txtEmail");
String strEmail2 = request.getParameter("txtEmail2");
String strAcctNo = request.getParameter("txtAcctNo");
String strTel = request.getParameter("txtTel");
String strPartType = request.getParameter("txtPartType");
String strPlate = request.getParameter("txtPlate");
//Retain entered Participant's info
if (strName == null)
{
strName="";
}
if (strEmail == null)
{
strEmail="";
}
if (strEmail2 == null)
{
strEmail2="";
}
if (strAcctNo == null)
{
strAcctNo="";
}
if (strTel == null)
{
strTel="";
}
if (strPlate == null)
{
strPlate="";
}
CustomResultSet crs = null;
//using Connection Pool
String propFile = "/ist/config_uobkhco/mysqlutil.properties";
JSPMysqlDatabaseAccess db = JSPMysqlDatabaseAccess._getInstance(propFile);
SQLMysqlUtil sqlmysqlutil = null;
try
{
//Get Connection fr pool
sqlmysqlutil = db.pool.borrowConnection();
// Construct DB SQL scripts.
String sqlc = "SELECT CourseID, Name, DATE_FORMAT(Date, '%e %b %Y') AS sDate, Venue, Time, PartType From Ind_Course WHERE Publish='Y' AND CourseID='"+strCourseID+"' and SeatsTaken < MaxSeats";
//testing sql
//String sqlc = "SELECT CourseID, Name, DATE_FORMAT(Date, '%e %b %Y') AS sDate, Venue, Time, PartType From Course WHERE CourseID='"+strCourseID+"' and SeatsTaken < MaxSeats";
sqlmysqlutil.setSQL(sqlc);
//out.println("After setSQL 2 ");
crs = new CustomResultSet(sqlmysqlutil.executeQuery());
//out.println("After SQLQuery 2 ");
sqlmysqlutil.reset();
if (crs.getRowCount()<=0) {
%>
<%
}
}//end-try
catch (Exception ex)
{
System.err.println("ERROR in connection - " + ex.getMessage());
}
finally
{
db.pool.returnConnection(sqlmysqlutil);
}
%>
<%! // servlet methods
private void ImageVerification (int height, int width, String outfile, String value) throws IOException
{
BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Random rand=new Random(System.currentTimeMillis());
Graphics2D g = bimage.createGraphics();
FileOutputStream outf=new FileOutputStream(outfile);
// create a random color
Color color = new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255));
// the the background to the random color to fill the
// background and make it darker
g.setColor(color.darker());
g.fillRect(0, 0, width, height);
// set the font
g.setFont(new Font("arial",Font.BOLD,20));
// generate a random value
//this.value = "1234"; // UUID.randomUUID().toString().replace("-","").substring(0,5);
int w = (g.getFontMetrics()).stringWidth(value);
int d = (g.getFontMetrics()).getDescent();
int a = (g.getFontMetrics()).getMaxAscent();
int x = 0, y =0;
// randomly set the color and draw some straight lines through it
for (int i = 0; i < height; i += 5)
{
g.setColor(new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255)));
g.drawLine(x, y + i, width, y+i);
}
// reset x and y
x=0;
y=0;
// randomly set the color of the lines and just draw think at an angle
for (int i = 0; i < height; i += 5)
{
g.setColor(new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255)));
g.drawLine(x, y + d - i, width + w, height + d - i);
}
// randomly set the color and make it really bright for more readability
g.setColor(new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255)).brighter().brighter());
// we need to position the text in the center of the box
x = width/2 - w/2;
y = height/2 + a/2 - 2;
// affine transform is used to rock the text a bit
AffineTransform fontAT = new AffineTransform();
int xp = x-2;
// walk through each character and rotate it randomly
for (int c=0;cUOB Kay Hian