protected void MyClosedHandlerDeleteEl(object sender, EventArgs e) { if (!deleateEl.isCancel) { carShop = carShop.DeleateElementIndex(deleateEl.domainValue, deleateEl.value); carShop.WriteIn(dataGridView1); } }
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); }
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); }
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); }
//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); }
private void Form1_Load(object sender, EventArgs e) { carShop = new CarShop(0); this.FormClosed += MyClosedHandlerMainForm; AddRecord.Enabled = false; dataGridView1.Enabled = false; groupBox1.Enabled = false; поискToolStripMenuItem.Enabled = false; ShowInfoCheck.Enabled = false; сохранитьToolStripMenuItem.Enabled = false; запаролитьToolStripMenuItem.Enabled = false; редактированиеЗаписейToolStripMenuItem.Enabled = false; выводToolStripMenuItem.Enabled = false; }
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); }
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); }