Ejemplo n.º 1
0
        internal static Сontainer ReadFromFile(StreamReader sr)
        {
            var container = new Сontainer();

            string _Id             = sr.ReadLine();
            string _Number         = sr.ReadLine();
            string _DepartureCitys = sr.ReadLine();
            string _ArrivalCitys   = sr.ReadLine();
            string _DepatureDate   = sr.ReadLine();
            string _ArrivalDate    = sr.ReadLine();
            string _ItemsCount     = sr.ReadLine();

            container.Id             = int.Parse(_Id);
            container.Number         = _Number;
            container.DepartureCitys = (DepartureCitys)Enum.Parse(typeof(DepartureCitys), _DepartureCitys);
            container.ArrivalCitys   = (ArrivalCitys)Enum.Parse(typeof(ArrivalCitys), _ArrivalCitys);
            container.DepatureDate   = DateTime.Parse(_DepatureDate);
            container.ArrivalDate    = DateTime.Parse(_ArrivalDate);
            container.ItemsCount     = int.Parse(_ItemsCount);

            Validation.DepartureDateValidation(container.DepatureDate);
            Validation.ArrivalDateValidation(container.DepatureDate, container.ArrivalDate);

            return(container);
        }
Ejemplo n.º 2
0
        private string[] ContainersFieldToArray(Сontainer Сontainers)
        {
            var FieldsArray = (from x in typeof(Сontainer)
                               .GetProperties(BindingFlags.Public | BindingFlags.Instance)
                               select x.GetValue(Сontainers, null).ToString()).ToArray();

            return(FieldsArray);
        }
Ejemplo n.º 3
0
        public void AddContainer()
        {
            Сontainer container = CreateNewContainer();

            Сontainers.Add(new Сontainer(container));

            Console.WriteLine("\nContainer has been added!\n");

            AddContainersToFile();
        }
Ejemplo n.º 4
0
        private Сontainer CreateNewContainer()
        {
            var container = new Сontainer();

            while (true)
            {
                try
                {
                    Console.Write("Input Id: ");
                    container.Id = int.Parse(Console.ReadLine());
                    var allId = new string[Сontainers.Count];
                    allId = Enumerable.Range(0, allId.Length).Select(x => allId[x] = Сontainers[x].Id.ToString()).ToArray();
                    Validation.IdValidation(container.Id.ToString(), allId);


                    Console.Write("Input Container Number: ");
                    container.Number = Console.ReadLine();

                    Console.Write("Input Departure Citys: ");
                    container.DepartureCitys = (DepartureCitys)Enum.Parse(typeof(DepartureCitys), Console.ReadLine());

                    Console.Write("Input Arrival Citys: ");
                    container.ArrivalCitys = (ArrivalCitys)Enum.Parse(typeof(ArrivalCitys), Console.ReadLine());

                    Console.Write("Input DepatureDate: ");
                    container.DepatureDate = DateTime.Parse(Console.ReadLine());
                    Validation.DepartureDateValidation(container.DepatureDate);

                    Console.Write("Input Arrival Date: ");
                    container.ArrivalDate = DateTime.Parse(Console.ReadLine());
                    Validation.ArrivalDateValidation(container.DepatureDate, container.ArrivalDate);

                    Console.Write("Input Items Count: ");
                    container.ItemsCount = int.Parse(Console.ReadLine());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "\nTry again. . .\n");
                    continue;
                }
                break;
            }
            return(container);
        }