private void dgvPhieuMuon_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     for (int i = 0; i < dgvPhieuMuon.Rows.Count; i++)
     {
         for (int j = 0; j < dgvPhieuMuon.Columns.Count; j++)
         {
             if (dgvPhieuMuon.Rows[i].Cells[j].Selected == true)
             {
                 string strSoPhieu   = dgvPhieuMuon.Rows[i].Cells[0].Value.ToString();
                 string strMaThe     = dgvPhieuMuon.Rows[i].Cells[1].Value.ToString();
                 string strMaDocGia  = BUS_OBJ.layMaTheTheoMaDocGia(strMaThe);
                 string strTenDocGia = BUS_OBJ.layTenDocGia(strMaDocGia);
                 string strMaSach    = dgvPhieuMuon.Rows[i].Cells[2].Value.ToString();
                 string strTenSach   = BUS_OBJ.layTenSach(strMaSach);
                 string strNgayMuon  = dgvPhieuMuon.Rows[i].Cells[3].Value.ToString();
                 string strNgayTra   = dgvPhieuMuon.Rows[i].Cells[4].Value.ToString();
                 string strTinhTrang = dgvPhieuMuon.Rows[i].Cells[5].Value.ToString();
                 string strGhiChu    = dgvPhieuMuon.Rows[i].Cells[6].Value.ToString();
                 string strCaption   = "Số phiếu: " + strSoPhieu + "\n" +
                                       "Mã thẻ: " + strMaThe + "\n" +
                                       "Tên độc giả: " + strTenDocGia + "\n" +
                                       "Mã sách: " + strMaSach + "\n" +
                                       "Tên sách: " + strTenSach + "\n" +
                                       "Ngày mượn: " + strNgayMuon + "\n" +
                                       "Ngày trả: " + strNgayTra + "\n" +
                                       "Tình trạng: " + strTinhTrang + "\n" +
                                       "Ghi chú: " + strGhiChu + "\n";
                 dgvPhieuMuon.Rows[i].Cells[j].ToolTipText = strCaption;
                 dgvPhieuMuon.ShowCellToolTips             = true;
             }
         }
     }
 }
