예제 #1
0
 public static LOAISANPHAM GetCategory(int id)
 {
     using (var db = new shopDB())
     {
         return(db.SingleOrDefault <LOAISANPHAM>("select * from LOAISANPHAM where MaLoaiSanPham = @0", id));
     }
 }
예제 #2
0
 public static SANPHAM GetProduct(int id)
 {
     using (var db = new shopDB())
     {
         return(db.SingleOrDefault <SANPHAM>("select * from SANPHAM where MaSanPham = @0", id));
     }
 }
예제 #3
0
 public static void UpdateCategory(LOAISANPHAM lsp)
 {
     using (var db = new shopDB())
     {
         db.Update <LOAISANPHAM>("SET TenLoaiSanPham=@0 WHERE MaLoaiSanPham=@1", lsp.TenLoaiSanPham, lsp.MaLoaiSanPham);
     }
 }
예제 #4
0
 public static void Delete(int id)
 {
     try
     {
         using (var db = new shopDB())
         {
             db.Execute("delete from LOAISANPHAM where MaLoaiSanPham = @0", id);
         }
     }
     catch
     {
     }
 }
예제 #5
0
 public static void UpdateProduct(SANPHAM Sp, int valueImg)
 {
     if (valueImg == 0)
     {
         using (var db = new shopDB())
         {
             db.Update <SANPHAM>("SET TenSanPham=@0, Gia=@1, GiamGia=@2,MoTa=@3, LoaiSp=@4 WHERE MaSanPham=@5", Sp.TenSanPham, Sp.Gia, Sp.GiamGia, Sp.MoTa, Sp.LoaiSp, Sp.MaSanPham);
         }
     }
     else
     {
         using (var db = new shopDB())
         {
             db.Update <SANPHAM>("SET TenSanPham=@0, Gia=@1, GiamGia=@2, HinhAnh=@3, MoTa=@4, LoaiSp=@5 WHERE MaSanPham=@6", Sp.TenSanPham, Sp.Gia, Sp.GiamGia, Sp.HinhAnh, Sp.MoTa, Sp.LoaiSp, Sp.MaSanPham);
         }
     }
 }
예제 #6
0
        public static IEnumerable <LOAISANPHAM> List()
        {
            var db = new shopDB();

            return(db.Query <LOAISANPHAM>("select * from loaisanpham"));
        }
예제 #7
0
        public static Page <SANPHAM> SanPham(int pagenume, int itemperpage, int id)
        {
            var db = new shopDB();

            return(db.Page <SANPHAM>(pagenume, itemperpage, "select * from sanpham where LoaiSP = @0", id));
        }
예제 #8
0
        public static SANPHAM GetProduct(int id)
        {
            var db = new shopDB();

            return(db.SingleOrDefault <SANPHAM>("select * from sanpham where MaSanPham = @0", id));
        }