<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 language="javascript" src="../inc/Admin.js"></script>
<script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
<script charset="utf-8" src="../../KindEditor/kindeditor.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"-->
<%
'**************************************************
'商品分类开始
'**************************************************
Function ProSortID(SortPath)
dim sSql,sRs,Depth
	sSql="Select id From Angel_CaseSort where SortPath='"&SortPath&"'"
	set srs = server.createobject("adodb.recordset")
	sRs.Open sSql,Conn,1,1
		ProSortID=sRs(0)
	sRs.close()
	set sRs=nothing
	ProSortID=ProSortID
End Function

Function SortDepth(id)
dim sSql,sRs,Depth
	sSql="Select SortPath From Angel_CaseSort where id="&id
	set srs = server.createobject("adodb.recordset")
	sRs.Open sSql,Conn,1,1
		Depth=split(sRs(0),",")
		Depth= ubound(Depth)-1
	sRs.close()
	set sRs=nothing
	SortDepth=Depth
End Function

Function NextID(id)
dim sSql,sRs,Depth
	sSql="Select top 1 id From Angel_CaseSort where ParentID="&id
	set srs = server.createobject("adodb.recordset")
	sRs.Open sSql,Conn,1,1
		NextID=sRs(0)
	sRs.close()
	set sRs=nothing
End Function

sub CaseClass_Option(CurrentID,Angel_languageid)
	dim rsClass,sqlClass,strTemp,tmpDepth,i
	dim arrShowLine(20)
	for i=0 to ubound(arrShowLine)
		arrShowLine(i)=False
	next
	sqlClass="Select * From Angel_CaseSort where Angel_languageid="&Angel_languageid&" order by SortPath,ID asc"'RootID根栏目ID,OrderID排序ID
	set rsClass=Conn.execute(sqlClass)
	
	if rsClass.bof and rsClass.eof then 
		response.write "<option value=''>请先添加栏目</option>"
	else
		do while not rsClass.eof
		
			tmpDepth=SortDepth(rsClass("id"))'Depth栏目层数
			if NextID(rsClass("ParentID"))>0 then'NextID同级的下一个栏目ID
				arrShowLine(tmpDepth)=True
			else
				arrShowLine(tmpDepth)=False
			end if
			
			strTemp="<option value='" & rsClass("SortPath") & "'"
			
			if CurrentID>0 and rsClass("ID")=CurrentID then
				 strTemp=strTemp & " selected"
			end if
			strTemp=strTemp & ">"
			
			if tmpDepth>0 then
				for i=1 to tmpDepth
					strTemp=strTemp & "&nbsp;&nbsp;"
					if i=tmpDepth then
						if NextID(rsClass("ParentID"))>0 then
							strTemp=strTemp & "├&nbsp;"
						else
							strTemp=strTemp & "└&nbsp;"
						end if
					else
						if arrShowLine(i)=True then
							strTemp=strTemp & "│"
						else
							strTemp=strTemp & "&nbsp;"
						end if
					end if
				next
			end if
			strTemp=strTemp & rsClass("SortName")
			strTemp=strTemp & "</option>"
			response.write strTemp
			rsClass.movenext
		loop
	end if
	rsClass.close
	set rsClass=nothing
end sub
'商品分类 end
%>
<!--
<script language="javascript">
function small_pic(){
var value1 = document.getElementById("SmallPic").value;
	if (value1!=""){

		if (value1.substring(0,7)=="http://"){
			document.getElementById("SmallPicView").src =value1;
		}
		else{
			document.getElementById("SmallPicView").src ="<%=webpath%>"+value1;
		}
		
		document.getElementById("SmallPicView").style.display="block";
		document.getElementById("SmallDown").style.display="none";
		document.getElementById("SmallUp").style.display="block";
		}
	else{
		document.getElementById("SmallPicView").style.display="none";
	}
}

function small_pic2(){
document.getElementById("SmallPicView").style.display="none";
document.getElementById("SmallDown").style.display="block";
document.getElementById("SmallUp").style.display="none"
}


function Big_pic(){
var value2 = document.getElementById("BigPic").value;
	if (value2!=""){
		if (value2.substring(0,7)=="http://"){
			document.getElementById("BigPicView").src = value2;
		}
		else{
			document.getElementById("BigPicView").src = "<%=webpath%>"+value2;
		}
		document.getElementById("BigPicView").style.display="block";
		document.getElementById("BigDown").style.display="none";
		document.getElementById("BigUp").style.display="block";
		}
	else{
		document.getElementById("BigPicView").style.display="none";
	}
}

