Esempio n. 1
0
        private ObjectResult TraerKilometrosPorEmpresa(string connectionString, string empresaId, string fechaDesde, string fechaHasta)
        {
            DateTimeFormatInfo arCulture   = new CultureInfo("es-ES", false).DateTimeFormat;
            Kilometraje        kilometraje = new Kilometraje();

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                var query = "Select * from Kilometraje ";

                using (var sqlCommand = connection.CreateCommand())
                {
                    if (empresaId != string.Empty)
                    {
                        query += " where EmpresaId ='" + empresaId + "'";
                    }

                    if (!String.IsNullOrWhiteSpace(fechaHasta))
                    {
                        query += " and Fecha <='" + fechaHasta + "'";
                    }

                    if (!String.IsNullOrWhiteSpace(fechaDesde))
                    {
                        query += " and Fechao >='" + fechaDesde + "'";
                    }

                    sqlCommand.CommandText = query;
                    using (SqlDataReader reader = sqlCommand.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            try
                            {
                                while (reader.Read())
                                {
                                    kilometraje.Id         = new Guid(reader[0].ToString());
                                    kilometraje.Kilometros = (int)reader[1];

                                    kilometraje.Nombre = reader[3].ToString();

                                    kilometraje.ConductorId     = new Guid(reader[7].ToString());
                                    kilometraje.ConductorNombre = reader[8].ToString();
                                    kilometraje.VehiculoId      = new Guid(reader[9].ToString());
                                    kilometraje.VehiculoPatente = reader[10].ToString();
                                    kilometraje.VehiculoTipo    = reader[11].ToString();

                                    kilometraje.DiaNoLaborableId = new Guid(reader[12].ToString());

                                    kilometraje.DiaNoLaborableNombre = reader[13].ToString();

                                    kilometraje.DiaSemana       = (int)reader[14];
                                    kilometraje.GruposVehiculos = reader[17].ToString();
                                    kilometraje.EmpresaId       = new Guid(reader[15].ToString());
                                    kilometraje.EmpresaNombre   = reader[16].ToString();
                                    kilometraje.Fecha           = reader[2].Equals(DBNull.Value) ? null : (DateTime?)reader[2];
                                    kilometraje.FechaCreacion   = reader[4].Equals(DBNull.Value) ? null : (DateTime?)reader[4];;
                                    kilometraje.FechaEdicion    = reader[5].Equals(DBNull.Value) ? null : (DateTime?)reader[5];;


                                    kilometrajes.Add(kilometraje);
                                }
                            }
                            catch (Exception ex)
                            {
                                reader.Close();
                                connection.Close();
                                return(StatusCode((int)HttpStatusCode.InternalServerError, "Mapping Error"));
                            }
                        }
                        else
                        {
                            reader.Close();
                            connection.Close();
                            return(StatusCode((int)HttpStatusCode.NoContent, "No rows found."));
                        }
                        reader.Close();
                    }
                }

                connection.Close();
            }

            var kilometrajeJson = JsonConvert.SerializeObject(kilometrajes);

            return(StatusCode((int)HttpStatusCode.OK, kilometrajeJson));
        }
