Example #1
0
        public List<Select.Vehiculo> list_Vehiculo()
        {
            try
            {
                List<Select.Vehiculo> vehiculos = new List<Select.Vehiculo>();
                Select.Vehiculo v;

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return vehiculos;
                    }

                    SqlCommand sqlCmd = new SqlCommand("VEHICULO_LIST_SISTEMA", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    v = Utils.select_vehiculo_parse(rows[i]);
                    vehiculos.Add(v);
                }

                return vehiculos;
            }
            catch (Exception ex)
            {
                Select.Vehiculo v = new Select.Vehiculo();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_LISTAR,
                    Servicio = Constantes.List_Vehiculo,
                    Input = "",
                    Descripcion = ex.ToString(),
                    Clase = v.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                return new List<Select.Vehiculo>();
            }
        }
Example #2
0
        public List<Select.Vehiculo> search_Vehiculo(Search.Vehiculo veh)
        {
            try
            {
                List<Select.Vehiculo> vehiculos = new List<Select.Vehiculo>();
                Select.Vehiculo v;

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return vehiculos;
                    }

                    SqlCommand sqlCmd = new SqlCommand("VEHICULO_SEARCH", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    sqlCmd.Parameters.Add("@ipsDescripcion", SqlDbType.VarChar).Value = veh.Descripcion;
                    sqlCmd.Parameters.Add("@ipsPlaca", SqlDbType.VarChar).Value = veh.Placa;
                    sqlCmd.Parameters.Add("@ipnMarca", SqlDbType.Int).Value = veh.Marca;
                    sqlCmd.Parameters.Add("@ipnModelo", SqlDbType.Int).Value = veh.Modelo;
                    sqlCmd.Parameters.Add("@ipnIdTienda", SqlDbType.Int).Value = veh.IdTienda;
                    sqlCmd.Parameters.Add("@ipbEstado", SqlDbType.Bit).Value = veh.Activo;
                    sqlCmd.Parameters.Add("@ipdDesde", SqlDbType.DateTime).Value = veh.Desde;
                    sqlCmd.Parameters.Add("@ipdHasta", SqlDbType.DateTime).Value = veh.Hasta;

                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    v = Utils.select_vehiculo_parse(rows[i]);
                    vehiculos.Add(v);
                }

                return vehiculos;
            }
            catch (Exception ex)
            {
                Select.Vehiculo v = new Select.Vehiculo();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_BUSCAR,
                    Servicio = Constantes.Search_Vehiculo,
                    Input = JsonSerializer.search_Vehiculo(veh),
                    Descripcion = ex.ToString(),
                    Clase = v.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                return new List<Select.Vehiculo>();
            }
        }
Example #3
0
        public static Select.Vehiculo select_vehiculo_parse(DataRow r)
        {
            Select.Vehiculo v = new Select.Vehiculo();
            v.IdVehiculo = Int32.Parse(r["Vehiculo"].ToString());
            v.Descripcion = r["Descripcion"].ToString();
            v.Placa = r["Placa"].ToString();
            v.Marca = r["Marca"].ToString();
            v.Modelo = r["Modelo"].ToString();
            v.Capacidad = Int32.Parse(r["Capacidad"].ToString());
            v.Fecha = DateTime.ParseExact(r["Fecha"].ToString(), "M/d/yyyy h:mm:ss ttt", null);
            v.Activo = Boolean.Parse(r["activo"].ToString());
            v.Tienda = r["Tienda"].ToString();

            return v;
        }