public List <CT_DDH> GetListCT_DDH() { List <CT_DDH> list = new List <CT_DDH> { }; var query = from ord in db.DonDatHangs from pro in db.SanPhams join d in db.CT_DDHs on new { ord.MaDDH, pro.MaSP } equals new { d.MaDDH, d.MaSP } into details from d in details select new { ord.MaDDH, pro.MaSP, d.DonGia, d.SoLuong }; //List<CT_DDH> list = db.CT_DDHs.ToList(); //foreach (CT_DDH ct in list) //{ // ct.SanPham = null; // ct.DonDatHang = null; //} foreach (var item in query) { CT_DDH ct = new CT_DDH(); ct.MaSP = item.MaSP; ct.MaDDH = item.MaDDH; ct.DonGia = item.DonGia; ct.SoLuong = item.SoLuong; list.Add(ct); } return(list); //return db.CT_DDHs.ToList(); }
public bool DeleteCT_DDH(int maddh, int masp) { try { CT_DDH m = db.CT_DDHs.Single(ddh => ddh.MaDDH == maddh && ddh.MaSP == masp); db.CT_DDHs.DeleteOnSubmit(m); db.SubmitChanges(); return(true); } catch { return(false); } }
public bool UpdateCT_DDH(int maddh, int masp, int soluong, int dongia) { try { CT_DDH m = db.CT_DDHs.Single(ddh => ddh.MaDDH == maddh && ddh.MaSP == masp); m.SoLuong = soluong; m.DonGia = dongia; db.SubmitChanges(); return(true); } catch { return(false); } }
public bool InsertCT_DDH(int maddh, int masp, int soluong, int dongia) { try { CT_DDH m = new CT_DDH(); m.MaDDH = maddh; m.MaSP = masp; m.SoLuong = soluong; m.DonGia = dongia; db.CT_DDHs.InsertOnSubmit(m); db.SubmitChanges(); return(true); // thêm thành công } catch { return(false); } }
private void detach_CT_DDHs(CT_DDH entity) { this.SendPropertyChanging(); entity.SanPham = null; }
private void attach_CT_DDHs(CT_DDH entity) { this.SendPropertyChanging(); entity.SanPham = this; }
private void detach_CT_DDHs(CT_DDH entity) { this.SendPropertyChanging(); entity.DonDatHang = null; }
private void attach_CT_DDHs(CT_DDH entity) { this.SendPropertyChanging(); entity.DonDatHang = this; }
partial void DeleteCT_DDH(CT_DDH instance);
partial void UpdateCT_DDH(CT_DDH instance);
partial void InsertCT_DDH(CT_DDH instance);