Exemplo n.º 1
0
        private void AsignarDatos(ECarreras eCarrera)
        {
            StringBuilder info = new StringBuilder();

            info.Append("Código carrera: ").Append(eCarrera.Id_carrera.ToString());
            info.Append(Environment.NewLine);
            info.Append("Cliente: ").Append(eCarrera.ECliente.Nombre_cliente);
            info.Append(Environment.NewLine);
            info.Append("Dirección: ").Append(eCarrera.EDireccion.Direccion).Append(" ");
            info.Append("Barrio: ").Append(eCarrera.EDireccion.EBarrio.Nombre_barrio);
            this.txtInformacion.Text = info.ToString();

            TimeSpan diferenciaHoras = new TimeSpan();

            DateTime horaInicio = new DateTime();

            horaInicio = DateTime.Parse(eCarrera.Hora_carrera);

            DateTime horaActual = new DateTime();

            horaActual = DateTime.Parse(DateTime.Now.ToString("HH:mm:ss"));

            diferenciaHoras = horaActual - horaInicio;
            double minutos = diferenciaHoras.TotalMinutes;

            this.lblTiempoTranscurrido.Text = Convert.ToInt32(minutos) + " minutos transcurridos.";
        }
Exemplo n.º 2
0
        private void AsignarDatos(ECarreras eCarrera)
        {
            //Asignar la hora de inicio
            if (this.ConvertHour(ECarrera.Hora_carrera, out TimeSpan HoraInicio))
            {
                DateTime time = DateTime.Today.Add(HoraInicio);
                //this.lblHoraInicio.Text = "Hora de inicio: " + HoraInicio.ToString(@"hh\:mm\:ss");
                this.lblHoraInicio.Text = "Hora de inicio: " + time.ToString("hh:mm tt");
            }

            //Asignar el tiempo de llegada
            this.lblTiempoLlegada.Text = "Tiempo de llegada: " + ECarrera.Tiempo_llegada.ToString() + " min. ";

            //Asignar la información de la carrera
            StringBuilder info = new StringBuilder();

            info.Append("Vehículo: ").Append(eCarrera.EVehiculo.Id_vehiculo);
            info.Append(Environment.NewLine);
            info.Append("Cliente: ").Append(eCarrera.ECliente.Nombre_cliente).Append(" Código: ").Append(eCarrera.ECliente.Id_cliente);
            info.Append(Environment.NewLine);
            info.Append("Dirección: ").Append(eCarrera.EDireccion.Direccion).Append(" ");
            info.Append("Barrio: ").Append(eCarrera.EDireccion.EBarrio.Nombre_barrio);
            info.Append(Environment.NewLine);
            info.Append("Observaciones: ").Append(eCarrera.Observaciones);
            this.txtInformacion.Text = info.ToString();

            this.Hora_carrera = eCarrera.Hora_carrera;

            if (eCarrera.Estado_carrera.Equals("TERMINADA"))
            {
                this.lblTiempoTranscurrido.Text = "Carrera terminada";
                this.btnCancelar.Visible        = false;
                this.btnConfiguracion.Visible   = false;
                this.btnTerminar.Visible        = false;
                return;
            }

            if (eCarrera.Estado_carrera.Equals("CANCELADA"))
            {
                this.lblTiempoTranscurrido.Text = "Carrera cancelada";
                this.btnCancelar.Visible        = false;
                this.btnConfiguracion.Visible   = false;
                this.btnTerminar.Visible        = false;
                return;
            }

            //Iniciar el timer
            if (aTimer != null)
            {
                aTimer.Enabled = true;
            }
        }
Exemplo n.º 3
0
        private void BtnAsignarCarrera_Click(object sender, EventArgs e)
        {
            if (this.EDireccion != null && this.ECliente != null && this.EVehiculo != null)
            {
                if (int.TryParse(this.tiempoLlegada.Value.ToString(), out int tiempo_llegada))
                {
                    MensajeEspera.ShowWait("Asignando...");
                    ECarreras eCarrera = new ECarreras
                    {
                        ECliente   = this.ECliente,
                        EDireccion = this.EDireccion,
                        EVehiculo  = this.EVehiculo,
                        EEmpleado  = new EEmpleados {
                            Id_empleado = 1
                        },
                        Fecha_carrera   = DateTime.Now,
                        Hora_carrera    = DateTime.Now.ToString("HH:mm:ss"),
                        Lugar_ubicacion = this.txtLugarUbicacion.Text,
                        Tiempo_llegada  = tiempo_llegada,
                        Estado_carrera  = "PENDIENTE",
                        Observaciones   = ""
                    };

                    string rpta = ECarreras.InsertarCarrera(eCarrera, out int id_carrera);
                    if (rpta.Equals("OK"))
                    {
                        MensajeEspera.CloseForm();
                        //Mensajes.MensajeInformacion("La carrera fue aprobada con el siguiente código: " + id_carrera.ToString(),
                        //    "Entendido");
                        eCarrera.Id_carrera = id_carrera;
                        this.OnCarreraAsignada?.Invoke(eCarrera, e);
                        this.Close();
                    }
                    else
                    {
                        throw new Exception(rpta);
                    }
                }
            }
            else
            {
                Mensajes.MensajeInformacion("Verifique los datos seleccionados", "Entendido");
            }
        }
