<% userPageRights="{plane}" %>
<!--#include file="check.asp"-->
<!--#include file="../Include/Char.asp" -->
<%
'Define Variable 
dim i
dim rs,rs1,rst
dim mCityName,mGrade,mSql,mFlag
Set rs1=Server.CreateObject("Adodb.Recordset")
'initialization 
mFlag=true'add
if request("action")="edit" then mFlag=false

'Insert Records
if request("action")="add" then
  dim m
  mSql="Select * From Plane_ScheduledFlight"
  rs1.Open mSql,conn,1,3
  rs1.AddNew
  rs1("F_SFNumber")=Trim(Request.Form("txtSFNumber"))
  rs1("F_StartStation")=Trim(Request.Form("selStartStation"))
  rs1("F_EndStation")=Trim(Request.Form("selEndStation"))
  rs1("F_PlaneTypeID")=Trim(Request.Form("selPlaneTypeID"))
  rs1("F_Schedule")=Trim(Request.Form("txtSchedule"))
  rs1("F_TakeOffTime")=Trim(Request.Form("txtTakeOffTime"))
  rs1("F_ArriveTime")=Trim(Request.Form("txtArriveTime"))
  rs1("F_Price")=Trim(Request.Form("txtPrice"))
  rs1("F_MemberPrice")=Trim(Request.Form("txtMemberPrice"))
  rs1("F_Addtime")=Trim(Request.Form("txtAddtime"))
  rs1.Update
  rs1.close
  response.redirect "ScheduledFlightManage.asp"
end if

'modify
if Request.QueryString("action")="modify" then
  dim mModifyID
  mModifyID=Request.QueryString("rModifyID")
  mSql="Select * From Plane_ScheduledFlight Where F_ID=" & mModifyID 
  Set rs1=conn.Execute(mSql)
  mStartStation=Trim(rs1("F_StartStation"))
  mEndStation=Trim(rs1("F_EndStation"))
  mSFNumberID=Trim(rs1("F_SFNumber"))
  mPlaneTypeID=Trim(rs1("F_PlaneTypeID"))
  mSchedule=Trim(rs1("F_Schedule"))
  mTakeOffTime=Trim(rs1("F_TakeOffTime"))
  mArriveTime=Trim(rs1("F_ArriveTime"))  
  mPrice=Trim(rs1("F_Price"))       
  mMemberPrice=Trim(rs1("F_MemberPrice")) 
  mAddtime=Trim(rs1("F_AddTime"))
  mFlag=False
end if

'Modify Records
if Request.QueryString("action")="save" then
  dim mSaveID
  mSaveID=Request.QueryString("rSaveID")
  mSql="Select * From Plane_ScheduledFlight Where F_ID="&mSaveID
  rs1.open mSql,conn,1,3
  rs1("F_SFNumber")=Trim(Request.Form("txtSFNumber2"))
  rs1("F_StartStation")=Trim(Request.Form("selStartStation2"))
  rs1("F_EndStation")=Trim(Request.Form("selEndStation2"))
  rs1("F_PlaneTypeID")=Trim(Request.Form("selPlaneTypeID2"))
  rs1("F_Schedule")=Trim(Request.Form("txtSchedule2"))
  rs1("F_TakeOffTime")=Trim(Request.Form("txtTakeOffTime2"))
  rs1("F_ArriveTime")=Trim(Request.Form("txtArriveTime2"))
  rs1("F_Price")=Trim(Request.Form("txtPrice2"))
  rs1("F_MemberPrice")=Trim(Request.Form("txtMemberPrice2"))
  rs1("F_Addtime")=Trim(Request.Form("txtAddtime2"))
  rs1.Update
  rs1.Close
  Response.Redirect "ScheduledFlightManage.asp"
  flag=false
end if

