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();
        }