<!--#include file="Access.asp"  -->
<!-- #include file="inc/functions.asp" -->
<!-- #include file="x_to_html/index_to_html.asp" -->
<!-- #include file="x_to_html/firm_content_to_html.asp" -->

<% '更新数据到数据表
page=request.querystring("page")
act=request.querystring("act")
keywords=request.querystring("keywords")
article_id=cint(request.querystring("id"))
com_yes=request.querystring("com_yes")			


act1=Request("act1")
If act1="save" Then 
a_id=cint(request.form("a_id"))
a_name=trim(request.form("a_name"))
a_author=trim(request.form("a_author"))
a_cid=trim(request.form("cid"))
a_pid=trim(request.form("pid"))
a_ppid=trim(request.form("ppid"))
a_image=trim(request.form("web_image"))
a_about=trim(request.form("a_about"))
a_address=trim(request.form("a_address"))
a_zip=trim(request.form("a_zip"))
a_owner=trim(request.form("a_owner"))
a_tel=trim(request.form("a_tel"))
a_mobile=trim(request.form("a_mobile"))
a_email=trim(request.form("a_email"))
a_url=trim(request.form("a_url"))
a_hit=trim(request.form("a_hit"))
a_order=trim(request.form("a_order"))
a_com_yes=trim(request.form("a_com_yes"))
a_index_push=trim(request.form("a_index_push"))
a_view_yes=trim(request.form("a_view_yes"))
a_time=now()

set rs_author=server.createobject("adodb.recordset")
sql="select [id] from web_com where [author]="&a_author&" and [id]<>"&a_id&""
rs_author.open(sql),cn,1,1
if not rs_author.eof then
response.write "<script language=javascript>alert('该用户已经创建企业/商铺,请重新选择发布者!');history.go(-1);</script>"
else

set rs=server.createobject("adodb.recordset")
sql="select * from web_com where id="&a_id&""
rs.open(sql),cn,1,3
rs("name")=a_name
rs("cid")=a_cid
rs("pid")=a_pid
rs("ppid")=a_ppid
if a_author<>"0" then
rs("author")=a_author
end if
rs("image")=a_image
rs("about")=a_about
rs("address")=a_address
rs("zip")=a_zip
rs("owner")=a_owner
rs("tel")=a_tel
rs("mobile")=a_mobile
rs("email")=a_email
rs("url")=a_url
rs("hit")=a_hit
rs("order")=a_order
rs("index_push")=a_index_push
rs("com_yes")=a_com_yes
rs("view_yes")=a_view_yes
rs("edit_time")=a_time

filepath=rs("file_path")

rs.update

rs.close
set rs=nothing

call firm_content_to_html(a_id,filepath)

response.Write "<script language='javascript'>alert('修改成功！');location.href='com_list.asp?page="&page&"&com_yes="&com_yes&"&act="&act&"&keywords="&keywords&"';</script>"
end if
rs_author.close
set rs_author=nothing

end if 
 %>
 
 <!-- 三级联动菜单 开始 -->
<script language="JavaScript">
<!--
<%
'二级数据保存到数组
Dim count2,rsClass2,sqlClass2
set rsClass2=server.createobject("adodb.recordset")
sqlClass2="select id,pid,ppid,name from web_com_type where ppid=2 order by id " 
rsClass2.open sqlClass2,cn,1,1
%>
var subval2 = new Array();
//数组结构：一级根值,二级根值,二级显示值
<%
count2 = 0
do while not rsClass2.eof
%>
subval2[<%=count2%>] = new Array('<%=rsClass2("pID")%>','<%=rsClass2("ID")%>','<%=rsClass2("Name")%>')
<%
count2 = count2 + 1
rsClass2.movenext
loop
rsClass2.close
%>

<%
'三级数据保存到数组
Dim count3,rsClass3,sqlClass3
set rsClass3=server.createobject("adodb.recordset")
sqlClass3="select id,pid,ppid,name from web_com_type where ppid=3 order by id" 
rsClass3.open sqlClass3,cn,1,1
%>
var subval3 = new Array();
//数组结构：二级根值,三级根值,三级显示值
<%
count3 = 0
do while not rsClass3.eof
%>
subval3[<%=count3%>] = new Array('<%=rsClass3("pID")%>','<%=rsClass3("ID")%>','<%=rsClass3("Name")%>')
<%
count3 = count3 + 1
rsClass3.movenext
loop
rsClass3.close
%>

