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

📄 index2.jsp

📁 jsp写的一个简单的售药系统(系统需求分析).采用sql2000数据库,通过odbc连接
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="Connections/syxt.jsp" %>
<%
// *** Edit Operations: declare variables

// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
  String queryString = request.getQueryString();
  String tempStr = "";
  for (int i=0; i < queryString.length(); i++) {
    if (queryString.charAt(i) == '<') tempStr = tempStr + "&lt;";
    else if (queryString.charAt(i) == '>') tempStr = tempStr + "&gt;";
    else if (queryString.charAt(i) == '"') tempStr = tempStr +  "&quot;";
    else tempStr = tempStr + queryString.charAt(i);
  }
  MM_editAction += "?" + tempStr;
}

// connection information
String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;

// redirect information
String MM_editRedirectUrl = null;

// query string to execute
StringBuffer MM_editQuery = null;

// boolean to abort record edit
boolean MM_abortEdit = false;

// table information
String MM_editTable = null, MM_editColumn = null, MM_recordId = null;

// form field information
String[] MM_fields = null, MM_columns = null;
%>
<%
// *** Insert Record: set variables

if (request.getParameter("MM_insert") != null && request.getParameter("MM_insert").toString().equals("form1")) {

  MM_editDriver     = MM_syxt_DRIVER;
  MM_editConnection = MM_syxt_STRING;
  MM_editUserName   = MM_syxt_USERNAME;
  MM_editPassword   = MM_syxt_PASSWORD;
  MM_editTable  = "dbo.xsdxz";
  MM_editRedirectUrl = "index2.jsp?a0="+request.getParameter("a0");
  String MM_fieldsStr = "ypbh|value|ph|value|sl|value|je|value|a0|value|xzh|value";
  String MM_columnsStr = "ypbh|none,none,NULL|ph|none,none,NULL|sl|none,none,NULL|je|none,none,NULL|djh|none,none,NULL|xzh|none,none,NULL";

  // create the MM_fields and MM_columns arrays
  java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|");
  MM_fields = new String[tokens.countTokens()];
  for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken();

  tokens = new java.util.StringTokenizer(MM_columnsStr,"|");
  MM_columns = new String[tokens.countTokens()];
  for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken();

  // set the form values
  for (int i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = ((request.getParameter(MM_fields[i])!=null)?(String)request.getParameter(MM_fields[i]):"");
  }
 
  // append the query string to the redirect URL
  if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
  }
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it
int slst=9999;

