private void buttonOk_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBoxName.Text) && !string.IsNullOrEmpty(textBoxPrice.Text)) { double price = 0; int waste = 0; bool correctWaste = false; try { price = Convert.ToDouble(textBoxPrice.Text); } catch { ErrorsViewWrapper.ShowError(ErrorTexts.INCORRECT_PRICE); } try { waste = Convert.ToInt32(textBoxWaste.Text); if (waste < 100) { correctWaste = true; } else { ErrorsViewWrapper.ShowError(ErrorTexts.INCORRECT_WASTE); } } catch { ErrorsViewWrapper.ShowError(ErrorTexts.INCORRECT_WASTE); } if (price > 0 && correctWaste) { ConsumblesCore.AddConsumble(textBoxName.Text, ConsumblesTypesCore.ConsumbleTypes.GetID(comboBoxType.SelectedItem.ToString()), ConsumbleCategorieCore.consumbleCategories.GetID(comboBoxCategory.SelectedItem.ToString()), MeasuresCore.Measures.GetID(comboBoxMeasuring.SelectedItem.ToString()), 0, price, waste); AdminForm.instance.AddConsumbleToGrid(textBoxName.Text); this.Close(); } } else if (string.IsNullOrEmpty(textBoxName.Text) && string.IsNullOrEmpty(textBoxPrice.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_NAME_AND_PRICE); } else if (string.IsNullOrEmpty(textBoxName.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_NAME); } else if (string.IsNullOrEmpty(textBoxPrice.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_PRICE); } }
private void buttonOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCount.Text) && string.IsNullOrEmpty(textBoxPrice.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_PRICE_AND_COUNT); } else if (string.IsNullOrEmpty(textBoxCount.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_COUNT); } else if (string.IsNullOrEmpty(textBoxPrice.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_PRICE); } else { bool isOK = true; double price = 0, count = 0; try { price = Convert.ToDouble(textBoxPrice.Text); } catch { isOK = false; ErrorsViewWrapper.ShowError(ErrorTexts.INCORRECT_PRICE); } try { count = Convert.ToDouble(textBoxCount.Text); } catch { isOK = false; ErrorsViewWrapper.ShowError(ErrorTexts.INCORRECT_COUNT); } if (isOK) { int id = ArrivalCore.AddArrival(ConsumblesCore.Consumbles.GetID(comboBoxConsumbles.SelectedItem.ToString()), SuppliersCore.Suppliers.GetID(comboBoxSupplier.SelectedItem.ToString()), EmployeesCore.Emplyees.GetID(comboBoxCook.SelectedItem.ToString()), count, price); ArrivalCore.GetArrivals(); ConsumblesCore.GetConsumbles(); AdminForm.instance.AddArrivalToGrid(id); AdminForm.instance.UpdateDataGridViewConsumbles(); this.Close(); } } }
private void ComboBoxCategory_SelectedIndexChanged(object sender, EventArgs e) { try { Consumbles consumbles = ConsumblesCore.GetConsumbles(ConsumbleCategorieCore.consumbleCategories.GetID(comboBoxCategory.SelectedItem.ToString())); comboBoxConsumbles.DataSource = consumbles.ToList(); comboBoxConsumbles.SelectedIndex = 0; buttonOk.Enabled = true; } catch { comboBoxConsumbles.Text = ""; buttonOk.Enabled = false; } }
private void buttonOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCount.Text) && string.IsNullOrEmpty(richTextBoxComment.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_COUNT_AND_COMMENT); } else if (string.IsNullOrEmpty(textBoxCount.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_COUNT); } else if (string.IsNullOrEmpty(richTextBoxComment.Text)) { ErrorsViewWrapper.ShowError(ErrorTexts.ENTER_COMMENT); } else { bool isOK = true; double count = 0; try { count = Convert.ToDouble(textBoxCount.Text); } catch { isOK = false; ErrorsViewWrapper.ShowError(ErrorTexts.INCORRECT_COUNT); } if (isOK) { WriteOffCore.AddWriteOff(ConsumblesCore.Consumbles.GetID(comboBoxConsumbles.SelectedItem.ToString()), EmployeesCore.Emplyees.GetID(comboBoxCook.SelectedItem.ToString()), count, richTextBoxComment.Text); WriteOffCore.GetWriteOff(); ConsumblesCore.GetConsumbles(); AdminForm.instance.UpdateDataGridViewWriteOff(); AdminForm.instance.UpdateDataGridViewConsumbles(); this.Close(); } } }