private void btnAddCate_Click(object sender, EventArgs e) { bool result = false; string name = txtCateName.Text.Trim(); int idCate = Convert.ToInt32(txtCategoryID.Text.Trim()); bool existed = CategoryDAO.Instance.IsExistedCategory(name); if (txtCateName.Text.Equals("")) { MessageBox.Show("Empty input."); return; } if (existed) { MessageBox.Show("This category: " + name + " is existed."); return; } result = CategoryDAO.Instance.AddCategory(name); if (result) { MessageBox.Show("Add Successfully!"); LoadListCategory(); LoadCategoryBinding(cbFoodCategory); LoadListFood(); ReLoadCategory.Invoke(); } else { MessageBox.Show("Add failed!"); } }
private void btnRestore_Click(object sender, EventArgs e) { bool result = false; int idFood = Convert.ToInt32(txtFoodID.Text.Trim()); result = FoodDAO.Instance.RestoreFood(idFood); if (result) { MessageBox.Show("Restore Successfully!"); LoadListFood(); rdActive.Checked = true; DeleteFood.Invoke(); ReLoadCategory.Invoke(); } else { MessageBox.Show("Restore failed!"); } }
private void btnDeleteFood_Click(object sender, EventArgs e) { bool result = false; int idFood = Convert.ToInt32(txtFoodID.Text.Trim()); if (MessageBox.Show(string.Format("Delete this FoodID: {0}?", idFood), "Notification!!!", MessageBoxButtons.OKCancel) == DialogResult.OK) { result = FoodDAO.Instance.DeleteFood(idFood); if (result) { MessageBox.Show("Delete Successfully!"); LoadListFood(); DeleteFood.Invoke(); ReLoadCategory.Invoke(); } else { MessageBox.Show("Delete failed!"); } } }
private void btnDeleteCate_Click(object sender, EventArgs e) { bool result = false; int idCate = Convert.ToInt32(txtCategoryID.Text.Trim()); if (MessageBox.Show(string.Format("Delete this CategoryID: {0}?", idCate), "Notification!!!", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { result = CategoryDAO.Instance.DeleteCategory(idCate); if (result) { MessageBox.Show("Delete Successfully!"); LoadListCategory(); LoadCategoryBinding(cbFoodCategory); LoadListFood(); ReLoadCategory.Invoke(); LoadTable.Invoke(); } else { MessageBox.Show("Delete failed!"); } } }
private void btnUpdateCate_Click(object sender, EventArgs e) { bool result = false; string name = txtCateName.Text.Trim(); int idCate = Convert.ToInt32(txtCategoryID.Text.Trim()); bool existed = CategoryDAO.Instance.IsExistedCategory(name); if (txtCateName.Text.Equals("")) { MessageBox.Show("Empty input."); return; } if (MessageBox.Show(string.Format("Update this CategoryID: {0}?", idCate), "Notification!!!", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { if (existed) { MessageBox.Show("This category: " + name + " is existed."); return; } result = CategoryDAO.Instance.UpdateCategory(name, idCate); if (result) { MessageBox.Show("Update Successfully!"); LoadListCategory(); LoadCategoryBinding(cbFoodCategory); LoadListFood(); ReLoadCategory.Invoke(); } else { MessageBox.Show("Update failed!"); } } }