private void LoadFoodInfo(int foodId) { Food objFood = FoodBusiness.GetFoodFromId(foodId); txtFoodName.Text = objFood.Name.ToString(); ID = foodId; }
private void btnEditFood_Click(object sender, EventArgs e) { double foodPrice = Double.Parse(txtFoodPrice.Text); bool ketQua = FoodBusiness.EditFoodPrice(ID, foodPrice); if (ketQua) { this.Close(); } }
private FoodBusiness ConsumedFoodReminder() { FoodBusiness food = new FoodBusiness(); UserModel userInfo = authenticate.GetUserInfoFromSession(); food.RemindThings = food.GetRemindedThings(userInfo.HomeId); if (food.RemindThings.Count == 0) { food.Message = "Nothing consumed"; } return(food); }
private void PrintFoodReminds() { FoodBusiness foodOps = ConsumedFoodReminder(); foreach (var item in foodOps.RemindThings) { FoodModel food = (FoodModel)item; divFoodInfo.InnerHtml += "<div class=\"row\">"; divFoodInfo.InnerHtml += string.Format("<div class=\"col-md-4\">{0}</div>", food.FoodName); divFoodInfo.InnerHtml += string.Format("<div class=\"col-md-4\">{0}</div>", food.BuyDate.ToShortDateString()); divFoodInfo.InnerHtml += string.Format("<div class=\"col-md-4\">{0}</div>", food.ConsumedDate.ToShortDateString()); divFoodInfo.InnerHtml += "</div>"; } }
protected void btnSave_Click(object sender, EventArgs e) { try { UserModel userInfo = authenticate.GetUserInfoFromSession(); FoodBusiness food = new FoodBusiness(txbFoodName.Text, Convert.ToDateTime(txbBuyDate.Text), Convert.ToDateTime(txbBestBeforeDate.Text), userInfo.HomeId); food.SaveFood(); spnMessage.InnerText = "Food successfully has been saved!"; spnMessage.Attributes.Add("class", "label label-success"); } catch (Exception ex) { spnMessage.InnerText = ex.Message; spnMessage.Attributes.Add("class", "label label-danger"); } }
private void btnDeleteFood_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Bạn có chắn chắn muốn xóa không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { int foodId; foodId = (int)dtgFood.CurrentRow.Cells[0].Value; bool ketQua = FoodBusiness.DeleteFood(foodId); if (ketQua) { LoadFoodList(); } } }
private void btnAddFood_Click(object sender, EventArgs e) { string foodName = txtFoodName.Text; double foodPrice = Double.Parse(txtFoodPrice.Text); bool ketQua = false; if (String.IsNullOrEmpty(txtFoodName.Text) && String.IsNullOrEmpty(txtFoodPrice.Text)) { MessageBox.Show("Bạn chưa điền đủ hoặc điều sai thông tin cần nhập!", "Thông báo"); } else { ketQua = FoodBusiness.AddFood(foodName, foodPrice); } if (ketQua) { MessageBox.Show("Thêm thông tin món ăn thành công!", "Thông báo"); this.Close(); } }
public void LoadFoodListToComboBox() { cboFoodName.DataSource = FoodBusiness.GetFoodList(); cboFoodName.DisplayMember = "Name"; }
public void LoadFoodList() { dtgFood.DataSource = FoodBusiness.GetFoodList(); }