private void choiceItemTap(object sender, System.Windows.Input.GestureEventArgs e) { TextChoiceTip.Visibility = Visibility.Collapsed; popChoiceLine.Visibility = Visibility.Collapsed; int xid = Convert.ToInt32(((TextBlock)sender).Tag.ToString()); NingboBus busDB = App.busDB; var lineList = (from s in busDB.Cnbusw where s.Id == xid select s ).ToList(); App.lineInfo = lineList[0]; //查找该路线经过的站牌 var stationList = (from s in busDB.Cnbus where s.Xid == xid where s.Kind == 1 orderby s.Pm select s).ToList(); App.stationList = stationList; NavigationService.Navigate(new Uri("/ViewResult/LineDetail.xaml", UriKind.Relative)); }
//线路查询 private void buttonFindLine_Click(object sender, RoutedEventArgs e) { TextChoiceTip.Visibility = Visibility.Collapsed; int num; try { num = Convert.ToInt32(textLineNum.Text); } catch (FormatException ex) { MessageBox.Show("请输入数字线路名"); return; } NingboBus busDB = App.busDB; //查找该路线信息 var lineList = (from s in busDB.Cnbusw where s.Shuzi == num select s ).ToList(); if (lineList.Count == 0) { MessageBox.Show("找不到该线路。"); return; } if (lineList.Count > 1) { popChoiceLine.ItemsSource = lineList; popChoiceLine.Visibility = Visibility.Visible; TextChoiceTip.Visibility = Visibility.Visible; return; } App.lineInfo = lineList[0]; int xid = (int)lineList[0].Id; //查找该路线经过的站牌 var stationList = (from s in busDB.Cnbus where s.Xid == xid where s.Kind == 1 orderby s.Pm select s).ToList(); App.stationList = stationList; NavigationService.Navigate(new Uri("/ViewResult/LineDetail.xaml", UriKind.Relative)); }
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 Button_Click(object sender, RoutedEventArgs e) { Button item = (Button)sender; int lineNum = Convert.ToInt32(item.Tag.ToString()); NingboBus busDB = App.busDB; var stationList = (from s in busDB.Cnbus where s.Xid == lineNum where s.Kind == 1 orderby s.Pm select s).ToList(); var lineInfo = (from s in busDB.Cnbusw where s.Id == lineNum select s ).ToList()[0]; App.stationList = stationList; App.lineInfo = lineInfo; NavigationService.Navigate(new Uri("/ViewResult/LineDetail.xaml", UriKind.Relative)); }