private void btnUpdate_Click(object sender, EventArgs e) { try { if (txtid.Text != "") { KindOfDish dish = new KindOfDish(); dish.KindOfDishId = int.Parse(txtid.Text); dish.Name = txtName.Text; if (kind.UpdateKind(dish)) { MessageBox.Show("Sửa Thành công"); UploadData(); } else { MessageBox.Show("Sửa Thất Bại "); } } else { MessageBox.Show("Chọn Loại cần sửa"); } } catch (Exception ev) { MessageBox.Show("Lỗi " + ev.Message); } }
private void btnAdd_Click(object sender, EventArgs e) { KindOfDish dish = new KindOfDish(); dish.Name = txtName.Text; kind.AddKind(dish); UploadData(); }
public bool AddKind(KindOfDish kd) { try { using (MR = new ManagerResterant()) { MR.KindOfDishes.Add(kd); MR.SaveChanges(); return(true); } } catch (Exception e) { MessageBox.Show(e.Message); return(false); } }
public bool DeleteKind(int id) { try { using (MR = new ManagerResterant()) { KindOfDish d = MR.KindOfDishes.Find(id); MR.KindOfDishes.Remove(d); MR.SaveChanges(); return(true); } } catch (Exception e) { MessageBox.Show(e.Message); return(false); } }
public bool UpdateKind(KindOfDish kd) { try { using (MR = new ManagerResterant()) { KindOfDish d = MR.KindOfDishes.SingleOrDefault(x => x.KindOfDishId == kd.KindOfDishId); d.Name = kd.Name; MR.SaveChanges(); return(true); } } catch (Exception e) { MessageBox.Show(e.Message); return(false); } }
public bool UpdateKind(KindOfDish d) { return(new KindOfDishDataAccess().UpdateKind(d)); }
public bool AddKind(KindOfDish d) { return(new KindOfDishDataAccess().AddKind(d)); }