private void btnTimTheoTen_Click(object sender, EventArgs e)
        {
            errorTimTenDocGia.SetError(txtTimPhieuTheoTen, "");
            if (txtTimPhieuTheoTen.Text == "")
            {
                errorTimTenDocGia.SetError(txtTimPhieuTheoTen, "Nhập Tên Đọc Giả Của Phiếu Cần Tìm");
                return;
            }
            PhieuMuonSachDAO pms = new PhieuMuonSachDAO();

            pms.TenNguoiMuonSach = txtTimPhieuTheoTen.Text;

            PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
            List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.TimPhieuTheoten(pms);

            lvDSPhieuMuon.Items.Clear();
            foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
            {
                ListViewItem lvi = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                lvi.SubItems.Add(pmsBLL.TenNguoiMuonSach);
                lvi.SubItems.Add(pmsBLL.TenSach);
                lvi.SubItems.Add(pmsBLL.NgayMuon.ToString());
                lvi.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                lvi.SubItems.Add(pmsBLL.NgayTraSach.ToString());
                lvDSPhieuMuon.Items.Add(lvi);
            }
            txtTimMaPhieu.Text = "";
        }
        private void lvNguoiMuonSachDS_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvNguoiMuonSachDS.SelectedItems.Count > 0)
            {
                ListViewItem lvi         = lvNguoiMuonSachDS.SelectedItems[0];
                string       ma          = lvi.SubItems[0].Text;
                string       hoten       = lvi.SubItems[1].Text;
                string       sodienthoai = lvi.SubItems[2].Text;
                string       diachi      = lvi.SubItems[3].Text;
                string       email       = lvi.SubItems[4].Text;
                string       namsinh     = lvi.SubItems[5].Text;
                txtNMSMa.Text          = ma;
                TxtNMSTen.Text         = hoten;
                TxtNMSSoDienThoai.Text = sodienthoai;
                TxtNMSDiaChi.Text      = diachi;
                TxtNMSEmail.Text       = email;
                TxtNMSNamSinh.Text     = namsinh;

                PhieuMuonSachDAO pms = new PhieuMuonSachDAO();
                pms.TenNguoiMuonSach = TxtNMSTen.Text;

                PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
                List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.TimPhieuChuaDongTheoTen(pms);
                lvDSPhieuMuonMo.Items.Clear();
                foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
                {
                    ListViewItem lvii = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                    lvii.SubItems.Add(pmsBLL.NgayMuon.ToString());
                    lvii.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                    lvDSPhieuMuonMo.Items.Add(lvii);
                }
            }
        }
        private void HienThiPhieuUSer()
        {
            NguoiMuonSach nms = new NguoiMuonSach();

            nms.Id = int.Parse(this.iddg);
            NguoiMuonSachBLL     nmsbll    = new NguoiMuonSachBLL();
            List <NguoiMuonSach> dsngmsach = nmsbll.TimNguoiMuonTheoMa(nms);

            foreach (NguoiMuonSach tennms in dsngmsach)
            {
                this.ten = tennms.HoTen;
            }
            PhieuMuonSachDAO pms = new PhieuMuonSachDAO();

            pms.TenNguoiMuonSach = ten;
            PhieuMuonSachBLL        pmsdgbll = new PhieuMuonSachBLL();
            List <PhieuMuonSachDAO> dsphieu  = pmsdgbll.PhieuCuaDG(pms);

            lvPhieuMuonUser.Items.Clear();
            foreach (PhieuMuonSachDAO ctpms in dsphieu)
            {
                ListViewItem lvi = new ListViewItem(ctpms.MaPhieuMuon + "");
                lvi.SubItems.Add(ctpms.TenSach);
                lvi.SubItems.Add(ctpms.TrangThai);
                lvi.SubItems.Add(ctpms.NgayMuon.ToString());
                lvi.SubItems.Add(ctpms.NgayDuKienTra.ToString());
                lvi.SubItems.Add(ctpms.NgayTraSach.ToString());
                lvPhieuMuonUser.Items.Add(lvi);
            }
        }
        private void btnTimTheoMa_Click(object sender, EventArgs e)
        {
            errorTimMaPhieu.SetError(txtTimMaPhieu, "");
            if (txtTimMaPhieu.Text == "")
            {
                errorTimMaPhieu.SetError(txtTimMaPhieu, "Nhập Mã Phiếu Muốn Tìm");
                return;
            }
            errorIntMaPhieu.SetError(txtTimMaPhieu, "");
            if (!txtTimMaPhieu.Text.All(char.IsDigit))
            {
                errorIntMaPhieu.SetError(txtTimMaPhieu, "Mã Phiếu là số");
                return;
            }
            PhieuMuonSachDAO pms = new PhieuMuonSachDAO();

            pms.MaPhieuMuon = int.Parse(txtTimMaPhieu.Text);

            PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
            List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.TimPhieuTheoMa(pms);

            lvDSPhieuMuon.Items.Clear();
            foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
            {
                ListViewItem lvi = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                lvi.SubItems.Add(pmsBLL.TenNguoiMuonSach);
                lvi.SubItems.Add(pmsBLL.TenSach);
                lvi.SubItems.Add(pmsBLL.NgayMuon.ToString());
                lvi.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                lvi.SubItems.Add(pmsBLL.NgayTraSach.ToString());
                lvDSPhieuMuon.Items.Add(lvi);
            }
            txtTimPhieuTheoTen.Text = "";
        }
        private void btnTHTimMaP_Click(object sender, EventArgs e)
        {
            if (txtTHTimMaP.Text == "")
            {
                HienThiDSTatCaPhieu();
            }
            else
            {
                errIntMaPhieu.SetError(txtTHTimMaP, "");
                if (!txtTHTimMaP.Text.All(char.IsDigit))
                {
                    errIntMaPhieu.SetError(txtTHTimMaP, "Mã Phiếu là số");
                    return;
                }
                PhieuMuonSachDAO pms = new PhieuMuonSachDAO();
                pms.MaPhieuMuon = int.Parse(txtTHTimMaP.Text);

                PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
                List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.TimPhieuTheoMa(pms);
                lvTHDSP.Items.Clear();
                foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
                {
                    ListViewItem lvi = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                    lvi.SubItems.Add(pmsBLL.TenNguoiMuonSach);
                    lvi.SubItems.Add(pmsBLL.TrangThai);
                    lvi.SubItems.Add(pmsBLL.NgayMuon.ToString());
                    lvi.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                    lvi.SubItems.Add(pmsBLL.NgayTraSach.ToString());
                    lvi.SubItems.Add(pmsBLL.TenSach);
                    lvTHDSP.Items.Add(lvi);
                }
            }
            LoadText();
        }
        private void btnTimThoiGianTao_Click(object sender, EventArgs e)
        {
            errorNgay.SetError(txtTimNgay, "");
            if (!txtTimNgay.Text.All(char.IsDigit) && txtTimNgay.Text != "")
            {
                errorNgay.SetError(txtTimNgay, "Xin Nhập Ngày");
                return;
            }
            errorNgay.SetError(txtTimNgay, "");
            if (txtTimNgay.Text == "")
            {
                errorNgay.SetError(txtTimNgay, "Xin Nhập Ngày");
                return;
            }
            errorThang.SetError(txtTimThang, "");
            if (!txtTimThang.Text.All(char.IsDigit) && txtTimThang.Text != "")
            {
                errorThang.SetError(txtTimThang, "Xin Nhập Tháng");
                return;
            }
            errorThang.SetError(txtTimThang, "");
            if (txtTimThang.Text == "")
            {
                errorThang.SetError(txtTimThang, "Xin Nhập Tháng");
                return;
            }
            errorNam.SetError(txtTimNam, "");
            if (!txtTimNam.Text.All(char.IsDigit) && txtTimNam.Text != "")
            {
                errorNam.SetError(txtTimNam, "Xin Nhập Năm");
                return;
            }
            errorNam.SetError(txtTimNam, "");
            if (txtTimNam.Text == "")
            {
                errorNam.SetError(txtTimNam, "Xin Nhập Năm");
                return;
            }
            PhieuMuonSachDAO pms = new PhieuMuonSachDAO();

            pms.ngay  = int.Parse(txtTimNgay.Text);
            pms.thang = int.Parse(txtTimThang.Text);
            pms.nam   = int.Parse(txtTimNam.Text);

            PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
            List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.TimphieuTheoNgay(pms);

            lvDSPhieuMuon.Items.Clear();
            foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
            {
                ListViewItem lvi = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                lvi.SubItems.Add(pmsBLL.TenNguoiMuonSach);
                lvi.SubItems.Add(pmsBLL.TenSach);
                lvi.SubItems.Add(pmsBLL.NgayMuon.ToString());
                lvi.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                lvi.SubItems.Add(pmsBLL.NgayTraSach.ToString());
                lvDSPhieuMuon.Items.Add(lvi);
            }
        }
        private void ChapThuanPhieuChoMuon()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtCMMaP.Text);
            PhieuMuonSachBLL pmsbll           = new PhieuMuonSachBLL();
            bool             chapthuanchomuon = pmsbll.ChapThuanPhieuChoMuon(pms);

            if (chapthuanchomuon)
            {
                MessageBox.Show("Đã lưu thông tin mượn sách của đọc giả", "Thông báo");
            }
        }
        private void ChapThuanDuyet()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtCDMaP.Text);

            PhieuMuonSachBLL pmsbll    = new PhieuMuonSachBLL();
            bool             chapthuan = pmsbll.ChapThuanPhieuDuyet(pms);

            if (chapthuan)
            {
                MessageBox.Show("Bạn Đã Chấp Thuận Phiếu \n Đợi Đọc Giả Đến Nhận Nhé", "Thông Báo");
            }
        }
        private void ChoMuonSachTaiCho()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.NguoiMuonSachId = this.madg;
            pms.SachId          = this.masach;
            pms.NgayMuon        = dtCMTCNgayMuon.Value;
            pms.NgayDuKienTra   = dtCMTCDuKienTra.Value;

            PhieuMuonSachBLL pmsbll   = new PhieuMuonSachBLL();
            bool             phieumoi = pmsbll.ThemPhieuMuon(pms);

            if (phieumoi)
            {
                MessageBox.Show("Đã Lưu thông tin mượn sách của đọc giả", "Thông Báo");
            }
        }
        //End  tab Cho Mượn Tại Chỗ

        // start  tab trả sách
        private void HienThiDSChuaTraSach()
        {
            PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
            List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.LayPhieuDangMo();

            lvTSPMS.Items.Clear();
            foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
            {
                ListViewItem lvi = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                lvi.SubItems.Add(pmsBLL.TenNguoiMuonSach);
                lvi.SubItems.Add(pmsBLL.TenSach);
                lvi.SubItems.Add(pmsBLL.NgayMuon.ToString());
                lvi.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                lvi.SubItems.Add(pmsBLL.NgayTraSach.ToString());
                lvTSPMS.Items.Add(lvi);
            }
        }
        private void TuChoiPhieuChoMuon()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtCMMaP.Text);
            PhieuMuonSachBLL pmsbll        = new PhieuMuonSachBLL();
            bool             tuchoichomuon = pmsbll.TuChoiPhieuChoMuon(pms);
            Sach             sac           = new Sach();

            sac.TenSach = txtCMS.Text;
            SachBLL sacbll     = new SachBLL();
            bool    dgkhongden = sacbll.CapNhatDocGiaKhongDen(sac);

            if (dgkhongden && tuchoichomuon)
            {
                MessageBox.Show("Đã cập nhật thông tin", "Thông báo");
            }
        }
