<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("cancheckmoney")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf Request("id")<>"" And not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Request("sendtime")<>"" And not Isdate(Request("sendtime"))  Then
	ef=True
	ec="时间格式不对！"
ElseIf not IsNumeric(Request("usermoney"))  Then
	ef=True
	ec="金额应该是数字！"
ElseIf Request("title")="" Then
	ef=True
	ec="每项内容都必须要输入！"
ElseIf Request("recman")="" Then
	ef=True
	ec="每项内容都必须要输入！"
ElseIf Request("postid")="" Then
	ef=True
	ec="每项内容都必须要输入！"
ElseIf Request("address")="" Then
	ef=True
	ec="每项内容都必须要输入！"
ElseIf Request("con")="" Then
	ef=True
	ec="每项内容都必须要输入！"
'ElseIf Request("usercodeinfo")="" Then
'	ef=True
'	ec="每项内容都必须要输入！"
end If

if not ef then
 Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsfapiao = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Fapiao  where id ='"&Request("id")&"' "
dsfapiao.Open Sql,conn,1,3
if dsfapiao.Eof Then
	ef=True
	ec="不存在的发票编号。"
Else
If Request("Submit")="删除" Then
dsfapiao.delete
dsfapiao.update
Response.Redirect "fapiao.asp"
End if
End If
End If

if not ef Then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&dsfapiao ("username")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end If

if not ef Then
if session("AgnRunasUser")=True then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_agent where username='"&dsfapiao("username")&"'"
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="代理不存在!"
end if
end If
end If

if not ef Then
If Clng(Request("usermoney"))<Application("MinFapiaomoney") Or  Clng(Request("usermoney"))<0 Then
'	ef=True
'	ec="您输入的开发票金额小于最少的允许金额!"
End if
End If



if not ef Then
If Request("usermoney")*Application("FapiaoPaypercent")/100>ds("usermoney") Then
'	ef=True
'	ec="您帐上的可用金额不足!共需要"&Request("usermoney")*Application("FapiaoPaypercent")/100&"元"
End if
End If


if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
<%=htmlwrite("html9")%>
<%

'if dsfapiao.Eof Then
'dsfapiao.addnew
'dsfapiao("usermoney")=Request("usermoney")
'isnew=true
'End if

'dsfapiao("username")=session("username")
dsfapiao("title")=Request("title")
dsfapiao("titleID")=Request("titleID")
dsfapiao("recman")=Request("recman")
dsfapiao("postid")=Request("postid")
dsfapiao("address")=Request("address")
dsfapiao("con")=Request("con")
dsfapiao("usercodeinfo")=Request("usercodeinfo")
dsfapiao("admcodeinfo")=Request("admcodeinfo")
If Request("sendtime")<>"" Then dsfapiao("sendtime")=Request("sendtime")
'dsfapiao("apptime")=Now
dsfapiao("status")=Request("status")
dsfapiao("mobi")=Request("mobi")
dsfapiao("sendtype")=Request("sendtype")

dsfapiao.update



%>

<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0 background="img/midtop4.gif">
  <TBODY>
    <TR>
      <TD width=53 align="left" background="img/midtop1.gif"><strong> 　 </strong><font color="#FFFFFF">─<strong>&gt;</strong></font> </TD>
      <TD align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="7" background="img/midtop.gif">&nbsp;</td>
          <td width="90" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="fapiao.asp"><font color="#FFFFFF"><strong>发票管理</strong></font></a></td>
          <td width="5" background="img/midtop2.gif">&nbsp;</td>
        </tr>
      </table></TD>
      <TD width="83">&nbsp;</TD>
      <TD width="83" align="left">&nbsp;</TD>
      <TD align="left">&nbsp;</TD>
      <TD width=23 align="right"><IMG height=59 
                  src="img/rtop4.jpg" 
                  width=19></TD>
    </TR>
  </TBODY>
</TABLE>


<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=19 background="img/midlef.gif" id=rightid>&nbsp;</TD>
      <TD height="300" align="center" vAlign=top bgcolor="#FFFFFF"><br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
      保存成功。</TD>
      <TD width=18 background="img/midri.gif">&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD width=30><IMG height=19 
                  src="img/rb1.jpg" 
                  width=30></TD>
      <TD 
                background=img/rb2.jpg>&nbsp;</TD>
      <TD width=30><IMG height=19 
                  src="img/rb3.jpg" 
                  width=30></TD>
    </TR>
  </TBODY>
</TABLE>


<%=htmlwrite("html10")%>
<%
end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
