?? adminentryrecord.jsp
字號:
<%@ include file="Common.jsp" %><%!
//
// Filename: AdminEntryRecord.jsp
static final String sFileName = "AdminEntryRecord.jsp";
static final String PageBODY = "bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#800080\" alink=\"#FF0000\"";
static final String FormTABLE = "border=\"0\" cellspacing=\"0\" cellpadding=\"2\"";
static final String FormHeaderTD = "align=\"center\" bgcolor=\"#99CCFF\"";
static final String FormHeaderFONT = "style=\"font-size: 12pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\"";
static final String FieldCaptionTD = "bgcolor=\"#FFFF99\"";
static final String FieldCaptionFONT = "style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\"";
static final String DataTD = "bgcolor=\"#F5F5F5\"";
static final String DataFONT = "style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\"";
static final String ColumnFONT = "style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\"";
static final String ColumnTD = "bgcolor=\"#FFD9E5\"";
%><%
String cSec = checkSecurity(3, session, response, request);
if ("sendRedirect".equals(cSec) ) return;
boolean bDebug = false;
String sAction = getParam( request, "FormAction");
String sForm = getParam( request, "FormName");
String sEntryErr = "";
java.sql.Connection conn = null;
java.sql.Statement stat = null;
String sErr = loadDriver();
conn = cn();
stat = conn.createStatement();
if ( ! sErr.equals("") ) {
try {
out.println(sErr);
}
catch (Exception e) {}
}
if ( sForm.equals("Entry") ) {
sEntryErr = EntryAction(request, response, session, out, sAction, sForm, conn, stat);
if ( "sendRedirect".equals(sEntryErr)) return;
}
%>
<html>
<head>
<title>YellowPages</title>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<jsp:include page="Header.jsp" flush="true"/>
<table>
<tr>
<td valign="top">
<% Entry_Show(request, response, session, out, sEntryErr, sForm, sAction, conn, stat); %>
<SCRIPT Language="JavaScript">
if (document.forms["Entry"])
document.Entry.onsubmit=delconf;
function delconf() {
if (document.Entry.FormAction.value == 'delete')
return confirm('Delete record?');
}
</SCRIPT>
</td>
</tr>
</table>
</body>
</html>
<%
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
%>
<%!
String EntryAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sAction, String sForm, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
String sEntryErr ="";
try {
if (sAction.equals("")) return "";
String sSQL="";
String transitParams = "";
String primaryKeyParams = "";
String sQueryString = "";
String sPage = "";
String sParams = "";
String sActionFileName = "AdminEntriesGrid.jsp";
String sWhere = " ";
boolean bErr = false;
long iCount = 0;
String pPKitem_id = "";
if (sAction.equalsIgnoreCase("cancel") ) {
try {
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
}
catch ( java.sql.SQLException ignore ) {}
response.sendRedirect (sActionFileName);
return "sendRedirect";
}
final int iinsertAction = 1;
final int iupdateAction = 2;
final int ideleteAction = 3;
int iAction = 0;
if ( sAction.equalsIgnoreCase("insert") ) { iAction = iinsertAction; }
if ( sAction.equalsIgnoreCase("update") ) { iAction = iupdateAction; }
if ( sAction.equalsIgnoreCase("delete") ) { iAction = ideleteAction; }
// Create WHERE statement
if ( iAction == iupdateAction || iAction == ideleteAction ) {
pPKitem_id = getParam( request, "PK_item_id");
if ( isEmpty(pPKitem_id)) return sEntryErr;
sWhere = "item_id=" + toSQL(pPKitem_id, adNumber);
}
String fldname="";
String fldcategory_id="";
String fldcity="";
String fldstate="";
String fldzip="";
String fldphone="";
String fldaddress="";
String fldemail="";
String flditem_url="";
String fldnotes="";
String flditem_id="";
// Load all form fields into variables
fldname = getParam(request, "name");
fldcategory_id = getParam(request, "category_id");
fldcity = getParam(request, "city");
fldstate = getParam(request, "state");
fldzip = getParam(request, "zip");
fldphone = getParam(request, "phone");
fldaddress = getParam(request, "address");
fldemail = getParam(request, "email");
flditem_url = getParam(request, "item_url");
fldnotes = getParam(request, "notes");
// Validate fields
if ( iAction == iinsertAction || iAction == iupdateAction ) {
if ( isEmpty(fldname) ) {
sEntryErr = sEntryErr + "The value in field Name is required.<br>";
}
if ( isEmpty(fldcategory_id) ) {
sEntryErr = sEntryErr + "The value in field Category is required.<br>";
}
if ( ! isNumber(fldcategory_id)) {
sEntryErr = sEntryErr + "The value in field Category is incorrect.<br>";
}
if (sEntryErr.length() > 0 ) {
return (sEntryErr);
}
}
sSQL = "";
// Create SQL statement
switch (iAction) {
case iinsertAction :
sSQL = "insert into items (" +
"name," +
"category_id," +
"city," +
"state," +
"zip," +
"phone," +
"address," +
"email," +
"url," +
"notes)" +
" values (" +
toSQL(fldname, adText) + "," +
toSQL(fldcategory_id, adNumber) + "," +
toSQL(fldcity, adText) + "," +
toSQL(fldstate, adText) + "," +
toSQL(fldzip, adText) + "," +
toSQL(fldphone, adText) + "," +
toSQL(fldaddress, adText) + "," +
toSQL(fldemail, adText) + "," +
toSQL(flditem_url, adText) + "," +
toSQL(fldnotes, adText) + ")";
break;
case iupdateAction:
sSQL = "update items set " +
"name=" + toSQL(fldname, adText) +
",category_id=" + toSQL(fldcategory_id, adNumber) +
",city=" + toSQL(fldcity, adText) +
",state=" + toSQL(fldstate, adText) +
",zip=" + toSQL(fldzip, adText) +
",phone=" + toSQL(fldphone, adText) +
",address=" + toSQL(fldaddress, adText) +
",email=" + toSQL(fldemail, adText) +
",url=" + toSQL(flditem_url, adText) +
",notes=" + toSQL(fldnotes, adText);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -