コード例 #1
0
 public bool ThemMoiSanPham(SanPham_OBJ obj)
 {
     try
     {
         db.SanPhams.Add(MapperBase(obj));
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
 public bool CapNhapSanPham(SanPham_OBJ obj)
 {
     try
     {
         Base.SanPham sanPham = MapperBase(obj);
         db.Entry(sanPham).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #3
0
 public Base.SanPham MapperBase(SanPham_OBJ obj)
 {
     Base.SanPham bs = new Base.SanPham()
     {
         MaSanPham     = obj.MaSanPham,
         TenSanPham    = obj.TenSanPham,
         SoLuongTon    = obj.SoLuongTon,
         DonGia        = obj.DonGia,
         MoTa          = obj.MoTa,
         AnhBia        = obj.AnhBia,
         MaLoaiSanPham = obj.MaLoaiSanPham,
         MaNhaSanXuat  = obj.MaNhaSanXuat,
         HienThi       = obj.HienThi
     };
     return(bs);
 }
コード例 #4
0
        public SanPham_OBJ Mapper(Base.SanPham item)
        {
            SanPham_OBJ obj = new SanPham_OBJ()
            {
                MaSanPham     = item.MaSanPham,
                TenSanPham    = item.TenSanPham,
                SoLuongTon    = item.SoLuongTon,
                DonGia        = item.DonGia,
                MoTa          = item.MoTa,
                AnhBia        = item.AnhBia,
                MaLoaiSanPham = item.MaLoaiSanPham,
                MaNhaSanXuat  = item.MaNhaSanXuat,
                HienThi       = item.HienThi
            };

            return(obj);
        }