📄 index.jsp
字号:
<%@ 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 + "<";
else if (queryString.charAt(i) == '>') tempStr = tempStr + ">";
else if (queryString.charAt(i) == '"') tempStr = tempStr + """;
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.xsd";
MM_editRedirectUrl = "index2.jsp";
String MM_fieldsStr = "khmc|value|jhrq|value|zdr|value|ywy|value|fhy|value|qsy|value";
String MM_columnsStr = "khbh|none,none,NULL|jhrq|',none,NULL|zdr|',none,''|ywy|',none,''|fhy|',none,''|qsr|',none,''";
// 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: 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.xsd";
MM_editRedirectUrl = "index2.jsp?a0="+request.getParameter("a0");
String MM_fieldsStr = "khmc|value|jhrq|value|zdr|value|ywy|value|fhy|value|qsy|value";
String MM_columnsStr = "khbh|none,none,NULL|jhrq|',none,NULL|zdr|',none,''|ywy|',none,''|fhy|',none,''|qsr|',none,''";
// 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
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, new String(MM_dbValues_prep[i].toString().getBytes("ISO8859_1"),"UTF-8"));
}
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.khzl");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
%>
<%
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 max(djh)+1 FROM dbo.xsd ");
ResultSet Recordset2 = StatementRecordset2.executeQuery();
boolean Recordset2_isEmpty = !Recordset2.next();
boolean Recordset2_hasData = !Recordset2_isEmpty;
Object Recordset2_data=Recordset2.getObject("");
if(Recordset2_data==null)Recordset2_data="1";
int Recordset2_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>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
<label></label>
<p>
<label></label>
</p>
<p>销售单第一步:</p>
<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.khmc;
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;
SelMatch(document.all.khmc);
}
msg.appendChild(selText);
n++;
}
}
}
else {
document.all.msg.style.display="none";
}
}
else {
//press down key
if(event.keyCode==40){
j++;
for (var i=0; i<src.length; i++)
{
tmpObj = document.getElementById("selText"+i);
if(tmpObj != null){
tmpObj.style.backgroundColor='#ffffff';
tmpObj.style.color ='#000000';
}
}
tmpObj = document.getElementById("selText"+j);
if(tmpObj != null){
tmpObj.style.backgroundColor='#003399';
tmpObj.style.color ='#ffffff';
}else{
j = 0;
}
}
//press up key
if (event.keyCode==38){
j--;
for (var i=0; i<src.length; i++)
{
tmpObj = document.getElementById("selText"+i);
if(tmpObj != null){
tmpObj.style.backgroundColor='#ffffff';
tmpObj.style.color ='#000000';
}
}
tmpObj = document.getElementById("selText"+j);
if(tmpObj != null){
tmpObj.style.backgroundColor='#003399';
tmpObj.style.color ='#ffffff';
}else{
j = 2;
}
}
//press enter key
if (event.keyCode==13){
tmpObj = document.getElementById("selText"+j);
document.all.box2.value = tmpObj.innerHTML;
msg.style.display="none";
document.getElementById("txtSection").value=tmpObj.value;
}
}
}
function SelMatch(src)
{
var currSel = document.all.box2.value;
for (var i=0;i<src.length;i++){
if (src(i).text==currSel)
{
src.options(i).selected = true;
}
}
}
function NoMsg()
{
if(document.activeElement.id=="msg")
return false;
else
document.all.msg.style.display='none';
}
//-->
</Script>
<table width="100%" border="0">
<tr>
<td width="24%" align="center" >请输入客户编号:</td>
<td width="76%" >
<div style="position:relative;">
<span style="margin-left:230px;width:18px;overflow:hidden;">
<select style="HEIGHT: 22px; WIDTH: 253px; margin-left:-232px;" onchange="SelectValue(this)" onclick="SelMatch(this)" id="khmc" name="khmc" >
<option selected="selected" value=" ">————请选择———</option>
<%
while (Recordset1_hasData) {
%>
<option value="<%=Recordset1.getObject("khbh")%>"><%=Recordset1.getObject("khmc")%></option>
<%
Recordset1_hasData = Recordset1.next();
}
Recordset1.close();
Recordset1 = StatementRecordset1.executeQuery();
Recordset1_hasData = Recordset1.next();
Recordset1_isEmpty = !Recordset1_hasData;
%>
</select></span>
<input name="box2" id="box2" style="width:230px;position:absolute;left:0px;" onkeyup="InputValue(this)" onblur="NoMsg()" onfocus="this.select();InputValue(this)" >
<div id="msg" style="border:1px solid green; font-size :14PX;white-space:nowrap;overflow:hidden;
width:230px;position:absolute;left:0px;top:20px;display:none "></div>
</div>
<Input Type="Hidden" Name="txtSection" id="txtSection">
</td>
</tr> <tr></tr>
<tr>
<td align="center">交货日期:</td>
<td ><input type="text" name="jhrq" id="jhrq" /></td>
</tr>
<tr>
<td align="center">开单日期:</td>
<td ><label>
<input type="text" name="kdrq" id="kdrq" />
</label></td>
</tr>
<tr>
<td align="center">制单人:</td>
<td ><label>
<input name="zdr" type="text" id="zdr" value="<%=session.getValue("MM_Username")%>" />
</label></td>
</tr>
<tr>
<td align="center">业务员:</td>
<td ><label>
<input type="text" name="ywy" id="ywy" />
</label></td>
</tr>
<tr>
<td align="center">发货员:</td>
<td ><label>
<input type="text" name="fhy" id="fhy" />
</label></td>
</tr>
<tr>
<td align="center">签收员:</td>
<td ><label>
<input type="text" name="qsy" id="qsy" />
</label></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="button" id="button" value="下一步" />
</label>
<input name="a0" type="hidden" id="a0" value="<%=Recordset2_data%>" />
</p>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
<%
Recordset1.close();
StatementRecordset1.close();
ConnRecordset1.close();
%>
<%
Recordset2.close();
StatementRecordset2.close();
ConnRecordset2.close();
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -