<% Option Explicit %>
<!--#include file="../../Inc/Cls_DB.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
'==============================================================================
'软件名称：风讯网站信息管理系统
'当前版本：Foosun Content Manager System 2.0 
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P119") then Call ReturnError()
Dim Result
Dim OrdinaryID,OrdinaryName,OrdinaryUrl,RsTempObj,OperateType,Sql
OrdinaryID = Request("OrdinaryID")
OperateType = Request("OperateType")
Result = Request.Form("Result")
if OrdinaryID <> "" then
	Sql = "Select * from Routine where ID=" & OrdinaryID & " and Type=" & OperateType
	Set RsTempObj = Server.CreateObject("ADODB.RecordSet")
	RsTempObj.Open Sql,Conn,3,3
	if Not RsTempObj.Eof then
		OrdinaryName = RsTempObj("Name")
		OrdinaryUrl = RsTempObj("Url")
		if Result = "Submit" then
			OrdinaryName = Request.Form("Name")
			OrdinaryUrl = Request.Form("Url")
			Dim OrdNameModObj
			Set OrdNameModObj = Conn.Execute("Select ID from Routine where Name='"&Request.Form("Name")&"' and Type="&OperateType&"")
			If Not OrdNameModObj.eof then
				Response.Write("<script>alert(""名称与已有记录重复,请重新输入"");</script>")
				'Response.End
			else
				RsTempObj("Name") = Request.Form("Name")
				RsTempObj("Url") = Request.Form("Url")
				RsTempObj.UpDate
				if Err.Number = 0 then
					%>
					<script language="JavaScript">
						alert('修改成功');
						dialogArguments.location.reload();
						window.close();
					</script>
					<%
				else
					%>
					<script language="JavaScript">
						alert('修改失败');
						dialogArguments.location.reload();
						window.close();
					</script>
					<%
				end if
			End If
			OrdNameModObj.Close
			Set OrdNameModObj = Nothing
		end if
	else
		%>
		<script language="JavaScript">
			alert('参数传递错误');
			dialogArguments.location.reload();
			window.close();
		</script>
		<%
	end if
	Set RsTempObj = Nothing
else
	OrdinaryName = ""
    If OperateType="2" or OperateType="5" then
		OrdinaryUrl = "http://"
	Elseif OperateType="3" or OperateType="4" then
		OrdinaryUrl = "mailto:"
	else
		OrdinaryUrl = ""
	End If
	if Result = "Submit" then
		OrdinaryName = Request.Form("Name")
		OrdinaryUrl = Request.Form("Url")
		Dim OrdNameObj
		Set OrdNameObj = Conn.Execute("Select ID from Routine where Name='"&Request.Form("Name")&"' and Type="&OperateType&"")
		If Not OrdNameObj.eof then
			Response.Write("<script>alert(""名称与已有记录重复,请重新输入"");</script>")
		else
			Sql = "insert into Routine(Name,Url,Type) values ('" & Request.Form("Name") & "','" & Request.Form("Url") & "'," & OperateType & ")"
			Conn.Execute(Sql)
			if Err.Number = 0 then
				%>
				<script language="JavaScript">
					alert('添加成功');
					dialogArguments.location.reload();
					window.close();
				</script>
				<%
			else
				%>
				<script language="JavaScript">
					alert('添加失败');
					dialogArguments.location.reload();
					window.close();
				</script>
				<%
			end if
		End If
		OrdNameObj.Close
		Set OrdNameObj = Nothing
	end if
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>常规管理添加和修改</title>
</head>
<link href="../../CSS/css.css" rel="stylesheet">
<link href="Class.css" rel="stylesheet">
<body topmargin="0" leftmargin="0">
<div align="center">
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
   <form name="OrdinaryForm" action="" method="post">
    <tr height="5">
      <td></td>
      <td></td>
      <td width="80%"></td>
    </tr>
    <tr> 
      <td><div align="right"></div></td>
      <td>名称</td>
      <td><input style="width:90%;" value="<% = OrdinaryName %>" type="text" name="Name"></td>
    </tr>
    <tr> 
      <td width="6%"> <div align="right"></div></td>
      <td width="14%">链接</td>
      <td><input style="width:90%;" value="<% = OrdinaryUrl %>" type="text" name="Url"></td>
    </tr>
    <tr> 
      <td colspan="3"><div align="center"> 
                
            <input type="button" name="Submit" onClick="CheckForm();" value=" 确 定 ">
                <input name="OperateType" value="<% = OperateType %>" type="hidden" id="OperateType">
                  <input name="Result" type="hidden" id="Result" value="Submit">
                <input type="hidden" value="<% = OrdinaryID %>" name="OrdinaryID">
                  <input type="button" onClick="window.close();" name="Submit2" value=" 取 消 ">
              </div></td>
    </tr></form>
  </table>
</div>
</body>
</html>
<script>
var OrdType = '<% = OperateType %>';
function ChooseType()
{
 if (OrdType=='1') document.OrdinaryForm.Url.disabled=true;
 else document.OrdinaryForm.Url.disabled=false;
}
function CheckForm()
{
	if (document.OrdinaryForm.Name.value=='')
	{
		alert('请填写名称');
	}
	else
	{
		document.OrdinaryForm.submit();
	}
}
ChooseType();
</script>
<%
Set Conn = Nothing
%>