📄 bookmaint.jsp
字号:
break;
}
if ( sBookErr.length() > 0 ) return sBookErr;
try {
// Execute SQL statement
stat.executeUpdate(sSQL);
}
catch(java.sql.SQLException e) {
sBookErr = e.toString(); return (sBookErr);
}
try {
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
}
catch ( java.sql.SQLException ignore ) {}
response.sendRedirect (sActionFileName + sParams);
return "sendRedirect";
}
catch (Exception e) {out.println(e.toString()); }
return (sBookErr);
}
void Book_Show(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sBookErr, String sForm, String sAction, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
try {
String sSQL="";
String sQueryString = "";
String sPage = "";
String sWhere = "";
String transitParams = "";
String transitParamsHidden = "";
String requiredParams = "";
String primaryKeyParams ="";
java.util.Hashtable rsHash = new java.util.Hashtable();
String pitem_id = "";
String fldcategory_id="";
String flditem_id="";
String fldname="";
String fldauthor="";
String fldprice="";
String fldproduct_url="";
String fldimage_url="";
String fldnotes="";
String fldis_recommended="";
boolean bPK = true;
if ( "".equals(sBookErr)) {
// Load primary key and form parameters
fldcategory_id = getParam( request, "category_id");
flditem_id = getParam( request, "item_id");
transitParamsHidden += "<input type=\"hidden\" name=\"Trn_category_id\" value=\""+getParam( request, "category_id")+"\">";
transitParams += "Trn_category_id="+getParam( request, "category_id")+"&";
pitem_id = getParam( request, "item_id");
}
else {
// Load primary key, form parameters and form fields
flditem_id = getParam( request, "item_id");
fldname = getParam( request, "name");
fldauthor = getParam( request, "author");
fldcategory_id = getParam( request, "category_id");
fldprice = getParam( request, "price");
fldproduct_url = getParam( request, "product_url");
fldimage_url = getParam( request, "image_url");
fldnotes = getParam( request, "notes");
fldis_recommended = getParam( request, "is_recommended");
transitParamsHidden += "<input type=\"hidden\" name=\"Trn_category_id\" value=\""+getParam( request, "Trn_category_id")+"\">";
transitParams += "Trn_category_id="+getParam( request, "Trn_category_id")+"&";
pitem_id = getParam( request, "PK_item_id");
}
if ( isEmpty(pitem_id)) { bPK = false; }
sWhere += "item_id=" + toSQL(pitem_id, adNumber);
primaryKeyParams += "<input type=\"hidden\" name=\"PK_item_id\" value=\""+pitem_id+"\"/>";
sSQL = "select * from items where " + sWhere;
out.println(" <table style=\"\">");
out.println(" <tr>\n <td style=\"background-color: #336699; text-align: Center; border-style: outset; border-width: 1\" colspan=\"2\"><font style=\"font-size: 12pt; color: #FFFFFF; font-weight: bold\">书籍</font></td>\n </tr>");
if ( ! sBookErr.equals("")) {
out.println(" <tr>\n <td style=\"background-color: #FFFFFF; border-width: 1\" colspan=\"2\"><font style=\"font-size: 10pt; color: #000000\">"+sBookErr+"</font></td>\n </tr>");
}
sBookErr="";
out.println(" <form method=\"get\" action=\""+sFileName+"\" name=\"Book\">");
java.sql.ResultSet rs = null;
if ( bPK && ! (sAction.equals("insert") && "Book".equals(sForm))) {
// Open recordset
rs = openrs( stat, sSQL);
rs.next();
String[] aFields = getFieldsName( rs );
getRecordToHash( rs, rsHash, aFields );
rs.close();
flditem_id = (String) rsHash.get("item_id");
if ( "".equals(sBookErr)) {
// Load data from recordset when form displayed first time
fldname = (String) rsHash.get("name");
fldauthor = (String) rsHash.get("author");
fldcategory_id = (String) rsHash.get("category_id");
fldprice = (String) rsHash.get("price");
fldproduct_url = (String) rsHash.get("product_url");
fldimage_url = (String) rsHash.get("image_url");
fldnotes = (String) rsHash.get("notes");
fldis_recommended = (String) rsHash.get("is_recommended");
}
if (sAction.equals("") || ! "Book".equals(sForm)) {
flditem_id = (String) rsHash.get("item_id");
fldname = (String) rsHash.get("name");
fldauthor = (String) rsHash.get("author");
fldcategory_id = (String) rsHash.get("category_id");
fldprice = (String) rsHash.get("price");
fldproduct_url = (String) rsHash.get("product_url");
fldimage_url = (String) rsHash.get("image_url");
fldnotes = (String) rsHash.get("notes");
fldis_recommended = (String) rsHash.get("is_recommended");
}
}
else {
if ( "".equals(sBookErr)) {
flditem_id = toHTML(getParam(request,"item_id"));
fldcategory_id = toHTML(getParam(request,"category_id"));
fldis_recommended= "0";
}
}
// Show form field
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">书名</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<input type=\"text\" name=\"name\" maxlength=\"100\" value=\""+toHTML(fldname)+"\" size=\"30\">");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">作者</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<input type=\"text\" name=\"author\" maxlength=\"100\" value=\""+toHTML(fldauthor)+"\" size=\"30\">");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">类别</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">");
out.print("<select name=\"category_id\">"+getOptions( conn, "select category_id, name from categories order by 2",false,true,fldcategory_id)+"</select>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">价格</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<input type=\"text\" name=\"price\" maxlength=\"10\" value=\""+toHTML(fldprice)+"\" size=\"10\">");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">产品链接</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<input type=\"text\" name=\"product_url\" maxlength=\"100\" value=\""+toHTML(fldproduct_url)+"\" size=\"40\">");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Image URL</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<input type=\"text\" name=\"image_url\" maxlength=\"100\" value=\""+toHTML(fldimage_url)+"\" size=\"40\">");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">备注</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<textarea name=\"notes\" cols=\"60\" rows=\"8\">"+toHTML(fldnotes)+"</textarea>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">推荐</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">");
if ( fldis_recommended.equalsIgnoreCase("1") ) {
out.print("<input checked type=\"checkbox\" name=\"is_recommended\" value=\"1\">");
}
else {
out.print("<input type=\"checkbox\" name=\"is_recommended\" value=\"1\">");
}
out.println("</td>\n </tr>");
out.print(" <tr>\n <td colspan=\"2\" align=\"right\">");
if ( bPK && ! (sAction.equals("insert") && "Book".equals(sForm))) {
out.print("<input type=\"submit\" value=\"修改\" onclick=\"document.Book.FormAction.value = 'update';\">");out.print("<input type=\"submit\" value=\"删除\" onclick=\"document.Book.FormAction.value = 'delete';\">");out.print("<input type=\"submit\" value=\"取消\" onclick=\"document.Book.FormAction.value = 'cancel';\">");
out.print("<input type=\"hidden\" name=\"FormName\" value=\"书籍\"><input type=\"hidden\" value=\"update\" name=\"FormAction\">");
}
else {
out.print("<input type=\"submit\" value=\"添加\" onclick=\"document.Book.FormAction.value = 'insert';\">");out.print("<input type=\"submit\" value=\"取消\" onclick=\"document.Book.FormAction.value = 'cancel';\">");
out.print("<input type=\"hidden\" name=\"FormName\" value=\"书籍\"><input type=\"hidden\" value=\"insert\" name=\"FormAction\">");
}out.print("<input type=\"hidden\" name=\"item_id\" value=\""+toHTML(flditem_id)+"\">");
out.print(transitParamsHidden+requiredParams+primaryKeyParams);
out.println("</td>\n </tr>\n </form>\n </table>");
}
catch (Exception e) { out.println(e.toString()); }
} %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -