<!--#include file="conn.asp"-->
<%
      if session("admin")="" then
          response.redirect "admin.asp"
      end if
%>
<!--#include file="char.asp"-->
<%
    dim rs,sql
    dim qihao
    dim bianhao
    dim riqi
    dim maizhu
    dim maijin
    dim zhongzhu
    dim zhongjin
    dim zhongyi
    dim zhonger
    dim zhongsan
    dim zhongsi
    dim zhongwu
    dim zhongliu
    dim hongqiu
    dim lanqiu
    dim tebie
    dim qita
    dim errmsg
    dim founderr
    founderr=false
    if trim(request.form("qihao"))="" then
          founderr=true
          errmsg="<li>彩票期号不能为空</li>"
    end if
    if trim(request.form("riqi"))="" then
          founderr=true
          errmsg="<li>开奖日期不能为空</li>"
    end if
    
    if founderr=false then
        qihao=htmlencode(request.form("qihao"))
    set rs=server.createobject("adodb.recordset")
    if request("action")="add" then
        call newsoft()
    elseif request("action")="edit" then
        call editsoft()
    else
        founderr=true
        errmsg=errmsg+"<li>没有选定参数</li>"
    end if
sub newsoft()
    sql="select * from caipiao where (bianhao is null)" 
    rs.open sql,conn,1,3
    rs.addnew
    rs("qihao")=qihao
    if request.form("qita")<>"" then
        rs("qita")=trim(request.form("qita"))
    end if
    if request.form("maizhu")<>"" then
        rs("maizhu")=trim(request.form("maizhu"))
    end if
    if request.form("maijin")<>"" then
        rs("maijin")=trim(request.form("maijin"))
    end if
    if request.form("zhongzhu")<>"" then
        rs("zhongzhu")=trim(request.form("zhongzhu"))
    end if
    if request.form("zhongjin")<>"" then
        rs("zhongjin")=trim(request.form("zhongjin"))
    end if
    if request.form("zhongyi")<>"" then
        rs("zhongyi")=trim(request.form("zhongyi"))
    end if
    if request.form("zhonger")<>"" then
        rs("zhonger")=trim(request.form("zhonger"))
    end if
    if request.form("zhongsan")<>"" then
        rs("zhongsan")=trim(request.form("zhongsan"))
    end if
    if request.form("zhongsi")<>"" then
        rs("zhongsi")=trim(request.form("zhongsi"))
    end if
    if request.form("zhongwu")<>"" then
        rs("zhongwu")=trim(request.form("zhongwu"))
    end if
    if request.form("zhongliu")<>"" then
        rs("zhongliu")=trim(request.form("zhongliu"))
    end if
    if request.form("hongqiu")<>"" then
        rs("hongqiu")=trim(request.form("hongqiu"))
    end if
    if request.form("lanqiu")<>"" then
        rs("lanqiu")=trim(request.form("lanqiu"))
    end if
    if request.form("tebie")<>"" then
        rs("tebie")=trim(request.form("tebie"))
    end if
    if request.form("riqi")<>"" then
        rs("riqi")=trim(request.form("riqi"))
    end if
    rs.update
    bianhao=rs("bianhao")
end sub
sub editsoft()
    sql="select * from caipiao where bianhao="&request("id")
    rs.open sql,conn,1,3
        rs("qihao")=qihao
    if request.form("qita")<>"" then
        rs("qita")=trim(request.form("qita"))
    end if
    if request.form("maizhu")<>"" then
        rs("maizhu")=trim(request.form("maizhu"))
    end if
    if request.form("maijin")<>"" then
        rs("maijin")=trim(request.form("maijin"))
    end if
    if request.form("zhongzhu")<>"" then
        rs("zhongzhu")=trim(request.form("zhongzhu"))
    end if
    if request.form("zhongjin")<>"" then
        rs("zhongjin")=trim(request.form("zhongjin"))
    end if
    if request.form("zhongyi")<>"" then
        rs("zhongyiu")=trim(request.form("zhongyi"))
    end if
    if request.form("zhonger")<>"" then
        rs("zhonger")=trim(request.form("zhonger"))
    end if
    if request.form("zhongsan")<>"" then
        rs("zhongsan")=trim(request.form("zhongsan"))
    end if
    if request.form("zhongsi")<>"" then
        rs("zhongsi")=trim(request.form("zhongsi"))
    end if
    if request.form("zhongwu")<>"" then
        rs("zhongwu")=trim(request.form("zhongwu"))
    end if
    if request.form("zhongliu")<>"" then
        rs("zhongliu")=trim(request.form("zhongliu"))
    end if
    if request.form("hongqiu")<>"" then
        rs("hongqiu")=trim(request.form("hongqiu"))
    end if
    if request.form("lanqiu")<>"" then
        rs("lanqiu")=trim(request.form("lanqiu"))
    end if
    if request.form("tebie")<>"" then
        rs("tebie")=trim(request.form("tebie"))
    end if
    if request.form("riqi")<>"" then
        rs("riqi")=trim(request.form("riqi"))
    end if
    rs.update
    bianhao=rs("bianhao")
end sub
    rs.close
    set rs=nothing
    conn.close
    set conn=nothing
%>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div align="center"><center>
<br><br>
<table class="border" align=center width="50%" border="0" cellpadding="4" cellspacing="0" bordercolor="#999999">
  <tr align=center>
    <td width="100%" class="title"  height="20"><b>
<%if request("action")="add" then%>添加<%else%>修改<%end if%>记录成功</b></td>
  </tr>
  <tr>
    <td class="tdbg"><p align="left"><br>
        本期编号为:<%response.write bianhao%><br>
        本期期号为:<%response.write qihao%></p>
    您可以进行其他操作
    </td>
  </tr>
</table>
</center></div>
<%
else
    Error()
end if
%>
</body>
</html>
<%
sub Error()
    response.write "   <html><head><link rel='stylesheet' href='style.css'></head><body>"
        response.write "   <br><br><br>"
        response.write "    <table align='center' width='300' border='0' cellpadding='4' cellspacing='0' class='border'>"
        response.write "      <tr > "
        response.write "        <td class='title' colspan='2' height='15'> "
        response.write "          <div align='center'>由于以下的原因不能保存数据!</div>"
        response.write "        </td>"
        response.write "      </tr>"
        response.write "      <tr> "
        response.write "        <td align=center class='tdbg' colspan='2' height='23'> "
        response.write "          <br>"
        response.write errmsg& " <br><br>"
        response.write "        <a href='javascript:onclick=history.go(-1)'>返回</a>"        
        response.write "        <br><br></td>"
        response.write "      </tr>   </table></body></html>" 
end sub
%>



 
											





 
	    

 
	