public string Devolucion(int indice, DateTime fecha, double km) { Alquiler alquiler = registro[indice]; alquiler.KmRecorridos = km; registro.RemoveAt(indice); int dias = fecha.Day - alquiler.Fecha.Day; alquiler.DiasTranscurridos = dias; int demora = 0; if (dias <= alquiler.Dias && fecha.Hour < 22) { alquiler.PrecioFinal = alquiler.Precio; } else { demora = dias - alquiler.Dias; if (fecha.Hour >= 22) { demora++; } alquiler.PrecioFinal += alquiler.Precio + alquiler.Auto.Valor * alquiler.UnidadCosto * 1.10 * demora; alquiler.AdicionalDias = alquiler.Auto.Valor * alquiler.UnidadCosto * 1.10 * demora; } double kmPermitidos = (alquiler.Dias + demora) * 500; if (km > kmPermitidos) { double diferencia = km - kmPermitidos; if (diferencia <= 100) { alquiler.PrecioFinal += diferencia * 3 * alquiler.UnidadCosto; alquiler.AdicionalKm = diferencia * 3 * alquiler.UnidadCosto; } else if (diferencia > 100) { alquiler.PrecioFinal += diferencia * 5 * alquiler.UnidadCosto; alquiler.AdicionalKm = diferencia * 5 * alquiler.UnidadCosto; } } LiberarVehiculo(alquiler.Auto); AgregarRegistro(alquiler); return(Factura(alquiler)); }
public string Factura(Alquiler alquiler) { string texto; if (alquiler.Auto is VehiculoConChofer) { texto = "Razon Social: " + empresa.RazonSocial + "\nCliente: " + alquiler.VerCliente.Nombre + "\nCuit: " + alquiler.VerCliente.cuitCuil + "\nPatente: " + alquiler.Auto.Patente + "\nKm permitidos: " + alquiler.Dias * 500 + "\nKm recorridos: " + alquiler.KmRecorridos + "\nAdicional por km: $" + alquiler.AdicionalKm + "\nDias permitidos: " + alquiler.Dias + "\nDias transcurridos: " + alquiler.DiasTranscurridos + "\nAdicional dias: $" + alquiler.AdicionalDias + "\nViáticos: $" + alquiler.Viaticos + "\nValor Inicial: $" + alquiler.Precio.ToString() + "\nValor Final: $" + alquiler.PrecioFinal; } else { texto = "Razon Social: " + empresa.RazonSocial + "\nCliente: " + alquiler.VerCliente.Nombre + "\nCuit: " + alquiler.VerCliente.cuitCuil + "\nPatente: " + alquiler.Auto.Patente + "\nKm permitidos: " + alquiler.Dias * 500 + "\nKm recorridos: " + alquiler.KmRecorridos + "\nAdicional por km: $" + alquiler.AdicionalKm + "\nDias permitidos: " + alquiler.Dias + "\nDias transcurridos: " + alquiler.DiasTranscurridos + "\nAdicional dias: $" + alquiler.AdicionalDias + "\nValor Inicial: $" + alquiler.Precio.ToString() + "\nValor Final: $" + alquiler.PrecioFinal; } return(texto); }
public int Alquiler(Cliente unCliente, DateTime fecha, int dias, bool chofer, string patente) { Alquiler nuevoAlquiler; int posicion = 0; if (chofer == true) // Con chofer { int indice = BuscarVehiculo(patente, chofer); nuevoAlquiler = new Alquiler(unCliente, listaDeVehiculosConChofer[indice], fecha, dias, unidad); listaDeVehiculosConChofer[indice].Disponible = false; registro.Add(nuevoAlquiler); posicion = registro.IndexOf(nuevoAlquiler); } else if (chofer == false) // Sin chofer { int indice = BuscarVehiculo(patente, chofer); nuevoAlquiler = new Alquiler(unCliente, ListaDeVehiculos[indice], fecha, dias, unidad); ListaDeVehiculos[indice].Disponible = false; registro.Add(nuevoAlquiler); posicion = registro.IndexOf(nuevoAlquiler); } return(posicion); }
public void AgregarRegistro(Alquiler unAlquiler) { historico.Add(unAlquiler); }
public string Importar(string path) { FileStream fls = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader srd = new StreamReader(fls); List <string> lineas = new List <string>(); while (srd.EndOfStream == false) { string linea = srd.ReadLine(); lineas.Add(linea); } BackUp(); registro.Clear(); listaDeVehiculos.Clear(); listaDeVehiculosConChofer.Clear(); foreach (string l in lineas) { string[] datos = l.Split(';'); Cliente cl; Vehiculo vh; Alquiler alq; if (datos[0] == "alquiler") { // 2 al 9 cl = new Cliente(datos[2], datos[3], datos[4], datos[5], Convert.ToInt32(datos[6]), datos[7], datos[8], datos[9]); if (datos.Contains("chofer") == true) { // 12 al 25 // alquiler con chofer vh = new VehiculoConChofer(datos[12], datos[13], datos[14], Convert.ToInt32(datos[15]), Convert.ToInt32(datos[16]), datos[18], datos[19], datos[20], datos[21], datos[22], datos[23], datos[24], datos[25], Convert.ToInt32(datos[26])); DateTime fecha = DateTime.Parse(datos[27]); alq = new Alquiler(cl, vh, fecha, Convert.ToInt32(datos[28]), Convert.ToDouble(datos[29])); } else { // 11 al 15 // Alquiler sin chofer vh = new Vehiculo(datos[11], datos[12], datos[13], Convert.ToInt32(datos[14]), Convert.ToInt32(datos[15])); DateTime fecha = DateTime.Parse(datos[16]); alq = new Alquiler(cl, vh, fecha, Convert.ToInt32(datos[17]), Convert.ToDouble(datos[18])); } registro.Add(alq); } else if (datos[0] == "vehiculo") { vh = new Vehiculo(datos[1], datos[2], datos[3], Convert.ToInt32(datos[4]), Convert.ToInt32(datos[5])); listaDeVehiculos.Add(vh); } else if (datos[0] == "vehiculoconchofer") { VehiculoConChofer vhcc = new VehiculoConChofer(datos[2], datos[3], datos[4], Convert.ToInt32(datos[5]), Convert.ToInt32(datos[6]), datos[8], datos[9], datos[10], datos[11], datos[12], datos[13], datos[14], datos[15], Convert.ToInt32(datos[16])); listaDeVehiculosConChofer.Add(vhcc); } } srd.Close(); fls.Dispose(); return("Los datos han sido importados exitosamente"); }
public string Ticket(int indice) { Alquiler alquiler = registro[indice]; return("TICKET:\nRazon Social: " + empresa.RazonSocial + "\nVehiculo: " + alquiler.Auto.Modelo + "\nPatente: " + alquiler.Auto.Patente + "\nCliente: " + alquiler.VerCliente.nombre + "\nFecha Alquiler: " + alquiler.Fecha.ToString("dd/MM/yyyy") + "\nFecha Devolucion: " + alquiler.FechaDevolucion.ToString("dd/MM/yyyy") + "\nValor: $" + alquiler.Precio); }