private void BtnBuscar_Click(object sender, EventArgs e) { int numeroPlanilla = int.TryParse(txtNumeroPlanilla.Text, out int numPlanilla) ? numPlanilla : 0; DateTime? fecha = chkFecha.Checked ? dtpFecha.Value : (DateTime?)null; ChoferBE chofer = (ChoferBE)cmbChofer.SelectedItem; VehiculoBE coche = (VehiculoBE)cmbCoche.SelectedItem; RecorridoBE recorrido = (RecorridoBE)cmbRecorrido.SelectedItem; try { List <PlanillaHorariaBE> planillas = PlanillaHoraria.Buscar(numeroPlanilla, fecha, chofer, coche, recorrido); dgvResultadoBusqueda.DataSource = planillas.Select(p => new GridItem { Planilla = p, Id = p.Id, Fecha = p.Fecha, Chofer = p.Chofer.Nombre, Vehiculo = p.Vehiculo.Patente, Recorrido = p.Recorrido.ToString(), Detalles = ObtenerLeyenda("btnVer") }).ToList(); } catch { MostrarError(); } }
private void BtnGuardar_Click(object sender, EventArgs e) { if (ValidarGrilla()) { try { foreach (DataGridViewRow row in dgvViajes.Rows) { GridItem gridItem = row.DataBoundItem as GridItem; ViajeBE viaje = gridItem.Viaje; viaje.Completado = row.Cells["colCompletado"].Value != null && (bool)row.Cells["colCompletado"].Value; if (row.Cells["colHoraRealLlegada"].Value != null) { viaje.HoraRealLlegada = new DateTime() + TimeSpan.Parse(row.Cells["colHoraRealLlegada"].Value.ToString()); } if (row.Cells["colDensidadPasajeros"].Value != null) { viaje.Completitud = completitudes.FirstOrDefault(c => c.Value == row.Cells["colDensidadPasajeros"].Value.ToString()).Key; } } PlanillaHoraria.GuardarViajes(planillaHoraria); MessageBox.Show(ObtenerLeyenda("msgPlanillaActualizada")); } catch { MostrarError(); } } }
private void RefrescarGeneracionPlanillas() { DateTime ultimaFecha = PlanillaHoraria.ObtenerUltimaPlanilla(); if (ultimaFecha == default) { lblUltimaPlanillaInfo.Text = ObtenerLeyenda("msgNoHayPlanillas"); } else { string leyendaUltimaPlanillaInfo = ObtenerLeyenda("lblUltimaPlanillaInfo"); if (leyendaUltimaPlanillaInfo.Contains("{0}")) { lblUltimaPlanillaInfo.Text = string.Format(leyendaUltimaPlanillaInfo, ultimaFecha.ToString("dd/MM/yyyy")); } } DateTime proximaFecha = GeneradorDePlanillas.ObtenerProximaFecha(ultimaFecha, out bool puedeGenerarse); string leyendaGenerarPlanillas = ObtenerLeyenda("btnGenerarPlanillas"); if (leyendaGenerarPlanillas.Contains("{0}")) { btnGenerarPlanillas.Text = string.Format(leyendaGenerarPlanillas, proximaFecha.ToString("dd/MM/yyyy")); } btnGenerarPlanillas.Enabled = puedeGenerarse; }