function changeselect1(locationid)
{
    document.form1.pid.length = 0;
    document.form1.pid.options[0] = new Option('选择二级分类','');
    document.form1.ppid.length = 0;
    document.form1.ppid.options[0] = new Option('选择三级分类','');
    for (i=0; i<subval2.length; i++)
    {
        if (subval2[i][0] == locationid)
        {document.form1.pid.options[document.form1.pid.length] = new Option(subval2[i][2],subval2[i][1]);}
    }
}

function changeselect2(locationid)
{
    document.form1.ppid.length = 0;
    document.form1.ppid.options[0] = new Option('选择三级分类','');
    for (i=0; i<subval3.length; i++)
    {
        if (subval3[i][0] == locationid)
        {document.form1.ppid.options[document.form1.ppid.length] = new Option(subval3[i][2],subval3[i][1]);}
    }
}
//-->
</script><!-- 三级联动菜单 结束 --> 
 
	<%
Call header()

%>

         <script language='javascript'>
function checksignup1() {
if ( document.form1.a_name.value == '' ) {
window.alert('请输入名称^_^');
document.form1.a_name.focus();
return false;}

if ( document.form1.cid.value == '' ) {
window.alert('请选择分类^_^');
document.form1.cid.focus();
return false;}

if(document.form1.a_zip.value.search(/^([0-9]*)([.]?)([0-9]*)$/)   ==   -1)   
      {   
  window.alert("请输入数字^_^");   
document.form1.a_zip.focus();
return false;}

if(document.form1.a_tel.value.search(/^([0-9]*)([.]?)([0-9]*)$/)   =='')   
      {   
  window.alert("请输入数字^_^");   
document.form1.a_tel.focus();
return false;}

if(document.form1.a_mobile.value.search(/^([0-9]*)([.]?)([0-9]*)$/)   ==   -1)   
      {   
  window.alert("请输入数字^_^");   
document.form1.a_mobile.focus();
return false;}

if(document.form1.a_hit.value.search(/^([0-9]*)([.]?)([0-9]*)$/)   ==   -1)   
      {   
  window.alert("请输入数字^_^");   
document.form1.a_hit.focus();
return false;}

if(document.form1.a_order.value.search(/^([0-9]*)([.]?)([0-9]*)$/)   ==   -1)   
      {   
  window.alert("请输入数字^_^");   
document.form1.a_order.focus();
return false;}

if ( document.form1.a_email.value.length> 0 &&!document.form1.a_email.value.indexOf('@')==-1|document.form1.a_email.value.indexOf('.')==-1 ) {
window.alert('请设置正确的Email地址^_^');
document.form1.a_email.focus();
return false;}

return true;}
</script>
<%
      
			set rs=server.createobject("adodb.recordset")
sql="select * from web_com where id="&article_id&""
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
%>  <form id="form1" name="form1" method="post" action="?act1=save&com_yes=<%=com_yes%>&page=<%=page%>&act=<%=act%>&keywords=<%=keywords%>">

	<table cellpadding='3' cellspacing='1' border='0' class='tableBorder' align=center>
	<tr>
	  <th class='tableHeaderText' colspan=2 height=25>修改<% if com_yes="" then
	  response.write "企商"
	  elseif com_yes=0 then
	  response.write "商铺"
	  elseif com_yes=1 then
	  response.write "企业"
	  end if%>信息</th>
	<tr>
	  <td height=23 class='forumRow'>发布者</td>
	  <td class='forumRow'>
	   <select name="a_author" id="a_author">
	   <option value="0">请选择</option>
<% set rsp=server.createobject("adodb.recordset")
		   sql="select id,username from web_register"
		   rsp.open(sql),cn,1,1
		   if not rsp.eof and not rsp.bof then
		   do while not rsp.eof 
		   %> <option value="<%=rsp("id")%>" <%if rsp("id")=cint(rs("author")) then
		response.write "selected"
		end if%>>[<%=rsp("id")%>] <%=rsp("username")%></option>
            <%
			rsp.movenext
			loop
			end if
			rsp.close
			set rsp=nothing%></select>
</td>
	  </tr>
	<tr>
	<td width="15%" height=23 class='forumRowHighLight'>名称 (必填) </td>
	<td class='forumRowHighLight'><input name='a_name' type='text' id='a_name' value="<%=rs("name")%>" size='70' maxlength="80">
	<input name='a_id' type='hidden' id='a_id' value="<%=rs("id")%>" size='70'>
	  &nbsp;</td>
	</tr>
	<tr>
	<td class='forumRow' height=23>分类 (必选)</td>
    <td class='forumRow'><%
set rsc1=server.createobject("adodb.recordset")
sql1="select id,pid,ppid,name from web_com_type where ppid=1 order by id" 
rsc1.open sql1,cn,1,1
%>
         <select name="cid" id="cid" onChange="changeselect1(this.value)">
              <option value="">选择一级分类</option>
              <% '输出一级分类，并选定当前分类
count1 = 0
do while not rsc1.eof
%><option value="<%=rsc1("ID")%>"  <%
if rs("cid")<>"" then

if cint(rs("cid"))=rsc1("id") then
response.write "selected"
end if
end if
%>><%=rsc1("Name")%></option>
<%count1 = count1 + 1
rsc1.movenext
loop
rsc1.close
%>
            </select>
            &nbsp;&nbsp;
	
            <select name="pid" id="pid"  onchange="changeselect2(this.value)">
              <option value="">选择二级分类</option>
			 		<%'输出二级分类，并选定当前分类
		if rs("pid")<>"" then	
set rsc2=server.createobject("adodb.recordset")
sqlClass2="select id,pid,ppid,name from web_com_type where ppid=2 and pid="&cint(rs("cid"))&" order by id" 
rsc2.open sqlClass2,cn,1,1

count1 = 0
do while not rsc2.eof
%><option value="<%=rsc2("ID")%>"  <%if cint(rs("pid"))=rsc2("id") then
response.write "selected"
end if%>><%=rsc2("Name")%></option>
<%count1 = count1 + 1
rsc2.movenext
loop
rsc2.close
end if
%>
            </select>
            &nbsp;&nbsp;
				
            <select name="ppid" id="ppid">
              <option value="">选择三级分类</option>
			  			  		<% '输出三级分类，并选定当前分类
								if rs("ppid")<>"" then
set rsc3=server.createobject("adodb.recordset")
sqlClass3="select id,pid,ppid,name from web_com_type where ppid=3 and pid="&cint(rs("pid"))&" order by id" 
rsc3.open sqlClass3,cn,1,1

count1 = 0
do while not rsc3.eof
%><option value="<%=rsc3("ID")%>"  <%if cint(rs("ppid"))=rsc3("id") then
response.write "selected"
end if%>><%=rsc3("Name")%></option>
<%count1 = count1 + 1
rsc3.movenext
loop
rsc3.close
end if
%>
            </select>&nbsp;</td>
	</tr>
	  <tr>
	    <td class='forumRowHighLight' height=23>形象图片或LOGO</td>
	    <td width="85%" class='forumRowHighLight'><table width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <td width="22%"  ><input name="web_image" type="text" id="web_image"  value="<%=rs("image")%>" size="30" maxlength="80"></td>
           <td width="78%" ><iframe width="500" name="ad" frameborder=0 height=30 scrolling=no src=upload.asp></iframe></td>
         </tr>
       </table></td>
      </tr>
	<tr>
	  <td class='forumRow' height=23>简介</td>
	  <td class='forumRow'> <textarea name='a_about' style='display:none' dataType='Require'  ><%=rs("about")%></textarea>
 <iframe ID='eWebEditor1' src='editor/ewebeditor.htm?id=a_about&style=coolblue&originalfilename=d_originalfilename&savefilename=d_savefilename&savepathfilename=d_savepathfilename' frameborder='0' scrolling='no' width='100%' HEIGHT='350'></iframe></td>
	</tr>
	<tr>
	  <td class='forumRowHighLight' height=23>地址</td>
	  <td class='forumRowHighLight'><span class="forumRow">
	    <input name='a_address' type='text' id='a_address' value="<%=rs("address")%>" size='40' maxlength="80">
	  </span></td>
	  </tr>
	<tr>
	  <td class='forumRow' height=23>邮编</td>
	  <td class='forumRow'>
	    <input name='a_zip' type='text' id='a_zip' value="<%=rs("zip")%>" size='40' maxlength="80">
      &nbsp;只能是数字</td>
	</tr>
	<tr>
	  <td class='forumRowHighLight' height=23>联系人</td>
	  <td class='forumRowHighLight'>
	    <input name='a_owner' type='text' id='a_owner' value="<%=rs("owner")%>" size='40' maxlength="80">
	 </td>
	</tr>
	<tr>
	  <td class='forumRow' height=23>电话</td>
	  <td class='forumRow'><input name='a_tel' type='text' id='a_tel' value="<%=rs("tel")%>" size='40' maxlength="80">
