private void btnAdd_Click(object sender, EventArgs e) { if (txtName.Text.Trim() == "") { MessageBox.Show("Name of the meal required"); return; } if (cmbCtgy.SelectedIndex < 0) { MessageBox.Show("Select a category"); return; } if (cmbQtyType.SelectedIndex < 0) { MessageBox.Show("Select a quantity type"); return; } if (numPrice.Value == 0) { MessageBox.Show("Input a price amount"); return; } //bool hasStock = cMeals meal = new cMeals(0, txtName.Text, numPrice.Value, Convert.ToUInt32(cmbCtgy.SelectedValue), Convert.ToUInt32(cmbQtyType.SelectedValue), dtpDtAdd.Value.ToString(), rdbHaveStock.Checked); if (meal.checkMeal()) { MessageBox.Show("This meal already exists"); return; } if (meal.saveRecord()) { MessageBox.Show("Added"); } else { MessageBox.Show("Sorry could not be added"); return; } clear(); }
private void button1_Click(object sender, EventArgs e) { cMeals meal = new cMeals(); meal.MealID = Convert.ToUInt32(cmbItems.SelectedValue); meal.Deleted = false; meal.Name = Convert.ToString(cmbItems.Text); meal.Price = Convert.ToDecimal(cmbPrice.SelectedValue); meal.CategoryID = Convert.ToUInt32(cmbCategory.SelectedValue); meal.QuanTypeID = Convert.ToUInt32(cmbQty.SelectedValue); meal.DateAdded = DateTime.Now.ToString(); meal.HasStock = false; if (meal.saveRecord()) { MessageBox.Show("Not Tracking " + meal.Name + ".\nYou may add stock."); } else MessageBox.Show("Tracking"); }
private void btnSave_Click(object sender, EventArgs e) { if (!loggedUser.access(Convert.ToInt16(btnSave.Tag))) { return; } if (!pEdt.Enabled) { MessageBox.Show("Select an item and edit before saving"); return; } if (txtName.Text.Trim() == "") { MessageBox.Show("Name of the meal required"); return; } if (cmbCtgy.SelectedIndex < 0) { MessageBox.Show("Select a category"); return; } if (cmbQtyType.SelectedIndex < 0) { MessageBox.Show("Select a quantity type"); return; } if (numPrice.Value == 0) { MessageBox.Show("Input a price amount"); return; } cMeals meal = new cMeals(); meal.MealID = Convert.ToUInt32(dgvCat["MealID", dgvCat.CurrentCell.RowIndex].Value); meal.Deleted = rdbDeleted.Checked; meal.Name = txtName.Text; meal.Price = Convert.ToDecimal(numPrice.Value); meal.CategoryID = Convert.ToUInt32(cmbCtgy.SelectedValue); meal.QuanTypeID = Convert.ToUInt32(cmbQtyType.SelectedValue); meal.DateAdded = dtpDtAdd.Value.ToString(); meal.HasStock = rdbHaveStock.Checked; //if (meal.checkMeal()) //{ // MessageBox.Show("This meal already exists!"); // return; //} if (meal.saveRecord()) { MessageBox.Show("Saved"); clear(); } else MessageBox.Show("Not Saved"); LoadMeals(); }