<!--#include file="../include/Conn.jsp"-->
<!--#include file="../Include/Char.jsp" -->
<!--#include file="Admin_IsLogin.jsp" -->
<%
'Define Variable 
dim i
dim rs,rst
dim mSFNumberName,mGrade,mSql,mFlag
'initialization 
mFlag=true'add
if request("action")="edit" then mFlag=false

'Insert Records
if request("action")="add" then
  mSFNumberName=Trim(server.htmlencode(request("txtSFNumberName")))
  if Trim(Request.QueryString("grade"))="" then mGrade=1 else mGrade=Cint(Request.QueryString("grade"))
  mSql="insert into Plane_SFNumberType(F_SFNumberName,F_Grade)values('"&mSFNumberName&"',"&mGrade&")"
  conn.execute(mSql)
  response.redirect "SFNumberTypeManage.jsp"
end if

'Modify Records
if request("action")="editsave" then
  mSFNumberName=Trim(server.htmlencode(request.form("txtSFNumberName2")))
  mSql="update Plane_SFNumberType set F_SFNumberName='" & mSFNumberName &"' where F_ID="&request.querystring("SFNumberID")
  conn.execute(mSql)
  response.redirect "SFNumberTypeManage.jsp"
  flag=false
end if

'Delect Records
if request("action")="delete" then
  mSql = "DELETE FROM Plane_SFNumberType WHERE F_ID=" &Request.QueryString("SFNumberID")
  conn.execute mSql
  Response.Redirect "SFNumberTypeManage.jsp"
end if

'Sort Grade Up
If Request.QueryString("action")="up" then
   mSql="update Plane_SFNumberType set F_Grade=F_Grade-1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update Plane_SFNumberType set F_Grade=F_Grade+1 where F_Grade="&cint(request.querystring("grade"))-1&" and F_ID<>"&Request.QueryString("F_ID")
   conn.execute(mSql)
   Response.Redirect "SFNumberTypeManage.jsp"
 End if

'Sort Grade Down
If Request.QueryString("action")="down" then
   mSql="update Plane_SFNumberType set F_Grade=F_Grade+1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update Plane_SFNumberType set F_Grade=F_Grade-1 where F_Grade="&cint(request.querystring("grade"))+1&" and F_ID<>"&Request.QueryString("F_ID")
   conn.execute(mSql)
   Response.Redirect "SFNumberTypeManage.jsp"
 End if
%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../include/Style.css" rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&action=delete';
}
</SCRIPT>
<script language="javascript">
function CheckData(){
  if (document.form1.txtSFNumberName.value=="")
   {
    alert("名称不能为空");
	document.form1.txtSFNumberName.focus();
	return false;
   }
}

function CheckData2(){
  if (document.form2.txtSFNumberName2.value=="")
   {
    alert("名称不能为空");
	document.form2.txtSFNumberName2.focus();
	return false;
   }
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
 <center>
   <%
      admin_flag="53"
      if instr(session("flag"),admin_flag)=0 or isnull(session("flag"))=true then
         Response.write "<br><br><br><br><b><font color=red>对不起，您没有管理本页面的权限!</font></B>"
		 Response.end
	  end if
    %>
 </center>
<br>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="44%"><b>功能：[航班号管理]</b></td>
    <td width="81%" align="right"><a href="SFNumberTypeManage.jsp#input">→添加记录</a></td>
  </tr>
</table>
<table width="96%" border="0" cellspacing="1" cellpadding="1" align="center">
  <tr bgcolor="#CCCCCC" align="center"> 
    <td height="11" width="6%"><b><font color="#FFFFFF">ID</font></b></td>
    <td width="6%" height="11"><b><font color="#FFFFFF">新序</font></b></td>
    <td width="11%"><b><font color="#FFFFFF">航班号名称</font></b></td>
    <td width="12%"><b><font color="#FFFFFF">排序</font></b></td>
    <td height="11" width="14%"><b><font color="#FFFFFF">管理</font></b></td>
  </tr>
</table>
<%  
    set rs=server.createobject("ADODB.recordset")
    mSql="select * from Plane_SFNumberType order by F_Grade"
    rs.open mSql,conn,1,1
	if rs.eof then
      response.write "<p align=center><font color=red><B> 暂无记录！</B></font></p>"
    else
      for i=1 to rs.recordcount 
%>
<table width="96%" border="0" cellspacing="1" cellpadding="1" align="center">
  <tr bgcolor="f2f2f2"> 
    <td height="2" width="6%" align="center"><%=rs("F_ID")%></td>
    <td width="6%" height="2" align="center" bgcolor="f2f2f2"><%=i%> </td>
    <td width="11%" align="center" bgcolor="f2f2f2"><%=rs("F_SFNumberName")%></td>
    <td width="12%" align="center" bgcolor="f2f2f2"> 
      <%
	 if i=1 then 
	    Response.write "拉上"
	  else
		Response.write "<a href='SFNumberTypeManage.jsp?action=up&F_ID="&rs("F_ID")&"&grade="&i&"'>拉上</a>"
      end if
	  Response.write "|"
	  if i=rs.recordcount then 
	    response.write "拉下"
	  else
		response.write "<a href='SFNumberTypeManage.jsp?action=down&F_ID="&rs("F_ID")&"&grade="&i&"'>拉下</a>"
      end if
	%>
    </td>
    <td height="2" width="14%" align="center"> 
	<a href="javascript:jDelete('SFNumberTypeManage.jsp?SFNumberID=<%=rs("F_ID")%>&Page=<%=cstr(pageno)%>')">删除</a> 
      | <a href='SFNumberTypeManage.jsp?action=edit&SFNumberName=<%=rs("F_SFNumberName")%>&SFNumberID=<%=rs("F_ID")%>&Page=<%=cstr(pageno)%>#edit'>编辑</a> 
    </td>
  </tr>
</table>
 <%
  rs.movenext
  Next 
 %>
<hr size="1" width="96%"><br>
<%
 end if
 if mFlag=true then'add
%>
<a name="input"></a>
<table width="96%" border="0" cellspacing="0" cellpadding="0" align="center" height="54">
  <tr> 
    <form name="form1" method="post" action="SFNumberTypeManage.jsp?action=add&grade=<%=i%>" onSubmit="return CheckData()">
      <td> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="32">
          <tr> 
            <td height="6"><b>功能：[添加记录]</b></td>
          </tr>
          <tr>
            <td height="7">航班号名称： 
              <input name="txtSFNumberName" type="text" id="txtSFNumberName" style="width:300;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="" size="54" maxlength="20">
              <br>
            </td>
          </tr>
          <tr> 
            <td height="33"> 
              <input type="submit" value="提交信息" name="B3" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              &nbsp; 
              <input type="reset" value="从新来过" name="B3" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
            </td>
          </tr>
        </table>
      </td>
    </form>
  </tr>
</table>
<%else%>
<a name="edit"></a>
<table width="96%" border="0" cellspacing="0" cellpadding="0" align="center" height="54">
  <tr> 
    <form name="form2" method="post" action="SFNumberTypeManage.jsp?action=editsave&SFNumberID=<%=request("SFNumberID")%>" onSubmit="return CheckData2()">
      <td> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="32">
          <tr> 
            <td height="6"><b>功能：[修改记录]</b></td>
          </tr>
          <tr>
            <td height="7">航班号名称： 
              <input name="txtSFNumberName2" type="text" id="txtSFNumberName2" style="width:300;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=request("SFNumberName")%>" size="54" maxlength="20">
              <br>
            </td>
          </tr>
          <tr> 
            <td height="35"> 
              <input type="submit" value="提交信息" name="B32" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              &nbsp; 
              <input type="reset" value="从新来过" name="B32" style="width:80;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
            </td>
          </tr>
        </table>
      </td>
    </form>
  </tr>
</table>
<%end if%>
</body>
</html>