if (request.getParameter("MM_insert") != null) {
  // create the insert sql statement
  StringBuffer MM_tableValues = new StringBuffer(), MM_dbValues = new StringBuffer();
  String[] MM_dbValues_prep = new String[MM_fields.length/2];
  for (int i=0; i+1 < MM_fields.length; i+=2) {
    String formVal = MM_fields[i+1];
    String elem;
    java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],",");
    elem = (String)tokens.nextToken(); // consume the delim
    String altVal   = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
    String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
    if (formVal.length() == 0) {
        if(emptyVal.equals("NULL")) {
            formVal = null;
        } else if(emptyVal.charAt(0) == '\'') {
            formVal = emptyVal.substring(1, emptyVal.length()-1);
        } else {
            formVal = emptyVal;
        }
    } else if (altVal.length() != 0) {
        if(altVal.charAt(0) == '\'') {
            formVal = altVal.substring(1, altVal.length()-1);
        } else {
            formVal = altVal;
        }
    }
    MM_dbValues_prep[i/2] = formVal;
    MM_tableValues.append((i!=0)?",":"").append(MM_columns[i]);
    MM_dbValues.append((i!=0)?",":"").append('?');
  }
  MM_editQuery = new StringBuffer("insert into " + MM_editTable);
  MM_editQuery.append(" (").append(MM_tableValues.toString()).append(") values (");
  MM_editQuery.append(MM_dbValues.toString()).append(")");
  
  if (!MM_abortEdit) {
    // finish the sql and execute it
    Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
    Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
    PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
    for(int i=0; i<MM_dbValues_prep.length; i++) {
        MM_editStatement.setObject(i+1, MM_dbValues_prep[i]);
    }
    MM_editStatement.executeUpdate();
    MM_connection.close();

    // redirect with URL parameters
    if (MM_editRedirectUrl.length() != 0) {
      response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
      return;
    }
  }
}
%>
<%
Driver DriverRecordset1 = (Driver)Class.forName(MM_syxt_DRIVER).newInstance();
Connection ConnRecordset1 = DriverManager.getConnection(MM_syxt_STRING,MM_syxt_USERNAME,MM_syxt_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM dbo.ypms");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>销售单第二步</title>
<script type="text/javascript">
<!--
function removeOptions(selectObj) {     if (typeof selectObj != 'object')     {         selectObj = document.getElementById(selectObj);     }          var len = selectObj.options.length;      for (var i=0; i < len; i++)     {                 selectObj.options[0] = null;     } } 
function setSelectOption(selectObj, optionList, firstOption, selected) {     if (typeof selectObj != 'object')     {         selectObj = document.getElementById(selectObj);     }           removeOptions(selectObj);           var start = 0;            if (firstOption)     {         selectObj.options[0] = new Option(firstOption, '');               start ++;     }      var len = optionList.length;      for (var i=0; i < len; i++)     {            selectObj.options[start] = new Option(optionList[i].txt, optionList[i].val);               if(selected == optionList[i].val)         {             selectObj.options[start].selected = true;         }           start ++;     }  } 




<%
Driver DriverRecordset2 = (Driver)Class.forName(MM_syxt_DRIVER).newInstance();
Connection ConnRecordset2 = DriverManager.getConnection(MM_syxt_STRING,MM_syxt_USERNAME,MM_syxt_PASSWORD);
PreparedStatement StatementRecordset2 = ConnRecordset2.prepareStatement("SELECT distinct ypbh FROM dbo.kc");
ResultSet Recordset2 = StatementRecordset2.executeQuery();

%>

 var cityArr = []; 
var xsdjg=[];
 
 <%
 while(Recordset2.next()){
 String tt1=Recordset2.getString("ypbh");
 
 Driver DriverRecordset3 = (Driver)Class.forName(MM_syxt_DRIVER).newInstance();
Connection ConnRecordset3 = DriverManager.getConnection(MM_syxt_STRING,MM_syxt_USERNAME,MM_syxt_PASSWORD);
 PreparedStatement StatementRecordset3 = ConnRecordset3.prepareStatement("SELECT ph FROM dbo.kc where ypbh='"+tt1+"'");
ResultSet Recordset3 = StatementRecordset3.executeQuery();

 Driver DriverRecordset4 = (Driver)Class.forName(MM_syxt_DRIVER).newInstance();
Connection ConnRecordset4 = DriverManager.getConnection(MM_syxt_STRING,MM_syxt_USERNAME,MM_syxt_PASSWORD);
 PreparedStatement StatementRecordset4 = ConnRecordset4.prepareStatement("SELECT xsdj FROM dbo.ypms where ypbh='"+tt1+"'");
ResultSet Recordset4 = StatementRecordset4.executeQuery();
Recordset4.next();
%>
 
 xsdjg['<%=tt1%>']=<%=Recordset4.getObject("xsdj")%>;
 cityArr['<%=tt1%>'] = [  
 <%
  Recordset4.close();
StatementRecordset4.close();
 ConnRecordset4.close();
 
 while(Recordset3.next()){
 String ttt2=Recordset3.getString("ph");

 
  %>
 {txt:'<%=ttt2 %>', val:'<%=ttt2 %>'} ,

<%
}
 
 Recordset3.close();
StatementRecordset3.close();
ConnRecordset3.close();

%>
  ];
 <% 
 }
  
 Recordset2.close();
StatementRecordset2.close();
ConnRecordset2.close();
 
 %>
 
 function setCity(province) {         setSelectOption('ph', cityArr[province], '-请选择-'); } 
 
 function setjine(shuliang)
 {
 var ypbh=document.getElementById('ypbh');
  var je=document.getElementById('je');
 if(ypbh.options[ypbh.selectedIndex].value!='')
 if((new Boolean(xsdjg[ypbh.options[ypbh.selectedIndex].value]*shuliang)))
 je.value=Math.round(xsdjg[ypbh.options[ypbh.selectedIndex].value]*shuliang);
 }
//-->
</script>

    <Script type="text/javascript">
	<!--
var j = 0;
function SelectValue(obj)
{
    var input = obj.parentNode.nextSibling;
    document.all.box2.value = obj.options[obj.selectedIndex].text;
    document.getElementById("txtSection").value=obj.options[obj.selectedIndex].value;
    //alert(document.getElementById("txtSection").value);
}

function InputValue(obj)
{
    var n = 1;    
    var tmpObj;
    var src = document.all.ypbh;
    var msg = document.all.msg;
    if(event.keyCode != 40 && event.keyCode != 38 && event.keyCode != 13){
        if(obj.value!=""){
             msg.style.display="";
             msg.innerHTML="";
             if(msg.hasChildNodes()) 
             { 
                msg.childNodes[0].parentNode.removeChild(msg.childNodes[0]); 
             }
             
             for (var i=0;i<src.length;i++){
               var selValue = document.createElement("div");
               var selText = document.createElement("div");
               selText.value = src(i).value;
               selText.innerHTML = src(i).text;          

               if (src(i).text.toLowerCase().indexOf(obj.value.toLowerCase())!=-1){ 
                    selText.setAttribute("id","selText"+n);
					selText.style.backgroundColor='#ffffff'; 
                    selText.onmouseover=function (){   
                    this.style.backgroundColor='#003399';   
                    this.style.color ='#ffffff'; 
                   }
                   selText.onmouseout=function (){   
                    this.style.backgroundColor='#ffffff'; 
                    this.style.color ='#000000';
                   }
                   selText.onclick=function (){   
                    document.all.box2.value = this.innerHTML;
                    msg.style.display="none";
                    document.getElementById("txtSection").value=this.value;

⌨️ 快捷键说明

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