function Big_pic2(){
document.getElementById("BigPicView").style.display="none";
document.getElementById("BigDown").style.display="block";
document.getElementById("BigUp").style.display="none"
}
</script>
-->
<BODY>
<% 
dim Result
Result=request.QueryString("Result")
dim ID,CaseName,ViewFlag,Content,CommendFlag,NewFlag,SmallPic,BigPic,SortName,SortID,SortPath,Intro,Price,OtherPic,Angel_languageid
ID=request.QueryString("ID")
call CaseEdit() 
%>

<%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,3
  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=Angel_languageid
  end if
%>
<script type="text/javascript">
        KE.show({
                id : 'content<%=rs("id")%>',
				autoSetDataMode: false,
				afterCreate : function(id) {
					KE.event.add(KE.$('editForm<%=rs("id")%>'), 'submit', function() {
						KE.sync(id);
					});
				},
				minWidth : 360,minHeight:300,allowUpload:true,resizeMode:1,
				imageUploadJson : '<%=AngelSysRootDir%>admin/Upfile.asp',
				items:[ 'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
'italic', 'underline', 'strikethrough', 'removeformat','|','justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'selectall', '-',
'plainpaste', 'wordpaste', '|','image','flash', 'media', 'advtable', 'hr', 'emoticons', 'specialchar', 'link', 'unlink', '|', 'fullscreen', 'about', 'preview']
        });
</script>
<ul>
<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>
  <tr>
    <td height="24" align="center" nowrap  bgcolor="#FFFFFF"><a href="CaseEdit.asp?Result=Add" >添加案例信息</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="CaseList.asp" >查看所有案例信息</a></td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#628AE1">
  <form name="editForm<%=mLid%>" method="post" action="CaseEdit.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=editProduct idth="100%">

      <tr>
        <td width="100" height="20" align="right">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="30" align="right">案例名称：</td>
        <td><input name="CaseName" type="text" class="textfield" id="CaseName" style="WIDTH: 350px" value="<%=CaseName%>" maxlength="100">
          <span class="STYLE1"> *</span>
          &nbsp;
          <input name="ViewFlag" type="checkbox" id="ViewFlag" style='HEIGHT: 13px;WIDTH: 13px;' value="1" checked <%if ViewFlag then response.write ("checked")%>>
          是否发布</td>
      </tr>
	  	  <tr>
        <td height="30" align="right">关键词：</td>
        <td><input name="Price" type="text" class="textfield" id="Price" style="WIDTH: 380px" value="<%=Price%>" maxlength="100">
          </td>
      </tr>
	  <tr>
        <td height="100" align="right">优化描述：</td>
        <td>
		<textarea name="Intro" id="Intro" cols="50" rows="6"><%=Intro%></textarea>
          </td>
      </tr>
	   <tr>
        <td height="30" align="right">所属类别：</td>
        <td><select name='SortPath'>
	       <%call CaseClass_Option(SortID,mLid)%>
	       </select></td>
      </tr>
	  <tr>
        <td height="25" align="right">标　　记：</td>
        <td><input name="CommendFlag" type="checkbox" id="CommendFlag" style="HEIGHT: 13px;WIDTH: 13px; " value="1" <%if CommendFlag then response.write ("checked")%>> 首页显示&nbsp;&nbsp;(<font color="#FF0000">将在首页优先展示</font>)</td>
      </tr>

      <tr>
        <td height="30" align="right">标　　记：</td>
        <td><input name="NewFlag" type="checkbox" id="NewFlag" style="HEIGHT: 13px;WIDTH: 13px;" value="1" <%if NewFlag then response.write ("checked")%>> 
  <span class="STYLE1">最新开课（将优先在首页显示）</span>&nbsp;&nbsp;
 </td>
      </tr>

      <tr>
        <td height="25" align="right">缩 略 图：</td>
        <td>
		<div style="height:26px;line-height:26px;width:230px;float:left">
