<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/connss.asp" -->
<!--#include file="include/global.asp" -->
<!--#include file="check.asp" -->
<%
if Right_Limit(47)<>1 then
response.Write "<script language=javascript>alert('对不起,你没有权限!');location.href='javascript:history.go(-1)'</script>"
end if

ty         = request("ty")
s1         = Request("s1")
s2         = Request("s2")
paihao     = Request("paihao")
paihao_s   = request("paihao_s")
guipao     = request("guipao")
guipao_s   = request("guipao_s")
jgws       = request("jgws")
beizu      = request("beizu")
bak_ty     = ""
bak_info   = ""

'if id="" then
'response.Write"<br>出错,请重试一次或联系管理员"
'else

if ty="update_ok" then
bak_ty="OK"

if s1="" then
bak_ty     = "NO"
bak_info   = bak_info&"接入商		不能为空\n"
end if

if s2="" then
bak_ty     = "NO"
bak_info   = bak_info&"机房		不能为空\n"
end if

if paihao_s="" then
bak_ty     = "NO"
bak_info   = bak_info&"排号		不能为空\n"
end if

if guipao_s="" then
bak_ty     = "NO"
bak_info   = bak_info&"柜号 	不能为空\n"
end if

if jgws="" then
bak_ty     = "NO"
bak_info   = bak_info&"机位数		不能为空\n"
end if

if bak_ty="OK" then

'  set rs_ct=server.createobject("adodb.recordset")
'  sql_ct="select * from cab_cab" 
'  rs_ct.open sql_ct,conn,1,3
'  rs_ct.addnew

'  rs_ct("uname")      = namet
'  rs_ct("sex")        = sex
'  rs_ct("documents")  = documents
'  rs_ct("tel")        = tel
'  rs_ct("mobile")     = mobile
'  rs_ct("fax")        = fax
'  rs_ct("qq")         = qq
'  rs_ct("msn")        = msn
'  rs_ct("email")      = email
'  rs_ct("web")        = web
'  rs_ct("c_id")       = id
 
'  rs_ct.update
'  rs_ct.close
  'conn.execute("update [customer] set lxr_id=lxr_id+1 where id="&id&"")

set rs_c_n = server.createobject("adodb.recordset")
If Isnumeric(paihao_s)=False Then
sql_c_n="select * from cab_no where P_no="&paihao_s&" and P_classID="&s1&" and P_typeID="&s2&""
else
sql_c_n="select * from cab_no where id="&paihao_s&" and P_classID="&s1&" and P_typeID="&s2&""
end If 
rs_c_n.Open sql_c_n,conn,1,1
if rs_c_n.eof or rs_c_n.bof then

  set rs_cn_cr=server.createobject("adodb.recordset")
  sql_cn_cr="select * from cab_no" 
  rs_cn_cr.open sql_cn_cr,conn,1,3
  rs_cn_cr.addnew
  rs_cn_cr("P_no")      = paihao_s
  rs_cn_cr("P_classID") = s1
  rs_cn_cr("P_typeID")  = s2
  rs_cn_cr.update
  newid=rs_cn_cr("id")
  rs_cn_cr.close
  set rs_cn_cr=nothing
else
  newid=rs_c_n("id")
end if
rs_c_n.closex
set rs_type=nothing

conn.execute("update cab_cab set cab_name='"&guipao_s&"' where id="&id&"")


  response.Write "<script language=javascript>alert('编辑成功成功!');location.href='Cabinets_update.asp?id="&id&"'</script>"

else
response.Write "<script language=javascript>alert('对不起,出错信息如下,请核对:\n\n"&bak_info&"');location.href='javascript:history.go(-1)'</script>"

end if
end if
'end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改企业联系人</title>
<link href="images/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="3">
  <form id="form1" name="form1" method="post" action="Cabinets_add.asp" onSubmit="return checkFormData()">
  <tr>
    <td height="35" colspan="2" align="center"><%=names%></td>
  </tr>
  <tr>
    <td height="1" colspan="2" align="center" bgcolor="#EEEEEE"></td>
  </tr>
  <tr>
    <td height="10" colspan="2" align="center" ></td>
  </tr>
  <tr>
    <td width="100" height="21" align="right" valign="middle"><span class="t5">*</span>机房:</td>
    <td valign="middle">
    
<!-- 三级联动菜单 开始 -->
<script language="JavaScript">
<!--
<%
'二级数据保存到数组
Dim count2,rsClass2,sqlClass2
set rsClass2=server.createobject("adodb.recordset")
sqlClass2="select * from pro_type" 
rsClass2.open sqlClass2,conn,1,1
%>
var subval2 = new Array();
//数组结构:一级根值,二级根值,二级显示值
<%
count2 = 0
do while not rsClass2.eof
%>
subval2[<%=count2%>] = new Array('<%=rsClass2("pro_class_id")%>','<%=rsClass2("pro_type_id")%>','<%=rsClass2("pro_title")%>')
<%
count2 = count2 + 1
rsClass2.movenext
loop
rsClass2.close
%>

