示例#1
0
        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!");
            }
        }
示例#2
0
        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!");
            }
        }
示例#3
0
        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!");
                }
            }
        }
示例#4
0
        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!");
                }
            }
        }
示例#5
0
        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!");
                }
            }
        }