private void button2_Click(object sender, EventArgs e) { ConteinerRepository conteinerRepository = new ConteinerRepository(); ProductRepository productRepository = new ProductRepository(); try { foreach (var elem in productCount) { conteinerRepository.Remove(elem.Key.Id, date, 2, elem.Value); } MessageBox.Show(@"Продукти успішно списані.", "Sucsess", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { invoiceFile.Workbooks.Close(); invoiceFile.Quit(); updateInformation(); } }
private void RemoveProductsForRemaking() { ProductRepository productRepository = new ProductRepository(); ConteinerRepository conteinerRepository = new ConteinerRepository(); foreach (var elementOfRemaking in productsForRemaking) { var product = productRepository.GetDataSource() .First(element => element.Name == elementOfRemaking.Name); var conteiner = conteinerRepository.GetDataSource() .First(elem => elem.ProductId == product.Id & elem.Weight == elementOfRemaking.Weight); conteinerRepository.Remove(conteiner.Id, dateTimePicker1.Value, 3, elementOfRemaking.Amount); } }
private void Button1_Click(object sender, EventArgs e) { try { if (radioButton1.Checked) { var productRepository = new ProductRepository(); var conteinerRepository = new ConteinerRepository(); var productConteiner = productRepository.GetProductConteinerDataSource(). First(element => $"{element.Name} {element.Weight}" == comboBox1.SelectedItem.ToString()); var product = productRepository.GetDataSource().First(element => element.Name == productConteiner.Name); var conteiner = conteinerRepository.GetDataSource().First(elem => elem.ProductId == product.Id & elem.Weight == productConteiner.Weight); conteinerRepository.Remove(conteiner.Id, dateTimePicker1.Value, 1, Decimal.ToInt32(numericUpDown1.Value)); } else if (radioButton2.Checked) { var ingredientRepository = new IngredientRepository(); var packageRepository = new PackageRepository(); var ingredientPackage = ingredientRepository.GetIngredientPackageDataSource(). First(element => $"{element.Name} {element.Weight}" == comboBox1.SelectedItem.ToString()); var ingredient = ingredientRepository.GetDataSource().First(element => element.Name == ingredientPackage.Name); var conteiner = packageRepository.GetDataSource().First(elem => elem.IngredientId == ingredient.Id & elem.Weight == ingredientPackage.Weight); packageRepository.Remove(conteiner.Id, dateTimePicker1.Value, Double.Parse(maskedTextBox1.Text)); } else { TareRepository tareRepository = new TareRepository(); Tare tareForRemoving = tareRepository.GetDataSource(). First(elem => $"{elem.Name} {elem.Amount}" == comboBox1.SelectedItem.ToString()); tareForRemoving.Amount = Decimal.ToInt32(numericUpDown1.Value); tareRepository.Remove(tareForRemoving); } RadioButton1_CheckedChanged(null, null); MessageBox.Show(@"Об'єкт успішно списано.", "Sucsess", MessageBoxButtons.OK, MessageBoxIcon.Information); updateInformation(); } catch (Exception) { MessageBox.Show(@"Помилка списання", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void comboBox1_KeyPress(object sender, KeyPressEventArgs e) { try { if (radioButton1.Checked && comboBox1.Text.Contains("№")) { int cantainerId = Int32.Parse(comboBox1.Text.Split('?')[1].Split('№')[0]); ConteinerRepository conteinerRepository = new ConteinerRepository(); Conteiner currConteiner = conteinerRepository.GetDataSource().First(n => n.Id == cantainerId); conteinerRepository.Remove(currConteiner.Id, dateTimePicker1.Value, 1, 1); //MessageBox.Show(@"Об'єкт успішно списано.", "Sucsess", MessageBoxButtons.OK, MessageBoxIcon.Information); updateInformation(); comboBox1.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }