| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2553 人关注过本帖
标题:菜鸟求助根据条件录入的ASP
只看楼主 加入收藏
amwje
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-11-15
收藏
 问题点数:0 回复次数:3 
菜鸟求助根据条件录入的ASP
图片附件: 游客没有浏览图片的权限,请 登录注册

求助:1、转账A框数据录为表1的支出。A,B的和录为表1的收入,同时录为表2的支出。2、C框录为表1和表2的支出。3、D框只录为表1的支出。
三个条件只能是其中一个,即只能条件1或2或3成立。
急急,求求大神了。谢谢!
搜索更多相关主题的帖子: 同时 条件 ASP 数据 录入 
2019-11-15 21:00
amwje
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-11-15
收藏
得分:0 
程序代码:
<!--#include file="heck.asp"-->
<%
InOut = Request("add")
If Request.form("add")=" 确认支出信息录入 " Then
adddate = Request.Form("adddate")
selpayer = Request.Form("selpayer")
seltype = Request.Form("seltype")
mo = Trim(Request.Form("mo"))
mo0 = Trim(Request.Form("mo0"))
mo1 = Trim(Request.Form("mo1"))
mo2 = Trim(Request.Form("mo2"))
hj=cint(mo)+cint(mo0)  '设置变量,让两个金额相加'
pjna = Trim(Request.Form("pjna"))
     if seltype="" then
     Response.Write "<script>alert('请用管理员帐号添加费用类型!');location='javascript:history.back(-1)';</SCRIPT>"
     Response.End
     end if
