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); }
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); } }
public bool themPhieuTraSach(ref DTO_TRASACH dtots, List <int> lsmasach) { BLL_PhieuMuonSach bllphieums = new BLL_PhieuMuonSach(); khoiTao_DoiTuongTraSach(ref dtots); foreach (int idsach in lsmasach) { tra_TungSach(ref dtots, idsach); themCTP_TraSach(idsach); bllphieums.suaCTP_MuonSach(dtots.ID_USER, idsach); } bllphieums.tongKet_MuonSach(dtots.ID_USER); return(dalphieuts.themPhieuTraSach(dtots)); }
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); }