<!--#include file="../../Conn.asp" -->
<!--#include file="../../Comm/Site_Class.asp" -->
<%
PagePath = "../../"

Set Qsite = New Site_Class

Qsite.SiteConfig_Master()
%>
<!--#include file="../Check_Login.asp" -->
<%
Qsite.Check_AdminFlag(arrAdminFlag(0 , 5))

If Request.Form <> "" Then
	If Request.Form("WorkExpSelId") = 0 Then
		SaveNewWorkExpSel()
	Else
		SaveEditWorkExpSel()
	End If
End If

If Request.QueryString("action") = "del" Then
	DelWorkExpSel(Qsite.chgStr(Trim(Request.QueryString("WorkExpSelId"))))
ElseIf Request.QueryString("action") = "up" Then
	UpPx(Qsite.chgStr(Trim(Request.QueryString("WorkExpSelId"))))
ElseIf Request.QueryString("action") = "down" Then
	DownPx(Qsite.chgStr(Trim(Request.QueryString("WorkExpSelId"))))
End If

Sub SaveNewWorkExpSel()
	Dim WorkExpSelName,Px
	WorkExpSelName = Qsite.chgStr(Trim(Request.Form("WorkExpSelName")))
	Px = Qsite.chgStr(Trim(Request.Form("Px")))
	
	If WorkExpSelName = "" Or IsNull(WorkExpSelName) Then
		Qsite.ShowMsg "请输入工作经验名称" , ""
	End If

	If Px = "" Or IsNull(Px) Or Not IsNumeric(Px) Then Px = 1
	
	Set Rs = Conn.Execute("select WorkExpSelName from WorkExpSelTbl where WorkExpSelName = '"& WorkExpSelName &"'")
	If Not Rs.Eof Then
		Qsite.ShowMsg "工作经验已经存在，请返回重新输入" , ""
	End If
	Set Rs = Nothing
	
	Conn.Execute("update WorkExpSelTbl set Px = Px + 1 where Px >= "& Px)
	
	Conn.Execute("insert into WorkExpSelTbl (WorkExpSelName , Px) values ('"& WorkExpSelName &"' , "& Px &")")
	
	Qsite.ShowMsg "工作经验添加成功" , "Admin_WorkExpSel.asp"
End Sub

Sub SaveEditWorkExpSel()
	Dim WorkExpSelId,WorkExpSelName,Px
	Dim OldPx
	WorkExpSelId = Qsite.chgStr(Trim(Request.Form("WorkExpSelId")))
	WorkExpSelName = Qsite.chgStr(Trim(Request.Form("WorkExpSelName")))
	Px = Qsite.chgStr(Trim(Request.Form("Px")))
	
	If WorkExpSelId = "" Or IsNull(WorkExpSelId) Or Not IsNumeric(WorkExpSelId) Then WorkExpSelId = 0
	
	If WorkExpSelName = "" Or IsNull(WorkExpSelName) Then
		Qsite.ShowMsg "请输入工作经验名称" , ""
	End If
	
	If Px = "" Or IsNull(Px) Or Not IsNumeric(Px) Then Px = 1
	
	Set Rs = Conn.Execute("select WorkExpSelName from WorkExpSelTbl where WorkExpSelName = '"& WorkExpSelName &"' and WorkExpSelId <> "& WorkExpSelId)
	If Not Rs.Eof Then
		Qsite.ShowMsg "工作经验已经存在，请返回重新输入" , ""
	End If
	Set Rs = Nothing
	
	Set Rs = Conn.Execute("select Px from WorkExpSelTbl where WorkExpSelId = "& WorkExpSelId)
	If Rs.Eof Then
		OldPx = Px
	Else
		OldPx = Rs("Px")
	End If
	
	If Cint(Px) > Cint(OldPx) Then
		Conn.Execute("update WorkExpSelTbl set Px = Px - 1 where Px > "& OldPx &" and Px <= "& Px)
	ElseIf Cint(Px) < Cint(OldPx) Then
		Conn.Execute("update WorkExpSelTbl set Px = Px + 1 where Px >= "& Px &" and Px < "& OldPx)
	End If
	
	Conn.Execute("update WorkExpSelTbl set WorkExpSelName = '"& WorkExpSelName &"' , Px = "& Px &" where WorkExpSelId = "& WorkExpSelId)
	
	Qsite.ShowMsg "工作经验修改成功" , "Admin_WorkExpSel.asp"
End Sub

Sub DelWorkExpSel(WorkExpSelId)
	Dim OldPx,Rs,dKey
	Dim IncludeWorkExpSelId
	
	If WorkExpSelId = "" Or IsNull(WorkExpSelId) Or Not IsNumeric(WorkExpSelId) Then WorkExpSelId = 0
	
	Set Rs = Conn.Execute("select Px from WorkExpSelTbl where WorkExpSelId = "& WorkExpSelId)
	If Rs.Eof Then
		OldPx = 9999
	Else
		OldPx = Rs("Px")
	End If
	Set Rs = Nothing
	
	Conn.Execute("delete from WorkExpSelTbl where WorkExpSelId =" & WorkExpSelId)
	
	Conn.Execute("update WorkExpSelTbl set Px = Px - 1 where Px > "& OldPx)
	
	Qsite.ShowMsg "工作经验删除成功" , "Admin_WorkExpSel.asp"
End Sub

Sub UpPx(WorkExpSelId)
	Dim OldPx
	
	If WorkExpSelId = "" Or IsNull(WorkExpSelId) Or Not IsNumeric(WorkExpSelId) Then WorkExpSelId = 0
	
	Set Rs = Conn.Execute("select Px from WorkExpSelTbl where WorkExpSelId = "& WorkExpSelId)
	If Rs.Eof Then
		OldPx = 1
	Else
		OldPx = Rs("Px")
	End If
	Set Rs = Nothing
	
	If Cint(OldPx) > 1 Then
		Conn.Execute("update WorkExpSelTbl set Px = Px + 1 where Px = "& OldPx - 1)
		Conn.Execute("update WorkExpSelTbl set Px = Px - 1 where WorkExpSelId = "& WorkExpSelId)
	End If
	
	Response.Redirect("Admin_WorkExpSel.asp")
	Response.End()
End Sub

Sub DownPx(WorkExpSelId)
	Dim maxPx,OldPx
	
	If WorkExpSelId = "" Or IsNull(WorkExpSelId) Or Not IsNumeric(WorkExpSelId) Then WorkExpSelId = 0
	
	Set Rs = Conn.Execute("select Px from WorkExpSelTbl where WorkExpSelId = "& WorkExpSelId)
	If Rs.Eof Then
		OldPx = 9999
	Else
		OldPx = Rs("Px")
	End If
	Set Rs = Nothing
	
	Set Rs = Conn.Execute("select top 1 Px from WorkExpSelTbl order by Px desc")
	If Rs.Eof Then
		maxPx = 9999
	Else
		maxPx = Rs("Px")
	End If
	Set Rs = Nothing
	
	If Cint(OldPx) < Cint(maxPx) Then
		Conn.Execute("update WorkExpSelTbl set Px = Px - 1 where Px = "& OldPx + 1)
		Conn.Execute("update WorkExpSelTbl set Px = Px + 1 where WorkExpSelId = "& WorkExpSelId)
	End If
	
	Response.Redirect("Admin_WorkExpSel.asp")
	Response.End()
End Sub

Dim WorkExpSelId,WorkExpSelName,WorkExpSelKey,Px,contPx
Dim strTitle,strSubmit

Set Rs = server.createobject("ADODB.Recordset")

Sql = "select * from WorkExpSelTbl order by Px asc"

Rs.Open "select top 1 * from WorkExpSelTbl order by Px desc" , Conn ,1 , 1
If Rs.Eof Then
	contPx = 1
Else
	contPx = Rs("Px") + 1
