Exemplo n.º 1
0
 public int getBookQuantityCanBorrow(ReaderBLL readerBLL)
 {
     if (CertificateDAL.getCertificateByReaderId(readerBLL.Code) != null)
     {
         return(3 - CertificateDAL.getCertificateByReaderId(readerBLL.Code).Count);
     }
     return(3);
 }
Exemplo n.º 2
0
 public bool checkBookBorrowMax(ReaderBLL readerBLL)
 {
     if (CertificateDAL.getCertificateByReaderId(readerBLL.Code) != null && CertificateDAL.getCertificateByReaderId(readerBLL.Code).Count >= 3)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
        public void Add(CertificateBLL certificate, List <Int32> listBook)
        {
            CertificateDAL.insert(certificate);
            List <CertificateBLL> certificateList = CertificateDAL.getLastCertificateByReaderId(certificate.Iddocgia);

            if (certificateList != null)
            {
                foreach (Int32 bookId in listBook)
                {
                    BookBorrowDAL.Insert(bookId, certificateList[certificateList.Count - 1].Idphieumuon);
                    BookDAL.changeStatus(bookId);
                }
            }
        }
Exemplo n.º 4
0
        private void LoadDataToGridView()
        {
            this.dgvCertificateStt.Rows.Clear();
            CertificateBLL        manageCertificateBLL = new CertificateBLL();
            List <CertificateBLL> manageCertificateArr = new List <CertificateBLL>();

            manageCertificateArr = CertificateDAL.getManageCertificateList();
            //MessageBox.Show("ok");
            foreach (CertificateBLL row in manageCertificateArr)
            {
                this.dgvCertificateStt.Rows.Add(row.Idphieumuon, row.Tentinhtrang, row.Ngaymuon, row.Hantra, row.Tendocgia, row.Lacnvc, row.Iddocgia);
            }
            this.GetSelectedValue();
            this.dgvCertificateStt.SelectionChanged += new EventHandler(dgvCertificateStt_SelectionChanged);
        }
Exemplo n.º 5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string key = this.txtSearch.Text;

            if (key == "".Trim())
            {
                MessageBox.Show("Please enter keyword!", "Notice");
                return;
            }
            string catalog = "";

            //MessageBox.Show(this.cboSearch.SelectedItem.ToString());
            if (this.cboSearch.SelectedItem.ToString() == "Certificate")
            {
                catalog += "phieumuon.maphieumuon";
                //MessageBox.Show(catalog);
            }
            else if (this.cboSearch.SelectedItem.ToString() == "Certificate Stt")
            {
                catalog += "tinhtrangphieumuon.tentinhtrang";
                //MessageBox.Show(catalog);
            }
            CertificateBLL        bookStatusBLL        = new CertificateBLL();
            List <CertificateBLL> certificateStatusArr = new List <CertificateBLL>();

            certificateStatusArr = CertificateDAL.search(key, catalog);
            this.dgvCertificateStt.Rows.Clear();
            if (certificateStatusArr != null)
            {
                //MessageBox.Show("ok");
                foreach (CertificateBLL row in certificateStatusArr)
                {
                    this.dgvCertificateStt.Rows.Add(row.Idphieumuon, row.Tentinhtrang, row.Ngaymuon, row.Hantra, row.Tendocgia, row.Lacnvc, row.Iddocgia);
                }
            }
            else
            {
                MessageBox.Show("Sorry! Can't find this certificate");
                return;
            }
            this.GetSelectedValue();
            this.dgvCertificateStt.SelectionChanged += new EventHandler(dgvCertificateStt_SelectionChanged);
        }
Exemplo n.º 6
0
        private void GetSelectedValue()
        {
            if (this.dgvCertificateStt.SelectedCells.Count > 0 && this.dgvCertificateStt.CurrentRow.Index < this.dgvCertificateStt.Rows.Count - 1)
            {
                int selectedrowindex = this.dgvCertificateStt.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = this.dgvCertificateStt.Rows[selectedrowindex];
                DateTime        current     = new DateTime();
                DateTime        endtime     = new DateTime();
                TimeSpan        tg;
                string          name     = Convert.ToString(selectedRow.Cells["clmnReaderName"].Value);
                bool            ob       = Convert.ToBoolean(selectedRow.Cells["clmnObject"].Value);
                string          id       = Convert.ToString(selectedRow.Cells["clmnReaderCode"].Value);
                DateTime        daystart = Convert.ToDateTime(selectedRow.Cells["clmnDayStart"].Value);
                DateTime        dayend   = Convert.ToDateTime(selectedRow.Cells["clmnDayEnd"].Value);
                current = DateTime.Now;
                endtime = Convert.ToDateTime(selectedRow.Cells["clmnDayEnd"].Value);
                tg      = endtime - current;
                this.txtReaderName.Text = name;
                this.txtReaderCode.Text = id;
                this.txtDayStart.Text   = daystart.ToShortDateString();
                this.txtDayEnd.Text     = dayend.ToShortDateString();
                if (ob)
                {
                    this.txtObject.Text = "Cán Bộ Công Nhân Viên";
                }
                else
                {
                    this.txtObject.Text = "Sinh Viên";
                }
                int songay = Convert.ToInt16(tg.Days);
                if (songay < 0)
                {
                    if (selectedRow.Cells["clmnStt"].Value.ToString() != "mới tạo")
                    {
                        this.txtOutOfDay.Text = "";
                    }
                    else
                    {
                        this.txtOutOfDay.Text = "trễ " + Math.Abs(songay) + " ngày";
                    }
                }

                /*if (id == "")
                 * {
                 *  this.btnDelete.Enabled = false;
                 *  this.btnSave.Enabled = false;
                 * }
                 * else
                 * {
                 *  this.btnDelete.Enabled = true;
                 *  this.btnSave.Enabled = true;
                 * }*/
                if (this.dgvCertificateStt.SelectedCells.Count > 0 && this.dgvCertificateStt.CurrentRow.Index < this.dgvCertificateStt.Rows.Count - 1)
                {
                    this.dgvDetailCertificate.Rows.Clear();
                    DetailCertificateBLL        manageCertificateBLL = new DetailCertificateBLL();
                    List <DetailCertificateBLL> manageCertificateArr = new List <DetailCertificateBLL>();
                    manageCertificateArr = CertificateDAL.getDetailCertificateList(Convert.ToInt32(selectedRow.Cells["clmnId"].Value));
                    //MessageBox.Show("ok");
                    foreach (DetailCertificateBLL row in manageCertificateArr)
                    {
                        this.dgvDetailCertificate.Rows.Add(row.Masach, row.Tensach);
                    }
                }
            }
            else
            {
                this.txtReaderName.Text = "";
                this.txtReaderCode.Text = "";
                this.txtDayStart.Text   = "";
                this.txtDayEnd.Text     = "";
                this.txtObject.Text     = "";
                this.txtOutOfDay.Text   = "";
                this.dgvDetailCertificate.Rows.Clear();
            }
        }