private void bttnMakeCashCount_Click(object sender, EventArgs e) { double Income = 0; double Outcome = 0; foreach (Movement movement in movementCollection.GetItsIncome()) { Income += movement.Amount; } foreach (Movement movement in movementCollection.GetItsOutcome()) { Outcome += movement.Amount; } lblBalance.Text = Convert.ToString(Income - Outcome); cashCount.Date = DateTime.Now; cashCountCollection.Add(cashCount); foreach (Movement movement in movementCollection.GetAll()) { if (movement.CashCount == null) { movement.CashCount = cashCount; } } xmlMovements.GenerateXMLMovements(movementCollection.GetAll()); xmlCashCounts.GenerateXMLCashCounts(cashCountCollection.GetAll()); BindData(); }
private void bttnPay_Click(object sender, EventArgs e) { if (numAmount.Value > 1) { Movement movement = new Movement(); if (cmbPayment.SelectedIndex == 0) { movement.Concept = Convert.ToString(cmbPayment.SelectedItem + " " + cmbService.SelectedItem); } else { if (cmbPayment.SelectedIndex == 1) { movement.Concept = Convert.ToString(cmbPayment.SelectedItem); } else { movement.Concept = txtConcept.Text; } } movement.Amount = Convert.ToDouble(numAmount.Value); movement.Date = DateTime.Now; movement.ItsIncome = false; movement.User = user; movementCollection.Add(movement); xmlMovements.GenerateXMLMovements(movementCollection.GetAll()); txtConcept.Text = null; Hide(); } else { MessageBox.Show("The value can't be negative nor equal to 1."); } }
private void bttnAdd_Click(object sender, EventArgs e) { try { Garage garage = new Garage(); Vehicle vehicle = new Vehicle(); TypeVehicle typeVehicle = new TypeVehicle(); garage.Number = Convert.ToInt16(lblNumber.Text); garage.Ubication = lblUbication.Text; garage.State = false; vehicle.Domain = maskDomain.Text; vehicle.Brand = txtBrand.Text; vehicle.Model = txtModel.Text; garage.Vehicle = vehicle; switch (cmbTypeOfVehicle.SelectedIndex) { case 0: { typeVehicle.Code = "1"; typeVehicle.Description = cmbTypeOfVehicle.SelectedItem.ToString(); break; } case 1: { typeVehicle.Code = "2"; typeVehicle.Description = cmbTypeOfVehicle.SelectedItem.ToString(); break; } case 2: { typeVehicle.Code = "3"; typeVehicle.Description = cmbTypeOfVehicle.SelectedItem.ToString(); break; } } garage.Vehicle.TypeVehicle = typeVehicle; if (rentalCollection.IfDomainExists(maskDomain.Text)) { MessageBox.Show("This domain already exists."); } else { if (radBttnHour.Checked == true) { RentalHour rentalHour = new RentalHour(); rentalHour.Date = DateTime.Now; rentalHour.Garage = garage; rentalHour.Since = DateTime.Now; rentalCollection.Add(rentalHour); xmlRentals.GenerateXMLRentals(rentalCollection.GetAll()); clickedBttn.Text = clickedBttn.Text + " HOUR\n" + garage.Vehicle.TypeVehicle.Description + " \n" + garage.Vehicle.Domain; } else { RentalMonth rentalMonth = new RentalMonth(); Movement movement = new Movement(); rentalMonth.Date = DateTime.Now; rentalMonth.Garage = garage; rentalMonth.Holder = txtOwner.Text; rentalMonth.DueDate = rentalMonth.Date.AddMonths(Convert.ToInt16(numMonth.Value)); rentalCollection.Add(rentalMonth); xmlRentals.GenerateXMLRentals(rentalCollection.GetAll()); movement.Concept = "MONTH: " + garage.Vehicle.TypeVehicle.Description + " " + garage.Vehicle.Domain; movement.Amount = rentalMonth.CalculateAmount(); movement.Date = DateTime.Now; movement.ItsIncome = true; movement.User = user; movement.CashCount = null; movementCollection.Add(movement); xmlMovements.GenerateXMLMovements(movementCollection.GetAll()); MessageBox.Show("You have to charge " + movement.Amount + " to your client."); clickedBttn.Text = clickedBttn.Text + " MONTH\n" + garage.Vehicle.TypeVehicle.Description + " \n" + garage.Vehicle.Domain; } garageCollection.Add(garage); clickedBttn.BackColor = Color.Red; Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }