コード例 #1
0
        public bool tra_TungSach(ref DTO_TRASACH dtots, int idsach)
        {
            BLL_Sach          bllsach    = new BLL_Sach();
            BLL_QuyDinh       bllquydinh = new BLL_QuyDinh();
            BLL_PhieuMuonSach bllphieums = new BLL_PhieuMuonSach();

            DataTable dtphieums = null;
            DateTime  datemuonsach = DateTime.Now;
            int       totalngaytra = 0, maxngaytra = 0, finetratre = 0, feethuesach = 0, feeboithuong = 0;

            try
            {
                dtphieums    = bllphieums.layCTMuonSach_ChuaTra(dtots.ID_USER, idsach);
                datemuonsach = Convert.ToDateTime(dtphieums.Rows[0]["CREATED_AT"].ToString());

                totalngaytra = DateTime.Now.Subtract(datemuonsach).Days;
                maxngaytra   = bllquydinh.layQuyDinh("So_Ngay_Muon_Toi_Da");
                finetratre   = bllquydinh.layQuyDinh("Tien_Phat");
                feethuesach  = bllquydinh.layQuyDinh("Tien_Muon_Sach");

                dtots.SONGAYTRE     += ((totalngaytra - maxngaytra > 0) ? (totalngaytra - maxngaytra) : 0);
                dtots.TIENTRE       += dtots.SONGAYTRE * finetratre;
                dtots.TIENBOITHUONG += 0;
                dtots.TIENTHUESACH  += feethuesach;
                dtots.TONGTIEN      += dtots.TIENTRE + dtots.TIENBOITHUONG + dtots.TIENTHUESACH;

                return(true);
            }
            catch (Exception ex)
            {
                //mess
            }

            return(false);
        }
コード例 #2
0
        public void tra_TungSach(ref DTO_TRASACH dtots, int idsach, int ishong)
        {
            BLL_Sach          bllsach    = new BLL_Sach();
            BLL_QuyDinh       bllquydinh = new BLL_QuyDinh();
            BLL_PhieuMuonSach bllphieums = new BLL_PhieuMuonSach();

            DTO_CHITIETMUONSACH dtoctms = null;
            DateTime            datemuonsach;
            int numngaytratre = 0, maxngaytra = 0, paymtratre = 0, feethuesach = 0, paymboithuong = 0;

            try
            {
                dtoctms      = bllphieums.layCTMuonSach_ChuaTra(dtots.ID_USER, idsach);
                datemuonsach = dtoctms.CREATED_AT;


                maxngaytra    = bllquydinh.layQuyDinh("So Ngay Muon Toi Da"); // 3
                paymtratre    = bllquydinh.layQuyDinh("Tien Phat");           // 1
                feethuesach   = bllquydinh.layQuyDinh("Tien Muon Sach");      // 2
                paymboithuong = bllquydinh.layQuyDinh("Tien Boi Thuong");     // 4

                numngaytratre = DateTime.Now.Subtract(datemuonsach).Days - maxngaytra;
                numngaytratre = (numngaytratre > 0 ? numngaytratre : 0);

                dtots.SONGAYTRE     += numngaytratre;
                dtots.TIENTRE       += numngaytratre * paymtratre;
                dtots.TIENBOITHUONG += ishong * paymboithuong;
                dtots.TIENTHUESACH  += feethuesach;
                dtots.TONGTIEN       = dtots.TIENTRE + dtots.TIENBOITHUONG + dtots.TIENTHUESACH;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        public bool themPhieuMuonSach(DTO_MUONSACH dtoms, List <int> lsmasach)
        {
            BLL_Sach    bllsach = new BLL_Sach();
            BLL_QuyDinh bllquydinh = new BLL_QuyDinh();
            int         maxsongaymuon = 0, totalphims = 0, feemuonsach = 0;

            maxsongaymuon = bllquydinh.layQuyDinh("So Ngay Muon Toi Da");
            feemuonsach   = bllquydinh.layQuyDinh("Tien Muon Sach");

            foreach (int idsach in lsmasach)
            {
                themCTP_MuonSach(dtoms.ID_USER, idsach);

                totalphims += feemuonsach;
            }

            dtoms.NGAYMUON   = DateTime.Today.Date.ToString("yyyy-MM-dd");
            dtoms.NGAYTRA    = DateTime.Today.AddDays(maxsongaymuon).Date.ToString("yyyy-MM-dd");
            dtoms.TONGTIEN   = totalphims;
            dtoms.TRANGTHAI  = 0;
            dtoms.CREATED_AT = DateTime.Now;
            dtoms.UPDATED_AT = DateTime.Now;

            return(dalphieums.themPhieuMuonSach(dtoms));

            return(false);
        }
コード例 #4
0
        public bool themPhieuTraSach(ref DTO_TRASACH dtots, List <int> lsmasach, int ctrltinhieu)
        {
            BLL_Sach          bllsach = new BLL_Sach();
            BLL_PhieuMuonSach bllphieums = new BLL_PhieuMuonSach();
            int idtrasach = 0, numsachhong = dtots.TIENBOITHUONG;

            khoiTao_DoiTuongTraSach(ref dtots);

            foreach (int idsach in lsmasach)
            {
                int ishong = (numsachhong-- > 0 ? 1 : 0);
                tra_TungSach(ref dtots, idsach, ishong);
            }

            if (ctrltinhieu == 1)
            {
                return(true);
            }

            idtrasach = dalphieuts.themPhieuTraSach(dtots);

            if (idtrasach > -1)
            {
                foreach (int idsach in lsmasach)
                {
                    themCTP_TraSach(idtrasach, idsach);
                    bllsach.suaTinhTrangSach(idsach, "Con Hang");
                    bllphieums.suaCTP_MuonSach(dtots.ID_USER, idsach);
                }

                bllphieums.tongKet_MuonSach(dtots.ID_USER);

                return(true);
            }

            return(false);
        }
コード例 #5
0
        public bool themPhieuMuonSach(DTO_MUONSACH dtoms, List <int> lsmasach)
        {
            BLL_Sach    bllsach = new BLL_Sach();
            BLL_QuyDinh bllquydinh = new BLL_QuyDinh();
            int         idmuonsach = 0, maxsongaymuon = 0, totalphims = 0, feemuonsach = 0;

            maxsongaymuon = bllquydinh.layQuyDinh("So Ngay Muon Toi Da"); // 3
            feemuonsach   = bllquydinh.layQuyDinh("Tien Muon Sach");      // 2

            foreach (int idsach in lsmasach)
            {
                totalphims += feemuonsach;
            }

            dtoms.NGAYMUON   = DateTime.Today.Date.ToString("yyyy-MM-dd");
            dtoms.NGAYTRA    = DateTime.Today.AddDays(maxsongaymuon).Date.ToString("yyyy-MM-dd");
            dtoms.TONGTIEN   = totalphims;
            dtoms.TRANGTHAI  = 0;
            dtoms.CREATED_AT = DateTime.Now;

            idmuonsach = dalphieums.themPhieuMuonSach(dtoms);


            if (idmuonsach > -1)
            {
                foreach (int idsach in lsmasach)
                {
                    themCTP_MuonSach(idmuonsach, idsach);
                    bllsach.suaTinhTrangSach(idsach, "Het Hang");
                }

                return(true);
            }

            return(false);
        }