Exemplo n.º 4
0
        private void BuscarReporte()
        {
            try
            {
                DataTable dtResumenPrincipal = new DataTable();
                DataTable dtVehiculos        = new DataTable();
                DataTable dtVehiculosEstado  = new DataTable();
                DataTable dtCarrerasPerdidas = new DataTable();

                string rpta           = "";
                bool   searchComplete = false;
                if (rdTotal.Checked)
                {
                    if (this.rdVehiculo.Checked)
                    {
                        EVehiculos eVehiculo = (EVehiculos)this.btnSeleccionar.Tag;
                        dtResumenPrincipal =
                            ECarreras.BuscarCarrerasReporte(eVehiculo.Id_vehiculo, out dtVehiculos,
                                                            out dtVehiculosEstado, out rpta);

                        if (!rpta.Equals("OK"))
                        {
                            throw new Exception(rpta);
                        }

                        searchComplete = true;
                    }
                }
                else if (rdTurno.Checked)
                {
                    if (this.DtTurnos == null)
                    {
                        Mensajes.MensajeInformacion("No hay turnos para realizar la búsqueda", "Entendido");
                        return;
                    }

                    if (string.IsNullOrEmpty(this.listaTurnos.Text))
                    {
                        Mensajes.MensajeInformacion("Debe seleccionar un turno", "Entendido");
                        return;
                    }

                    if (!int.TryParse(Convert.ToString(this.listaTurnos.SelectedValue), out int id_turno))
                    {
                        Mensajes.MensajeInformacion("Hubo un error al recuperar el id del turno, debe ser solo números, valor seleccionado: " +
                                                    Convert.ToString(this.listaTurnos.SelectedValue), "Entendido");
                        return;
                    }

                    DataRow[] rows = this.DtTurnos.Select(string.Format("Id_turno = {0}", id_turno));
                    if (rows.Length <= 0)
                    {
                        Mensajes.MensajeInformacion("No se encontró el turno guardado", "Entendido");
                        return;
                    }

                    dtCarrerasPerdidas = ECarreras_perdidas.BuscarCarrerasPerdidas("ID TURNO", id_turno.ToString(), out rpta);

                    //Obtener las fechas
                    ETurnos  eTurno     = new ETurnos(rows[0]);
                    DateTime horaInicio = DateTime.Today.Add(eTurno.Hora_inicio_turno);
                    DateTime horaFin    = DateTime.Today.Add(eTurno.Hora_fin_turno);
                    string   hora1      = horaInicio.ToString("HH:mm");
                    string   hora2      = horaFin.ToString("HH:mm");

                    if (this.rdVehiculo.Checked)
                    {
                        EVehiculos eVehiculo = (EVehiculos)this.btnSeleccionar.Tag;
                        dtResumenPrincipal =
                            ECarreras.BuscarCarrerasReporte(hora1, hora2, eTurno.Fecha_turno.ToString("yyyy-MM-dd"),
                                                            eVehiculo.Id_vehiculo, out dtVehiculos,
                                                            out dtVehiculosEstado, out rpta);

                        if (!rpta.Equals("OK"))
                        {
                            throw new Exception(rpta);
                        }

                        searchComplete = true;
                    }
                    else
                    {
                        dtResumenPrincipal =
                            ECarreras.BuscarCarrerasReporte(hora1, hora2, eTurno.Fecha_turno.ToString("yyyy-MM-dd"), out dtVehiculos,
                                                            out dtVehiculosEstado, out rpta);

                        if (!rpta.Equals("OK"))
                        {
                            throw new Exception(rpta);
                        }

                        searchComplete = true;
                    }
                }
                else
                {
                    dtResumenPrincipal =
                        ECarreras.BuscarCarrerasReporte(date1.Value.ToString("yyyy-MM-dd"), date2.Value.ToString("yyyy-MM-dd"),
                                                        out dtVehiculos, out dtVehiculosEstado, out rpta);

                    if (!rpta.Equals("OK"))
                    {
                        throw new Exception(rpta);
                    }

                    searchComplete = true;
                }

                if (searchComplete)
                {
                    StringBuilder resumen = new StringBuilder();
                    if (dtResumenPrincipal != null)
                    {
                        int       cantidadCancelada = 0;
                        DataRow[] rowsBusqueda      =
                            dtResumenPrincipal.Select("Estado_carrera = 'CANCELADA' ");
                        if (rowsBusqueda.Length > 0)
                        {
                            string cant = Convert.ToString(rowsBusqueda[0]["CantidadServicios"]);
                            if (!int.TryParse(cant, out cantidadCancelada))
                            {
                                cantidadCancelada = 0;
                            }
                        }

                        int cantidadPendiente = 0;
                        rowsBusqueda =
                            dtResumenPrincipal.Select("Estado_carrera = 'PENDIENTE' ");
                        if (rowsBusqueda.Length > 0)
                        {
                            string cant = Convert.ToString(rowsBusqueda[0]["CantidadServicios"]);
                            if (!int.TryParse(cant, out cantidadPendiente))
                            {
                                cantidadPendiente = 0;
                            }
                        }

                        int cantidadTerminada = 0;
                        rowsBusqueda =
                            dtResumenPrincipal.Select("Estado_carrera = 'TERMINADA' ");
                        if (rowsBusqueda.Length > 0)
                        {
                            string cant = Convert.ToString(rowsBusqueda[0]["CantidadServicios"]);
                            if (!int.TryParse(cant, out cantidadTerminada))
                            {
                                cantidadTerminada = 0;
                            }
                        }

                        int cantidadPerdida = dtCarrerasPerdidas.Rows.Count;

                        resumen.Append("Resultados de carreras: ").Append(Environment.NewLine);
                        resumen.Append("Carreras canceladas: ").Append(cantidadCancelada).Append(" - ");
                        resumen.Append("Carreras pendientes: ").Append(cantidadPendiente).Append(" - ");
                        resumen.Append("Carreras terminadas: ").Append(cantidadTerminada).Append(" - ");
                        resumen.Append("Carreras perdidas: ").Append(cantidadPerdida);
                    }
                    else
                    {
                        resumen.Append("No se encontraron carreras");
                    }

                    this.txtResultados.Text = Convert.ToString(resumen);

                    if (dtVehiculos != null)
                    {
                        this.dgvReporte.clearDataSource();
                        this.dgvReporte.PageSize = 30;
                        this.dgvReporte.SetPagedDataSource(dtVehiculos, this.bindingNavigator1);

                        this.dgvReporte.Columns["Id_vehiculo"].HeaderText       = "Código";
                        this.dgvReporte.Columns["CantidadServicios"].HeaderText = "Carreras";
                        this.dgvReporte.Columns["Propietario"].Visible          = false;
                        this.dgvReporte.Columns["Color"].Visible           = false;
                        this.dgvReporte.Columns["Estado_Vehiculo"].Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Mensajes.MensajeErrorCompleto(this.Name, "BuscarReporte",
                                              "Hubo un error al buscar reportes", ex.Message);
            }
        }