public List<string> Updater(MVTDeparture oldKunde, MVTDeparture newJunde, int JolID)
        {
            List<string> messageList = new List<string>();
            string FlightNumber = oldKunde.FlightNumber.Substring(2, 3);

            DateTime startDDate = FilterDate(Convert.ToDateTime(oldKunde.EstimatedTimeOfArrival), "start");
            DateTime endDDate = FilterDate(Convert.ToDateTime(oldKunde.EstimatedTimeOfArrival), "end");
            DateTime AirborneTimeDDate = FilterDate(Convert.ToDateTime(oldKunde.AirborneTime), "time");
            string startDate = startDDate.Year.ToString() + '-' + startDDate.Month.ToString() + '-' + startDDate.Day.ToString();

            string endDate = endDDate.Year.ToString() + '-' + endDDate.Month.ToString() + '-' + endDDate.Day.ToString();
            string AirboneTTime = AirborneTimeDDate.ToString("HHmm");

            string UpdateTExt = "";

            try
            {
                if (JolID == 1)
                    command.CommandText = "SELECT aodb.ArrivalFlight.arrivalFlightId, aodb.ArrivalFlight.flightNumber, aodb.ArrivalFlight.scheduledTime, aodb.ArrivalFlight.airlineId, aodb.ArrivalFlight.ATTR_7, aodb.Airline.iataCode, aodb.ArrivalFlight.ATTR_381"
                        + " FROM     aodb.ArrivalFlight INNER JOIN aodb.Airline ON aodb.ArrivalFlight.airlineId = aodb.Airline.airlineId"
                        + " WHERE (aodb.ArrivalFlight.flightNumber = N'" + FlightNumber
                        + "') AND (aodb.ArrivalFlight.scheduledTime BETWEEN CONVERT(DATETIME, '" + startDate
                        + "', 102) AND CONVERT(DATETIME, '" + endDate
                        + "', 102))";

                else command.CommandText = "SELECT * FROM [aodb].[ArrivalFlight]   where arrivalFlightId = 76 ";
                //command.CommandType = CommandType.Text;

                connection.Open();

                messageList.Add(command.CommandText);

                using (SqlDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while (dr.Read())
                    {
                        if (JolID == 1)
                            {
                            UpdateTExt = "";
                            if (oldKunde.AmountOfPassengers != 0)
                            {
                              UpdateTExt = UpdateTExt + ", ATTR_208 = '" + oldKunde.AmountOfPassengers+"'";
                            }
                            if (oldKunde.DelayCode != null)
                            {
                                UpdateTExt = UpdateTExt + ", ATTR_144 = '" + oldKunde.DelayCode + "'";
                            }
                            command.CommandText = "UPDATE AMS.aodb.ArrivalFlight set ATTR_381 = '" + AirboneTTime + "'"+ UpdateTExt +  " WHERE arrivalFlightId = " + dr["arrivalFlightId"].ToString();
                        }
                        else command.CommandText = "UPDATE Daily_Values SET Daily_Values.value = '" + dr["arrivalFlightId"].ToString() + "' WHERE Field='auaraiu' and Daily_ID=" + oldKunde.FlightNumber;

                    }
                }
                if (command.CommandText.StartsWith("UPDATE"))
                {
                    command.Connection.Open();
                    command.ExecuteNonQuery();
                    messageList.Add(command.CommandText);
                }
                return messageList;
            }
             catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
        }
        public List<MVTDeparture> FillListBox(string Occupation)
        {
            List<MVTDeparture> messageList = new List<MVTDeparture>();
            try
            {
                string line;
                Boolean Blok;
                Blok = false;
                int dayEA;
                string mvtType;
                MVT messageMVT = new MVT();
                MVTArrival messageMVTArrival = new MVTArrival();

                //MessageRCV-нің соңына дейін бару
                while (reader.Peek() >= 0)
                {

                    if (reader.ReadLine() == Occupation)
                    {
                        while (reader.Peek() >= 0)
                        {
                            if (reader.ReadLine().Length == 0)
                            {
                                break;
                            }
                        }
                        break;
                    }
                }

                while ((line = reader.ReadLine()) != null)
                {

                    MVTDeparture messageMVTDeparture = new MVTDeparture();

                    if (line == "MVT")
                    {
                        Blok = true;
                        messageMVT.FlightNumber = "";
                    }
                    else if (line.Length == 0)
                    {
                        Blok = false;
                    }
                    else if (Blok)
                    {
                        if (line.IndexOf("/") != -1 && messageMVT.FlightNumber == "")
                        {
                            messageMVT.FlightNumber = line.Substring(0, line.IndexOf("/"));
                            messageMVT.DayOfMonth = Convert.ToInt32(line.Substring(line.IndexOf("/") + 1, 2));
                           // B2775/08.EW399PO.MSQ
                            messageMVT.AircraftRegistration = line.Substring(line.IndexOf("/") + 4, (line.Length - 4) - (line.IndexOf("/") + 4));
                            messageMVT.Airport = line.Substring(line.Length - 3, 3);
                        }
                        else if (line.StartsWith("AAA") && line.IndexOf("/") != -1)
                        {

                            mvtType = line.Substring(0, line.IndexOf("/"));
                            messageMVTArrival.FlightNumber = messageMVT.FlightNumber;
                            messageMVTArrival.Registration = messageMVT.AircraftRegistration;
                            messageMVTArrival.AirportOfMovement = messageMVT.Airport;

                            //messageList.Add(messageMVTArrival.FlightNumber);
                            //messageList.Add(messageMVTArrival.Registration);
                            //messageList.Add(messageMVTArrival.AirportOfMovement);

                            if (mvtType.Length == 6)
                            {
                                messageMVTArrival.TouchDownTime = mvtType.Substring(2, 4);
                                //messageList.Add(messageMVTArrival.TouchDownTime);
                            }
                            else if (mvtType.Length == 7)
                            {
                                messageMVTArrival.TouchDownTime = mvtType.Substring(3, 4);
                                //messageList.Add(messageMVTArrival.TouchDownTime + "  7 counts");
                            }
                            else
                            {
                                messageMVTArrival.TouchDownTime = mvtType.Substring(4, 4);
                                messageMVTArrival.DayOfOperation = Convert.ToInt32(mvtType.Substring(2, 2));
                                //messageList.Add(messageMVTArrival.TouchDownTime + " Day: " + messageMVTArrival.DayOfOperation);
                            }

                            if ((line.Length - line.LastIndexOf("/")) == 7)
                            {
                                messageMVTArrival.OnBlockTime = "Off Block Day:" + line.Substring(line.LastIndexOf("/") + 1, 2) + " " + line.Substring(line.LastIndexOf("/") + 3, 4);
                                //messageList.Add(messageMVTArrival.OnBlockTime);

                            }
                            else
                            {
                                messageMVTArrival.OnBlockTime = "Off Block noDay:" + line.Substring(line.LastIndexOf("/") + 1, 4);
                                //messageList.Add(messageMVTArrival.OnBlockTime);
                            }
                            //listBox1.Items.Add(mvtType + " Arrival " + mvtType.Substring(0, 2));

                        }
                        else if (line.StartsWith("AD") && line.IndexOf("/") != -1 && (messageMVT.Airport != "TSE")
                            && line.Trim().EndsWith("TSE"))
                        {
                            mvtType = line.Substring(0, line.IndexOf("/"));

                            messageMVTDeparture.MessageIdentifier = "dep";
                            messageMVTDeparture.FlightNumber = messageMVT.FlightNumber;
                            messageMVTDeparture.DayofOperation = messageMVT.DayOfMonth;
                            messageMVTDeparture.Registration = messageMVT.AircraftRegistration;
                            messageMVTDeparture.DestinationAirport = messageMVT.Airport;

                            //messageList.Add(messageMVTDeparture.FlightNumber + " Day: " + Convert.ToString(messageMVTDeparture.DayofOperation));
                            //messageList.Add(messageMVTDeparture.Registration);
                            //messageList.Add(messageMVTDeparture.DestinationAirport);

                            messageMVTDeparture.OfBlockTime = mvtType.Substring(2, 4);

                            if (mvtType.Length == 6)
                            {

                                messageMVTDeparture.OfBlockTime = Convert.ToString(ConvertLocal(messageMVTDeparture.DayofOperation.ToString(), mvtType.Substring(2, 4)));
                                //messageList.Add(messageMVTDeparture.OfBlockTime);
                            }
                            else if (mvtType.Length == 7)
                            {
                                messageMVTDeparture.OfBlockTime = Convert.ToString(ConvertLocal("", mvtType.Substring(3, 4)));
                                //messageList.Add(messageMVTDeparture.OfBlockTime + "  7 counts");
                            }
                            else
                            {
                                messageMVTDeparture.OfBlockTime = Convert.ToString(ConvertLocal(mvtType.Substring(2, 2), mvtType.Substring(4, 4)));
                                messageMVTDeparture.DayofOperation = Convert.ToInt32(mvtType.Substring(2, 2));
                                //messageList.Add(messageMVTDeparture.OfBlockTime + " Day: " + messageMVTDeparture.DayofOperation);
                            }

                            if ((line.IndexOf(" ") - line.IndexOf("/")) == 7)
                            {
                                messageMVTDeparture.AirborneTime = Convert.ToString(ConvertLocal(line.Substring(line.IndexOf("/") + 1, 2), line.Substring(line.IndexOf("/") + 3, 4)));
                                //messageList.Add(messageMVTDeparture.AirborneTime);
                            }
                            else
                            {
                                messageMVTDeparture.AirborneTime = Convert.ToString(ConvertLocal(messageMVTDeparture.DayofOperation.ToString(), line.Substring(line.LastIndexOf("/") + 1, 4)));
                                //messageList.Add(messageMVTDeparture.AirborneTime);
                            }

                            if (line.Contains("EA") && (line.LastIndexOf(" ") - line.IndexOf("EA") == 8))
                            {
                                messageMVTDeparture.EstimatedTimeOfArrival = Convert.ToString(ConvertLocal(line.Substring(line.IndexOf(" ") + 3, 2), line.Substring(line.IndexOf(" ") + 5, 4)));
                                //messageList.Add(messageMVTDeparture.EstimatedTimeOfArrival);
                            }
                            else if (line.Contains("EA") && (line.LastIndexOf(" ") - line.IndexOf("EA") == 6))
                            {

                                messageMVTDeparture.EstimatedTimeOfArrival = Convert.ToString(ConvertLocal(messageMVTDeparture.DayofOperation.ToString(), line.Substring(line.IndexOf(" ") + 3, 4)));

                                if ((dayEA = Convert.ToDateTime(messageMVTDeparture.AirborneTime).Day) > Convert.ToDateTime(messageMVTDeparture.EstimatedTimeOfArrival).Day)
                                {
                                    messageMVTDeparture.EstimatedTimeOfArrival = Convert.ToString(ConvertLocal(dayEA.ToString(), line.Substring(line.IndexOf(" ") + 3, 4)));
                                }
                                //messageList.Add(messageMVTDeparture.EstimatedTimeOfArrival);
                            }
                            while ((line = reader.ReadLine()) != "")
                            {
                                if (reader.EndOfStream) break;
                                if (line.StartsWith("DL"))
                                {
                                    if (line.Length == 9)
                                    {
                                        messageMVTDeparture.DelayCode = line.Substring(2, 2);
                                        messageMVTDeparture.DelayTime = line.Substring(5, 4);
                                    }
                                    else if (line.Length == 17)
                                    {
                                        messageMVTDeparture.DelayCode = line.Substring(2, 2);
                                        messageMVTDeparture.DelayTime = line.Substring(8, 4);
                                    }

                                }
                                else if (line.StartsWith("PX"))
                                {

                                    if (line.Contains("/"))
                                    {
                                        //PX2/97
                                        string Transit = line.Substring(2, line.IndexOf("/") - 2);
                                        string Destination = "0";
                                        string Destination2 = "0";
                                        if (line.Length == 13)
                                        {
                                            Destination = line.Substring(line.IndexOf("/") + 1, 3);
                                            Destination2 = line.Substring(line.IndexOf("/") + 5, 3);
                                        } else Destination = line.Substring(line.IndexOf("/") + 1, line.Length - line.IndexOf("/") - 1);

                                        messageMVTDeparture.AmountOfPassengers = Convert.ToInt32(Transit) + Convert.ToInt32(Destination) + Convert.ToInt32(Destination2);
                                    }
                                    else if (!line.Contains(" ") && !line.Contains("+")) messageMVTDeparture.AmountOfPassengers = Convert.ToInt32(line.Substring(2, line.Length - 2));

                                }
                            }
                            Blok = false;
                        }

                        if (messageMVTDeparture.FlightNumber != null)
                        {
                            messageList.Add(messageMVTDeparture);
                        }

                    }
                    else if (line.StartsWith("Message RCV"))
                    {

                        SaveOccupation(line,"MVT");
                    }
                }

                return messageList;
            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                if (reader != null)
                {
            //                    reader.Close();
            //                    reader.Dispose();
                }
            }
        }