Set rs = Server.CreateObject("ADODB.RecordSet")
Sql = "Select * From 
    " rs.Open Sql,Conn,1,3 If mo2<>0 then '如果白条核销的情况 '往表公用插入支出数据 rs.addNew rs("InOut") = InOut rs("PayTypeID") = seltype rs("Moneys") = mo2 rs("Project") = checkform(pjna) rs("addTime") = adddate rs("data") = adddate rs("etime") = now() rs("user") = Request.Cookies("id") rs.Update rs.Close set rs=nothing Response.Write "<script>alert('操作成功!');this.location.href='gypay.asp';</SCRIPT>" elseIf mo1<>0 then '如果发票核销的情况 '往表公用插入支出数据 rs.addNew rs("InOut") = InOut rs("PayTypeID") = seltype rs("Moneys") = mo1 rs("Project") = checkform(pjna) rs("addTime") = adddate rs("data") = adddate rs("etime") = now() rs("user") = Request.Cookies("id") rs.Update rs.Close '往对公公用总表插入支出数据 Set rs = Server.CreateObject("ADODB.RecordSet") Sql = "Select * From [dglistgy]" rs.Open Sql,Conn,1,3 rs.addNew rs("InOut") = InOut rs("PayTypeID") = seltype rs("Moneys") = mo1 rs("Project") = checkform(pjna) rs("addTime") = adddate rs("data") = adddate rs("etime") = now() rs("user") = Request.Cookies("id") rs.Update rs.Close set rsy=nothing Response.Write "<script>alert('操作成功!');this.location.href='gypay.asp';</SCRIPT>" elseif mo1=0 and mo2=0 then '转账 rs.addNew rs("InOut") = InOut rs("PayTypeID") = seltype rs("Moneys") = mo rs("Project") = checkform(pjna+"实际支出) rs("addTime") = adddate rs("data") = adddate rs("etime") = now() rs("user") = Request.Cookies("id") rs.Update rs.Close '往表公用插入收入数据mo+mon rs.addNew rs("InOut") = InOut+1 rs("PayTypeID") = 3 rs("Moneys") = hj rs("Project") = checkform(pjna+"转账单金额") rs("addTime") = adddate rs("data") = adddate rs("etime") = now() rs("user") = Request.Cookies("id") rs.Update rs.Close '往对公公用总表插入支出数据 Set rs = Server.CreateObject("ADODB.RecordSet") Sql = "Select * From [dglistgy]" rs.Open Sql,Conn,1,3 rs.addNew rs("InOut") = InOut rs("PayTypeID") = seltype rs("Moneys") = hj rs("Project") = checkform(pjna) rs("addTime") = adddate rs("data") = adddate rs("etime") = now() rs("user") = Request.Cookies("id") rs.Update rs.Close Response.Write "<script>alert('操作成功!');this.location.href='gypay.asp';</SCRIPT>" End if End if %> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <link href="images/css.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .auto-style1 { height: 35px; } .auto-style2 { width: 35%; } .auto-style3 { width: 87px; } .auto-style7 { height: 29px; } .auto-style8 { color: #0066FF; } .auto-style9 { color: #FF0000; } .auto-style10 { width: 79px; } .auto-style11 { width: 314px; } </style> </head> <body> <script> var ie =navigator.appName=="Microsoft Internet Explorer"?true:false; function $(objID) { return document.getElementById(objID); } function CheckForm() { if (document.form1.adddate.value=="") { alert("请选择日期!"); return false; } if (document.form1.pjna.value=="") { alert("摘要名称不能为空!"); document.form1.pjna.focus(); return false; } if (document.form1.seltype.value=="") { alert("请选择费用类型!如果没有请先添加!"); return false; } } </script> <script type="text/javascript" src="images/time.js"></script> <table width="100%" border="0" align=center cellpadding="6" cellspacing="0"> <form action="" method=post name=form1 onSubmit="return CheckForm()"> <tr> <td colspan=5 align="center" bgcolor="#F9F9F9" class="auto-style1"><b> <%If InOut=0 Then Response.Write"<font color=red size=larger>学校公用经费支出记账</font>" End if %> </b></td> </tr> <tr> <td align="right" class="auto-style2">选择日期:</div></td> <td colspan="4" ><input name="adddate" type="text" size="20" readonly="readonly" onclick="showcalendar(event, this);" onfocus="showcalendar(event, this);if(this.value=='0000-00-00')this.value=''" /></td> </tr> <tr> <td align="right" class="auto-style2">费用类型:</td> <td colspan="4"><select name="seltype"> <% set rs=server.createobject("adodb.recordset") sql="select * from [type] Where InOut="&InOut&"" rs.open sql,conn,1,1 response.write "<option sel=selected value='' name=seltype>请选择</option>" do while not rs.eof response.write "<option " & sel & " value='"+CStr(rs("ID"))+"' name=seltype>"+rs("PayType")+"</option>"+chr(13)+chr(10) rs.movenext loop rs.close %> </select></td> </tr> <tr> <td class="auto-style2" ><div align="right">摘要:</div></td> <td colspan="4" ><input name="pjna" type="text" size="50" maxlength="50" class="auto-style11" /></td> </tr> <tr> <td align="right" class="auto-style2">业务选择:</td> <td colspan="4" > <strong>1.转&nbsp;</strong> <input name="mo" type="text" size="20" maxlength="10" class="auto-style3" /> <strong>(实+盈)</strong> <input name="mo0" type="text" size="20" maxlength="10" class="auto-style3" /></td> </tr> <tr> <td align="right" class="auto-style2"></td> <td colspan="4" > <span class="auto-style9"><strong>2.发票核销<input name="mo1" type="text" size="20" maxlength="10" class="auto-style3" /></strong></span> <span class="auto-style8"><strong>&nbsp;3.白条核销<input name="mo2" type="text" size="20" maxlength="10" class="auto-style10" /></strong></span></td> </tr> <tr> <td colspan="5" align="center" ><input type="submit" name="add" value=" 确认支出信息录入 " class="auto-style7" /></td> </tr> </form> </table> </body> </html>

请求帮改改。不知道什么搞了
2019-11-15 23:03
ke爱的小tu子
Rank: 2
等 级:论坛游民
帖 子:51
专家分:20
注 册:2021-2-11
收藏
得分:0 
哈哈

[此贴子已经被作者于2021-2-13 12:27编辑过]

