public MainWindow() { InitializeComponent(); _client = HttpClient.BeginSession("12306"); //if (_client.Restore()) //{ // new _12306Proxy(_client).T(); //} _ctlListForm.ItemsSource = Cities.Data; _ctlListTo.ItemsSource = Cities.Data; _ctlListPassenger.ItemsSource = Passengers.Data; _ctlListTrainType.ItemsSource = Trains.Types; LoginWindow window = new LoginWindow(_client); if (window.ShowDialog() == true) { _randCode = window.LoginModel.RandCode; _client.Store(); button1.IsEnabled = false; } else { button1.IsEnabled = true; } }
private void button1_Click(object sender, RoutedEventArgs e) { LoginWindow window = new LoginWindow(_client); if (window.ShowDialog() == true) { _randCode = window.LoginModel.RandCode; _client.Store(); } }
void AutoOrderWindow_Loaded(object sender, RoutedEventArgs e) { LoginWindow window = new LoginWindow(_client); if (window.ShowDialog() == true) { _client.Store(); //button1.IsEnabled = false; } else { Close(); return; } _12306Proxy proxy = new _12306Proxy(_client); //_ctlListPassenger.ItemsSource = proxy.GetOfflinePassengers(); _ctlListPassenger.ItemsSource = proxy.GetPassengers(); _ctlListTrain.ItemsSource = proxy.GetOfflineTrains(); List<SeatModel> seats = new List<SeatModel>(); #region 软卧 SeatModel seatRWTop = new SeatModel(); seatRWTop.caption = "软卧-上铺"; seatRWTop.seat = "4"; seatRWTop.seat_detail = "0"; seatRWTop.seat_detail_select = "3"; seats.Add(seatRWTop); SeatModel seatRWMiddle = new SeatModel(); seatRWMiddle.caption = "软卧-中铺"; seatRWMiddle.seat = "4"; seatRWMiddle.seat_detail = "0"; seatRWMiddle.seat_detail_select = "2"; seats.Add(seatRWMiddle); SeatModel seatRWBottom = new SeatModel(); seatRWBottom.caption = "软卧-下铺"; seatRWBottom.seat = "4"; seatRWBottom.seat_detail = "0"; seatRWBottom.seat_detail_select = "1"; seats.Add(seatRWBottom); #endregion #region 硬卧 SeatModel seatYWTop = new SeatModel(); seatYWTop.caption = "硬卧-上铺"; seatYWTop.seat = "3"; seatYWTop.seat_detail = "0"; seatYWTop.seat_detail_select = "3"; seats.Add(seatYWTop); SeatModel seatYWMiddle = new SeatModel(); seatYWMiddle.caption = "硬卧-中铺"; seatYWMiddle.seat = "3"; seatYWMiddle.seat_detail = "0"; seatYWMiddle.seat_detail_select = "2"; seats.Add(seatYWMiddle); SeatModel seatYWBottom = new SeatModel(); seatYWBottom.caption = "硬卧-下铺"; seatYWBottom.seat = "3"; seatYWBottom.seat_detail = "0"; seatYWBottom.seat_detail_select = "1"; seats.Add(seatYWBottom); #endregion SeatModel seatYZ = new SeatModel(); seatYZ.caption = "硬座"; seatYZ.seat = "1"; seatYZ.seat_detail = "0"; seatYZ.seat_detail_select = "0"; seats.Add(seatYZ); _ctlListSeat.ItemsSource = seats; DateTime limitDate = new DateTime(2013,1,7); for (int index = 0; index < 20 && DateTime.Now.Date.AddDays(index) < limitDate; index++) { Button btn = new Button(); btn.Width = 100; btn.Height = 14; btn.Margin = new Thickness(5,3,0,0); StackPanel sp = new StackPanel(); btn.Content = sp; TextBlock t1 = new TextBlock(); t1.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; t1.FontSize = 10; t1.Text = string.Format("{0}", DateTime.Now.AddDays(index).ToString("yyyy年MM月dd日")); TextBlock t2 = new TextBlock(); t2.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; t2.Text = GetDayCountString(index); sp.Children.Add(t1); sp.Children.Add(t2); btn.Tag = index; btn.Click += new RoutedEventHandler(btn_Click); _ctlWrapPanel.Children.Add(btn); } }