示例#1
0
        //Permite obtener el total de piezas por tipo de empaque
        public int ObtenerPiezasTotalesPorPack(int?id)
        {
            Conexion      conex = new Conexion();
            SqlCommand    cmd   = new SqlCommand();
            SqlDataReader reader;
            int           suma     = 0;
            int           pedidoId = Convert.ToInt32(id);
            string        query    = objPacking.ObtenerEstilosPorIdPedido(pedidoId);

            try
            {
                cmd.Connection  = conex.AbrirConexion();
                cmd.CommandText = "SELECT DISTINCT P.ID_TALLA, P.ID_SUMMARY, P.CANT_BOX, P.TOTAL_PIECES, PT.TYPE_PACKING  FROM packing_type_size PT, PACKING P " +
                                  "WHERE PT.ID_SUMMARY in(" + query + ") AND PT.TYPE_PACKING IN(1,2) AND P.ID_SUMMARY=PT.ID_SUMMARY";
                cmd.CommandType = CommandType.Text;
                reader          = cmd.ExecuteReader();
                if (!reader.Read())
                {
                    //Response.Write("Wrong Details");
                }
                while (reader.Read())
                {
                    suma += Convert.ToInt32(reader["TOTAL_PIECES"]);
                }
                conex.CerrarConexion();
            }
            finally
            {
                conex.CerrarConexion();
                conex.Dispose();
            }
            return(suma);
        }