// hien thi list dto public bool danhsachCTPT(List <ctptDTO> listctptDTO) { string query = string.Format("select* from [ct_phieumuon] "); SqlParameter[] parm = new SqlParameter[1]; // ko can thiet nhung phai co docgiaDTO dg = new docgiaDTO(); parm[0] = new SqlParameter("@masach", SqlDbType.Int); parm[0].Value = dg.MaThe; DataTable datatable = new DataTable(); datatable = conn.excuteNonQuery(query, parm); //gan value trong datatable vao DTO foreach (DataRow dr in datatable.Rows) { ctptDTO ctphieutraDTO = new ctptDTO(); ctphieutraDTO.Mapt = Int32.Parse(dr["mapt"].ToString()); ctphieutraDTO.Masach = Int32.Parse(dr["masach"].ToString()); ctphieutraDTO.Songaydamuon = Int32.Parse(dr["songaydamuon"].ToString()); ctphieutraDTO.Tienphatsach = Int32.Parse(dr["tienphatsach"].ToString()); listctptDTO.Add(ctphieutraDTO); } return(true); }
public dongPhieuTra(ctptDTO ctpt) { InitializeComponent(); lbMaSach.Text = ctpt.Masach.ToString(); lbTenSach.Text = new QuanLiSachBUS().Timsachtheoma(ctpt.Masach).Tensach; lbSoNgayDaMuon.Text = ctpt.Songaydamuon.ToString(); lbTienPhatChoSach.Text = ctpt.Tienphatsach.ToString(); }
private void initDongPhieuTra(ctptDTO ctpt) { dongPhieuTra dongPhieuTra = new dongPhieuTra(ctpt); dongPhieuTra.chkChonSach.Enabled = false; listDongPhieuTra.Add(dongPhieuTra); dongPhieuTra.Location = new Point(3, 3 + dongPhieuTra.Height * (listDongPhieuTra.Count() - 1)); pnDanhSachSachTra.Controls.Add(dongPhieuTra); }
public bool themCTPT(ctptDTO ctptDTO) { string query = string.Format("insert into [ct_phieutra] values( @songaydamuon,@tienphatsach, @mapt, @masach)"); SqlParameter[] param = new SqlParameter[4]; param[0] = new SqlParameter("@songaydamuon", SqlDbType.Int); param[0].Value = Convert.ToString(ctptDTO.Songaydamuon); param[1] = new SqlParameter("@tienphatsach", SqlDbType.Int); param[1].Value = Convert.ToString(ctptDTO.Tienphatsach); param[2] = new SqlParameter("@mapt", SqlDbType.Int); param[2].Value = Convert.ToString(ctptDTO.Mapt); param[3] = new SqlParameter("@masach", SqlDbType.Int); param[3].Value = Convert.ToString(ctptDTO.Masach); conn.excuteNonQuery2(query, param); return(true); }
/// <summary> /// Trả sách /// </summary> /// <param name="bandoc">Mã bạn đọc </param> /// <param name="sachs">danh sách các bạn đọc </param> /// <returns></returns> public List <ctptDTO> TraSach(docgiaDTO bandoc, List <sachDTO> sachtra) { docgiaDAL banDocDAL = new docgiaDAL(); sachDAL sachDAL = new sachDAL(); quydinhDAL quyDinhDAL = new quydinhDAL(); phieutraDAL phieutraDAL = new phieutraDAL(); ctptDAL ctptDAL = new ctptDAL(); giahanDAL giaHanDAL = new giahanDAL(); List <sachDTO> sachdangmuon = new List <sachDTO>(); List <DateTime> danhsachngaymuonsach = new List <DateTime>(); List <phieutraDTO> danhsachphieutra = new List <phieutraDTO>(); List <ctptDTO> danhsachchitietphieutra = new List <ctptDTO>(); quydinhDTO danhsachquydinh = new quydinhDTO(); quydinhDTO quydinh = new quydinhDTO(); quyDinhDAL.listquydinh(danhsachquydinh); quydinh = danhsachquydinh; sachDAL.SachDangMuon(bandoc.MaThe, sachdangmuon, danhsachngaymuonsach); phieutraDAL.danhsachPhieuTra(danhsachphieutra); //Thêm phiếu trả phieutraDTO phieutra = new phieutraDTO(); phieutra.Mapt = danhsachphieutra.Count + 1; phieutra.Mathe = bandoc.MaThe; phieutra.Ngaytra = DateTime.Now; phieutra.Tienphatkinay = 0; phieutraDAL.themPhieuTra(phieutra); int tienphatkinay = 0; foreach (sachDTO saxtra in sachtra) { giahanDTO giaHanDTO = new giahanDTO(); giaHanDAL.laygiahancuasach(saxtra.Masach, giaHanDTO); // kiễm tra quá hạn , tính tiền phạt khi trễ, mất sách DateTime ngaymuonsach = LayDatetimeDcMuonCuaSach(saxtra.Masach, sachdangmuon, danhsachngaymuonsach); int songaydamuon = SoNgayMuon(ngaymuonsach, DateTime.Now); int tienphatsachnay = 0; if (saxtra.Trangthai == (int)TrangThaiSach.DaMat) { tienphatsachnay = saxtra.Giatri; } if (songaydamuon > quydinh.Songayduocmuon + giaHanDTO.Solangiahan * 7) { tienphatsachnay = (songaydamuon - (quydinh.Songayduocmuon + giaHanDTO.Solangiahan * 7)) * quydinh.Tienphattrasachtremoingay; } tienphatkinay += tienphatsachnay; //thêm chi tiết phiếu trả ctptDTO ctptra = new ctptDTO(); ctptra.Mapt = phieutra.Mapt; ctptra.Masach = saxtra.Masach; ctptra.Songaydamuon = songaydamuon; ctptra.Tienphatsach = tienphatsachnay; ctptDAL.themCTPT(ctptra); danhsachchitietphieutra.Add(ctptra); //quẳng sách lại zô kho QuanLiSachBUS qlsachBUS = new QuanLiSachBUS(); if (saxtra.Trangthai != (int)TrangThaiSach.DaMat) { qlsachBUS.Travekho(saxtra); } else { qlsachBUS.MatSach(saxtra); } //xóa ngày cho phép giữ sách GiaHanSachBUS ghsax = new GiaHanSachBUS(); ghsax.XoaSoLanMuonSach(saxtra.Masach); } //sửa thông tin phiếu trả phieutra.Tienphatkinay = tienphatkinay; phieutraDAL.suaPhieuTra(phieutra); //thêm nợ vào bạn đọc bandoc.Tongtienno += tienphatkinay; banDocDAL.suaDocGia(bandoc, bandoc.MaThe); return(danhsachchitietphieutra); }