Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
        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));
        }
Пример #9
0
        public static Account ChiTiet(string us)
        {
            var db = new SmartShopConnectionDB();

            return(db.SingleOrDefault <Account>("SELECT * FROM Accounts WHERE UserName=@0", us));
        }
Пример #10
0
        public static ChungLoai ChiTiet(int id)
        {
            var db = new SmartShopConnectionDB();

            return(db.SingleOrDefault <ChungLoai>("SELECT * FROM chungloai WHERE MaCL=@0", id));
        }