<% Option Explicit %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>编辑单页</TITLE>
<link rel="stylesheet" href="../Images/CssAdmin.css">
<script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
<link rel="stylesheet" href="../../kindeditor4110/themes/default/default.css" />
<link rel="stylesheet" href="../../kindeditor4110/plugins/code/prettify.css" />
<script charset="utf-8" src="../../kindeditor4110/kindeditor.js"></script>
<script charset="utf-8" src="../../kindeditor4110/lang/zh_CN.js"></script>
<script charset="utf-8" src="../../kindeditor4110/plugins/code/prettify.js"></script>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</HEAD>
<!--#include file="../../Include/Const.asp" -->
<!--#include file="../../Include/Conn1.asp" -->
<!--#include file="../CheckAdmin.asp"-->
<BODY>
<% 
dim Result,rs,sql,n,showm,mLid,lid
Result=request.QueryString("Result")
dim ID,CompanyName,Content,Angel_languageid
ID=request.QueryString("ID")
call CompanyEdit() 

If Result = "Add" Then
%>
<div id="Language">
<div style="height:37px;background:#ffffff;border:1px #628ae1 solid;padding-top:5px; width:100%; padding-left:10px;clear:both;">
<h2>简体中文</h2>
</div>
<%end if%>
<br />
<%
  set rs = server.createobject("adodb.recordset")
  sql="select * from Angel_Language order by Lorder desc"
  rs.open sql,conn,1,1
  n=0
  do while not rs.eof
  if request("m")<>"" then
  showm=request("m")
  else
  showm=n
  end if
  if Result = "Add" then
  mLid=rs("id")
  Angel_languageid=rs("id")
  else
  mLid=""
  end if
%>
<ul>
<script type="text/javascript">
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content<%=rs("id")%>"]', {
				cssPath : '../../kindeditor4110/plugins/code/prettify.css',
				uploadJson : '../../kindeditor4110/asp/upload_json.asp',
				fileManagerJson : '../../kindeditor4110/asp/file_manager_json.asp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=editForm<%=rs("id")%>]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=editForm<%=rs("id")%>]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
</script>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#628AE1">
<tr>
    <td height="24" nowrap><font color="#FFFFFF"><img src="../Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>修改单页信息</strong></font></td>
  </tr>
  <form name="editForm<%=mLid%>" method="post" action="CompanyEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>&m=<%=showm%>">
  <tr>
    <td height="24" nowrap bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0" id=editCompany idth="100%">

      <tr>
        <td width="85" height="20" align="right">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="30" align="right">页面名称：</td>
        <td><input name="CompanyName" type="text" class="textfield" id="CompanyName" style="WIDTH: 380px" value="<%=CompanyName%>" maxlength="100">&nbsp;<span class="STYLE1">*</span></td>
      </tr>
      <tr>
        <td height="20" align="right" valign="top">信息内容：<br>
        <td>
      <textarea name="content<%=rs("id")%>" style="width:680px;height:300px;" id="content<%=rs("id")%>"><%=content%></textarea>
</td>
      </tr>
      <tr>
        <td height="30" align="right">&nbsp;	<input name="Angel_languageid" value="<%=Angel_languageid%>" type="hidden" /></td>
        <td valign="bottom"><input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
      </tr>
      <tr>
        <td height="20" align="right">&nbsp;</td>
        <td valign="bottom">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  </form>
</table>
</ul>
<%
rs.movenext
n=n+1
If Result = "Modify" then
if n>0 then exit do
end if
loop
rs.close%>

<%If Result = "Add" then%>
</div>
<%dim m
m=request.QueryString("m")
if m="" then m=0
%>
<script>
function $(id){return document.getElementById(id);}
function $tag(id,tagName){return $(id).getElementsByTagName(tagName)}
var onum=<%=m%>;//用于控制默认打开的标签
var Ds=$tag("Language","ul");
var Ts=$tag("Language","h2");
for(var i=0; i<Ds.length;i++){
if(i==onum){
Ds[i].style.display="block";
Ts[i].className = "title_current";
}
else{
Ds[i].style.display="none";
Ts[i].className = "title_normal";
}
Ts[i].value=i;
Ts[i].onmousedown=function(){
if(onum==this.value){return false;};
Ts[onum].className="title_normal";
Ts[this.value].className="title_current";
Ds[onum].style.display="none";
Ds[this.value].style.display="block";
onum=this.value;
}
}
</script>
<%end If%>
</div>
</BODY>
</HTML>
<%
sub CompanyEdit()
  dim Action,rsRepeat,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then '保存编辑产品信息
    set rs = server.createobject("adodb.recordset")

    if Result="Add" then '创建产品信息
	  sql="select * from Angel_Company"
      rs.open sql,conn,1,3
      rs.addnew
	  rs("id")=GetID("id","Angel_Company")
      rs("CompanyName")=trim(Request.Form("CompanyName"))
	  rs("Content")=trim(Request.Form("Content1"))
	  rs("AddTime")=now()
	  rs("Angel_languageid")=trim(Request.Form("Angel_languageid"))
	end if  
	if Result="Modify" then '修改产品信息
      sql="select * from Angel_Company where ID="&ID
      rs.open sql,conn,1,3
      rs("CompanyName")=trim(Request.Form("CompanyName"))
      rs("Content")=trim(Request.Form("content"&Request.Form("Angel_languageid")&""))
	  rs("Angel_languageid")=trim(Request.Form("Angel_languageid"))
	end if
	rs.update
	rs.close
    set rs=nothing 
    response.write "<script language=javascript> alert('成功编辑单页信息！');location.replace('CompanyList.asp?m="&request.QueryString("m")&"');</script>"
	response.End()
  else '提取产品信息
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from Angel_Company where ID="& ID
      rs.open sql,conn,1,1
      if rs.bof and rs.eof then
        response.write ("数据库读取记录出错！")
        response.end
      end if
	  CompanyName=rs("CompanyName")
      Content=rs("Content")
	  Angel_languageid=rs("Angel_languageid")
	  rs.close
      set rs=nothing 
    end if
  end if
end sub
%>