&nbsp;只能是数字</td>
	  </tr>
	<tr>
	  <td class='forumRowHighLight' height=23>手机</td>
	  <td class='forumRowHighLight'><input name='a_mobile' type='text' id='a_mobile' value="<%=rs("mobile")%>" size='40' maxlength="80">
&nbsp;只能是数字</td>
	  </tr>
	<tr>
	  <td class='forumRow' height=23>电子邮件</td>
	  <td class='forumRow'><input name='a_email' type='text' id='a_email' value="<%=rs("email")%>" size='40' maxlength="80"></td>
	  </tr>
	<tr>
	  <td class='forumRowHighLight' height=23>网址</td>
	  <td class='forumRowHighLight'><input name='a_url' type='text' id='a_url' value="<%=rs("url")%>" size='40' maxlength="80"></td>
	  </tr>	<tr>
	  <td class='forumRow' height=23>加入时间</td>
	  <td class='forumRow'>
	    <input name='a_time' type='text' id='a_time' value="<%=rs("time")%>" size='40' maxlength="80" readonly>
	  </td>
	  </tr>
	<tr>
	  <td class='forumRowHighLight' height=23>点击次数</td>
	  <td class='forumRowHighLight'><input name='a_hit' type='text' id='a_hit' value="<%=rs("hit")%>" size='10' maxlength="10">
      &nbsp;只能是数字</td>
	  </tr>
	<tr>
	  <td class='forumRow' height=23>排序</td>
	  <td class='forumRow'>
	    <input name='a_order' type='text' id='a_order' value="<%=rs("order")%>" size='10' maxlength="10"> 
	    &nbsp;只能是数字
</td>
	  </tr>
	<tr>
	  <td class='forumRowHighLight' height=23>类型</td>
	  <td class='forumRowHighLight'><input type="radio" name="a_com_yes" value="1" <%
		if rs("com_yes")=1 then
		response.write "checked"
		end if%>>
公司
      &nbsp;
      <input name="a_com_yes" type="radio" value="0" <%if rs("com_yes")=0 then
		response.write "checked"
		end if%>> 
      商家</td>
	  </tr>
	<tr>
	  <td class='forumRow' height=23>是否显示</td>
	  <td class='forumRow'><input type="radio" name="a_view_yes" value="1" <%
		if rs("view_yes")=1 then
		response.write "checked"
		end if%>>
是
      &nbsp;
      <input name="a_view_yes" type="radio" value="0" <%if rs("view_yes")=0 then
		response.write "checked"
		end if%>>
否</td>
	  </tr>

	
	<tr>
	  <td class='forumRowHighLight' height=23>是否推荐</td>
	  <td class='forumRowHighLight'><label>
	    <input type="radio" name="a_index_push" value="1" <%
		if rs("index_push")=1 then
		response.write "checked"
		end if%>>
      是
      &nbsp;
      <input name="a_index_push" type="radio" value="0" <%if rs("index_push")=0 then
		response.write "checked"
		end if%>>
      否</label></td>
	</tr>
	<tr><td height="50" colspan=2  class='forumRow'><div align="center">
	  <INPUT type=submit value='提交' onClick='javascript:return checksignup1()' name=Submit>
	  </div></td></tr>
	</table>
</form>
<%
else
response.write"未找到数据"
end if%>
<%
Call DbconnEnd()
 %>