public static DonDatHang LayMaDh(string username) { var db = new SmartShopConnectionDB(); var madh = db.SingleOrDefault <DonDatHang>("SELECT TOP 1 * FROM DonDatHang WHERE Username=@0 ORDER BY MaDH DESC", username); return(madh); }
public static Comment ChiTiet(string idUser) { var db = new SmartShopConnectionDB(); var cmt = db.SingleOrDefault <Comment>("SELECT TOP 1 * FROM [DAn_Web2].[dbo].[Comment] WHERE UserCmt=@0 ORDER BY IDCmt DESC", idUser); return(cmt); }
public static Loai ChiTiet(string id) { var db = new SmartShopConnectionDB(); var l = db.SingleOrDefault <Loai>("SELECT * FROM loai WHERE MaLoai=@0", id); l.dsCL = ChungLoaiBus.DanhSach(); return(l); }
public static Product ChiTiet(string id) { var db = new SmartShopConnectionDB(); var sp = db.SingleOrDefault <Product>("SELECT * FROM Product WHERE MaSP=@0", id); sp.dsLoai = LoaiBus.DanhSach(); sp.LuotXem = sp.LuotXem + 1; db.Update("Product", "MaSP", sp); return(sp); }
public static void Xoa(string us) { var db = new SmartShopConnectionDB(); var user = db.SingleOrDefault <viewUser>("SELECT * FROM viewUser where UserName=@0", us); string id = user.UserId; db.Execute("DELETE FROM AspNetUserRoles WHERE UserId=@0", id); db.Execute("DELETE FROM AspNetUsers WHERE UserName=@0", us); db.Execute("DELETE FROM Accounts WHERE UserName=@0", us); }
public static void PhanQuyen(string us) { var db = new SmartShopConnectionDB(); var user = db.SingleOrDefault <viewUser>("SELECT * FROM viewUser where UserName=@0", us); AspNetUserRole pq = new AspNetUserRole(); pq.RoleId = "12629e90-6c15-424b-abaa-164250682d15"; pq.UserId = user.UserId; db.Insert("AspNetUserRoles", pq); }
public static void Them(DonDatHang dh, List <ChiTietDH> ctdh, string username) { var db = new SmartShopConnectionDB(); db.Insert("DonDatHang", "MaDH", dh); var madh = db.SingleOrDefault <DonDatHang>("SELECT TOP 1 * FROM DonDatHang WHERE Username=@0 ORDER BY MaDH DESC", username); foreach (var item in ctdh) { item.MaDH = madh.MaDH; db.Insert("ChiTietDH", "MaDH", item); } }
public static Account Admin(string us) { var db = new SmartShopConnectionDB(); return(db.SingleOrDefault <Account>("SELECT R.Name FROM Accounts A,AspNetUsers Us,AspNetUserRoles UR,AspNetRoles R WHERE A.UserName=@0 AND A.UserName=Us.UserName AND Us.Id=UR.UserId AND UR.RoleId=R.Id", us)); }
public static Account ChiTiet(string us) { var db = new SmartShopConnectionDB(); return(db.SingleOrDefault <Account>("SELECT * FROM Accounts WHERE UserName=@0", us)); }
public static ChungLoai ChiTiet(int id) { var db = new SmartShopConnectionDB(); return(db.SingleOrDefault <ChungLoai>("SELECT * FROM chungloai WHERE MaCL=@0", id)); }