private void SearchLine(object sender, DoWorkEventArgs e) { FromToInfo arg = (FromToInfo)e.Argument; string strFrom = arg.from; string strTo = arg.to; NingboBus busDB = App.busDB; //终点站xid var xidInFrom = (from d in busDB.Cnbus where d.Zhan == strFrom select d.Xid).ToList(); if (xidInFrom.Count == 0) { e.Result = 1; //msg="对不起,未找到该起点站信息"; return; } var xidInTo = (from d in busDB.Cnbus where d.Zhan == strTo select d.Xid).ToList(); if (xidInTo.Count == 0) { e.Result = 2; //msg="对不起,未找到该终点站信息"; return; } //包含起点和重点站点路线id var idList = (from s in busDB.Cnbus where xidInTo.Contains(s.Xid) where xidInFrom.Contains(s.Xid) select s.Xid).ToList(); if (idList.Count == 0) { e.Result = 3; //msg = "对不起,未找到直达线路"; return; } //根据路线id查找路线信息 var lineList = (from s in busDB.Cnbusw where idList.Contains(s.Id) select s).ToList(); App.lineList = lineList; App.stationFrom = strFrom; App.stationTo = strTo; e.Result = 0; }
//站站查询 private void stationSearchButton_Click(object sender, RoutedEventArgs e) { stationSearchButton.Content = "正在搜索"; stationSearchButton.IsEnabled = false; progressBar1.Visibility = Visibility.Visible; bw = new BackgroundWorker(); bw.WorkerSupportsCancellation = false; bw.WorkerReportsProgress = false; bw.DoWork += new DoWorkEventHandler(SearchLine); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(SearchLineComplete); string strFrom = staionFromText.Text; string strTo = staionToText.Text; FromToInfo arg = new FromToInfo() { from = strFrom, to = strTo }; bw.RunWorkerAsync(arg); //return; //if (SearchLine(stationFrom, stationTo)) //{ // stationSearchButton.Content = "查找"; // stationSearchButton.IsEnabled = true; // //progressBar1.Visibility = Visibility.Collapsed; // //NavigationService.Navigate(new Uri("/ViewResult/LineResult.xaml", UriKind.Relative)); //} //else //{ // stationSearchButton.Content = "查找"; // stationSearchButton.IsEnabled = true; // progressBar1.Visibility = Visibility.Collapsed; //} }
//站站查询 private void stationSearchButton_Click(object sender, RoutedEventArgs e) { stationSearchButton.Content = "正在搜索"; stationSearchButton.IsEnabled = false; progressBar1.Visibility = Visibility.Visible; bw = new BackgroundWorker(); bw.WorkerSupportsCancellation = false; bw.WorkerReportsProgress = false; bw.DoWork += new DoWorkEventHandler(SearchLine); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(SearchLineComplete); string strFrom = staionFromText.Text; string strTo = staionToText.Text; FromToInfo arg = new FromToInfo() { from=strFrom,to=strTo}; bw.RunWorkerAsync(arg); //return; //if (SearchLine(stationFrom, stationTo)) //{ // stationSearchButton.Content = "查找"; // stationSearchButton.IsEnabled = true; // //progressBar1.Visibility = Visibility.Collapsed; // //NavigationService.Navigate(new Uri("/ViewResult/LineResult.xaml", UriKind.Relative)); //} //else //{ // stationSearchButton.Content = "查找"; // stationSearchButton.IsEnabled = true; // progressBar1.Visibility = Visibility.Collapsed; //} }