Beispiel #1
0
        public static Productos ObtenerProductosTrabajo(int IdTrabajo)
        {
            Productos colEntidad = new Productos();

            try {
                using (SqlCommand cmd = new SqlCommand("Select * from Productos where idTrabajo = @IdTrabajo order by Numero", Configuracion.ConexionBBDD))
                {
                    cmd.Parameters.Add("IdTrabajo", SqlDbType.Int).Value = IdTrabajo;
                    DataTable dt = new DataTable();
                    dt.Load(cmd.ExecuteReader());
                    foreach (DataRow dr in dt.Rows)
                    {
                        colEntidad.Add(new Producto()
                        {
                            Id        = UtilidadesSQL.ObtenerEntero(dr, "Id"),
                            IdTrabajo = IdTrabajo,
                            IdCaja    = UtilidadesSQL.ObtenerEntero(dr, "IdCaja"),
                            Numero    = UtilidadesSQL.ObtenerEntero(dr, "Numero"),
                            Peso      = UtilidadesSQL.ObtenerDecimal(dr, "Peso"),
                            Lote      = UtilidadesSQL.ObtenerCadena(dr, "Lote"),
                            Fecha     = UtilidadesSQL.ObtenerFecha(dr, "Fecha")
                        });;
                    }
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
            return(colEntidad);
        }
Beispiel #2
0
        private static Trabajo ObtenerEntidadTrabajo(DataRow dr)
        {
            int     totalCajas = 0;
            decimal totalKilos = 0;

            //TotalCajas
            string qSelect = "Select Count(Id) from Cajas (nolock) where IdTrabajo = @Id";

            using (SqlCommand cmd = new SqlCommand(qSelect, Configuracion.ConexionBBDD))
            {
                cmd.Parameters.Add("Id", SqlDbType.VarChar).Value = UtilidadesSQL.ObtenerEntero(dr, "Id");
                var result = cmd.ExecuteScalar();
                int.TryParse(result.ToString(), out totalCajas);
            };

            //TotalKilos
            qSelect = "Select Sum(Peso) from Cajas (nolock) where IdTrabajo = @Id";
            using (SqlCommand cmd = new SqlCommand(qSelect, Configuracion.ConexionBBDD))
            {
                cmd.Parameters.Add("Id", SqlDbType.VarChar).Value = UtilidadesSQL.ObtenerEntero(dr, "Id");
                var result = cmd.ExecuteScalar();
                decimal.TryParse(result.ToString(), out totalKilos);
            };

            return(new Trabajo()
            {
                Id = UtilidadesSQL.ObtenerEntero(dr, "Id"),
                Equipo = UtilidadesSQL.ObtenerCadena(dr, "equipo"),
                EtiquetaProducto = UtilidadesSQL.ObtenerCadena(dr, "EtiquetaProducto"),
                EtiquetaCaja = UtilidadesSQL.ObtenerCadena(dr, "EtiquetaCaja"),
                EtiquetaTotal = UtilidadesSQL.ObtenerCadena(dr, "EtiquetaTotal"),
                CopiasProducto = UtilidadesSQL.ObtenerEntero(dr, "CopiasProducto"),
                CopiasCaja = UtilidadesSQL.ObtenerEntero(dr, "CopiasCaja"),
                CopiasTotal = UtilidadesSQL.ObtenerEntero(dr, "CopiasTotal"),
                ImpresoraProducto = UtilidadesSQL.ObtenerCadena(dr, "ImpresoraProducto"),
                ImpresoraCaja = UtilidadesSQL.ObtenerCadena(dr, "ImpresoraCaja"),
                ImpresoraTotal = UtilidadesSQL.ObtenerCadena(dr, "ImpresoraTotal"),
                NumeroProductosCierre = UtilidadesSQL.ObtenerEntero(dr, "NumeroProductosCierre"),
                Lote = UtilidadesSQL.ObtenerCadena(dr, "Lote"),
                Fecha = UtilidadesSQL.ObtenerFecha(dr, "Fecha"),
                Finalizado = UtilidadesSQL.ObtenerBooleano(dr, "Finalizado"),
                TotalCajas = totalCajas,
                TotalKilos = totalKilos
            });
        }