End If
Rs.Close
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>工作经验管理</title>
<link href="../skins/css/main.css" rel="stylesheet" type="text/css">
<script language="javascript">
function PosDel(WorkExpSelId)
{
	var question = confirm("你确定要删除此条记录吗？");
	if (question !="0")
	{
		location.href = "Admin_WorkExpSel.asp?action=del&WorkExpSelId=" + WorkExpSelId;
	}
}
</script>
</head>

<body>
<%
WorkExpSelId = Qsite.chgStr(Trim(Request.QueryString("WorkExpSelId")))

If WorkExpSelId = "" Or IsNull(WorkExpSelId) Or Not IsNumeric(WorkExpSelId) Then WorkExpSelId = 0

If WorkExpSelId = 0 Then
	WorkExpSelName = ""
	Px = contPx
	strTitle = "添加工作经验"
	strSubmit = "添加"
Else
	Rs.Open "select * from WorkExpSelTbl where WorkExpSelId = "& WorkExpSelId , Conn , 1 , 1
	If Rs.Eof Then
		WorkExpSelId = 0
		WorkExpSelName = ""
		Px = contPx
		strTitle = "添加工作经验"
		strSubmit = "添加"
	Else
		WorkExpSelName = Rs("WorkExpSelName")
		Px = Rs("Px")
		strTitle = "修改工作经验"
		strSubmit = "修改"
	End If
End If
%>
<form name="PosForm" method="post" action="Admin_WorkExpSel.asp" style="margin:0">
	<table width="100%" border="0" cellspacing="1" cellpadding="5">
		<tr>
			<td height="25" class="td_title"><%=strTitle%></td>
		</tr>
		<tr>
			<td height="23" class="td_content">工作经验名称：
				<input name="WorkExpSelName" type="text" class="input_1" id="WorkExpSelName" size="50" value="<%=WorkExpSelName%>">
排序
<input name="Px" type="text" class="input_1" id="Px" size="20" value="<%=Px%>">			
	<input name="Submit" type="submit" class="input_1" value="<%=strSubmit%>">
	<%
	If WorkExpSelId <> 0 Then
	%>
	<input name="Submit" type="button" class="input_1" value="返回" onClick="javascript:history.back();">
	<%
	End If
	%>
	<input name="WorkExpSelId" type="hidden" id="WorkExpSelId" value="<%=WorkExpSelId%>"></td>
		</tr>
	</table>
	<br>
</form>
<%
If WorkExpSelId = 0 Then
%>
	<table width="100%" border="0" cellspacing="1" cellpadding="5">
		<tr>
			<td height="25" colspan="2" class="td_title">工作经验列表</td>
		</tr>
<%
Rs.Open Sql , Conn , 1 , 1
If Rs.Eof Then
%>
		<tr>
			<td height="23" colspan="2" class="td_content">暂无工作经验信息</td>
		</tr>
<%
Else
%>
		<tr>
<%
	i = 0
	Do While Not Rs.Eof
%>
			<td width="50%" height="23" class="td_content"><%=Rs("WorkExpSelName")%> &nbsp;&nbsp;&nbsp;[<a href="Admin_WorkExpSel.asp?action=up&WorkExpSelId=<%=Rs("WorkExpSelId")%>">前移</a> | <a href="Admin_WorkExpSel.asp?action=down&WorkExpSelId=<%=Rs("WorkExpSelId")%>">后移</a> | <a href="Admin_WorkExpSel.asp?WorkExpSelId=<%=Rs("WorkExpSelId")%>">修改</a> | <a href="#" onClick="PosDel('<%=Rs("WorkExpSelId")%>');return false;">删除</a>]</td>
<%
	Rs.MoveNext
	i = i + 1
	If i Mod 2 = 0 And Not Rs.Eof Then
		Response.Write("</tr></tr>")
	End If
	If i Mod 2 > 0 And Rs.Eof Then
		Response.Write("<td width=""50%"" class=""td_content"">&nbsp;</td>")
	End If
	Loop
%>
			
		</tr>
<%
End If
Rs.Close

Set Rs = Nothing
%>
</table>
<%
End If
%>
</body>
</html>
