public QL_SanPham(QL_SanPham sp, string tenloai) { this.MaSP = sp.MaSP; this.TenSanPham = sp.TenSanPham; this.TinhTrang = sp.TinhTrang; this.TenLoai = tenloai; this.Hinh = sp.Hinh; this.Gia = sp.Gia; this.MaLoaiSP = sp.MaLoaiSP; }
private bool ktSLNL(QL_SanPham sp) { foreach (QL_NguyenLieu_SanPham item in qlsp.QL_NguyenLieu_SanPhams.Where(t => t.MaSP == sp.MaSP)) { QL_NguyenLieu nl = qlsp.QL_NguyenLieus.SingleOrDefault(t => t.MaNL == item.MaNL); if (nl.SoLuong == 0) { return(false); } } return(true); }
public bool themSanPham(QL_SanPham sp, List <QL_NguyenLieu_SanPham> lstNLSP) { try { qlsp.QL_SanPhams.InsertOnSubmit(sp); foreach (QL_NguyenLieu_SanPham item in lstNLSP) { qlsp.QL_NguyenLieu_SanPhams.InsertOnSubmit(item); } return(true); } catch (Exception) { return(false); throw; } }
public bool xoaSP(string maSP) { QL_SanPham sp = qlsp.QL_SanPhams.SingleOrDefault(t => t.MaSP == maSP); try { if (qlsp.QL_SanPhams.Count(t => t.MaSP == sp.MaSP) != 0) { xoaHetNLcuaSP(sp.MaSP); } qlsp.QL_SanPhams.DeleteOnSubmit(sp); submitChange(); return(true); } catch (Exception) { return(false); } }
public bool suaSanPham(QL_SanPham sp, List <QL_NguyenLieu_SanPham> lstNLSP) { try { QL_SanPham currentSP = qlsp.QL_SanPhams.Single(t => t.MaSP == sp.MaSP); if (currentSP == null) { return(false); } currentSP.TenSanPham = sp.TenSanPham; currentSP.Gia = sp.Gia; currentSP.Hinh = sp.Hinh; currentSP.TinhTrang = sp.TinhTrang; currentSP.MaLoaiSP = sp.MaLoaiSP; qlsp.SubmitChanges(); if (lstNLSP.Count == 0) { return(true); } // xoa het nguyen lieu cap nhap lai xoaHetNLcuaSP(currentSP.MaSP); foreach (QL_NguyenLieu_SanPham item in lstNLSP) { qlsp.QL_NguyenLieu_SanPhams.InsertOnSubmit(item); } return(true); } catch (Exception) { return(false); throw; } }