Esempio n. 12
0
        private void TaoPhieuMoi()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.NguoiMuonSachId = int.Parse(txtConfirmMaDocGia.Text);
            pms.SachId          = int.Parse(txtConfirmMaSach.Text);
            pms.NgayMuon        = datetimeConfirmNgayMuon.Value;
            pms.NgayDuKienTra   = datetimeConfirmNgayDuKienTra.Value;

            PhieuMuonSachBLL pmsbll   = new PhieuMuonSachBLL();
            bool             phieumoi = pmsbll.ThemPhieuMuon(pms);

            if (phieumoi)
            {
                MessageBox.Show("Nhấn nút cập nhật nhé!!!", "Thông Báo");
                this.Close();
            }
        }
        private void HienThiDSPhieuDGKhongDen()
        {
            PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
            List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.DGKhongDen();

            lvTHDSP.Items.Clear();
            foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
            {
                ListViewItem lvi = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                lvi.SubItems.Add(pmsBLL.TenNguoiMuonSach);
                lvi.SubItems.Add(pmsBLL.TrangThai);
                lvi.SubItems.Add(pmsBLL.NgayMuon.ToString());
                lvi.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                lvi.SubItems.Add(pmsBLL.NgayTraSach.ToString());
                lvi.SubItems.Add(pmsBLL.TenSach);
                lvTHDSP.Items.Add(lvi);
            }
        }
        private void UserTaoPhieu()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.NguoiMuonSachId = int.Parse(iddg);
            pms.SachId          = int.Parse(txtMaSach.Text);
            pms.NgayMuon        = dateNgayMuon.Value;
            pms.NgayDuKienTra   = dateDuKienTra.Value;

            PhieuMuonSachBLL pmsbll   = new PhieuMuonSachBLL();
            bool             phieumoi = pmsbll.DocGiaTaoPhieu(pms);

            if (phieumoi)
            {
                MessageBox.Show("Mượn thành công, vui lòng chờ duyệt và đến thư viện nhận sách nhé." +
                                "\n Bạn có thể kiểm tra trạng thái ở tab Sách Mượn Của Tôi", "Thông Báo");
            }
        }
        private void HienThiDSPhieuMuonSachDaDong()
        {
            PhieuMuonSachBLL        phieumsBLL  = new PhieuMuonSachBLL();
            List <PhieuMuonSachDAO> dsphieumuon = phieumsBLL.LayPhieuDaDong();

            lvDSPhieuMuon.Items.Clear();
            foreach (PhieuMuonSachDAO pmsBLL in dsphieumuon)
            {
                ListViewItem lvi = new ListViewItem(pmsBLL.MaPhieuMuon + "");
                lvi.SubItems.Add(pmsBLL.TenNguoiMuonSach);
                lvi.SubItems.Add(pmsBLL.TenSach);
                lvi.SubItems.Add(pmsBLL.NgayMuon.ToString());
                lvi.SubItems.Add(pmsBLL.NgayDuKienTra.ToString());
                lvi.SubItems.Add(pmsBLL.NgayTraSach.ToString());
                lvDSPhieuMuon.Items.Add(lvi);
            }
            txtTimMaPhieu.Text      = "";
            txtTimPhieuTheoTen.Text = "";
        }
        private void SachBiLoi()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtCDMaP.Text);
            PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL();
            bool             tuchoi = pmsbll.TuChoiPhieuDuyet(pms);

            Sach sac = new Sach();

            sac.TenSach = txtCDS.Text;
            SachBLL sacbll  = new SachBLL();
            bool    capnhat = sacbll.CapNhatTrangThaiLoi(sac);

            if (capnhat && tuchoi)
            {
                MessageBox.Show("Bạn Đã Từ Chối Phiếu Duyệt \n Xử lý sách bị lỗi nhé", "Thông Báo");
                LoadLDS();
            }
        }
        private void KhongTraSach()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtTSMaP.Text);
            PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL();
            bool             tuchoi = pmsbll.TuChoiPhieuDuyet(pms);

            Sach sac = new Sach();

            sac.TenSach = txtTSS.Text;
            SachBLL sacbll  = new SachBLL();
            bool    capnhat = sacbll.CapNhatTrangThaiLoi(sac);

            if (capnhat && tuchoi)
            {
                MessageBox.Show("Đã lưu thông tin", "Thông Báo");
                LoadLDS();
            }
        }
        private void DongPhieuMuon()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtConfirmMaPhieu.Text);
            pms.NgayTraSach = dtpConfirmNgayTra.Value;

            PhieuMuonSachBLL pmsbll     = new PhieuMuonSachBLL();
            bool             closephieu = pmsbll.DongPhieuMuon(pms);

            Sach sac = new Sach();

            sac.ID = int.Parse(txtMaSach.Text);
            SachBLL scbll     = new SachBLL();
            bool    trangthai = scbll.CapNhatPhieuMuon(sac);

            if (closephieu && trangthai)
            {
                MessageBox.Show("Nhấn nút cập nhật nhé!!!", "Thông Báo");
                this.Close();
            }
        }
        private void XuLySachLoi()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtTHMaP.Text);
            PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL();
            bool             xyly   = pmsbll.XuLySachLoi(pms);

            Sach idsach = new Sach();

            idsach.ID = int.Parse(txtTHMaS.Text);
            SachBLL trasachbll = new SachBLL();
            bool    capnhat    = trasachbll.CapNhatPhieuMuon(idsach);

            if (xyly && capnhat)
            {
                MessageBox.Show("Đã lưu thông tin", "Thông Báo");
            }
            else
            {
                MessageBox.Show("Stuck");
            }
        }
        private void TraSach()
        {
            PhieuMuonSach pms = new PhieuMuonSach();

            pms.MaPhieuMuon = int.Parse(txtTSMaP.Text);
            pms.NgayTraSach = dtTSNgayTra.Value;

            PhieuMuonSachBLL pmsbll  = new PhieuMuonSachBLL();
            bool             trasach = pmsbll.DongPhieuMuon(pms);
            Sach             idtra   = new Sach();

            idtra.ID = int.Parse(txtTSMaS.Text);
            SachBLL trasachbll = new SachBLL();
            bool    capnhat    = trasachbll.CapNhatPhieuMuon(idtra);

            if (trasach && capnhat)
            {
                MessageBox.Show("Đã lưu thông tin", "Thông Báo");
            }
            else
            {
                MessageBox.Show("Stuck");
            }
        }