public bool ReturnDisk(int idListRented)
        {
            ListRented rented = GetListRented(idListRented);

            rented.ActualReturnDate = DateTime.Today;
            return(UpdateListRented(rented));
        }
        public bool PayTheBill(int idListRented)
        {
            ListRented rented = GetListRented(idListRented);

            rented.StatusOnBill = PAID;
            return(UpdateListRented(rented));
        }
Beispiel #3
0
 public bool AddListRented(ListRented listRented)
 {
     try
     {
         context.ListRenteds.Add(listRented);
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #4
0
 public bool DeleteListRented(int idListRented)
 {
     try
     {
         ListRented listRentedDelete = context.ListRenteds.Find(idListRented);
         context.ListRenteds.Remove(listRentedDelete);
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        private ListRented ListItemToListRented(ListViewItem item)
        {
            int        idDisk     = Int32.Parse(item.SubItems[0].Text.ToString());
            int        idCustomer = Int32.Parse(txtMaKH.Text.ToString());
            int        timeRent   = Int32.Parse(item.SubItems[3].Text.ToString());
            double     lateFee    = double.Parse(item.SubItems[4].Text.ToString());
            ListRented rented     = new ListRented
            {
                ActualReturnDate   = null,
                RentalDate         = DateTime.Today,
                ExpectedReturnDate = DateTime.Today.AddDays(timeRent),
                IdCustomer         = idCustomer,
                IdDisk             = idDisk,
                LateFee            = lateFee,
                StatusOnBill       = null
            };

            return(rented);
        }
Beispiel #6
0
 public bool UpdateListRented(ListRented listRented)
 {
     try
     {
         ListRented listRentedUpdate = context.ListRenteds.Find(listRented.IdListRented);
         listRentedUpdate.IdDisk             = listRented.IdDisk;
         listRentedUpdate.IdCustomer         = listRented.IdCustomer;
         listRentedUpdate.LateFee            = listRented.LateFee;
         listRentedUpdate.RentalDate         = listRented.RentalDate;
         listRentedUpdate.ExpectedReturnDate = listRented.ExpectedReturnDate;
         listRentedUpdate.ActualReturnDate   = listRented.ActualReturnDate;
         listRentedUpdate.StatusOnBill       = listRented.StatusOnBill;
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        private void ThucHienThueDia()
        {
            if (txtMaKH.CheckMa() == false)
            {
                return;
            }
            ThucHienLayDiaDatTruoc();
            int idCustomer = Int32.Parse(txtMaKH.Text.ToString());

            foreach (var item in binding.DataSource as List <DiskInfoRent> )
            {
                ListRented rented = new ListRented {
                    IdDisk = item.IdDisk, IdCustomer = idCustomer, LateFee = item.LateFee, RentalDate = DateTime.Today, ExpectedReturnDate = DateTime.Today.AddDays(item.TimeRented), ActualReturnDate = null, StatusOnBill = null
                };
                if (dbRented.AddListRented(rented) == false)
                {
                    MessageBox.Show("Thuê đĩa thất bại", "Thuê đĩa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            MessageBox.Show("Thuê đĩa thành công", "Thuê đĩa", MessageBoxButtons.OK, MessageBoxIcon.Error);
            db = ExpressionMethod.DBDiskRent();
            binding.DataSource = new List <DiskInfoRent>();
        }
 public bool UpdateListRented(ListRented listRented)
 {
     return(db.UpdateListRented(listRented));
 }
 public bool AddListRented(ListRented listRented)
 {
     return(db.AddListRented(listRented));
 }