<input name="SmallPic" type="text" class="textfield" id="SmallPic" style="WIDTH: 230px;" value="<%=SmallPic%>" maxlength="100" > 
</div>
<div style="height:26px;line-height:26px;width:360px;float:left">
<iframe src="../upload.asp?action=simg&lid=<%=mLid%>" width="270" height="25" frameborder="0" scrolling="no"></iframe>尺寸：130*145</div>		
</td>
      </tr>



	  <!--
      <tr style="display:none">
        <td height="1" align="right"></td>
        <td><a href="#" onClick="small_pic();" id="SmallDown" style="width:100px; color:#0066CC;float:left">查看图片↓</a><a href="#" onClick="small_pic2();" id="SmallUp" style="width:100px;display:none; float:left;color:#0066CC;">查看图片↑</a><a href="#" style="width:40px; float:left; color:#888888" onClick="DelPic('smallpic',<%=ID%>);">删除×</a><br>
		<img src="" width="100" height="75" border="0" id="SmallPicView" style="display:none">	</td>
      </tr>
      <tr style="display:none">
        <td height="25" align="right">案例文件：</td>
        <td><input name="BigPic" type="text" class="textfield" id="BigPic" style="WIDTH: 340px;" value="<%=BigPic%>" maxlength="100">
            <a href="javaScript:OpenScript('../inc/UpFileForm.asp?Result=BigPic',460,250)"><img src="../Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a>&nbsp;格式：FLV；建议文件小于15M</td>
      </tr>
    
      <tr style="display:none">
        <td height="1" align="right"></td>
        <td><a href="#" onClick="Big_pic();" id="bigDown" style="width:100px; color:#0066CC;float:left">查看图片↓</a><a href="#" onClick="Big_pic2();" id="bigUp" style="width:100px;display:none; float:left;color:#0066CC;">查看图片↑</a><a  href="#" style="width:40px; float:left; color:#888888" onClick="DelPic('bigpic',<%=ID%>);">删除×</a><br>
            <img src="" width="300" height="210" border="0" id="BigPicView" style="display:none"></td>
      </tr>
	    -->



    <tr>
      <td align="right" class="forumRow">更多图片：</td>
      <td class="forumRowHighlight">

<%
if Request("Result")="Modify" then
If Not(IsNull(OtherPic)) Then
Dim htmlshop
%>
      <input name="Num_3" type="text" id="Num_3<%=Angel_languageid%>" value="<%= ubound(OtherPic)+1 %>" size="5" /> 张
        <input type="button" value="设置" onClick="num_3(<%=Angel_languageid%>)" />
        <input type="button" value="增加一张"  onClick="num_3_1(<%=Angel_languageid%>)" />
        <br />
        <span id="num_3_str<%=Angel_languageid%>">
<% for htmlshop=0 to ubound(OtherPic) %>
<!--
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="28"><input name="more<%= htmlshop+1 %>_pic" type="text" id="more<%= htmlshop+1 %>_pic" value="<%= trim(OtherPic(htmlshop)) %>" style="width: 300" />
              <input type="button" value="上传图片" onclick="showUploadDialog('image', 'editForm.more<%= htmlshop+1 %>_pic', '')"></td>
          </tr>
        </table>
-->
<div style="clear:both;width:auto;">
<div style="height:26px;line-height:26px;width:230px;float:left">
<input name="more<%= htmlshop+1 %>_pic" type="text" class="textfield" id="more<%= htmlshop+1 %>_pic" style="WIDTH: 230px;" value="<%= trim(OtherPic(htmlshop)) %>" maxlength="100" > 
</div>
<div style="height:26px;line-height:26px;width:360px;float:left">
<iframe src="../upload.asp?action=addpic&fpicid=<%= htmlshop+1 %>&lid=<%=mLid%>" width="270" height="25" frameborder="0" scrolling="no"></iframe>
</div>	
</div>
<% next %>
        </span>
<%
else
%>
      <input name="Num_3" type="text" id="Num_3<%=Angel_languageid%>" value="0" size="5" /> 张
        <input type="button" value="设置" onClick="num_3(<%=Angel_languageid%>)" />
        <input type="button" value="增加一张"  onClick="num_3_1(<%=Angel_languageid%>)" />
        <br />
        <span id="num_3_str<%=Angel_languageid%>">
        
        </span>
<%
end if
else
%>
      <input name="Num_3" type="text" id="Num_3<%=Angel_languageid%>" value="0" size="5" /> 张
        <input type="button" value="设置" onClick="num_3(<%=Angel_languageid%>)" />
        <input type="button" value="增加一张"  onClick="num_3_1(<%=Angel_languageid%>)" />
        <br />
        <span id="num_3_str<%=Angel_languageid%>">
        
        </span>
<%
End If
%>


      </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" type="hidden" value="<%=Angel_languageid%>" /></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%>
</BODY>
</HTML>
<%
sub CaseEdit()
  dim Action,rsRepeat,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then '保存编辑案例信息
    set rs = server.createobject("adodb.recordset")
    if len(trim(request.Form("CaseName")))<1 then
      response.write ("<script language=javascript> alert('案例名称为必填项目！');history.back(-1);</script>")
      response.end
	end if
    if Result="Add" then '创建案例信息
	  sql="select * from Angel_Case"
      rs.open sql,conn,1,3
      rs.addnew
      rs("CaseName")=trim(Request.Form("CaseName"))
	  rs("Price")=trim(Request.Form("Price"))
	  rs("Intro")=trim(Request.Form("Intro"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
	  if Request.Form("SortPath")="" then
        response.write ("<script language=javascript> alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  else
	    rs("SortPath")=Request.Form("SortPath")
		rs("SortID")=ProSortID(""&Request.Form("SortPath")&"")
	  end if

	  rs("SmallPic")=trim(Request.Form("SmallPic"))
	  Num_3=CheckStr(Request.Form("Num_3"),1)
	  if Num_3="" then Num_3=0
	  if Num_3>0 then
		For i=1 to Num_3
			If CheckStr(Request.Form("more"&i&"_pic"),0)<>"" Then
				If OtherPic="" then
					OtherPic=CheckStr(Request.Form("more"&i&"_pic"),0)
				Else
					OtherPic=OtherPic&"*"&CheckStr(Request.Form("more"&i&"_pic"),0)
				End if
			End If
		Next
	  end if
	  rs("OtherPic")=OtherPic
	  rs("BigPic")=trim(Request.Form("BigPic"))
	  
	  if Request.Form("CommendFlag")=1 then
        rs("CommendFlag")=Request.Form("CommendFlag")
	  else
        rs("CommendFlag")=0
	  end if
	  
	  if Request.Form("NewFlag")=1 then
        rs("NewFlag")=Request.Form("NewFlag")
	  else
        rs("NewFlag")=0
	  end if
	  rs("Content")=trim(Request.Form("Content"&Request.Form("Angel_languageid")))
	  rs("AddTime")=now()
	  rs("Angel_languageid")=trim(request.Form("Angel_languageid"))
	end if  
	if Result="Modify" then '修改案例信息
      sql="select * from Angel_Case where ID="&ID
      rs.open sql,conn,1,3
      rs("CaseName")=trim(Request.Form("CaseName"))
	  rs("Price")=trim(Request.Form("Price"))
	  rs("Intro")=trim(Request.Form("Intro"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
	  if Request.Form("SortPath")="" then
        response.write ("<script language=javascript> alert('请选择所属分类！');history.back(-1);</script>")
        response.end
	  else
	    rs("SortPath")=Request.Form("SortPath")
		rs("SortID")=ProSortID(""&Request.Form("SortPath")&"")
	  end if

	  rs("SmallPic")=trim(Request.Form("SmallPic"))
	  Num_3=CheckStr(Request.Form("Num_3"),1)
	  if Num_3="" then Num_3=0
	  if Num_3>0 then
		For i=1 to Num_3
			If CheckStr(Request.Form("more"&i&"_pic"),0)<>"" Then
				If OtherPic="" then
					OtherPic=CheckStr(Request.Form("more"&i&"_pic"),0)
				Else
					OtherPic=OtherPic&"*"&CheckStr(Request.Form("more"&i&"_pic"),0)
				End if
			End If
		Next
	  end if
	  rs("OtherPic")=OtherPic
	  rs("BigPic")=trim(Request.Form("BigPic"))
	  if Request.Form("CommendFlag")=1 then
        rs("CommendFlag")=Request.Form("CommendFlag")
	  else
        rs("CommendFlag")=0
	  end if
	  
	  if Request.Form("NewFlag")=1 then
        rs("NewFlag")=Request.Form("NewFlag")
	  else
        rs("NewFlag")=0
	  end if
	  rs("Content")=trim(Request.Form("Content"&Request.Form("Angel_languageid")))
	end If
	rs("Angel_languageid")=trim(request.Form("Angel_languageid"))
	rs.update
	rs.close
    set rs=nothing
    response.write "<script language=javascript> alert('成功编辑案例信息！');location.replace('CaseList.asp?m="&request("m")&"');</script>"
  else '提取案例信息
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from Angel_Case where ID="& ID
      rs.open sql,conn,1,1
      if rs.bof and rs.eof then
        response.write ("数据库读取记录出错！")
        response.end
      end if
	  CaseName=rs("CaseName")
	  ViewFlag=rs("ViewFlag")
	  SortName=SortText(rs("SortID"))
	  SortID=rs("SortID")
	  SortPath=rs("SortPath")
	  SmallPic=rs("SmallPic")
	  BigPic=rs("BigPic")
	  OtherPic=rs("OtherPic")
	  If Not(IsNull(OtherPic)) Then
	  OtherPic=split(OtherPic,"*")
	  End If
	  CommendFlag=rs("CommendFlag")
	  NewFlag=rs("NewFlag")
      Content=rs("Content")
	  Intro=rs("Intro")
	  Price=rs("Price")
	  Angel_languageid=rs("Angel_languageid")
	  rs.close
      set rs=nothing 
    end if
  end if
end sub
%>
<%
'生成所属类别--------------------------
Function SortText(ID)
  Dim rs,sql
  Set rs=server.CreateObject("adodb.recordset")
  sql="Select * From Angel_CaseSort where ID="&ID
  rs.open sql,conn,1,1
  SortText=rs("SortName")
  rs.close
  set rs=nothing
End Function
%>