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

📄 saleedit.asp

📁 一个用asp实现简单的小型OA系统
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="session.asp"-->
<!--#include file="Connections/conn.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = MM_conn_STRING
  MM_editTable = "Sales"
  MM_editColumn = "Saleid"
  MM_recordId = "" + Request.Form("MM_recordId") + ""
  MM_editRedirectUrl = "Salelist.asp"
  MM_fieldsStr  = "Dates|value|Clerk|value|Customer|value|fahuo|value|huoyun|value|daishou|value|huikuan|value|fanli|value|alei|value|blei|value|jiajia|value|remark|value|Department|value|Operates|value|opertime|value"
  MM_columnsStr = "Dates|',none,NULL|Clerk|none,none,NULL|Customer|',none,''|fahuo|none,none,NULL|huoyun|none,none,NULL|daishou|none,none,NULL|huikuan|none,none,NULL|fanli|none,none,NULL|alei|none,none,NULL|blei|none,none,NULL|jiajia|none,none,NULL|remark|',none,''|Department|none,none,NULL|Operates|none,none,NULL|opertime|',none,NULL"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
  Next
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<%
Dim yewuyuan__MMColParam
yewuyuan__MMColParam = "1"
If (Request("MM_EmptyValue") <> "") Then 
  yewuyuan__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim yewuyuan
Dim yewuyuan_numRows

Set yewuyuan = Server.CreateObject("ADODB.Recordset")
yewuyuan.ActiveConnection = MM_conn_STRING
yewuyuan.Source = "SELECT * FROM user WHERE power = " + Replace(yewuyuan__MMColParam, "'", "''") + ""
yewuyuan.CursorType = 0
yewuyuan.CursorLocation = 2
yewuyuan.LockType = 1
yewuyuan.Open()

yewuyuan_numRows = 0
%>
<%
Dim huoyun
Dim huoyun_numRows

Set huoyun = Server.CreateObject("ADODB.Recordset")
huoyun.ActiveConnection = MM_conn_STRING
huoyun.Source = "SELECT * FROM huoyun"
huoyun.CursorType = 0
huoyun.CursorLocation = 2
huoyun.LockType = 1
huoyun.Open()

huoyun_numRows = 0
%>
<%
Dim rs__MMColParam
rs__MMColParam = "1"
If (Request.QueryString("Saleid") <> "") Then 
  rs__MMColParam = Request.QueryString("Saleid")
End If
%>
<%
Dim rs
Dim rs_numRows

Set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = MM_conn_STRING
rs.Source = "SELECT * FROM Sales WHERE Saleid = " + Replace(rs__MMColParam, "'", "''") + ""
rs.CursorType = 0
rs.CursorLocation = 2
rs.LockType = 1
rs.Open()

rs_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>业务员发货明细修改</title>
<link href="sty.css" rel="stylesheet" type="text/css">
</head>

<body>
<form method="post" action="<%=MM_editAction%>" name="form1">
  <table align="center" bgcolor="#F1F5FE">
   <caption>
    <strong>业务员发货明细修改</strong>
  </caption>
    <tr valign="baseline">
      <td nowrap align="right">发货时间:</td>
      <td>
        <input type="text" name="Dates" value="<%=(rs.Fields.Item("Dates").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">业务员:</td>
      <td>
        <select name="Clerk">
          <%
While (NOT yewuyuan.EOF)
%>
          <option value="<%=(yewuyuan.Fields.Item("userid").Value)%>" <%If (Not isNull(rs.Fields.Item("Clerk").Value)) Then If (CStr(yewuyuan.Fields.Item("userid").Value) = CStr(rs.Fields.Item("Clerk").Value)) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(yewuyuan.Fields.Item("realname").Value)%></option>
          <%
  yewuyuan.MoveNext()
Wend
If (yewuyuan.CursorType > 0) Then
  yewuyuan.MoveFirst
Else
  yewuyuan.Requery
End If
%>
        </select>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">客户:</td>
      <td>
        <input type="text" name="Customer" value="<%=(rs.Fields.Item("Customer").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">发货量:</td>
      <td>
        <input type="text" name="fahuo" value="<%=(rs.Fields.Item("fahuo").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">货运部:</td>
      <td>
        <select name="huoyun">
          <%
While (NOT huoyun.EOF)
%>
          <option value="<%=(huoyun.Fields.Item("huoyunid").Value)%>" <%If (Not isNull(rs.Fields.Item("huoyun").Value)) Then If (CStr(huoyun.Fields.Item("huoyunid").Value) = CStr(rs.Fields.Item("huoyun").Value)) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(huoyun.Fields.Item("huoyun").Value)%></option>
          <%
  huoyun.MoveNext()
Wend
If (huoyun.CursorType > 0) Then
  huoyun.MoveFirst
Else
  huoyun.Requery
End If
%>
        </select>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">代收款:</td>
      <td>
        <input type="text" name="daishou" value="<%=(rs.Fields.Item("daishou").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">汇款:</td>
      <td>
        <input type="text" name="huikuan" value="<%=(rs.Fields.Item("huikuan").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">返利:</td>
      <td>
        <input type="text" name="fanli" value="<%=(rs.Fields.Item("fanli").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">A类:</td>
      <td>
        <input type="text" name="alei" value="<%=(rs.Fields.Item("alei").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">B类:</td>
      <td>
        <input type="text" name="blei" value="<%=(rs.Fields.Item("blei").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">加价:</td>
      <td>
        <input type="text" name="jiajia" value="<%=(rs.Fields.Item("jiajia").Value)%>" size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap>备注:</td>
      <td>
        <textarea name="remark" cols="50" rows="5"><%=(rs.Fields.Item("remark").Value)%></textarea>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">部门:</td>
      <td>
        <select name="Department">
          <option value="1"  <%If (Not isNull(rs.Fields.Item("Department").Value)) Then If ("1" = CStr(rs.Fields.Item("Department").Value)) Then Response.Write("SELECTED") : Response.Write("")%>>兽药部</option>
          <option value="2"  <%If (Not isNull(rs.Fields.Item("Department").Value)) Then If ("2" = CStr(rs.Fields.Item("Department").Value)) Then Response.Write("SELECTED") : Response.Write("")%>>禽药部</option>
        </select>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td>
        <input name="提交" type="submit" value="确定修改">
        <input name="submit" type="reset" value="重新修改">
      </td>
    </tr>
  </table>
  <input type="hidden" name="Operates" value="<%=(rs.Fields.Item("Operates").Value)%>" size="32">
  <input type="hidden" name="opertime" value="<%=(rs.Fields.Item("opertime").Value)%>" size="32">
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="MM_recordId" value="<%= rs.Fields.Item("Saleid").Value %>">
</form>
<p>&nbsp;</p>
</body>
</html>
<%
yewuyuan.Close()
Set yewuyuan = Nothing
%>
<%
huoyun.Close()
Set huoyun = Nothing
%>
<%
rs.Close()
Set rs = Nothing
%>

⌨️ 快捷键说明

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