Beispiel #2
0
 private void btnDuyet_Click(object sender, EventArgs e)
 {
     if (lbSoPhieu.Text != "-")
     {
         try
         {
             string maThe = "";
             //conn.Open();
             //SqlCommand cmd = new SqlCommand("Select MaThe from The where MaDocGia = '" + lbMaThe.Text + "'", conn);
             maThe = BUS_OBJ.layMaTheTheoMaDocGia(lbMaThe.Text);
             if (maThe == "")
             {
                 MetroFramework.MetroMessageBox.Show(this, "Mã thẻ không khả dụng.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 BUS_OBJ.duyetYeuCauTraSach(Convert.ToInt32(lbSoPhieu.Text), lbMaThe.Text, lbMaSach.Text);
                 HienThiDuLieu();
                 btnCancel_Click(sender, e);
                 MetroFramework.MetroMessageBox.Show(this, "Duyệt thành công. \nĐề nghị thu hồi sách về kho.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception ex)
         {
             MetroFramework.MetroMessageBox.Show(this, ex.Message);
         }
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "Hãy chọn 1 phiếu mượn.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #3
0
 private void btnMuon_Click(object sender, EventArgs e)
 {
     if (lbMaSach.Text == "")
     {
         MetroFramework.MetroMessageBox.Show(this, "Hãy chọn 1 cuốn sách.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (lbSoBanTon.Text == "0")
         {
             MetroFramework.MetroMessageBox.Show(this, "Mã sách này hiện đã được mượn hết.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             try
             {
                 string maThe = BUS_OBJ.layMaTheTheoMaDocGia(txtMaThe.Text);
                 if (maThe == "")
                 {
                     MetroFramework.MetroMessageBox.Show(this, "Mã thẻ của bạn không khả dụng.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     int soSachDangMuon = 0;
                     int soSachDuocMuon = 0;
                     soSachDangMuon = BUS_OBJ.laySoSachDangMuon(maThe);
                     soSachDuocMuon = BUS_OBJ.laySoSachDuocMuon(maThe);
                     if (soSachDangMuon < soSachDuocMuon)
                     {
                         frmPhieuMuon muon = new frmPhieuMuon(this);
                         muon.setLabelMaThe(maThe);
                         muon.setLabelMaSach(lbMaSach.Text);
                         muon.setLabelTenSach(lbTenSach.Text);
                         this.Opacity = .75;
                         muon.ShowDialog();
                     }
                     else
                     {
                         MetroFramework.MetroMessageBox.Show(this, "Hiện bạn đã mượn hết số lượng sách được mượn. \nVui lòng trả những sách đã mượn để tiếp tục.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }
                 }
             }
             catch (Exception ex)
             {
                 MetroFramework.MetroMessageBox.Show(this, ex.Message);
             }
             finally
             {
             }
         }
     }
 }
 private void btnDuyet_Click(object sender, EventArgs e)
 {
     if (lbSoPhieu.Text != "-")
     {
         try
         {
             string maThe = "";
             maThe = BUS_OBJ.layMaTheTheoMaDocGia(lbMaThe.Text);
             if (maThe == "")
             {
                 MetroFramework.MetroMessageBox.Show(this, "Mã thẻ không khả dụng.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 int soSachDangMuon = 0;
                 int soSachDuocMuon = 0;
                 soSachDuocMuon = BUS_OBJ.laySoSachDuocMuon(maThe);
                 soSachDangMuon = BUS_OBJ.laySoSachDangMuon(maThe);
                 if (soSachDangMuon < soSachDuocMuon)
                 {
                     PhieuMuon_DTO phieuMuon = new PhieuMuon_DTO(Convert.ToInt32(lbSoPhieu.Text), lbMaThe.Text, lbMaSach.Text,
                                                                 dtpNgayMuon.Value, dtpNgayTra.Value, cboTinhTrang.SelectedItem.ToString(), rtbGhiChu.Text);
                     BUS_OBJ.duyetPhieuMuon(phieuMuon);
                     HienThiDuLieu();
                     btnCancel_Click(sender, e);
                 }
                 else
                 {
                     MetroFramework.MetroMessageBox.Show(this, "Thẻ này đã mượn hết số lượng sách được mượn. \nHãy yêu cầu trả những sách đã mượn để tiếp tục.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     rtbGhiChu.Focus();
                 }
             }
         }
         catch (Exception ex)
         {
             MetroFramework.MetroMessageBox.Show(this, ex.Message);
         }
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "Hãy chọn 1 phiếu mượn.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         rtbGhiChu.Focus();
     }
 }
Beispiel #5
0
 private void btnMuon_Click_1(object sender, EventArgs e)
 {
     if (datagvSach.SelectedRows == null)
     {
         MetroFramework.MetroMessageBox.Show(this, "Hãy chọn 1 cuốn sách.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (datagvSach.Rows[0].Cells[9].Value.ToString() == "0")
         {
             MetroFramework.MetroMessageBox.Show(this, "Mã sách này hiện đã được mượn hết.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             try
             {
                 string maThe = BUS_OBJ.layMaTheTheoMaDocGia(user.TenDangNhap);
                 if (maThe == "")
                 {
                     MetroFramework.MetroMessageBox.Show(this, "Mã thẻ của bạn không khả dụng.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     int soSachDangMuon = 0;
                     int soSachDuocMuon = 0;
                     soSachDangMuon = BUS_OBJ.laySoSachDangMuon(maThe);
                     soSachDuocMuon = BUS_OBJ.laySoSachDuocMuon(maThe);
                     if (soSachDangMuon < soSachDuocMuon)
                     {
                         frmPhieuMuon muon = new frmPhieuMuon(this);
                         muon.setLabelMaThe(maThe);
                         for (int i = 0; i < datagvSach.Rows.Count; i++)
                         {
                             for (int j = 0; j < datagvSach.Columns.Count; j++)
                             {
                                 if (datagvSach.Rows[i].Cells[j].Selected == true)
                                 {
                                     muon.setLabelMaSach(datagvSach.Rows[i].Cells[0].Value.ToString());
                                     muon.setLabelTenSach(datagvSach.Rows[i].Cells[1].Value.ToString());
                                 }
                             }
                         }
                         this.Opacity = .75;
                         muon.ShowDialog();
                     }
                     else
                     {
                         MetroFramework.MetroMessageBox.Show(this, "Hiện bạn đã mượn hết số lượng sách được mượn. \nVui lòng trả những sách đã mượn để tiếp tục.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }
                 }
             }
             catch (Exception ex)
             {
                 MetroFramework.MetroMessageBox.Show(this, ex.Message);
             }
             finally
             {
             }
         }
     }
 }