<%
'三级数据保存到数组
Dim count3,rsClass3,sqlClass3
set rsClass3=server.createobject("adodb.recordset")
sqlClass3="select * from cab_no" 
rsClass3.open sqlClass3,conn,1,1
%>
var subval3 = new Array();
//数组结构:二级根值,三级根值,三级显示值
<%
count3 = 0
do while not rsClass3.eof
%>
subval3[<%=count3%>] = new Array('<%=rsClass3("P_typeID")%>','<%=rsClass3("id")%>','<%=rsClass3("P_no")%>')
<%
count3 = count3 + 1
rsClass3.movenext
loop
rsClass3.close
%>

function changeselect1(locationid)
{
    document.form1.s2.length = 0;
    document.form1.s2.options[0] = new Option('===机房===','');
    document.form1.paihao.length = 0;
    document.form1.paihao.options[0] = new Option('===排号===','');
    document.form1.paihao_s.value = "可选择也可输入";
    for (i=0; i<subval2.length; i++)
    {
        if (subval2[i][0] == locationid)
        {document.form1.s2.options[document.form1.s2.length] = new Option(subval2[i][2],subval2[i][1]);}
    }
}

function changeselect2(locationid)
{
    document.form1.paihao.length = 0;
    document.form1.paihao.options[0] = new Option('==排号==','');
    document.form1.paihao_s.value = "可选择也可输入";
    for (i=0; i<subval3.length; i++)
    {
        if (subval3[i][0] == locationid)
        {document.form1.paihao.options[document.form1.paihao.length] = new Option(subval3[i][2],subval3[i][1]);}
    }
}

//-->
</script>
<%
Dim count1,rsClass1,sqlClass1
set rsClass1=server.createobject("adodb.recordset")
sqlClass1="select * from pro_class" 
rsClass1.open sqlClass1,conn,1,1
%>
<select name="s1" onChange="changeselect1(this.value)">
<option>=接入商=</option>
<%
count1 = 0
do while not rsClass1.eof
response.write"<option value="&rsClass1("pro_class_id")&">"&rsClass1("class_name")&"</option>"
count1 = count1 + 1
rsClass1.movenext
loop
rsClass1.close
%>
</select>

<select name="s2"  onChange="changeselect2(this.value)"> 
<option>===机房===</option>
</select>


<!-- 三级联动菜单 结束 -->
</td>
  </tr>
  <tr>
    <td height="21" align="right" valign="middle"><span class="t5">*</span>排号:</td>
    <td valign="top"><div style="position:absolute; border:1pt solid #7F9DB9; overflow:hidden; width:188px; height:21px; clip:rect(-1px 190px 190px 170px);">
    <select name="paihao" id="paihao" style="width:190px;height:20px;margin:-1px;" onChange="javascript:document.getElementById('paihao_s').value=document.getElementById('paihao').options[document.getElementById('paihao').selectedIndex].value;changeselect3(this.value)">
    <option value="可选择也可输入" style="color:#c2c2c2;">===请选择===</option>
    </select>
    </div>
    <div style="position:absolute; border-top:1pt solid #7F9DB9; border-left:1pt solid #7F9DB9; border-bottom:1pt solid #7F9DB9; width:170px; height:21px;">
    <input type="text" name="paihao_s" id="paihao_s" value="可选择也可输入" style="width:170px;height:15px;border:0pt;">
    </div>
    </td>
  </tr>
  <tr>
    <td height="21" align="right" valign="middle"><span class="t5">*</span> 柜号:</td>
    <td valign="middle"><input type="text" name="guipao_s" id="guipao_s" /></td>
  </tr>
  <tr>
    <td height="21" align="right" valign="middle"><span class="t5">*</span> 每柜机位数:</td>
    <td valign="middle"><input type="text" name="jgws" id="jgws"></td>
  </tr>
  <tr>
    <td height="20" align="right">备注:</td>
    <td><textarea name="beizu" rows="6" id="beizu"></textarea></td>
  </tr>
  <tr>
    <td height="40" align="right"><input name="ty" type="hidden" id="ty" value="add_ok" /></td>
    <td valign="bottom"><input type="submit" name="button" id="button" value="   提 交   "></td>
  </tr>
<script language="javascript">
function checkFormData() {
  if ( form1.class.value == 0 ) {
    alert ( "请选择!" );
	form1.class.focus();
	return false;
  }
  if ( form1.type.value == "" ) {
    alert ( "请输入机柜数!" );
	form1.type.focus();
	return false;
  }
  if ( form1.jgws.value == "" ) {
    alert ( "请输入机柜位数!" );
	form1.jgws.focus();
	return false;
  }
  if ( form1.jgws.value.search ("\d") != 0 ) {
    alert ( "请输入机柜位数!" );
	form1.jgws.focus();
	return false;
  }
}
</script>
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  </form>
</table>
</body>
</html>