Example #1
0
 protected void MyClosedHandlerRecords(object sender, EventArgs e)
 {
     if (newRec.isCorrect)
     {
         carShop.AddProduct(newRec.name, newRec.manufacturer, newRec.price, newRec.amount, newRec.shopNumber, newRec.minimumLot);
         carShop.WriteIn(dataGridView1);
     }
 }
Example #2
0
        public CarShop Search(string valueUpDown, string searchValue)
        {
            CarShop carShopSearch = new CarShop(0);

            switch (valueUpDown)
            {
            case "Наименование":
                for (int i = 0; i < carShop.Length; i++)
                {
                    if (carShop[i].ReturnName() == searchValue)
                    {
                        carShopSearch.AddProduct(carShop[i].ReturnName(), carShop[i].ReturnManufacturer(), carShop[i].ReturnPrice(), carShop[i].ReturnAmount(), carShop[i].ReturnShopNumber(), carShop[i].ReturnMinimumLot());
                    }
                }
                break;

            case "Фирма":
                for (int i = 0; i < carShop.Length; i++)
                {
                    if (carShop[i].ReturnManufacturer() == searchValue)
                    {
                        carShopSearch.AddProduct(carShop[i].ReturnName(), carShop[i].ReturnManufacturer(), carShop[i].ReturnPrice(), carShop[i].ReturnAmount(), carShop[i].ReturnShopNumber(), carShop[i].ReturnMinimumLot());
                    }
                }
                break;

            case "Номер магазина":
                for (int i = 0; i < carShop.Length; i++)
                {
                    if (carShop[i].ReturnShopNumber() + "" == searchValue)
                    {
                        carShopSearch.AddProduct(carShop[i].ReturnName(), carShop[i].ReturnManufacturer(), carShop[i].ReturnPrice(), carShop[i].ReturnAmount(), carShop[i].ReturnShopNumber(), carShop[i].ReturnMinimumLot());
                    }
                }
                break;

            case "ID элемента":
                int x = Int32.Parse(searchValue) - 1;
                carShopSearch.AddProduct(carShop[x].ReturnName(), carShop[x].ReturnManufacturer(), carShop[x].ReturnPrice(), carShop[x].ReturnAmount(), carShop[x].ReturnShopNumber(), carShop[x].ReturnMinimumLot());
                break;
            }
            return(carShopSearch);
        }
Example #3
0
        private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string path = openFileDialog1.FileName;

            MessageBox.Show(path);
            saveToPath = path;
            carShop    = new CarShop(1);
            using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open)))//Считывание
            {
                isPass = reader.ReadBoolean();
                if (isPass)
                {
                    password = reader.ReadString();
                }
                while (reader.PeekChar() > -1)
                {
                    string name         = reader.ReadString();
                    string manufacturer = reader.ReadString();
                    int    price        = reader.ReadInt32();
                    int    amount       = reader.ReadInt32();
                    int    shopNumber   = reader.ReadInt32();
                    int    minimumLot   = reader.ReadInt32();

                    carShop.AddProduct(name, manufacturer, price, amount, shopNumber, minimumLot);
                }
            }
            if (isPass)
            {
                запаролитьToolStripMenuItem.Text = "Изменить пароль";
            }
            else
            {
                запаролитьToolStripMenuItem.Text = "Запаролить";
            }

            AddRecord.Enabled                              = true;
            dataGridView1.Enabled                          = true;
            groupBox1.Enabled                              = true;
            поискToolStripMenuItem.Enabled                 = true;
            сохранитьToolStripMenuItem.Enabled             = true;
            запаролитьToolStripMenuItem.Enabled            = true;
            редактированиеЗаписейToolStripMenuItem.Enabled = true;
            выводToolStripMenuItem.Enabled                 = true;

            carShop.WriteIn(dataGridView1);
        }
