Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Viaje
- {
- public partial class Form1 : Form
- {
- double cInternacional = 0;
- double cNacional = 0;
- double cViajes = 0;
- int cTren = 0;
- int cBarco = 0;
- int c160;
- double aPrecios;
- Viaje m = new Viaje();
- public Form1()
- {
- InitializeComponent();
- }
- private void cmdRegistrar_Click(object sender, EventArgs e)
- {
- Viaje v = new Viaje();
- v.pCodigo = Convert.ToInt32(txtCodigo.Text);
- v.pDestino = txtDestino.Text;
- v.pFecha = dtpFecha.Value;
- v.pPrecio = Convert.ToDouble(txtPrecio.Text);
- if (v.pPrecio > 160)
- {
- c160++;
- lblPrecioViajes.Text = Convert.ToString(c160);
- }
- aPrecios += v.pPrecio;
- if (rbtInternacional.Checked)
- {
- v.pTipo = 2;
- cInternacional++;
- }
- else
- {
- v.pTipo = 1;
- cNacional++;
- }
- if (cViajes == 0)
- {
- m = v;
- lblViajeBarato.Text = "Viaje mas Barato: " + m.pPrecio;
- }
- else
- if (v.pPrecio < m.pPrecio)
- m = v;
- cViajes++;
- v.pTransporte = cmbTransporte.SelectedIndex + 1;
- if (v.pTipo == 1)
- {
- if (v.pTransporte == 2)
- cTren++;
- }
- else
- if (v.pTransporte == 4)
- cBarco++;
- lblViajesNacionales.Text = "Viajes Nacionales: " + Convert.ToString(Math.Round(cNacional/cViajes *100,2));
- lblViajesInternacionales.Text = "Viajes Internacionales: " + Convert.ToString(Math.Round(cInternacional / cViajes * 100,2));
- lblViajesNacTren.Text = "Viajes Nacionales en Tren: " + Convert.ToString(cTren);
- lblViajesInterBarco.Text = "Viajes Internacionales en Barco: " + Convert.ToString(cBarco);
- lblViajeBarato.Text = "Viaje Mas Barato: " + m.pPrecio;
- lblPrecioPromedio.Text = "Precio promedio de Viajes: " + Convert.ToString(Math.Round(aPrecios / cViajes,2));
- MessageBox.Show(v.toStringClase());
- }
- }
- }
Add Comment
Please, Sign In to add comment