<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("jfname")=""  or Instr(Request.Form ("jfname"), "'")>1  Then
	ef=True
	ec="机房名没填或有特殊字符！"
ElseIf Request.Form ("jgname")=""  or Instr(Request.Form ("jgname"), "'")>1  Then
	ef=True
	ec="机柜名没填或有特殊字符！"
ElseIf Request.Form ("jginfo")=""  or Instr(Request.Form ("jginfo"), "'")>1  Then
	ef=True
	ec="机柜说明没填或有特殊字符！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="ID应该是数字！"
elseIf session("cansetserver")="" Then
	ef=True
	ec="您没有此操作的权限。"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_IDCJG where jgname='"&Request.Form ("jgname")&"'"
		ds.Open Sql,conn,1,3
if not ds.Eof and Request.Form ("modify")<>"修改" and Request.Form ("delit")<>"删除" then
	ef=True
	ec="已存在同名的机柜产品！"
end if

if Request.Form ("modify")="修改" Then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_IDCJG where id='"&Request.Form ("id")&"'"
		ds.Open Sql,conn,1,3
if ds.Eof then
	ef=True
	ec="没找到要修改的机柜！"
end if
End If

if Request.Form ("delit")="删除" And Not ef and not ds.Eof then
Set dsph = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_IDCProductlist where ServerlistID='"&Request.Form ("id")&"' or ServerlistID2='"&Request.Form ("id")&"' or ServerlistID3='"&Request.Form ("id")&"' or ServerlistID4='"&Request.Form ("id")&"' or ServerlistID5='"&Request.Form ("id")&"'"
	dsph.Open Sql,conn,1,1
if not dsph.Eof then
	ef=True
	ec="此机柜已有开通的产品，只能修改，不能删除！"
end if
dsph.close
set dsph=nothing
end if

if not ef then
if Request.Form ("delit")<>"删除" then
if Request.Form ("modify")<>"修改" then ds.addnew
ds("jfname")=Request.Form("jfname")
ds("jgname")=Request.Form("jgname")
ds("jginfo")=Request.Form("jginfo")
ds("hardcon")=Request.Form("hardcon")

Else

SQL="delete from FreeHost.FreeHost_IDCIP where JGID='"&ds ("id")&"'"
  conn.Execute Sql

ds.delete
end if
ds.Update

ds.Close
set ds=nothing
conn.Close 
set conn=nothing
Response.Redirect "idcjg.asp"
end if

end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>