<!--#include file="../inc/Secure.htm"-->
<%dim ThisKey
ThisKey = "r"
%>
<!--#include file="../inc/permission.htm"-->
<!--#include file="../inc/conn.htm"-->
<!--#include file="../inc/dbtools.htm"-->
<%
ID=trim(request("ID"))
if ID="" then ID=0
msg=trim(request("msg"))
if msg<>"" then response.write "<p align=center><font color=red>"& msg &"</font></p>"
dim NewID

if request("cmdUp")<>"" then	
	Name=replace(trim(request("Name")),"'","''")
	CheckNamelist=replace(trim(request("CheckNameList")),"'","''")
	CheckIDList=TRIM(request("CheckIDList"))
	StepID=TRIM(request("StepID"))
	StepName=TRIM(request("StepName"))
	if CheckIDList="" then CheckIDList=0
	response.write name&"<br>"& checknamelist&"<br>"&checkidlist&"<br>"&stepid&"<br>"&stepNAME
	if Name<>"" and CheckIDlist<>"" and StepID<>"" then
		if ID=0 then
			AddDocCheck()
			ID=NewID
		else
			strCheckNameList2=GetTableValue("tblDocCheck","CheckNameList","ID",ID)&"."&CheckNamelist
			strCheckIDList2=GetTableValue("tblDocCheck","CheckList","ID",ID)&"."&CheckIDList
			strCheckStepID2=GetTableValue("tblDocCheck","CheckStepID","ID",ID)&","&StepID
			strCheckStepName2=GetTableValue("tblDocCheck","CheckStepName","ID",ID)&","&StepName

			UpdateDocCheck(ID)
		end if
		response.redirect "AddPath.htm?ID="& ID &"&Msg="& SERVER.URLencode("添加成功！")
		oconn.close
		response.end
	else
		response.write "<p align=center><font color=red>填写不完整！</font></p>"
	end if
end if
if ID<>0 then
	set rstmp=server.createobject("adodb.recordset")
	sql="select * from tblDocCheck where ID="& ID
	rstmp.open sql,oConn
	if not rstmp.eof then
	strName=trim(rstmp("Name"))
	strCheckName=trim(rstmp("CheckNameList"))
	strCheckStepName=trim(rstmp("CheckStepName"))
	arrName=split(strCheckName,".")
	arrStep=split(strCheckStepName,",")
	
	end if
	rstmp.close
	set rstmp=nothing
end if

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/main.css">
</head>
<script src="Popup.js"></script>
<body bgcolor="#FFFFFF">
<BR><BR>
<div align=center>
<form name="DocForm" method="post" action="">
<table border=1 cellpadding=3 cellspacing=1 width="100%" bgcolor=#FFFFFF bordercolordark="#FFFFFF" bordercolorlight="#999999">
<tr>
	<td align=center colspan=2>
	<%if id=0 then
	response.write "<b>添加新路径</b>"
	else
	response.write "<b>添加路径细节</b>"
	end if%>
	</td>
</tr>
<tr>
	<td align=center>
	流程路径名：<input type="text" class="input" name="Name" value="<%=strName%>" size=20 maxlength=50>
	</td>
</tr>
<tr>
	<td align=center>
	<table border=0 width="80%">
	<%
	if id<>0 and (not isempty(arrName)) then
	for i=0 to ubound(arrName)%>
		<tr><td align=center><%="("&arrName(i)&")"&"——<font color=red>"&arrStep(i)&"</font>"%></td></tr>
		<tr><td align=center>|<br>|</td></tr>
	<%next
	end if%>
	</table>
	</td>
</tr>

<tr>
	<td align=center>
	人名：<INPUT TYPE="text" class="doc_txt" size=30 readonly name="CheckNameList" value="<%=strCheckNameList%>">
	操作：<INPUT TYPE="text" class="doc_txt" size=10 readonly name="StepName" value="<%=StepName%>">添加路径步骤
	<INPUT TYPE="button" name="cmdAttach" value="选择" onclick="OpenWindow('MultiUsers2.htm','UserWindow')" class="font9boldwhite"></td>
</tr>
<tr>
	<td align=center><BR>
		<INPUT TYPE="submit" name="cmdUp" value="保 存" onclick="return CheckData();" class="font9boldwhite">		
		<INPUT TYPE="button" name="cmdCancel" value="返  回" onclick="javascript:window.location.href='Managepath.htm'"  class="font9boldwhite">
	</td>

</tr>
</table>
<INPUT TYPE="hidden" name="CheckIDList" value="<%=strCheckIDList%>">

<INPUT TYPE="hidden" name="StepID" value="<%=StepID%>">
<INPUT TYPE="hidden" name="ID" value="<%=ID%>">
</form>
</body>
<BR><BR>
</html>
<!--#include file="../inc/conn_close.htm"-->
<script language="JavaScript">
function OpenWindow(url,windowname)
{
window.open(url,windowname,'left=80,top=50,height=350,width=640,toolbar=no,menubar=no,scrollbars=yes,status=no')
}
function OpenWindow1(url,windowname)
{
window.open(url,windowname,'left=150,top=100,height=80,width=420,toolbar=no,menubar=no,scrollbars=yes')
}
function CheckData()
{
	if(jtrim(document.DocForm.Name.value)=="")
	{
		alert("您必须输入路径名。")
		document.DocForm.Name.focus();
		return false;
	}
	if(jtrim(document.DocForm.CheckNameList.value)=="")
	{
		alert("请选择路径。")
		return false;
	}	
			
	return true;
}
</script>
<script language=javascript src="../inc/jtrim.js"></script>
<%
Function GetTableValue(TableName,Field,ValueField,Value)
	if TableName<>"" and Value<>"" then
		Set RsTmp = Server.Createobject("Adodb.recordset")
		strSql = "Select "& Field &" from "& TableName &" where "& ValueField &"='"& Value &"'"
		Rstmp.open strSql,oConn,1,1
		If not Rstmp.eof then
			GetTableValue=trim(Rstmp(Field))
		else
			GetTableValue=""
		end if
		Rstmp.close
		set RsTmp = Nothing
	else
		GetTableValue=""
	end if
End Function


Sub AddDocCheck()
	sql="SET NOCOUNT ON;"
	sql=sql&" INSERT INTO tblDocCheck(Name,CheckList,CheckNameList,CheckStepID,CheckStepName) VALUES('" & Name & _
		"','"& CheckIDlist & _
		"','"& CheckNameList & _
		"','"& StepID & _
		"','"& StepName & _
		"');"
		sql=sql & "Select @@IDENTITY AS NewID;"
		'response.write sql
		Set Rs1=oConn.execute (sql)
		NewID = Rs1("NewID")
end sub

Sub UpdateDocCheck(ID)
	sql="Update tblDocCheck set Name='"& Name &"',CheckList='"& strCheckIDList2 &"',CheckNameList='"& strCheckNameList2 &"',CheckStepID='"& strCheckStepID2 &"',CheckStepName='"& strCheckStepName2 &"' where ID="& ID
	'response.write sql
	oConn.execute (sql)
end sub


%>