Example #4
0
        public CarShop DeleateElementIndex(string valueUpDown, string deleateValue)
        {
            CarShop carShopDeleateElement = new CarShop(0);

            switch (valueUpDown)
            {
            case "Наименование":
                for (int i = 0; i < carShop.Length; i++)
                {
                    if (carShop[i].ReturnName() == deleateValue)
                    {
                        Array.Clear(carShop, i, 1);
                    }
                }
                break;

            case "Фирма":
                for (int i = 0; i < carShop.Length; i++)
                {
                    if (carShop[i].ReturnManufacturer() == deleateValue)
                    {
                        Array.Clear(carShop, i, 1);
                    }
                }
                break;

            case "Номер магазина":
                for (int i = 0; i < carShop.Length; i++)
                {
                    if (carShop[i].ReturnShopNumber() + "" == deleateValue)
                    {
                        Array.Clear(carShop, i, 1);
                    }
                }
                break;

            case "ID элемента":
                int x = Int32.Parse(deleateValue) - 1;
                Array.Clear(carShop, x, 1);
                break;
            }
            for (int i = 0; i < carShop.Length; i++)
            {
                if (carShop[i].ReturnPrice() > 0)
                {
                    carShopDeleateElement.AddProduct(carShop[i].ReturnName(), carShop[i].ReturnManufacturer(), carShop[i].ReturnPrice(), carShop[i].ReturnAmount(), carShop[i].ReturnShopNumber(), carShop[i].ReturnMinimumLot());
                }
            }

            return(carShopDeleateElement);
        }
Example #5
0
        public CarShop CoutShopElements(int shop)
        {
            CarShop carShopCoutShopElements = new CarShop(0);

            for (int i = 0; i < carShop.Length; i++)
            {
                if (carShop[i].ReturnShopNumber() == shop)
                {
                    carShopCoutShopElements.AddProduct(carShop[i].ReturnName(), carShop[i].ReturnManufacturer(), carShop[i].ReturnPrice(), carShop[i].ReturnAmount(), carShop[i].ReturnShopNumber(), carShop[i].ReturnMinimumLot());
                }
            }

            return(carShopCoutShopElements);
        }
Example #6
0
        //App A
        public CarShop CoutMinimalLot5()
        {
            CarShop carShopCoutMinimalLot5 = new CarShop(0);

            for (int i = 0; i < carShop.Length; i++)
            {
                if (carShop[i].ReturnMinimumLot() < 5)
                {
                    carShopCoutMinimalLot5.AddProduct(carShop[i].ReturnName(), carShop[i].ReturnManufacturer(), carShop[i].ReturnPrice(), carShop[i].ReturnAmount(), carShop[i].ReturnShopNumber(), carShop[i].ReturnMinimumLot());
                }
            }

            return(carShopCoutMinimalLot5);
        }
Example #7
0
        private void файлНа20ЗаписейToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string path = @"C:\Users\rasia\source\repos\CursachV2\Cars";

            saveToPath = path;
            carShop    = new CarShop(1);
            using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open)))//Считывание
            {
                isPass = reader.ReadBoolean();
                if (isPass)
                {
                    password = reader.ReadString();
                }
                while (reader.PeekChar() > -1)
                {
                    string name         = reader.ReadString();
                    string manufacturer = reader.ReadString();
                    int    price        = reader.ReadInt32();
                    int    amount       = reader.ReadInt32();
                    int    shopNumber   = reader.ReadInt32();
                    int    minimumLot   = reader.ReadInt32();

                    carShop.AddProduct(name, manufacturer, price, amount, shopNumber, minimumLot);
                }
            }

            AddRecord.Enabled                              = true;
            dataGridView1.Enabled                          = true;
            groupBox1.Enabled                              = true;
            поискToolStripMenuItem.Enabled                 = true;
            сохранитьToolStripMenuItem.Enabled             = true;
            запаролитьToolStripMenuItem.Enabled            = true;
            редактированиеЗаписейToolStripMenuItem.Enabled = true;
            выводToolStripMenuItem.Enabled                 = true;

            carShop.WriteIn(dataGridView1);
        }