private void BttnRenew_Click(object sender, EventArgs e)
 {
     try
     {
         Movement movement = new Movement();
         movement.Concept = "MONTH: " + cmbTypeOfVehicle.SelectedItem.ToString() + " " + txtDomainComplete.Text;
         movement.Amount = Convert.ToInt32(numRenew.Value) * 1500;
         movement.Date = DateTime.Now;
         movement.ItsIncome = true;
         movement.User = user;
         movementCollection.Add(movement);
         xmlMovements.GenerateXMLMovements(movementCollection.GetAll());
         rentalCollection.SearchRentMonthByNumber(Convert.ToInt16(lblNumber.Text)).DueDate.AddMonths(Convert.ToInt32(numRenew.Value));
         rentalCollection.AddRentalsList(xmlRentals.GetRentals());
         MessageBox.Show("Charge your client " + Convert.ToInt32(numRenew.Value) * 1500 + " so he can renew his rent.");
         Close();
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
        private void FormMenu_Load(object sender, EventArgs e)
        {
            try
            {
                cashCountCollection.AddCashCountList(xmlCashCounts.GetCashCounts());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            xmlCashCounts.GenerateXMLCashCounts(cashCountCollection.GetAll());

            try
            {
                rentalCollection.AddRentalsList(xmlRentals.GetRentals());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            xmlRentals.GenerateXMLRentals(rentalCollection.GetAll());

            try
            {
                movementCollection.AddMovementsList(xmlMovements.GetMovements());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            xmlMovements.GenerateXMLMovements(movementCollection.GetAll());

            int amountAlerts = 0;

            BindData();
            DataGridViewColumn Column = dgvIncomes.Columns[3];

            Column.Visible = false;
            Column         = dgvOutcomes.Columns[3];
            Column.Visible = false;



            try
            {
                foreach (Rental rental in xmlRentals.GetRentals())
                {
                    if (rental.Garage.State == false)
                    {
                        garageCollection.Add(rental.Garage);
                        if (rental is RentalMonth)
                        {
                            RentalMonth rentalMonth = (RentalMonth)rental;
                            TimeSpan    dateAux     = rentalMonth.DueDate - DateTime.Today;
                            if (dateAux.TotalDays <= 5)
                            {
                                alerts.Add(rentalMonth);
                                amountAlerts = amountAlerts + 1;
                            }
                        }
                    }
                }

                foreach (Button button in groupGarages.Controls)
                {
                    Rental rental = rentalCollection.SearchRentByNumber(Convert.ToInt16(button.Text));

                    if (rental != null)
                    {
                        if (rental.Garage.State == false)
                        {
                            button.BackColor = Color.Red;
                            if (rental is RentalHour)
                            {
                                button.Text = button.Text + " HOUR\n" + rental.Garage.Vehicle.TypeVehicle.Description + " \n" + rental.Garage.Vehicle.Domain;
                            }
                            else
                            {
                                button.Text = button.Text + " MONTH\n" + rental.Garage.Vehicle.TypeVehicle.Description + " \n" + rental.Garage.Vehicle.Domain;
                            }
                            rental = null;
                        }
                    }
                }

                if (amountAlerts > 0)
                {
                    MessageBox.Show("¡ " + amountAlerts + " alquileres a punto de terminar! Revisar ¡Alertas! para más información.");
                }
            }
            catch
            {
                MessageBox.Show("¡Error cargando cocheras. Avisar a administrador! (Error 001 - XML)");
            }
        }