<%@ Page Language="C#"%>
<%@ Import Namespace="System.Net"%>
<%@ Import Namespace="System.IO"%><script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
  if(Request.Form["Train_Start"]!=null)
{
   string tStart=Request.Form["Train_Start"];
string tEnd=Request.Form["Train_End"];
  HttpWebRequest oRequest = (HttpWebRequest)WebRequest.Create("http://www.xa-rail.com.cn/chaxun/query/Passenger.asp");  oRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";  string strPost="Train_Start="+tStart+"&Train_End="+tEnd; 
   byte[] somebyte=Encoding.Default.GetBytes(strPost); 
   oRequest.Method = "POST";
   oRequest.ContentLength =somebyte.Length;
      
   
   //strPost.Length;
   oRequest.ContentType = "application/x-www-form-urlencoded";   StreamWriter oStreamWriter= new StreamWriter(oRequest.GetRequestStream(),System.Text.Encoding.GetEncoding("GB2312"));
   oStreamWriter.Write(strPost);
   oStreamWriter.Close();
   HttpWebResponse oResponse  = (HttpWebResponse)oRequest.GetResponse();
  
   StreamReader sr = new StreamReader(oResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
   string sResultContents = sr.ReadToEnd();
int start,stop;
start=sResultContents.IndexOf("<table");//截取掉版权信息
if(start!=-1)
{
stop=sResultContents.IndexOf("</table>",start)+8;
string temp = sResultContents.Substring(start, stop - start);
StringBuilder sb=new StringBuilder(temp);
start=temp.IndexOf("<td width="+ '"'+"15"+'"'+" align="+'"'+"center"+'"'+ " height="+'"'+"17"+'"'+ " bgcolor="+'"'+"#FFC86A"+'"'+">");
stop=temp.IndexOf("</td>",start)+5;
sb.Remove(start,stop-start);
temp=sb.ToString();
string lastLine="<td width="+ '"'+"97"+'"'+" align="+'"'+"center"+'"'+ " height="+'"'+"21"+'"'+">";
start=temp.IndexOf(lastLine);
stop=temp.IndexOf("</td>",start)+5;
sb.Remove(start,stop-start);
temp=sb.ToString();
int[,] points=new int[100,2];
start=stop=0;//初始化   
for(int i=0;start!=-1;i++)
{
for(int j=0;j<2;j++)
{
if(j==0)
{
start=temp.IndexOf(lastLine);
points[i,j]=start;
if(points[i,j]==-1)
{
break;
}
}else if(j==1)
{
stop=temp.IndexOf("</td>",start)+5;
points[i,j]=stop;
}
}//end j
if(start!=-1)
{
sb.Remove(start,stop-start);
temp=sb.ToString();
}
}//end for
sb.Replace("#FFC86A","#27B4F8");
sb.Replace("fff8e9","ffffff");
     Response.Write(sb);
     sr.Close();
     oResponse.Close();
    }else
{
Response.Write("没有查到你要查找的内容");
     }
 }
}   
</script>
<div align="center"><img src="go_1.gif" width="20" height="12" align="absmiddle"><strong><font color="#FF0000" size="2"><a href="http://www.cwestc.com/trainTime2/add.aspx">按经停站查询点击这里</a></font></strong> 
</div>
<form runat="server">
  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>  <FONT color=#000000 
size=3>            起始站:</FONT> <FONT color=#000000> 
  <INPUT name=Train_Start> <BR>
  <FONT 
size=3>            到达站:</FONT></FONT> 
  <input name=Train_End>
  <INPUT type=submit value="确 定" name=B1> <INPUT type=reset value="取 消" name=B2></td>
    </tr>
  </table>
 
</form> 
<div align="center"><font size="2"> 版权所有:<a href="http://www.cwestc.com">中国西部煤炭网</a></font><br/>
  <font size="2">建议使用 IE 或 NETSCAPE 4.0以上版本进行浏览,最佳显示800*600<br/>
  </font> <br/>
</div>