public static bool KiemTraSLT(string MaSP, int SL) { DataTable dt = SanPhamBUS.DanhSachSPTheoMa(MaSP); int soluongton = 0, hieu; foreach (DataRow row in dt.Rows) { soluongton = (int)row["SoLuongTon"]; } hieu = soluongton - SL; if (hieu < 0) { return(false); } else { return(true); } }
public bool suaSL(DataTable dtChiTietDonHang) { foreach (DataRow CTDonHang in dtChiTietDonHang.Rows) { SanPhamPublic SP = new SanPhamPublic(); SanPhamBUS spbus = new SanPhamBUS(); try { SP.MASP = CTDonHang.Field <string>("MaSP"); int slcu = spbus.LaySanPham(SP).SOLUONG; int slt = CTDonHang.Field <int>("SoLuong"); SP.SOLUONG = slcu - slt; spbus.capnhatsoluong(SP); } catch (Exception ex) { throw ex; } } return(true); }