Exemplo n.º 1
0
        private void btn_tradia_Click(object sender, EventArgs e)
        {
            DateTime now = DateTime.Now;

            listKH  = new List <eKhachHang>();
            listDVD = new List <eDVD>();
            int count = 0;

            foreach (DataGridViewRow row in dgvDsTra.Rows)
            {
                int      id_phieu = Convert.ToInt32(row.Cells[0].Value.ToString());
                DateTime ngayThue = Convert.ToDateTime(row.Cells[2].Value.ToString());
                int      id_dvd   = Convert.ToInt32(row.Cells[1].Value.ToString());
                double   time     = theLoaiBUL.GetTheLoaiByID(tieuDeBUL.GetTieuDeByID(dvdBul.FindDVDById(id_dvd).id_TieuDe).id_TheLoai).thoiGianThue;
                eDVD     dvd      = dvdBul.FindDVDById(id_dvd);
                if (!listDVD.Contains(dvd))
                {
                    listDVD.Add(dvd);
                }
                eKhachHang kh = khBul.Find(Convert.ToInt32(row.Cells[3].Value.ToString()));
                if (!listKH.Contains(kh))
                {
                    listKH.Add(kh);
                }
                if ((now - ngayThue).TotalDays > time)
                {
                    count = phieuTTBul.UpdatePhieuThue_Tre(id_phieu, now, PHI_TRE_HEN);
                }
                else
                {
                    count = phieuTTBul.UpdatePhieuThue(id_phieu, now, now, 0);
                }
                dvdBul.UpdateTrangThaiDVD(id_dvd, -1);
            }
            if (count == 1)
            {
                MessageBox.Show("Trả đĩa thành công");
                table.Clear();
                LoadData();
            }
            CheckPhiTreHen();
            UpdateDVDDatTruoc();
        }
Exemplo n.º 2
0
        private void btn_dat_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = this.dgv_dstieude.Rows[vitri];
            //Ma tieu de
            int            s   = Convert.ToInt32(row.Cells[0].Value.ToString());
            ePhieuDatTruoc pdt = new ePhieuDatTruoc();
            int            id  = Convert.ToInt32(txt_idkh.Text);

            eKhachHang kh = khachHangBUL.Find(id);

            if (kh != null)
            {
                eDVD dvd = dVDBUL.getDVDOnShelf(s);
                if (dvd != null)
                {
                    pdt.id_DVD       = dvd.id_DVD;
                    pdt.id_TieuDe    = s;
                    pdt.ngayDatTruoc = DateTime.Today;
                    pdt.id_KhachHang = kh.id_KhachHang;
                    pdt.trangThai    = 0;
                    phieuDatTruocBUL.Save(pdt);
                    MessageBox.Show("Đặt trước thành công");

                    dVDBUL.UpdateTrangThaiDVD(dvd.id_DVD, 0);
                }
                else
                {
                    pdt.id_TieuDe    = s;
                    pdt.ngayDatTruoc = DateTime.Today;
                    pdt.id_KhachHang = kh.id_KhachHang;
                    pdt.trangThai    = 0;
                    phieuDatTruocBUL.Save(pdt);
                    MessageBox.Show("Đặt trước thành công");
                }
            }
            else
            {
                MessageBox.Show("Không tìm thấy khách hàng");
                return;
            }
            dgv_dstieude.DataSource = tieuDeBUL.getTieuDes();
        }
Exemplo n.º 3
0
        private void btn_ttphi_Click(object sender, EventArgs e)
        {
            int      count = 0;
            DateTime now   = DateTime.Now;

            if (idkh == 0)
            {
                MessageBox.Show("Bạn hãy đưa vào thông tin khách hàng");
                return;
            }
            if (dsDiaThue.RowCount != 0)
            {
                foreach (DataGridViewRow row in dsDiaThue.Rows)
                {
                    int id_DVD = Convert.ToInt32(row.Cells[0].Value.ToString());
                    count = phieuTTBul.AddPhieuThue(id_DVD, idkh, now);
                    if (count == 1)
                    {
                        dVDBUL.UpdateTrangThaiDVD(id_DVD, 1);   // 1 là trạng thái đang cho thuê
                    }
                }
            }
            if (dgvphitrehanthanhtoan.Rows.Count != 0)
            {
                foreach (DataGridViewRow row in dgvphitrehanthanhtoan.Rows)
                {
                    int id_DVD = Convert.ToInt32(row.Cells[1].Value.ToString());
                    count = treHenbul.ThanhToanPhiTreHen(idkh, id_DVD, now);
                }
            }
            if (count == 1)
            {
                MessageBox.Show("Thanh toán thành công");
                listThue.Clear();
                listPhieuPhiTreHenSau.Clear();
                dsDiaThue.DataSource = ConvertListToDataTable(listThue);
                FormatGridViewDiaThue(dsDiaThue);
                dgvphitrehanthanhtoan.DataSource = ConvertListToDataTableTreHan(listPhieuPhiTreHenSau);
                FormatGridViewTrehan(dgvphitrehanthanhtoan);
            }
        }