DataTable LoadDsSach()
        {
            SachBUS bus = new SachBUS();
            string  str = "SELECT MaSach FROM SACH";

            return(bus.GetDatasByCommand(str));
        }
Ejemplo n.º 2
0
 /* Sự kiện chọn một dòng trong dgv để hiện thị chi tiết độc giả và hiện thị những cuốn sách đang mượn */
 private void dgvReaders_SelectionChanged(object sender, EventArgs e)
 {
     if (dgvReaders.CurrentRow != null)
     {
         int       index  = dgvReaders.CurrentRow.Index;
         DocGiaDTO docGia = (dgvReaders.DataSource as List <DocGiaDTO>)[index];
         lbNameReader.Text                   = docGia.Ten;
         lbPhoneReader.Text                  = docGia.Sdt;
         lbTypeOfReader.Text                 = docGia.Maloai.Socuonstr;
         lbSttReader.Text                    = docGia.TrangThaiChiTiet;
         dgvBookIsLend.DataSource            = SachBUS.GetBookIsLend(docGia);
         dgvBookIsLend.Columns[0].Visible    = false;
         dgvBookIsLend.Columns[1].HeaderText = "Tên đầu sách";
         dgvBookIsLend.Columns[2].HeaderText = "Stt";
         dgvBookIsLend.Columns[3].Visible    = false;
         if (docGia.TrangThai == DocGiaDTO.UnLock)
         {
             btnChangeStatus.Text = "Khóa";
             pnlReader.Controls.Add(lblMonth);
             pnlReader.Controls.Add(cbbTimeBlock);
         }
         else
         {
             btnChangeStatus.Text = "Mở";
             pnlReader.Controls.Remove(lblMonth);
             pnlReader.Controls.Remove(cbbTimeBlock);
         }
     }
 }
        public AddBook()
        {
            InitializeComponent();
            List <SachDTO> listBook = SachBUS.GetAll();

            dtgBook.ItemsSource = listBook;
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DataGridViewRow dgvRow = dtgrvSachTV.CurrentRow;
            int             MaSach = (int)dgvRow.Cells[0].Value;
            SachBUS         sb     = new SachBUS();

            sb.UpdateRecord(MaSach, true);

            ChiTietMuonDTO ctmuon = new ChiTietMuonDTO();

            ctmuon.MaSach  = MaSach;
            ctmuon.NgayTra = dtNgTra.Value;

            ChiTietMuonBUS ctmBus = new ChiTietMuonBUS();

            ctmBus.Insert(ctmuon);

            PhieuMuonDTO phieuMuon = new PhieuMuonDTO();

            phieuMuon.MaDocGia = int.Parse(txtMaDG.Text);
            phieuMuon.NgayMuon = DateTime.Now;

            PhieuMuonBUS pmBus = new PhieuMuonBUS();

            pmBus.Insert(phieuMuon);

            btnChon_Click(sender, e);
        }