Esempio n. 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            rootView = inflater.Inflate(UServices.getLayoutId(mPage), container, false);

            mScrollContainer = rootView.FindViewById <NestedScrollView>(Resource.Id.scroll_container);

            if (mPage == 0)
            {
                N_Placa      = rootView.FindViewById <AutoCompleteTextView>(Resource.Id.ET_T0_Item01);
                LISTA_PLACAS = mViewModel.obtenerListaPlacas();
                ArrayAdapter adaptador = new ArrayAdapter <string>(Context, Android.Resource.Layout.SimpleDropDownItem1Line, LISTA_PLACAS);
                N_Placa.Adapter = adaptador;

                Modelo = rootView.FindViewById <TextView>(Resource.Id.ET_T0_Item02);

                N_Placa.TextChanged += (o, e) =>
                {
                    String modeloFila = mViewModel.obtenerModeloDePlaca(N_Placa.Text.ToString());
                    Modelo.Text = modeloFila;
                };

                Kilometraje      = rootView.FindViewById <TextView>(Resource.Id.ET_T0_Item03);
                FilaAdvertencia  = rootView.FindViewById <TableRow>(Resource.Id.T0_fila_advertencia); //Mantenimiento se encuentra proximo
                FilaAlarma       = rootView.FindViewById <TableRow>(Resource.Id.T0_fila_alarma);      //alarma mas de 5000
                CheckAdvertencia = rootView.FindViewById <CheckBox> (Resource.Id.CB_T0_Item04);

                Kilometraje.TextChanged += (o, e) =>
                {
                    if (Kilometraje.Length() > 0)
                    {
                        int Resultado = mViewModel.evaluarKilometraje(N_Placa.Text.ToString(), Kilometraje.Text.ToString());
                        if (Resultado == 2)
                        {
                            Log.Info(TAG, "resultado: " + Resultado);
                            FilaAlarma.Visibility      = ViewStates.Visible;
                            FilaAdvertencia.Visibility = ViewStates.Gone;
                        }
                        else if (Resultado == 1)
                        {
                            Log.Info(TAG, "resultado: " + Resultado);
                            FilaAlarma.Visibility      = ViewStates.Gone;
                            FilaAdvertencia.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            Log.Info(TAG, "resultado: " + Resultado);
                            FilaAlarma.Visibility      = ViewStates.Gone;
                            FilaAdvertencia.Visibility = ViewStates.Gone;
                        }
                    }
                };

                Nombre_Conductor = rootView.FindViewById <TextView>(Resource.Id.ET_T0_Item07);
                String Conductor = mUserPreferences.GetString("Nombre", String.Empty);
                Nombre_Conductor.Text    = Conductor;
                Nombre_Conductor.Enabled = false;
            }

            if (mPage == 4)
            {
                Fecha_SOAT       = rootView.FindViewById <TextView>(Resource.Id.TV_T4_Item01);
                Fecha_RevTecnica = rootView.FindViewById <TextView>(Resource.Id.TV_T4_Item02);

                Estado_Fecha_SOAT   = rootView.FindViewById(Resource.Id.color_estado_doc_SOAT);
                Estado_SOAT         = rootView.FindViewById <EditText>(Resource.Id.ET_T4_Item01);
                Fila_SOAT           = rootView.FindViewById <TableRow>(Resource.Id.TR_T4_Row_SOAT);
                N_Fecha_SOAT        = rootView.FindViewById <EditText>(Resource.Id.ET_T4_Item02);
                N_Fecha_SOAT.Click += (o, e) =>
                {
                    mFragmentCallbacks.showDateDialog(DIALOG_ID_FECHASOAT);
                };

                Estado_Fecha_RevTecnica   = rootView.FindViewById(Resource.Id.color_estado_doc_RevTecnica);
                Estado_RevTecnica         = rootView.FindViewById <EditText>(Resource.Id.ET_T4_Item03);
                Fila_RevTecnica           = rootView.FindViewById <TableRow>(Resource.Id.TR_T4_Row_RevTecnica);
                N_Fecha_RevTecnica        = rootView.FindViewById <EditText>(Resource.Id.ET_T4_Item04);
                N_Fecha_RevTecnica.Click += (o, e) =>
                {
                    mFragmentCallbacks.showDateDialog(DIALOG_ID_FECHAREV);
                };

                string F_SOAT       = DateToString(DateTime.Parse(mDocumentPreferences.GetString("FechaSOAT", String.Empty)));
                string F_RevTecnica = DateToString(DateTime.Parse(mDocumentPreferences.GetString("FechaRevTecnica", String.Empty)));

                Fecha_SOAT.Text       = F_SOAT;
                Fecha_RevTecnica.Text = F_RevTecnica;

                evaluar_Fechas(F_SOAT, F_RevTecnica);
            }

            RetainInstance = true;

            return(rootView);
        }