Example #1
0
 public static void Them(string masanpham, string mataikhoan, string tensanpham, int soluong, int gia, string hinhchinh)
 {
     using (var db = new ConnectDBShopDB())
     {
         var listx = db.Query <GioHang>("SELECT * FROM GioHang WHERE MaTaiKhoan = '" + mataikhoan + "' AND MaSanPham = '" + masanpham + "'").ToList();
         if (listx.Count() > 0)
         {
             //tolist tao 1 bang,dem trong do neu > 0 thi da có sp. chi update len
             //Goi ham update so luong
             int sl = (int)listx.ElementAt(0).SoLuong + soluong;
             CapNhat(masanpham, mataikhoan, tensanpham, sl, gia, hinhchinh);
         }
         else//<0 thi tạo moi 1 gio hang
         {
             GioHang giohang = new GioHang()
             {
                 MaSanPham  = masanpham,
                 MaTaiKhoan = mataikhoan,
                 TenSanPham = tensanpham,
                 SoLuong    = soluong,
                 Gia        = gia,
                 HinhChinh  = hinhchinh,
                 TongTien   = gia * soluong
             };
             db.Insert(giohang);
         }
     }
 }
Example #2
0
        public static void ThemLSP(LoaiSanPham lsp)
        {
            var db = new ConnectDBShopDB();

            db.Insert(lsp);
        }
Example #3
0
        public static void InsertSP(SanPham sp)
        {
            var db = new ConnectDBShopDB();

            db.Insert(sp);
        }
Example #4
0
        //ADMIN
        public static void ThemNSX(NhaSanXuat nsx)
        {
            var db = new ConnectDBShopDB();

            db.Insert(nsx);
        }