Пример #1
0
 private void FindTrain_BUTTON_Click(object sender, RoutedEventArgs e)
 {
     if ((Arrival_BOX.Text != "") && (Departure_BOX.Text != "") && (Departure_BOX.Text != ""))
     {
         try
         {
             if (Arrival_BOX.Text != Departure_BOX.Text)
             {
                 ApplicationLogic AL    = new ApplicationLogic();
                 string[]         Data  = { Arrival_BOX.Text, Departure_BOX.Text, Arrival_Date.Text };
                 List <string>    Routs = AL.CatchStringListResult(Connected, "call FindRout", Data);
                 if (Routs.Count > 0)
                 {
                     List <string> TrainsList = new List <string>();
                     for (int i = 0; i < Routs.Count; i++)
                     {
                         string[] args       = { Routs[i], Arrival_BOX.Text, Arrival_Date.Text, Departure_BOX.Text };
                         var      TMPInputer = AL.CatchStringListResult(Connected, "call newFindTrainList", args);
                         for (int j = 0; j < TMPInputer.Count; j++)
                         {
                             if (TMPInputer[j] != "-1")
                             {
                                 TrainsList.Add(TMPInputer[j]);
                             }
                         }
                     }
                     if (TrainsList.Count > 0)
                     {
                         ReservationControl RCN = new ReservationControl();
                         RCN = new ReservationControl();
                         RCN.SetConnection = Connected;
                         RCN.SetArrival    = Arrival_BOX.Text;
                         RCN.SetDeparture  = Departure_BOX.Text;
                         RCN.SetDate       = Arrival_Date.Text;
                         RCN.SetRouts      = Routs;
                         RCN.SetTrainsList = TrainsList;
                         RCN.SetMenu       = this;
                         PerfectReflectionGRID.Children.Add(RCN);
                         Reflector.IsEnabled = false;
                     }
                     else
                     {
                         throw new System.Exception();
                     }
                 }
                 else
                 {
                     throw new System.Exception();
                 }
             }
             else
             {
                 throw new System.Exception();
             }
         }
         catch (System.Exception)
         {
             AL.MessageShow("К сожалению, поездов по нужному Вам маршруту в данное время нет. Попробуйте выбрать другой день", "=(");
         }
     }
     else
     {
         AL.MessageErrorShow("Вы не заполнили данные", "Ошибка");
     }
 }