2021-02-13 12:13
ke爱的小tu子
Rank: 2
等 级:论坛游民
帖 子:51
专家分:20
注 册:2021-2-11
收藏
得分:0 
回复 2楼 amwje
<%

'<!--#include file="heck.asp"-->

%>

<%
sub conn_open(conn,path)
    set conn=server.createobject("adodb.connection")
    conn.connectionstring="Provider = Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath(path)
    conn.open
end sub

sub conn_close(conn)
    conn.close
    set conn=nothing
end sub


sub rs_open3(rs,sql)
    set rs = server.createobject("adodb.recordset")
    rs.open sql,conn,1,3
end sub

sub rs_close(rs)
    rs.close
    set rs=nothing
end sub

sub tt(str,url)
    response.write "<script>alert("""&str&""");location.href="""&url&""";</script>"
    response.end
end sub
'-------------------------------------华丽的分割线---------------------------------------------------------------
'接收8条表单数据,先把数据全部接收,后续才做判断。
'逻辑要清晰,不要混乱得一批。
'默认前端对提交的数据已经事先处理过,所以不需要继续处理数据。只判断表单提交数据是否为空,以此为依据判断该如何提交数据到access。如果前端不做业务逻辑判断,请你送个大耳瓜子过去。服务器资源有限,不要什么都想到在服务器上去弄。


InOut = Request("add")
adddate = Request.Form("adddate")'选择日期
seltype = Request.Form("seltype")'费用类型
mo = Trim(Request.Form("mo"))'转账----------A框
mo0 = Trim(Request.Form("mo0"))'(实+盈)-------B框
mo1 = Trim(Request.Form("mo1"))'发票核销-------C框
mo2 = Trim(Request.Form("mo2"))'白条核销------D框
pjna=Request.Form("pjna")'摘要


'求助:1、转账A框数据录为表1的支出。A,B的和录为表1的收入,同时录为表2的支出。2、C框录为表1和表2的支出。3、D框只录为表1'的支出。
'三个条件只能是其中一个,即只能条件1或2或3成立。
'急急,求求大神了。谢谢!
'跳转页面:gypay.asp

call conn_open(conn,"db.mdb")'打开access

if mo<>"" then'A框数据不为空,按照你的要求,A框数据提交到表1支出。
    sql="select 支出 from 表1"
    call rs_open3(rs,sql)
        rs.addnew
            rs("支出")=mo
        rs.update
    call rs_close(rs)
    call conn_close(conn)'关闭access
    call tt("提交成功","gypay.asp")
    response.end
end if

if mo<>"" and mo0<>"" then'A框,B框同时不为空,按照你的要求提交收入到表1
    sql="select 收入 from 表1"
    call rs_open3(rs,sql)
        rs.addnew
            rs("收入")=mo+mo0
        rs.update
    call rs_close(rs)

    sql="select 支出 from 表2"'按照你的要去,同时录入表2的支出
    call rs_open3(rs,sql)
        rs.addnew
            rs("支出")=mo+mo0
        rs.update
    call rs_close(rs)
    call conn_close(conn)'关闭access
    call tt("提交成功","gypay.asp")
    response.end
end if


if mo1<>"" then
    sql="select 支出 from 表1"'按照你的要求,c框录入为表1,表2的支出。
    call rs_open3(rs,sql)
        rs.addnew
            rs("支出")=mo1
        rs.update
    call rs_close(rs)

    sql="select 支出 from 表2"
    call rs_open3(rs,sql)
        rs.addnew
            rs("支出")=mo1
        rs.update
    call rs_close(rs)
    call conn_close(conn)'关闭access
    call tt("提交成功","gypay.asp")
    response.end
end if


if mo2<>"" then
    sql="select 支出 from 表1"'D框为表1的支出
    call rs_open3(rs,sql)
        rs.addnew
            rs("支出")=mo2
        rs.update
    call rs_close(rs)
    call conn_close(conn)'关闭access
    call tt("提交成功","gypay.asp")
    response.end
end if
%>
2021-02-15 12:24
快速回复:菜鸟求助根据条件录入的ASP
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025567 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved