<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<!--#include file="Connections/conn_news.asp" -->
<!--#include file="yns_config.asp" -->
<!--#include file="yns_chklogin.asp" -->
<% chk_user_login(3) %>
<!--#include file="yns_chkerror.asp" -->
<%

if (request.form("ts_id") <> "") then
Command1__mmid = request.form("ts_id")
else
response.Write yns_err_null
response.End()
end if

if (request.form("ts_pid") <> "") then
Command1__mmpid = request.form("ts_pid")
else
response.Write yns_err_null
response.End()
end if

if (request.form("ts_name") <> "") then
Command1__mmname = request.form("ts_name")
else
response.Write yns_err_null
response.End()
end if

if (request.form("ts_dir") <> "") then
Command1__mmdir = request.form("ts_dir")
else
response.Write yns_err_null
response.End()
end if

%>
<%
if request.Form("ts_dir1") = "" or request.Form("t_dir1") = "" then
response.Write yns_err_null
response.End()
end if
%>
<%
Dim rst__MMColParam
rst__MMColParam = "1"
If (Request.Form("ts_pid") <> "") Then
  rst__MMColParam = Request.Form("ts_pid")
End If
%>
<%
Dim rst
Dim rst_numRows

Set rst = Server.CreateObject("ADODB.Recordset")
rst.ActiveConnection = MM_conn_news_STRING
rst.Source = "SELECT * FROM t_type WHERE t_id = " + Replace(rst__MMColParam, "'", "''") + ""
rst.CursorType = 0
rst.CursorLocation = 2
rst.LockType = 1
rst.Open()

rst_numRows = 0
%>
<%
   dim fso
   dim f_path
   dim f_path1
   f_path = server.MapPath((rst.Fields.Item("t_dir").Value)&"/"&request.Form("ts_dir"))
Set fso = CreateObject("Scripting.FileSystemObject")
if request.Form("ts_dir1") <> "" then
f_path1 = server.MapPath(request.Form("t_dir1")&"/"&request.Form("ts_dir1"))
if f_path1 <> f_path then
   If not fso.FolderExists(server.MapPath(rst.Fields.Item("t_dir").Value)) then
   fso.CreateFolder (server.MapPath(rst.Fields.Item("t_dir").Value))
   end if
   If not fso.FolderExists(f_path) then
       if not fso.FolderExists(f_path1) then
	   fso.CreateFolder (f_path1)
	   end if
   fso.MoveFolder f_path1, f_path
   else
%>
<script language=javascript>
alert( "操作失败,文件夹已经存在!"  );
location.href = "javascript:history.back()"
</script>
<%
   response.End()
   end if
else
   If not fso.FolderExists(server.MapPath(rst.Fields.Item("t_dir").Value)) then
   fso.CreateFolder (server.MapPath(rst.Fields.Item("t_dir").Value))
   end if
   if not fso.FolderExists(f_path1) then
   fso.CreateFolder (f_path1)
   end if
end if

else
   If not fso.FolderExists(server.MapPath(rst.Fields.Item("t_dir").Value)) then
   fso.CreateFolder (server.MapPath(rst.Fields.Item("t_dir").Value))
   end if
   if not fso.FolderExists(f_path1) then
   fso.CreateFolder (f_path1)
   end if
end if
Set fso = nothing
%>
<%

set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_conn_news_STRING
Command1.CommandText = "UPDATE t_type_son  SET ts_pid = " + Replace(Command1__mmpid, "'", "''") + ", ts_name = '" + Replace(Command1__mmname, "'", "''") + "', ts_dir = '" + Replace(Command1__mmdir, "'", "''") + "'  WHERE ts_id = " + Replace(Command1__mmid, "'", "''") + ""
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>湖南百润医药有限公司-------康曼德www.hnicp.com</title>
<meta http-equiv="refresh" content="1;URL=yns_type.asp">
</head>

<body>
更新成功, 等待返回...
</body>
</html>
<%
rst.Close()
Set rst = Nothing
%>