Ejemplo n.º 5
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtTenSach.Text == "")
     {
         MessageBox.Show("-Tên sách không được để trống.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         SachDTO S = new SachDTO();
         S.MaSach  = txtMaSach.Text;
         S.TenSach = txtTenSach.Text;
         S.MaTL    = cboTheLoai.SelectedValue.ToString();
         S.MaNXB   = cboNXB.SelectedValue.ToString();
         S.MaTG    = cboTacGia.SelectedValue.ToString();
         if (SachBUS.ThemSach(S) == true)
         {
             MessageBox.Show("Thêm thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtMaSach.Text = SachBUS.GetIDSach();
             txtTenSach.ResetText();
         }
         else
         {
             MessageBox.Show("Thêm thất bại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        private void frmXuatBaoCaoNhapKho_Load(object sender, EventArgs e)
        {
            BaoCaoNhapKho report = new BaoCaoNhapKho();

            report.SetDataSource(SachBUS.BaoCaoNhapKhoS(ngay));
            crvBaoCaoNhapKho.ReportSource = report;
        }
Ejemplo n.º 7
0
        private void frmMuonTraSach_Load(object sender, EventArgs e)
        {
            qdBUS  = new QuyDinhBUS();
            listQD = new List <QuyDinhDTO>();
            listQD = qdBUS.select();

            this.comboBox_PhuongThuc.Items.Insert(0, "Toàn bộ");
            this.comboBox_PhuongThuc.Items.Insert(1, "Bằng mã phiếu mượn");
            this.comboBox_PhuongThuc.Items.Insert(2, "Bằng mã phiếu trả");
            this.comboBox_PhuongThuc.Items.Insert(3, "Bằng mã đọc giả");
            this.comboBox_PhuongThuc.Items.Insert(4, "Bằng mã sách");
            this.comboBox_PhuongThuc.SelectedIndex = 0;
            dgBus         = new DocGiaBUS();
            sachBus       = new SachBUS();
            ldgBus        = new LoaiDocGiaBUS();
            pmBus         = new PhieuMuonBUS();
            listPhieuMuon = new List <PhieuMuonDTO>();
            listDocGia    = new List <DocGiaDTO>();
            listSach      = new List <SachDTO>();
            //  loadData_Vao_GridView("", DocGiaDAL.TimToanBo);
            listPhieuMuon = pmBus.select();
            loadLoaiDocGia_Combobox();
            loadMaSach_Combobox();
            loadData_Vao_GridView(listPhieuMuon);
        }
Ejemplo n.º 8
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            SachDTO s = new SachDTO();

            try
            {
                s.MaSach = int.Parse(txtMaSach.Text);
            }
            catch
            {
                MessageBox.Show("Mã sách không được rỗng chọn từ danh sách bên dưới để cập nhật");
            }

            s.TenSach = txtTenSach.Text;
            s.TacGia  = txtTacGia.Text;
            try
            {
                s.SoLuongTon = int.Parse(txtSoLuongTon.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Số lượng tồn không được để trống và điền vào số");
                return;
            }
            s.GiaBan    = int.Parse(txtGiaBan.Text);
            s.MaTheLoai = int.Parse(cbTheLoai.SelectedValue.ToString());

            if (SachBUS.CapNhatSach(s) == false)
            {
                MessageBox.Show("Mã sách không tồn tại trong CSDL");
            }
            HienThiDanhSach();
            MessageBox.Show("Cập nhật thành công");
        }
Ejemplo n.º 9
0
        //lay cac thong tin ve bao cao ton,tao bao cao
        private void butTao_Click(object sender, EventArgs e)
        {
            Thang           = int.Parse(cbThang.Text);
            Nam             = int.Parse(txtNam.Text);
            baocaoton.Thang = int.Parse(cbThang.Text);
            baocaoton.Nam   = int.Parse(txtNam.Text);
            if (objBaoCao.KiemTra(baocaoton.Thang, baocaoton.Nam) == true)
            {
                SachBUS objSach = new SachBUS();

                DataTable dtSach = objSach.GetSach();
                for (int i = 0; i < dtSach.Rows.Count; i++)
                {
                    baocaoton.MaSach     = dtSach.Rows[i]["masach"].ToString();
                    baocaoton.TenSach    = dtSach.Rows[i]["tensach"].ToString();
                    baocaoton.SoLuongTon = GetSLTon(baocaoton.Thang, baocaoton.Nam, baocaoton.MaSach);

                    baocaoton.SoLuongNhap = GetSLNhap(baocaoton.Thang, baocaoton.Nam, baocaoton.MaSach);
                    baocaoton.SoLuongBan  = GetSLBan(baocaoton.Thang, baocaoton.Nam, baocaoton.MaSach);
                    baocaoton.SoLuongTon += baocaoton.SoLuongNhap - baocaoton.SoLuongBan;


                    if (objBaoCao.ThemBaoCao(baocaoton) != true)
                    {
                        MessageBox.Show("Lỗi dữ liệu");
                        break;
                    }
                }
            }
            BangBaoCaoTon fr = new BangBaoCaoTon();

            fr.Show();
        }
Ejemplo n.º 10
0
 private void Combobox_CategoriesBook_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (Combobox_CategoriesBook.SelectedValue != null)
     {
         ListViewBooks.ItemsSource = SachBUS.loadByMaLoai(Combobox_CategoriesBook.SelectedValue.ToString());
     }
 }
Ejemplo n.º 11
0
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            string idsach, tensach, idtacgia, idtheloai, tinhtrang;
            int    nxb;

            idsach    = txtMaSach.Text;
            tensach   = txtTenSach.Text;
            idtacgia  = comboTG.SelectedValue.ToString();
            idtheloai = comboTheLoai.SelectedValue.ToString();
            nxb       = int.Parse(txtNXB.Text);
            tinhtrang = txtTinhTrang.Text;

            Sach sach = new Sach(idsach, tensach, idtacgia, idtheloai, nxb, tinhtrang);

            try
            {
                int numerOfRows = new SachBUS().Add(sach);
                MessageBox.Show("Them thanh cong");
                Init();
            }

            catch (SqlException ex)
            {
                MessageBox.Show("Loi them sach\n" + ex.Message);
            }
        }
Ejemplo n.º 12
0
        private void dgvSach_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var senderGrid = (DataGridView)sender;

                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                    e.RowIndex >= 0)
                {
                    string idSach    = txtMaSach.Text;
                    string name      = txtTenSach.Text;
                    string idTG      = comboTG.ToString();
                    string idTL      = comboTheLoai.ToString();
                    string tinhTrang = txtTinhTrang.Text;
                    int    nxb       = int.Parse(txtNXB.Text);
                    Sach   s         = new Sach(idSach, name, idTG, idTL, nxb, tinhTrang);
                    bool   b         = new SachBUS().DeleteSach(s);
                    if (b)
                    {
                        MessageBox.Show("Xóa Thành Công");
                    }
                    Init();
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Xoa that bai", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void LoadTacGia()
        {
            List <TACGIA> tacgias = SachBUS.GetTacGias();

            cbbTacGia.DataSource    = tacgias;
            cbbTacGia.DisplayMember = "TenTacGia";
        }
Ejemplo n.º 14
0
 void LoadData()
 {
     if (SachBUS.TimKiemTheoTheLoai(cboTheLoai.SelectedValue.ToString()).Rows.Count > 0)
     {
         dgvDanhSach.DataSource = SachBUS.TimKiemTheoTheLoai(cboTheLoai.SelectedValue.ToString());
         Custom();
         dgvDanhSach.ClearSelection();
         for (int i = 0; i < dgvDanhSach.RowCount; i++)
         {
             DataGridViewCellStyle style = new DataGridViewCellStyle();
             style.BackColor = Color.Yellow;
             if (int.Parse(dgvDanhSach.Rows[i].Cells[5].Value.ToString()) <= 10)
             {
                 dgvDanhSach.Rows[i].DefaultCellStyle = style;
             }
         }
     }
     else
     {
         MessageBox.Show("Không tìm thấy.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         dgvDanhSach.DataSource = SachBUS.TimKiemTheoTheLoai(cboTheLoai.SelectedValue.ToString());
         Custom();
         dgvDanhSach.ClearSelection();
     }
 }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string idSach  = txtIDSach.Text;
            string tenSach = txtTenSach.Text;

            if (idSach != "")
            {
                if (MessageBox.Show(this, $"Bạn có muốn xóa sách { tenSach } không ?", "Xác nhận", MessageBoxButtons.YesNoCancel,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        SachBUS.DelteSach(Int32.Parse(idSach));
                        MessageBox.Show(this, "Xóa sách thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadSach();
                    }
                    catch
                    {
                        MessageBox.Show(this, $"Không thể xóa sách { tenSach }", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                return;
            }
            else
            {
                MessageBox.Show(this, "Bạn chưa chọn sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void LoadTheLoai()
        {
            List <THELOAI> theloais = SachBUS.GetTheLoais();

            cbbTheLoai.DataSource    = theloais;
            cbbTheLoai.DisplayMember = "TenTheLoai";
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            string   idSach     = txtIDSach.Text;
            string   tenSach    = txtTenSach.Text;
            int      idTheLoai  = ((THELOAI)cbbTheLoai.SelectedItem).IDTheLoai;
            int      idTacGia   = ((TACGIA)cbbTacGia.SelectedItem).IDTacGia;
            int      namXuatBan = Int32.Parse(cbbNamXuatBan.SelectedItem.ToString());
            string   nxb        = txtNhaXuatBan.Text;
            DateTime ngayNhap   = dtPickerNgayNhap.Value;
            string   triGia     = txtTriGia.Text;
            bool     tinhTrang  = cbbTinhTrang.SelectedIndex == 0 ? true : false;

            if (idSach != "")
            {
                if (!IsEmpty(tenSach, nxb, triGia))
                {
                    SachBUS.UpdateSach(Int32.Parse(idSach), tenSach, idTheLoai, idTacGia, namXuatBan, nxb, ngayNhap, Double.Parse(triGia), tinhTrang);
                    MessageBox.Show(this, "Cập nhật sách thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadSach();
                    return;
                }
            }
            else
            {
                MessageBox.Show(this, "Bạn chưa chọn sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string   tenSach    = txtTenSach.Text;
            int      idTheLoai  = ((THELOAI)cbbTheLoai.SelectedItem).IDTheLoai;
            int      idTacGia   = ((TACGIA)cbbTacGia.SelectedItem).IDTacGia;
            int      namXuatBan = Int32.Parse(cbbNamXuatBan.SelectedItem.ToString());
            string   nxb        = txtNhaXuatBan.Text;
            DateTime ngayNhap   = dtPickerNgayNhap.Value;
            string   triGia     = txtTriGia.Text;
            bool     tinhTrang  = cbbTinhTrang.SelectedIndex == 0 ? true : false;

            if (!IsEmpty(tenSach, nxb, triGia))
            {
                try
                {
                    SachBUS.AddSach(tenSach, idTheLoai, idTacGia, namXuatBan, nxb, ngayNhap, Double.Parse(triGia), tinhTrang);
                    MessageBox.Show(this, "Thêm sách thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadSach();
                    btnLuu.Enabled = false;
                }
                catch
                {
                    MessageBox.Show(this, "Không thể thêm sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
        }
Ejemplo n.º 19
0
 private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (txtSearch.Text == "")
     {
         ListViewBooks.ItemsSource = SachBUS.loadByMaLoai(Combobox_CategoriesBook.SelectedValue.ToString());
     }
 }
Ejemplo n.º 20
0
        //Kiem tra sach, luu thong tin sach vao doi tuong hoa don
        int KiemTraSach(string masach, int soluong)
        {
            SachBUS objSach = new SachBUS();

            if (objSach.GetSach(masach) != null)
            {
                if (objSach.GetSach(masach).Rows.Count == 0)
                {
                    MessageBox.Show("mã sách không đúng");
                    txtMasach.Focus();
                    return(0);
                }
                else
                {
                    int ton = ThietLap.TonMin;
                    if (int.Parse(objSach.GetSach(masach).Rows[0]["soluong"].ToString()) - soluong < ton)
                    {
                        MessageBox.Show("số lượng tồn không đủ");
                        return(0);
                    }
                    hd.TenSach = objSach.GetSach(masach).Rows[0]["tensach"].ToString();
                    hd.Theloai = objSach.GetSach(masach).Rows[0]["theloai"].ToString();
                    hd.Gia     = int.Parse(objSach.GetSach(masach).Rows[0]["gia"].ToString());
                    hd.Gia     = hd.Gia * 105 / 100;
                    return(1);
                }
            }
            else
            {
                MessageBox.Show("Lỗi dữ liệu");
                return(0);
            }
        }
Ejemplo n.º 21
0
        private void frmXuatBaoCaoDoanhThu_Load(object sender, EventArgs e)
        {
            BaoCaoDoanhThu report = new BaoCaoDoanhThu();

            report.SetDataSource(SachBUS.BaoCaoDoanhThuS(ngay));
            crvBaoCao.ReportSource = report;
        }
Ejemplo n.º 22
0
        //private void btnThem_Click(object sender, EventArgs e)
        //{
        //    string idsach, tensach, idtacgia, idtheloai, tinhtrang;
        //    int nxb;
        //    idsach = txtMaSach.Text;
        //    tensach = txtTenSach.Text;
        //    idtacgia = comboTG.SelectedValue.ToString();
        //    idtheloai = comboTheLoai.SelectedValue.ToString();
        //    nxb = int.Parse(txtNXB.Text);
        //    tinhtrang = txtTinhTrang.Text;

        //    Sach sach = new Sach(idsach, tensach, idtacgia, idtheloai, nxb, tinhtrang);

        //    try
        //    {
        //        int numerOfRows = new SachBUS().Add(sach);
        //        MessageBox.Show("Them thanh cong");
        //        Init();
        //    }

        //    catch (SqlException ex)
        //    {
        //        MessageBox.Show("Loi them sach\n" + ex.Message);

        //    }
        //}

        private void btnSua_Click(object sender, EventArgs e)
        {
            string idsach, tensach, idtacgia, idtheloai, tinhtrang;
            int    nxb;

            idsach    = txtMaSach.Text;
            tensach   = txtTenSach.Text;
            idtacgia  = comboTG.SelectedValue.ToString();
            idtheloai = comboTheLoai.SelectedValue.ToString();
            nxb       = int.Parse(txtNXB.Text);
            tinhtrang = txtTinhTrang.Text;

            Sach sach = new Sach(idsach, tensach, idtacgia, idtheloai, nxb, tinhtrang);

            try
            {
                bool b = new SachBUS().UpdateSa(sach);
                Init();
                dgvSach.DataSource = new SachBUS().getSach();
                MessageBox.Show("Sửa thông tin sách thành công\n");
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Lỗi sửa thông tin sách\n" + ex.Message);
            }
        }
Ejemplo n.º 23
0
        private void frmXuatThongKeTonKho_Load(object sender, EventArgs e)
        {
            ThongKeTonKho report = new ThongKeTonKho();

            report.SetDataSource(SachBUS.ThongKeTonKho());
            crvThongKe.ReportSource = report;
        }
Ejemplo n.º 24
0
        private void btnTim_Click(object sender, EventArgs e)
        {
            string    idSach = comboTim.SelectedValue.ToString();
            DataTable tb     = new SachBUS().TimkiemtheoTen(idSach);

            dgvSach.DataSource = tb;
        }
Ejemplo n.º 25
0
        private void button_Xoa_Click(object sender, EventArgs e)
        {
            if (txtTenSach.Text.Equals("") == true || txtTacGia.Text.Equals("") == true)
            {
                MessageBox.Show("Chọn sách để xóa", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa sách '" + txtTenSach.Text + "' hay không ?",
                                                        "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                Sach sach = new Sach();
                sach.MaSach = this.maSach;
                SachBUS sachBUS = new SachBUS();

                if (sachBUS.delete(sach) == true)
                {
                    MessageBox.Show("Sách '" + sach.TenSach + "' đã được xóa", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    LoadDgvSach();
                }
                else
                {
                    MessageBox.Show("Xóa thất bại", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 26
0
 void SuaSach()
 {
     if (!CheckData())
     {
         return;
     }
     sach = new DTO.Sach
     {
         MaSach    = txtMaSach.Text,
         TenSach   = txtTenSach.Text,
         MaNXB     = Int32.Parse(cmbNhaXuatBan.SelectedValue.ToString()),
         MaTheLoai = Int32.Parse(cmbTheLoai.SelectedValue.ToString()),
         MoTa      = txtMoTa.Text,
         GiaBanLe  = Int32.Parse(txtGiaLe.Text),
         GiaBanSi  = Int32.Parse(txtGiaSi.Text),
         TacGia    = txtTacGia.Text,
         SoLuong   = Int32.Parse(txtGiaNhap.Text)
     };
     SachBUS.SuaSach(sach);
     MessageBox.Show(SachBUS.Message);
     if (BUS.SachBUS.IsSuccess)
     {
         LoadData();
         ResetControls();
         sach  = null;
         IsAdd = true;
     }
 }
Ejemplo n.º 27
0
        private void LoadSach()
        {
            SACH sach = SachBUS.FindSachById(idSach);

            txtIDSach.Text    = sach.IDSach.ToString();
            txtTenSach.Text   = sach.TenSach;
            txtTinhTrang.Text = sach.TinhTrang ? "Đang có người mượn" : "Chưa được mượn";
        }
Ejemplo n.º 28
0
 private void btn_delete_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow i in dGrV_main.SelectedRows)
     {
         SachBUS.Detete(int.Parse(i.Cells["masach"].Value.ToString()));
     }
     btn_load_all_Click(null, null);
 }
Ejemplo n.º 29
0
        private void btnTimTenTacGia_Click(object sender, EventArgs e)
        {
            int       matg = (int)cmbTenTacGia.SelectedValue;
            SachBUS   sb   = new SachBUS();
            DataTable dt   = new DataTable();

            dt = sb.LayBangTacGia(matg);
            dataGridView1.DataSource = dt;
        }
Ejemplo n.º 30
0
        private void btnTimMaSach_Click(object sender, EventArgs e)
        {
            int       masach = (int)cmbMaSach.SelectedValue;
            SachBUS   sb     = new SachBUS();
            DataTable dt     = new DataTable();

            dt = sb.LayBangMaSach(masach);
            dataGridView1.DataSource = dt;
        }