Exemplo n.º 1
0
        private void Search()
        {
            this._rentals = new BindingList <Rental>(viewModel.GetRentals());

            //if(this._rentals != null && this._rentals.Count > 0) {
            //	foreach(var item in _rentals) {
            //		item.RentBook = _bookService.GetBook(item.Book_Idx);
            //		item.RentCustomer = _customerService.GetCustomer(item.Customer_Idx);
            //	}
            //}

            //if (string.IsNullOrEmpty(textBox1.Text))
            //	this._rentals = new BindingList<Rental>(_viewModel.GetRentals());
            //else
            //	this._customers = new BindingList<Customer>(_viewModel.GetCustomers(textBox1.Text));

            this.dataGridView1.DataSource = this._rentals;

            this.dateTimePicker1.DataBindings.Clear();
            this.dateTimePicker2.DataBindings.Clear();
            this.textBox4.DataBindings.Clear();
            this.textBox5.DataBindings.Clear();
            this.textBox6.DataBindings.Clear();

            this.dateTimePicker1.DataBindings.Add("Value", this._rentals, "Rent_Start_Day");
            this.dateTimePicker2.DataBindings.Add("Value", this._rentals, "Rent_End_Day");
            this.textBox4.DataBindings.Add("Text", this._rentals, "Rent_Total_Cost");
            this.textBox5.DataBindings.Add("Text", this._rentals, "CustomerName");
            this.textBox6.DataBindings.Add("Text", this._rentals, "BookTitle");

            this.dataGridView1.Columns[0].Visible          = false;
            this.dataGridView1.Columns[1].Visible          = false;
            this.dataGridView1.Columns["CrudType"].Visible = false;
        }
Exemplo n.º 2
0
    public string Statement()
    {
        double totalAmount          = 0;
        int    frequentRenterPoints = 0;
        string result = "Rental Record for " + GetName() + "\n";

        foreach (Rental each in RentalService.GetRentals())
        {
            double thisAmount = 0;

            //determine amounts for each line
            switch (each.GetMovie().GetPriceCode())
            {
            case Movie.REGULAR:
                thisAmount += 2;
                if (each.GetDaysRented() > 2)
                {
                    thisAmount += (each.GetDaysRented() - 2) * 1.5;
                }
                break;

            case Movie.NEW_RELEASE:
                thisAmount += each.GetDaysRented() * 3;
                break;

            case Movie.CHILDRENS:
                thisAmount += 1.5;
                if (each.GetDaysRented() > 3)
                {
                    thisAmount += (each.GetDaysRented() - 3) * 1.5;
                }
                break;
            }

            frequentRenterPoints++;
            if ((each.GetMovie().GetPriceCode() == Movie.NEW_RELEASE) &&
                each.GetDaysRented() > 1)
            {
                frequentRenterPoints++;
            }

            result += "\t" + each.GetMovie().GetTitle() + "\t" +
                      thisAmount + "\n";
            totalAmount += thisAmount;
        }
        result += "Amount owed is " + totalAmount + "\n";
        result += "You earned " + frequentRenterPoints +
                  " frequent renter points";
        return(result);
    }
Exemplo n.º 3
0
 private List <RentalDto> GetRentalsOfReports(out decimal earnings, out decimal totalByCost)
 {
     return(_rentalService.GetRentals(out earnings, out totalByCost));
 }