void Load_all()
        {
            FileProduct file = new FileProduct();

            if (file.Total_number_records() != 0)
            {
                file = new FileProduct("Book");
                IEnumerable <Product> rez = file.Load_all();
                LoadAllItem?.Invoke(rez);
                file = new FileProduct("AddProducts");
                Product[] mass = file.Load_all();
                if (mass != null)
                {
                    Product[] massMagazine    = new Product[mass.Length];
                    Product[] massСhancellery = new Product[mass.Length];
                    for (int i = 0; i < mass.Length; i++)
                    {
                        if (mass[i] is Magazine)
                        {
                            massMagazine[i] = mass[i];
                        }
                        if (mass[i] is Сhancellery)
                        {
                            massСhancellery[i] = mass[i];
                        }
                    }
                    massMagazine    = massMagazine.Where(x => x != null).ToArray();
                    massСhancellery = massСhancellery.Where(x => x != null).ToArray();
                    LoadAllItem?.Invoke(massMagazine);
                    LoadAllItem?.Invoke(massСhancellery);
                }
            }
        }
Beispiel #2
0
        public Magazine(string[] mass)
        {
            FileProduct product = new FileProduct();

            Namber     = product.Total_number_records(); Name = mass[1]; Author = mass[2]; Topic = mass[3]; Storage = mass[4]; Genre = mass[5]; Manufacturer = mass[6]; Audience = mass[7]; Price = Convert.ToDouble(mass[8]);
            Maptemp    = new string[10];
            Maptemp[0] = mass[0]; Maptemp[1] = Convert.ToString(Namber); Maptemp[2] = Name; Maptemp[3] = Author; Maptemp[4] = Topic; Maptemp[5] = Storage; Maptemp[6] = Genre; Maptemp[7] = Manufacturer; Maptemp[8] = Audience; Maptemp[9] = Price.ToString();
            Type       = mass[0];
        }
Beispiel #3
0
        public Сhancellery(string[] mass)
        {
            FileProduct product = new FileProduct();

            Namber     = product.Total_number_records(); Name = mass[1]; Storage = mass[2]; Manufacturer = mass[3]; Appointment = mass[4]; Price = Convert.ToDouble(mass[5]);
            Maptemp    = new string[7];
            Maptemp[0] = mass[0]; Maptemp[1] = Convert.ToString(Namber); Maptemp[2] = Name; Maptemp[3] = Storage; Maptemp[4] = Manufacturer; Maptemp[5] = Appointment; Maptemp[6] = Price.ToString();
            Type       = mass[0];
        }
        void DeleteProduct(string[] mass)
        {
            IFile <Product> file;

            switch (mass[0])
            {
            case "Книги": file = new FileProduct("Book"); break;

            case "Журнал": file = new FileProduct("AddProducts"); break;

            case "Концелярия": file = new FileProduct("AddProducts"); break;

            //case "Концелярия": objectt = new Сhancellery(mass); break; Допилить
            default: throw new ArgumentException("Недопустимый код операции");
            }
            file.Deleting_Object(mass);
        }
        void AddProduct(string[] mass)
        {
            Product         objectt;
            IFile <Product> file;

            switch (mass[0])
            {
            case "Книги": objectt = new Book(mass); file = new FileProduct("Book"); break;

            case "Журнал": objectt = new Magazine(mass); file = new FileProduct("AddProducts"); break;

            case "Концелярия": objectt = new Сhancellery(mass); file = new FileProduct("AddProducts"); break;

            //case "Концелярия": objectt = new Сhancellery(mass); break; Допилить
            default: throw new ArgumentException("Недопустимый код операции");
            }
            if (file.Duplicate_search(mass) == true)
            {
                MessageBox.Show("Товар с такими данными уже зарегестрирован");
                return;
            }
            file.NewObject(objectt);
        }
Beispiel #6
0
 /// <summary>
 /// Create instance of FileProduct
 /// </summary>
 /// <param name="filePath"></param>
 public void Initialize(string filePath)
 {
     file          = new FileProduct(filePath);
     fileInfo      = new FileInfo(filePath);
     isInitialized = true;
 }