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); } } }
public static void ThemLSP(LoaiSanPham lsp) { var db = new ConnectDBShopDB(); db.Insert(lsp); }
public static void InsertSP(SanPham sp) { var db = new ConnectDBShopDB(); db.Insert(sp); }
//ADMIN public static void ThemNSX(NhaSanXuat nsx) { var db = new ConnectDBShopDB(); db.Insert(nsx); }