⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newsrecord.jsp

📁 是用ACCESS和JSP开发的新闻发布系统
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ include file="Common.jsp" %><%!
//
//   Filename: newsRecord.jsp


static final String sFileName = "newsRecord.jsp";
              
static final String PageBODY = "text=\"#000000\" link=\"#000080\" vlink=\"#000080\" alink=\"#000080\"";
static final String FormTABLE = "border=\"0\" cellspacing=\"2\" cellpadding=\"0\"";
static final String FormHeaderTD = "align=\"center\" bgcolor=\"#FFBB55\"";
static final String FormHeaderFONT = "style=\"font-size: 12pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\"";
static final String FieldCaptionTD = "bgcolor=\"#FFDD00\"";
static final String FieldCaptionFONT = "style=\"font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\"";
static final String DataTD = "";
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: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold\"";
static final String ColumnTD = "bgcolor=\"#000000\"";
%><%

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 snewsErr = "";

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("news") ) {
  snewsErr = newsAction(request, response, session, out, sAction, sForm, conn, stat);
  if ( "sendRedirect".equals(snewsErr)) return;
}

%>            
<html>
<head>
<title>news_edit</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 text="#000000" link="#000080" vlink="#000080" alink="#000080">
<jsp:include page="Header.jsp" flush="true"/>
 <table>
  <tr>
   
   <td valign="top">
<% news_Show(request, response, session, out, snewsErr, sForm, sAction, conn, stat); %>
    <SCRIPT Language="JavaScript">
if (document.forms["news"])
  document.news.onsubmit=delconf;
function delconf() {
if (document.news.FormAction.value == 'delete')
  return confirm('Delete record?');
}
</SCRIPT>
   </td>
  </tr>
 </table>


</body>
</html>
<%%>
<%
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
%>
<%!


  String newsAction(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 snewsErr ="";
    try {

      if (sAction.equals("")) return "";

      String sSQL="";
      String transitParams = "";
      String primaryKeyParams = "";
      String sQueryString = "";
      String sPage = "";
      String sParams = "";
      String sActionFileName = "newsGrid.jsp";
      String sWhere = " ";
      boolean bErr = false;
      long iCount = 0;

  
      String pPKnews_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 ) { 
        pPKnews_id = getParam( request, "PK_news_id");
        if ( isEmpty(pPKnews_id)) return snewsErr;
        sWhere = "news_id=" + toSQL(pPKnews_id, adNumber);
      }


      String fldname="";
      String fldtitle="";
     String fldnews_login="";
  String fldnews_password="";
   String fldnews_level="";
      String flddep_id="";
      String flddetail="";
      String flddate="";
      String fldhotnews="";
      String fldpicture="";
      String fldnews_id="";

      // Load all form fields into variables
    
      fldname = getParam(request, "name");
      fldtitle = getParam(request, "title");
     fldnews_login = getParam(request, "news_login");
     fldnews_password = getParam(request, "news_password");
     fldnews_level = getParam(request, "news_level");
      flddep_id = getParam(request, "dep_id");
      flddetail = getParam(request, "detail");
      flddate = getParam(request, "date");
      fldhotnews = getCheckBoxValue(getParam( request, "hotnews"), "1", "0", adNumber);
      fldpicture = getParam(request, "picture");
      // Validate fields
      if ( iAction == iinsertAction || iAction == iupdateAction ) {
        if ( isEmpty(fldname) ) {
          snewsErr = snewsErr + "The value in field Name is required.<br>";
        }
        if ( isEmpty(fldtitle) ) {
          snewsErr = snewsErr + "The value in field Title is required.<br>";
        }
    if ( isEmpty(flddep_id) ) {
          snewsErr = snewsErr + "The value in field Department is required.<br>";
        }
        if ( ! isNumber(flddep_id)) {
          snewsErr = snewsErr + "The value in field Department is incorrect.<br>";
        }

    if (snewsErr.length() > 0 ) {
       return (snewsErr);
     }
    }


      sSQL = "";
      // Create SQL statement

      switch (iAction) {
  
        case iinsertAction :
          
            sSQL = "insert into news (" + 
                "name," +
                "title," +
            
                "dep_id," +
                "detail," +
                "date," +
                "hotnews," +
                "picture)" +

                " values (" + 
                toSQL(fldname, adText) + "," +
                toSQL(fldtitle, adText) + "," +
               toSQL(flddep_id, adNumber) + "," +
                toSQL(flddetail, adText) + "," +
                toSQL(flddate, adText) + "," +
                fldhotnews + "," +
                toSQL(fldpicture, adText) + ")";
          break;
  
      case iupdateAction:
        
          sSQL = "update news set " +
                "name=" + toSQL(fldname, adText) +
                ",title=" + toSQL(fldtitle, adText) +
                ",dep_id=" + toSQL(flddep_id, adNumber) +
                ",detail=" + toSQL(flddetail, adText) +
                ",date=" + toSQL(flddate, adText) +

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -