コード例 #1
0
        public ActionResult ChuDe(string sapxep, string trang, string ma)
        {
            string machude = "1";

            if (ma != null && ma != "")
            {
                machude = ma;
            }
            int    soluongsach      = Sach_BUS.SoLuongSachCoTrongHeThongCuaMotChuDe(machude);
            int    sosachtrongtrang = 30;
            int    tranghientai     = 1;
            string cotsapxep        = "ngaydang";

            if (sapxep != null && sapxep != "")
            {
                cotsapxep = (string)sapxep;
            }
            if (trang != null && trang != "")
            {
                tranghientai = int.Parse(trang);
            }

            int sotrang = (int)Math.Ceiling((float)soluongsach / (float)sosachtrongtrang);

            if (tranghientai < 1)
            {
                tranghientai = 1;
            }
            else if (tranghientai > sotrang)
            {
                tranghientai = sotrang;
            }
            List <DauSachFull_DTO> dausachs = new List <DauSachFull_DTO>();

            if (sotrang > 0)
            {
                dausachs = Sach_BUS.DuyetKhoSachTheoChuDePhanTrang(machude, sosachtrongtrang, tranghientai, cotsapxep);
            }
            List <Sach_DTO> sachs = Sach_BUS.Top10DauSachXemNhieuNhatTheoMaChuDe(machude);
            ChuDe_DTO       chude = ChuDe_BUS.LayThongTinChiTietChuDeBoiMa(machude);

            ViewBag.soluongsach  = soluongsach;
            ViewBag.dausachs     = dausachs;
            ViewBag.tranghientai = tranghientai;
            ViewBag.sotrang      = sotrang;
            ViewBag.cotsapxep    = cotsapxep;
            ViewBag.sachs        = sachs;
            ViewBag.machude      = machude;
            ViewBag.chude        = chude;
            return(View("~/Views/ThuVien/KhoSach/ChuDe.cshtml"));
        }
コード例 #2
0
 public static bool Xoa(ChuDe_DTO CD)
 {
     try
     {
         con = DataProvider.KetNoi();
         string sTruyVan = string.Format("Delete From ChuDe where MaCD = '{0}'", CD.MaCD);
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #3
0
 public static bool Sua(ChuDe_DTO CD)
 {
     try
     {
         con = DataProvider.KetNoi();
         string sTruyVan = string.Format("Update ChuDe set TenCD = N'{0}' where MaSach='{1}'", CD.TenCD, CD.MaCD);
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #4
0
 public static bool Them(ChuDe_DTO CD)
 {
     try
     {
         string sTruyVan = string.Format("Insert into ChuDe(TenCD) values(N'{0}')", CD.TenCD);
         con = DataProvider.KetNoi();
         DataProvider.ThucThiTruyVanNonQuery(sTruyVan, con);
         DataProvider.DongKetNoi(con);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #5
0
ファイル: ChuDe_DAO.cs プロジェクト: dangngoctu/Re_LTW
        public static ChuDe_DTO LayThongTinChiTietChuDeBoiMa(string machude)
        {
            List <SqlParameter> paras = new List <SqlParameter>();

            paras.Add(new SqlParameter("@machude", machude));
            DataTable ketqua = SQLDataAccess.ThucThiSPTraVeKetQua("sp_LayDanhSachChuDe");

            if (ketqua.Rows.Count > 0)
            {
                ChuDe_DTO chude = new ChuDe_DTO();
                chude.Machude  = (string)ketqua.Rows[0]["machude"];
                chude.Tenchude = (string)ketqua.Rows[0]["tenchude"];
                return(chude);
            }
            return(null);
        }
コード例 #6
0
ファイル: ChuDe_DAO.cs プロジェクト: dangngoctu/Re_LTW
        public static List <ChuDe_DTO> LayDanhSachChuDe()
        {
            List <ChuDe_DTO> chudes = new List <ChuDe_DTO>();
            DataTable        ketqua = SQLDataAccess.ThucThiSPTraVeKetQua("sp_LayDanhSachChuDe");

            if (ketqua.Rows.Count > 0)
            {
                foreach (DataRow dong in ketqua.Rows)
                {
                    ChuDe_DTO chude = new ChuDe_DTO();
                    chude.Machude  = (string)dong["machude"];
                    chude.Tenchude = (string)dong["tenchude"];
                    chudes.Add(chude);
                }
            }
            return(chudes);
        }