コード例 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     int Number = Convert.ToInt32(this.numberTrain.Text);
      Train entTrn = Train.Search(Number);
      string Time1Arr = timeArrInit.Text;
      string Time1Dep = timeDepInit.Text;
      string Time2Arr = timeArrTerm.Text;
      string Time2Dep = timeDepTerm.Text;
      Station Stn1 = Station.SearchByName(Convert.ToString(initialStation.Text));
      Station Stn2 = Station.SearchByName(Convert.ToString(terminalStation.Text));
      if (entTrn == null)
      {
         Train Trn = new Train(Number);
         RouteNode  RN1 = new RouteNode(Stn1, Time1Arr, Time1Dep, Trn);
         RouteNode  RN2 = new RouteNode(Stn2, Time2Arr, Time2Dep, Trn);
         Trn.AddRouteNode(RN1);
         Trn.AddRouteNode(RN2);
      }
      else
      {
          Station    Stn = Station.SearchByName(Convert.ToString(wayStation.Text));
          string timeArr = timeArrWayS.Text;
          string timeDep = timeDepWays.Text;
          RouteNode  RN  = new RouteNode(Stn, timeArr, timeDep, entTrn);
          entTrn.AddRouteNode(RN);
      }
      FormEditTrains_Activated(sender, e);
      //textBox1_TextChanged(sender, e);
     textBox1_TextChanged(sender, e);
     add.Enabled = ConditionForEdit();
 }
コード例 #2
0
        /// <summary>
        /// Создает XML-элемент "Passengers" с пассажирами, которые едут в данном поезде.
        /// </summary>
        /// <param name="xmlOut"></param>
        /// <param name="train"></param>
        public static void SavePassengersToFile(XmlTextWriter xmlOut, Train train)
        {
            xmlOut.WriteStartElement("Passengers");

            List<Ticket> tickets = train.Tickets;
            foreach(Ticket ticket in tickets)
            {
                ticket.Passenger.SaveToFile(xmlOut, train);
            }

            xmlOut.WriteEndElement();
        }
コード例 #3
0
        /// <summary>
        /// Создает XML-элемент "Passenger" с данными о пасажире в нужном формате.
        /// </summary>
        /// <param name="xmlOut"></param>
        /// <param name="train"></param>
        public void SaveToFile(XmlWriter xmlOut, Train train)
        {
            xmlOut.WriteStartElement("Passenger");
            
            Ticket ticket = this.SearchTicketByTrain(train);

            xmlOut.WriteElementString("ID",             this.ID.ToString());
            xmlOut.WriteElementString("LName",          this.LastName);
            xmlOut.WriteElementString("FName",          this.FirstName);
            xmlOut.WriteElementString("TypeOfTicket",   ticket.Type);

            xmlOut.WriteEndElement();
        }
コード例 #4
0
ファイル: ClassData.cs プロジェクト: DrewYak/ProjectTrains
        /// <summary>
        /// Добавляет данные о пассажирах в программу и устанавливает связь 
        /// между поездами и пассажирами.
        /// </summary>
        /// <param name="Train">Поезд, в который добавляюся пассажиры из списка узлов.</param>
        /// <param name="Passengers">Список узлов типа Passenger.</param>
        private static void LoadPassengers(Train Train, XmlNodeList Passengers)
        {
            foreach(XmlNode Psg in Passengers)
            {
                int         ID              = Convert.ToInt32(Psg.ChildNodes[0].InnerText);
                Passenger   PAS             = Passenger.Search(ID);
                string      TypeOfTicket    = Psg.ChildNodes[3].InnerText;

                if (PAS != null)
                {
                    Ticket  Ticket  = new Ticket(Train, TypeOfTicket, PAS);
                }
                else
                {
                    string  LName   = Psg.ChildNodes[1].InnerText;
                    string  FName   = Psg.ChildNodes[2].InnerText;
                    PAS             = new Passenger(ID, FName, LName);
                    Ticket  Ticket  = new Ticket(Train, TypeOfTicket, PAS);
                }
            }
        }
コード例 #5
0
 private void FillResultForm(TrnResultByNumber ResultForm, Train Trn)
 {
     ResultForm.Owner                    = this;
     ResultForm.Number           .Text   = Trn.Number.ToString();
     ResultForm.PointOfDeparture .Text   = Trn.PointOfDeparture;
     ResultForm.TimeOfDeparture  .Text   = Trn.TimeOfDeparture;
     ResultForm.PointOfArrival   .Text   = Trn.PointOfArrival;
     ResultForm.TimeOfArrival    .Text   = Trn.TimeOfArrival;
 }
コード例 #6
0
ファイル: FormVisual.cs プロジェクト: DrewYak/ProjectTrains
 /// <summary>
 /// Рисует поезд.
 /// </summary>
 /// <param name="train"></param>
 /// <param name="g"></param>
 private void DrawTrain(Train train, Graphics g)
 {
     PointF p = train.Location(time);
     g.DrawEllipse(penTrain,     p.X + radiusStation - radiusTrain, p.Y + radiusStation - radiusTrain, radiusTrain * 2, radiusTrain * 2);
     g.FillEllipse(brushTrain,   p.X + radiusStation - radiusTrain, p.Y + radiusStation - radiusTrain, radiusTrain * 2, radiusTrain * 2);
 }
コード例 #7
0
ファイル: ClassData.cs プロジェクト: DrewYak/ProjectTrains
        /// <summary>
        /// Добавляет данные о поездах в оперативную память.
        /// </summary>
        /// <param name="Trains">Список узлов типа Train.</param>
        private static void LoadTrains(XmlNodeList Trains)
        {
            foreach(XmlNode Trn in Trains)
            {
                int         Number      = Convert.ToInt32(Trn.ChildNodes[0].InnerText);
                XmlNodeList RouteNodes  = Trn.ChildNodes[1].ChildNodes;
                XmlNodeList Passengers  = Trn.ChildNodes[2].ChildNodes;

                Train Train = new Train(Number);

                LoadRouteNodes   (Train, RouteNodes);
                LoadPassengers   (Train, Passengers);
            }
        }
コード例 #8
0
 /// <summary>
 /// Возвращает ссылку на билет по данному поезду.
 /// </summary>
 /// <param name="train"></param>
 /// <returns></returns>
 private Ticket SearchTicketByTrain(Train train)
 {
     List<Ticket> tickets = this.Tickets;
     foreach(Ticket ticket in tickets)
     {
         if(ticket.Train == train)
         {
             return ticket;
         }
     }
     return null;
 }
コード例 #9
-1
ファイル: ClassData.cs プロジェクト: DrewYak/ProjectTrains
 /// <summary>
 /// Добавляет данные о станциях в оперативную память и
 /// добавляет станции к маршруту поезда.
 /// </summary>
 /// <param name="NumberOfTrain">Номер поезда.</param>
 /// <param name="RouteNodes">Список узлов типа Station.</param>
 private static void LoadRouteNodes(Train Train, XmlNodeList RouteNodes)
 {
     foreach(XmlNode RouteNode in RouteNodes)
     {
         string      name            = RouteNode.ChildNodes[0].InnerText;
         string      timeOfDeparture = RouteNode.ChildNodes[1].InnerText;
         string      timeOfArrival   = RouteNode.ChildNodes[2].InnerText;
         Station     station         = Station.SearchByName(name);
         RouteNode   routenode       = new RouteNode(station, timeOfDeparture, timeOfArrival, Train);
         //Train.AddRouteNode(routenode);
     }
 }