'Delect Records
if request("action")="delete" then
  mSql = "DELETE FROM Plane_ScheduledFlight WHERE F_ID=" &Request.QueryString("CityID")
  conn.execute mSql
  Response.Redirect "ScheduledFlightManage.asp"
end if

%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../Files/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.txtSFNumber.value=="")
   {
    alert("航班号不能为空");
	document.form1.txtSFNumber.focus();
	return false;
   }

   	if (document.form1.txtPrice.value.length <1 || isNaN(document.form1.txtPrice.value))
	{
	alert("对不起,价格必须为数字型，且不能为空!");
	document.all.txtPrice.focus();
	return false;
	}
   	if (document.form1.txtMemberPrice.value.length <1 || isNaN(document.form1.txtMemberPrice.value))
	{
	alert("对不起,会员价格必须为数字型，且不能为空!");
	document.all.txtMemberPrice.focus();
	return false;
	}

   
}

function CheckData2(){
  if (document.form2.txtSFNumber2.value=="")
   {
    alert("航班号不能为空");
	document.form2.txtSFNumber2.focus();
	return false;
   }
   	if (document.form2.txtPrice2.value.length <1 || isNaN(document.form2.txtPrice2.value))
	{
	alert("对不起,价格必须为数字型，且不能为空!");
	document.all.txtPrice2.focus();
	return false;
	}
   	if (document.form2.txtMemberPrice2.value.length <1 || isNaN(document.form2.txtMemberPrice.value))
	{
	alert("对不起,会员价格必须为数字型，且不能为空!");
	document.all.txtMemberPrice2.focus();
	return false;
	}

   
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<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="ScheduledFlightManage.asp#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">航班号</font></b></td>
    <td width="5%" height="11"><b><font color="#FFFFFF">始发站</font></b></td>
    <td width="5%"><b><font color="#FFFFFF">终点站</font></b></td>
    <td width="6%"><b><font color="#FFFFFF">机型</font></b></td>
    <td width="6%"><b><font color="#FFFFFF">班期</font></b></td>
    <td width="6%"><b><font color="#FFFFFF">起飞时间</font></b></td>
    <td width="6%"><b><font color="#FFFFFF">到达时间</font></b></td>
    <td width="6%"><b><font color="#FFFFFF">价格</font></b></td>
    <td height="11" width="8%"><b><font color="#FFFFFF">管理</font></b></td>
  </tr>
</table>
<% 
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=20  
	mSql="Select * From Plane_ScheduledFlight order by F_Addtime Desc"
	rs.open mSql,conn,1,1
	if rs.eof then
	   response.write "<p align=center><font color=red><B> 暂无数据！</B></font></p>"
    	  'response.end
    else
	
    rs.pagesize=pmcount
    mpage=rs.pagecount
    if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then
        pageno=1
    end if
   rs.absolutepage=pageno
 Dim rc,re
 rc=rs.pagesize
 re=1
 do while not rs.eof and rc>0
%>
<table width="96%" border="0" cellspacing="1" cellpadding="1" align="center">
  <tr bgcolor="f2f2f2"> 
    <td height="2" width="6%" align="center"><%=rs("F_SFNumber")%></td>
    <td width="5%" align="center" bgcolor="f2f2f2">
	<%
	mSql="Select F_CityName From Plane_CityType Where F_ID="&rs("F_StartStation")
	Set rs1=conn.Execute(mSql)
	if Not rs1.Eof then Response.write rs1(0)
	rs1.Close	
	%>
	</td>
    <td width="5%" align="center" bgcolor="f2f2f2">
	<%
	 mSql="Select F_CityName From Plane_CityType Where F_ID="&rs("F_EndStation")
	 Set rs1=conn.Execute(mSql)
	 if Not rs1.Eof then Response.write rs1(0)
	 rs1.Close
	%></td>
    <td width="6%" align="center" bgcolor="f2f2f2">
	<%
    mSql="Select F_PlaneName From Plane_PlaneType Where F_ID="&rs("F_PlaneTypeID")
	Set rs1=conn.Execute(mSql)
	if Not rs1.Eof then Response.write rs1(0)
	rs1.Close
	%> </td>
    <td width="6%" align="center" bgcolor="f2f2f2"><%=rs("F_Schedule")%></td>
    <td width="6%" align="center" bgcolor="f2f2f2"><%=rs("F_TakeOffTime")%></td>
    <td width="6%" align="center" bgcolor="f2f2f2"><%=rs("F_ArriveTime")%></td>
    <td width="6%" align="center" bgcolor="f2f2f2"><%=rs("F_Price")%>/<font color="#FF0000"><%=rs("F_MemberPrice")%></font></td>
    <td height="2" width="8%" align="center"> <a href="javascript:jDelete('ScheduledFlightManage.asp?CityID=<%=rs("F_ID")%>&Page=<%=cstr(pageno)%>')">删除</a> 
      | <a href='ScheduledFlightManage.asp?action=modify&rModifyID=<%=rs("F_ID")%>&Page=<%=cstr(pageno)%>#edit'>编辑</a> 
    </td>
  </tr>
</table>
<%
 rs.movenext
 re=re+1
 rc=rc-1
 loop

%>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f6f6f6">
  <tr> 
    <td width="35%" height="22">[共<font color=red><%=rs.recordcount %></font>条记录 
      当前第<font color=red><%=pageno %></font>页/共<font color=red><%=mpage %></font>页] 
    </td>
    <td width="65%" align="right"> 
      <%if pageno>1 then
   response.write "<a href='ScheduledFlightManage.asp'>[首 页]</a>"
  else
   response.write "[首 页]"
  end if
%>
      <%if pageno>1 then
   response.write "<a href='ScheduledFlightManage.asp?pageno="&pageno-1&"'>[上一页]</a>"
  else
   response.write "[上一页]"
  end if
%>
      [ 
      <%
add=5'数字分页个数+1
if pageno-int(add/2)<=1 then m=1 else m=pageno-int(add/2)
if m+add>mpage then 
   n=mpage
   if mpage-add<=1 then m=1 else m=mpage-add
 else
   n=m+add
end if
for pno=m to n
 if pno=cint(pageno) then
  response.write "&nbsp;<font color=red>"&pno&"</font>"
 else

   response.write "<b>&nbsp;<a href='ScheduledFlightManage.asp?pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"
%>
      ] 
      <%
 if int(pageno) < int(rs.pagecount) then
   response.write "<a href='ScheduledFlightManage.asp?pageno="&pageno+1&"'>[下一页]</a>"
 else 
   response.write "[下一页]"
 end if
%>
      <%if int(pageno) < int(rs.pagecount) then
   response.write "<a href='ScheduledFlightManage.asp?pageno="&mpage&"'>[末 页]</a>"
  else
   response.write "[末 页]"
  end if
%>
    </td>
  </tr>
</table> 
<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="ScheduledFlightManage.asp?action=add" onSubmit="return CheckData()">
      <td> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="212">
          <tr> 
            <td height="14"><b>功能：[添加记录]</b></td>
          </tr>
          <tr>
            <td height="7">航 班 号： 
              <input name="txtSFNumber" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              <br>
              始 发 站： 
              <SELECT name=selStartStation style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
                <%
						mSql="Select * From Plane_CityType order By F_Grade"
						Set rs=conn.Execute(mSql)
						Do While Not rs.Eof
						  Response.write  "<OPTION value=" & rs("F_ID") & ">" & rs("F_CityName") & "</OPTION>"
						  rs.MoveNext
						Loop
						rs.Close
						%>
              </SELECT>
              <br>
              终 点 站： 
              <select name=selEndStation style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
                <%
						mSql="Select * From Plane_CityType order By F_Grade"
						Set rs=conn.Execute(mSql)
						Do While Not rs.Eof
						  Response.write  "<OPTION value=" & rs("F_ID") & ">" & rs("F_CityName") & "</OPTION>"
						  rs.MoveNext
						Loop
						rs.Close
						%>
              </select> <br>
              机　　型： 
              <SELECT name=selPlaneTypeID style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
                <%
						mSql="Select * From Plane_PlaneType order By F_Grade"
						Set rs=conn.Execute(mSql)
						Do While Not rs.Eof
						  Response.write  "<OPTION value=" & rs("F_ID") & ">" & rs("F_PlaneName") & "</OPTION>"
						  rs.MoveNext
						Loop
						rs.Close
						%>
              </SELECT>
              <br>
              班　　期： 
              <input name="txtSchedule" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              1234567<br>
              起飞时间：
<input name="txtTakeOffTime" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              <br>
              到达时间： 
              <input name="txtArriveTime" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              <br>
              原 价 格： 
              <input name="txtPrice" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              <br>
              会 员 价： 
              <input name="txtMemberPrice" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
              <br>
              发出日期： 
              <input name="txtAddtime" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=now%>"></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="ScheduledFlightManage.asp?action=save&rSaveID=<%=request("rModifyID")%>" 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="txtSFNumber2" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=mSFNumberID%>">
              <br>
              始 发 站： 
              <SELECT name=selStartStation2 style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
                <%
						mSql="Select * From Plane_CityType order By F_Grade"
						Set rs=conn.Execute(mSql)
						Do While Not rs.Eof
						  if mStartStation=Trim(rs("F_ID")) then
						     Response.write  "<OPTION selected value=" & rs("F_ID") & ">" & rs("F_CityName") & "</OPTION>"
						  else
						     Response.write  "<OPTION value=" & rs("F_ID") & ">" & rs("F_CityName") & "</OPTION>"
						  end if   
						  rs.MoveNext
						Loop
						rs.Close
						%>
              </SELECT> <br>
              终 点 站： 
              <select name=selEndStation2 style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
                <%
					
						mSql="Select * From Plane_CityType order By F_Grade"
						Set rs=conn.Execute(mSql)
						Do While Not rs.Eof
						  if Trim(mEndStation)=Trim(rs("F_ID")) then
						     Response.write  "<OPTION selected Value=" & rs("F_ID") & ">" & rs("F_CityName") & "</OPTION>"
						   else
						     Response.write  "<OPTION value=" & rs("F_ID") & ">" & rs("F_CityName") & "</OPTION>"
						   end if   
						   rs.MoveNext
						Loop
						rs.Close
						%>
              </select> <br>
              机　　型： 
              <SELECT name=selPlaneTypeID2 style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff">
                <%
						mSql="Select * From Plane_PlaneType order By F_Grade"
						Set rs=conn.Execute(mSql)
						Do While Not rs.Eof
						  if mStartStation=Trim(rs("F_ID")) then
						     Response.write  "<OPTION selected value=" & rs("F_ID") & ">" & rs("F_PlaneName") & "</OPTION>"
						  else
						     Response.write  "<OPTION value=" & rs("F_ID") & ">" & rs("F_PlaneName") & "</OPTION>"
						  end if   
						  rs.MoveNext
						Loop
						rs.Close
				
						%>
              </SELECT> <br>
              班　　期： 
              <input name="txtSchedule2" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=mSchedule%>">
              一二三四五<br>
              起飞时间： 
              <input name="txtTakeOffTime2" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=mTakeOffTime%>"> 
              <br>
              到达时间： 
              <input name="txtArriveTime2" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=mArriveTime%>"> 
              <br>
              原 价 格： 
              <input name="txtPrice2" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=mPrice%>"> 
              <br>
              会 员 价： 
              <input name="txtMemberPrice2" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=mMemberPrice%>"> 
              <br>
              发出日期： 
              <input name="txtAddtime2" type="text" style="width:145;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff" value="<%=now%>"> 
            </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>
