private void btnDataGrid_Click(object sender, EventArgs e) { foodSizeBindingSource.DataSource = Food_SizeBUS.GetAll(); foodTypeBindingSource.DataSource = Food_TypeBUS.GetAll(); combSizeFilter.DataSource = Food_SizeBUS.GetAll(); combTypeFilter.DataSource = Food_TypeBUS.GetAll(); foodDishBindingSource.DataSource = Food_DishBUS.GetAll(); }
private void btnCancel_Click(object sender, EventArgs e) { panCRUD.Enabled = true; panSave.Enabled = false; panFilter.Enabled = true; dataGridDish.Enabled = true; foodDishBindingSource.DataSource = Food_DishBUS.GetAll(); }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure want to delete this dish ?", "Waring", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Food_Dish fdish = foodDishBindingSource.Current as Food_Dish; Food_DishBUS.delete(fdish); foodDishBindingSource.DataSource = Food_DishBUS.GetAll(); } }
private void btnDataGridRef_Click(object sender, EventArgs e) { foodSizeBindingSource.DataSource = Food_SizeBUS.GetAll(); foodTypeBindingSource.DataSource = Food_TypeBUS.GetAll(); combSizeFilter.DataSource = Food_SizeBUS.GetAll(); combTypeFilter.DataSource = Food_TypeBUS.GetAll(); foodDishBindingSource.DataSource = Food_DishBUS.dish_NotLocked(); txtSearchName.Clear(); }
private void btnChangeQuan_Click(object sender, EventArgs e) { CusOrders cusO = cusOrdersBindingSource.Current as CusOrders; Food_Dish fd = Food_DishBUS.GetByName(cusO.name); CusOrders cusOder = CusOrderBUS.GetByName(cusO.name); int tempDish = 0; int changeQuan = int.Parse(txtChangeQuan.Text); if (changeQuan == 0 || txtChangeQuan.Text == " " || txtChangeQuan.Text == "") { MessageBox.Show("Number of dish can not be 0!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtChangeQuan.Clear(); txtChangeQuan.Focus(); foodDishBindingSource.DataSource = Food_DishBUS.dish_NotLocked(); return; } else { if (cusO != null) { if (changeQuan > fd.stock) { MessageBox.Show("Only " + fd.stock + "left!", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Error); cusOrdersBindingSource.DataSource = CusOrderBUS.GetAll(); return; } else { if (changeQuan > cusOder.numberDish) { tempDish = changeQuan - cusOder.numberDish; CusOrderBUS.changeQuantity(cusO); Food_DishBUS.stockCalulate(fd.Id, tempDish, true); foodDishBindingSource.DataSource = Food_DishBUS.dish_NotLocked(); labelCost.Text = CusOrderBUS.TotalCost().ToString() + "$"; } else { tempDish = cusOder.numberDish - changeQuan; CusOrderBUS.changeQuantity(cusO); Food_DishBUS.stockCalulate(fd.Id, tempDish, false); foodDishBindingSource.DataSource = Food_DishBUS.dish_NotLocked(); labelCost.Text = CusOrderBUS.TotalCost().ToString() + "$"; } } } else { return; } } }
private void btnSearch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchName.Text)) { return; } else { string fName = txtSearchName.Text; foodDishBindingSource.DataSource = Food_DishBUS.search(fName); txtSearchName.Clear(); txtSearchName.Focus(); } }
private void btnLock_Unclock_Click(object sender, EventArgs e) { Food_Dish fd = foodDishBindingSource.Current as Food_Dish; if (fd == null) { return; } else { int id = fd.Id; Food_DishBUS.dishLock_Unlock(id); foodDishBindingSource.DataSource = Food_DishBUS.GetAll(); } }
private void btnDelete_Click(object sender, EventArgs e) { CusOrders cusOrder = cusOrdersBindingSource.Current as CusOrders; CusOrders cusO = CusOrderBUS.GetByName(cusOrder.name); Food_Dish fd = Food_DishBUS.GetByName(cusO.name); if (cusOrder != null) { Food_DishBUS.stockCalulate(fd.Id, cusO.numberDish, false); CusOrderBUS.delete(cusOrder); cusOrdersBindingSource.RemoveCurrent(); labelCost.Text = CusOrderBUS.TotalCost().ToString() + "$"; foodDishBindingSource.DataSource = Food_DishBUS.dish_NotLocked(); } else { if (MessageBox.Show("List is empty! Please choose your food.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { dataDishView.Focus(); } return; } }
private void btnSave_Click(object sender, EventArgs e) { Food_Dish fdish = foodDishBindingSource.Current as Food_Dish; Food_Size fsize = foodSizeBindingSource.Current as Food_Size; Food_Type ftype = foodTypeBindingSource.Current as Food_Type; string sizeName = fsize.name; string typeName = ftype.nameType; string D_Name = txtD_Name.Text; double D_Price = double.Parse(txtD_Price.Text); string D_Descript = txtD_Description.Text; string D_ImageURL = fdish.imaGeURL; int D_Stock = int.Parse(txtStock.Text); int D_Id = fdish.Id; if (fdish == null) { MessageBox.Show("Nothing to edit!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); foodDishBindingSource.DataSource = Food_DishBUS.GetAll(); return; } else { if (string.IsNullOrEmpty(txtD_Name.Text) || string.IsNullOrEmpty(txtD_Price.Text) || string.IsNullOrEmpty(txtD_Description.Text)) { MessageBox.Show("Please type all the information!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (fdish.Id == 0) { if (Food_DishBUS.chekName(txtD_Name.Text)) { MessageBox.Show("This name is already exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtD_Name.Clear(); txtD_Price.Clear(); txtD_Description.Clear(); } else { Food_DishBUS.insert(D_Name, D_Price, D_Descript, D_ImageURL, typeName, sizeName, D_Stock); MessageBox.Show("Insert successfully!", "Insert dish name", MessageBoxButtons.OK, MessageBoxIcon.Information); foodDishBindingSource.DataSource = Food_DishBUS.GetAll(); foodDishBindingSource.MoveLast(); panCRUD.Enabled = true; panFilter.Enabled = true; panSave.Enabled = false; dataGridDish.Enabled = true; } } else { Food_DishBUS.edit(fdish, D_Name, D_Price, D_Descript, D_ImageURL, typeName, sizeName, D_Id, D_Stock); MessageBox.Show("Update successfully!", "Update dish name", MessageBoxButtons.OK, MessageBoxIcon.Information); foodDishBindingSource.DataSource = Food_DishBUS.GetAll(); panCRUD.Enabled = true; panSave.Enabled = false; panFilter.Enabled = true; dataGridDish.Enabled = true; } } } }
private void combSizeFilter_SelectedIndexChanged(object sender, EventArgs e) { int sizId = int.Parse(combSizeFilter.SelectedValue.ToString()); foodDishBindingSource.DataSource = Food_DishBUS.D_SizeFilter(sizId); }
private void btnSearch_Click(object sender, EventArgs e) { foodDishBindingSource.DataSource = Food_DishBUS.search(txtSearch.Text); txtSearch.Clear(); }
private void btnOrder_Click(object sender, EventArgs e) { cusOrdersBindingSource.Add(new CusOrders()); cusOrdersBindingSource.MoveLast(); Food_Dish fd = foodDishBindingSource.Current as Food_Dish; if (fd != null) { Regex pattern = new Regex(@"[0-9]"); if (pattern.IsMatch(txtNumberD.Text)) { string dName = fd.name; double dPrice = fd.price; int quantity; DateTime orderdate = DateTime.Now; if (int.TryParse(txtNumberD.Text, out quantity)) { if (CusOrderBUS.check_DishExist(dName) == false) { if (fd.stock < quantity) { MessageBox.Show("Only " + fd.stock + "left!", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumberD.Focus(); } else { CusOrderBUS.insert(dName, dPrice, quantity, orderdate); cusOrdersBindingSource.MoveLast(); cusOrdersBindingSource.DataSource = CusOrderBUS.GetAll(); labelCost.Text = CusOrderBUS.TotalCost().ToString() + "$"; txtNumberD.Clear(); Food_DishBUS.stockCalulate(fd.Id, quantity, true); foodDishBindingSource.DataSource = Food_DishBUS.dish_NotLocked(); } } else { MessageBox.Show("This food is already in your list! Please chood another food.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); dataDishView.Focus(); cusOrdersBindingSource.RemoveCurrent(); } } else { MessageBox.Show("Wrong number! Please type your number again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtNumberD.Focus(); cusOrdersBindingSource.RemoveCurrent(); } } else { if (MessageBox.Show("Please type the quantity of your dish!", "Missing your dish quantity!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information) == DialogResult.Retry) { cusOrdersBindingSource.MoveLast(); txtNumberD.Focus(); txtNumberD.Select(); cusOrdersBindingSource.RemoveCurrent(); } } } else { if (MessageBox.Show("Pleas choose your dish!", "Your order is empty!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information) == DialogResult.Retry) { txtNumberD.Clear(); dataDishView.Focus(); cusOrdersBindingSource.RemoveCurrent(); } } }