public static bool xoaMonAnTrongBangMonAn(DataTable tableMonAn, string tenMonAn) { if (MonAnBLL.LayMaMonAnTheoTen(tenMonAn) == "") { MessageBox.Show("Món ăn đã nhập không tồn tại\nVui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK); return(false); } if (tenMonAn == "") { MessageBox.Show("Chưa chọn món ăn để xóa", "Thông báo", MessageBoxButtons.OK); return(false); } if (tableMonAn.Rows.Find(tenMonAn) == null) { MessageBox.Show("Món ăn không tồn tại trong bảng", "Thông báo", MessageBoxButtons.OK); return(false); } DataRow row = tableMonAn.NewRow(); row["TenMonAn"] = tenMonAn; row["NangLuong"] = MonAnBLL.LayNangLuongMonAnTheoTen(tenMonAn); tableMonAn.Rows.Remove(tableMonAn.Rows.Find(tenMonAn)); return(true); }
public static bool themMonAnTrongBangMonAn(DataTable tableMonAn, string tenMonAn) { if (MonAnBLL.LayMaMonAnTheoTen(tenMonAn) == "") { MessageBox.Show("Món ăn đã nhập không tồn tại\nVui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK); return(false); } if (tableMonAn.Rows.Count >= 6) { MessageBox.Show("Không thể thêm món\nChỉ được chọn tối đa 6 món ăn cho một bữa ăn", "Thông báo", MessageBoxButtons.OK); return(false); } if (tableMonAn.Rows.Find(tenMonAn) != null) { MessageBox.Show("Món ăn đã tồn tại trong bảng", "Thông báo", MessageBoxButtons.OK); return(false); } DataRow row = tableMonAn.NewRow(); row["TenMonAn"] = tenMonAn; row["NangLuong"] = MonAnBLL.LayNangLuongMonAnTheoTen(tenMonAn); tableMonAn.Rows.Add(row); return(true); }
public static void getListMonAn(List <string> listMonAn, DataGridView dgv) { listMonAn.Clear(); for (int i = 0; i < dgv.RowCount; i++) { listMonAn.Add(MonAnBLL.LayMaMonAnTheoTen(dgv.Rows[i].Cells["TenMonAn"].Value.ToString().Trim())); } }