Example #1
0
        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();
        }
Example #2
0
 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);
     }
 }
Example #3
0
 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);
     }
 }
Example #4
0
        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);
            }
        }
Example #5
0
 private void detach_CT_DDHs(CT_DDH entity)
 {
     this.SendPropertyChanging();
     entity.SanPham = null;
 }
Example #6
0
 private void attach_CT_DDHs(CT_DDH entity)
 {
     this.SendPropertyChanging();
     entity.SanPham = this;
 }
Example #7
0
 private void detach_CT_DDHs(CT_DDH entity)
 {
     this.SendPropertyChanging();
     entity.DonDatHang = null;
 }
Example #8
0
 private void attach_CT_DDHs(CT_DDH entity)
 {
     this.SendPropertyChanging();
     entity.DonDatHang = this;
 }
Example #9
0
 partial void DeleteCT_DDH(CT_DDH instance);
Example #10
0
 partial void UpdateCT_DDH(CT_DDH instance);
Example #11
0
 partial void InsertCT_DDH(CT_DDH instance);