Example #1
0
        public List <ProductoRequerido> getAll()
        {
            String sqlSelect = "Select id_producto,material, cantidad,pedido,p.precio,p.id_detalle_trabajo " +
                               " from ProductoRequerido p ";

            Console.WriteLine(sqlSelect);
            SqlDataAdapter daProducto = new SqlDataAdapter(sqlSelect, new SqlConnection(connectionString));

            DataSet dsProducto = new DataSet();

            daProducto.Fill(dsProducto, "ProductoRequerido");
            Dictionary <Int32, ProductoRequerido> dictionary = new Dictionary <Int32, ProductoRequerido>();
            ProductoRequerido producto = null;

            foreach (DataRow row in dsProducto.Tables["ProductoRequerido"].Rows)
            {
                Int32 id = Int32.Parse(row["id_producto"].ToString());
                if (dictionary.ContainsKey(id) == false)
                {
                    producto            = new ProductoRequerido();
                    producto.IdProducto = id;
                    producto.Material   = row["material"].ToString();
                    producto.Cantidad   = Int32.Parse(row["cantidad"].ToString());
                    producto.Pedido     = Int32.Parse(row["pedido"].ToString());
                    producto.Precio     = (float)Double.Parse(row["precio"].ToString());
                    dictionary.Add(id, producto);
                } // if
            }     // for
            return(dictionary.Values.ToList <ProductoRequerido>());
        }
Example #2
0
        public List <DetalleTrabajo> getDetalleTrabajo(int idOrden)
        {
            String sqlSelect = "Select dt.id_detalle_trabajo,dt.descripcion,dt.precio,p.id_producto,p.material,p.pedido,p.precio as 'PrecioProducto'  from DetalleTrabajo dt, OrdenTrabajo o,ProductosPedidos p " +
                               "  where dt.id_orden_trabajo=o.id_orden_trabajo AND dt.id_detalle_trabajo = p.id_detalle_trabajo AND o.id_orden_trabajo like '%" + idOrden + "%'";

            Console.Write(sqlSelect);
            SqlDataAdapter daDetalleTrabajo = new SqlDataAdapter(sqlSelect, new SqlConnection(connectionString));
            DataSet        dsDetalleTrabajo = new DataSet();

            daDetalleTrabajo.Fill(dsDetalleTrabajo, "DetalleTrabajo");

            Dictionary <Int32, DetalleTrabajo> dictionary = new Dictionary <Int32, DetalleTrabajo>();
            DetalleTrabajo detalleTrabajo = null;

            foreach (DataRow row in dsDetalleTrabajo.Tables["DetalleTrabajo"].Rows)
            {
                Int32 id = Int32.Parse(row["id_detalle_trabajo"].ToString());
                if (dictionary.ContainsKey(id) == false)
                {
                    detalleTrabajo = new DetalleTrabajo();
                    detalleTrabajo.IdDetalleTrabajo = id;
                    detalleTrabajo.Descripcion      = row["descripcion"].ToString();
                    detalleTrabajo.PrecioTotal      = (float)Double.Parse(row["precio"].ToString());
                    dictionary.Add(id, detalleTrabajo);
                }
                int productoId = Int32.Parse(row["id_producto"].ToString());
                if (productoId > 0)
                {
                    ProductoRequerido producto = new ProductoRequerido();
                    producto.IdProducto = productoId;
                    producto.Cantidad   = 1;
                    producto.Material   = row["material"].ToString();
                    producto.Pedido     = Int32.Parse(row["pedido"].ToString());
                    producto.Precio     = (float)Double.Parse(row["PrecioProducto"].ToString());
                    detalleTrabajo.ListaProductosRequeridos.Add(producto);
                }
            }
            return(dictionary.Values.ToList <DetalleTrabajo>());
        }
Example #3
0
        public List <OrdenTrabajo> getAll()
        {
            String sqlSelect = "Select o.id_orden_trabajo, descripcion_solicitud_trabajo,fecha,precio_total,o.num_identificacion,o.num_placa,c.nombre,c.cod_cliente, " +
                               "  c.apellidos,c.correo,c.telefono,c.telefono_celular,c.direccion,c.cod_cliente,o.num_placa,v.cod_vehiculo,v.color, " +
                               "  v.marca,v.estilo,v.anio,v.potencia,v.cilindraje,v.capacidad,v.peso,v.num_chasis,v.num_motor,v.observaciones, " +
                               " dv.id_detalle_vehiculo,dv.cantidad, dv.observaciones,e.id_estado,e.descripcion as 'DescripcionEstado',t.id_tipo_detalle, t.descripcion as 'DescripcionTipoDetalle',  " +
                               " dt.id_detalle_trabajo,dt.precio,dt.descripcion, p.id_producto,p.material,p.pedido,p.precio as 'PrecioProducto' " +
                               " from OrdenTrabajo o, DetalleVehiculo dv, Estado e, TipoDetalle t, DetalleTrabajo dt, ProductosPedidos p,Cliente c,Vehiculo v " +
                               "   where  o.id_orden_trabajo=dt.id_orden_trabajo AND  dt.id_detalle_trabajo=p.id_detalle_trabajo AND " +
                               "   dv.id_orden_trabajo= o.id_orden_trabajo AND dv.id_tipo_detalle= t.id_tipo_detalle AND " +
                               " dv.id_estado=e.id_estado AND o.num_identificacion=c.num_identificacion AND o.num_placa=v.num_placa ";


            Console.Write(sqlSelect);
            SqlDataAdapter daOrden = new SqlDataAdapter(sqlSelect, new SqlConnection(connectionString));

            DataSet dsOrden = new DataSet();

            daOrden.Fill(dsOrden, "OrdenTrabajo");

            Dictionary <Int32, OrdenTrabajo> dictionary = new Dictionary <Int32, OrdenTrabajo>();
            OrdenTrabajo orden = null;

            foreach (DataRow row in dsOrden.Tables["OrdenTrabajo"].Rows)
            {
                Int32 id = Int32.Parse(row["id_orden_trabajo"].ToString());
                if (dictionary.ContainsKey(id) == false)
                {
                    orden         = new OrdenTrabajo();
                    orden.IdOrden = id;
                    orden.DescripcionSolicitudTrabajo = row["descripcion_solicitud_trabajo"].ToString();
                    DateTime fecha = Convert.ToDateTime(row["fecha"]);
                    orden.Fecha = fecha;
                    //   orden.Precio = (float)Double.Parse(row["precio_total"].ToString());

                    int codCliente = Int32.Parse(row["cod_cliente"].ToString());
                    if (codCliente > 0)
                    {
                        orden.Cliente.CodCliente        = codCliente;
                        orden.Cliente.NumIdentificacion = row["num_identificacion"].ToString();
                        orden.Cliente.Nombre            = row["nombre"].ToString();
                        orden.Cliente.Apellidos         = row["apellidos"].ToString();
                        orden.Cliente.Correo            = row["correo"].ToString();
                        orden.Cliente.Telefono          = row["telefono"].ToString();
                        orden.Cliente.TelefonoCelular   = row["telefono_celular"].ToString();
                        orden.Cliente.Direccion         = row["direccion"].ToString();
                    }

                    int codVehiculo = Int32.Parse(row["cod_vehiculo"].ToString());
                    if (codVehiculo > 0)
                    {
                        orden.Vehiculo.CodVehiculo   = codVehiculo;
                        orden.Vehiculo.Color         = row["color"].ToString();
                        orden.Vehiculo.Marca         = row["marca"].ToString();
                        orden.Vehiculo.Estilo        = row["estilo"].ToString();
                        orden.Vehiculo.Potencia      = row["potencia"].ToString();
                        orden.Vehiculo.Cilindraje    = row["cilindraje"].ToString();
                        orden.Vehiculo.Capacidad     = Int32.Parse(row["capacidad"].ToString());
                        orden.Vehiculo.Peso          = (float)Double.Parse(row["peso"].ToString());
                        orden.Vehiculo.NumChasis     = Int32.Parse(row["num_chasis"].ToString());
                        orden.Vehiculo.NumMotor      = Int32.Parse(row["num_motor"].ToString());
                        orden.Vehiculo.Observaciones = row["observaciones"].ToString();
                    }
                    int idDetalleVehiculo = Int32.Parse(row["id_detalle_vehiculo"].ToString());
                    if (idDetalleVehiculo > 0)
                    {
                        DetalleVehiculo detalleVehiculo = new DetalleVehiculo();
                        detalleVehiculo.IdDetalleVehiculo = idDetalleVehiculo;
                        detalleVehiculo.Cantidad          = Int32.Parse(row["cantidad"].ToString());
                        detalleVehiculo.Observaciones     = row["observaciones"].ToString();
                        detalleVehiculo.TipoDetalle       = new TipoDetalle(Int32.Parse(row["id_tipo_detalle"].ToString()), row["DescripcionTipoDetalle"].ToString());
                        detalleVehiculo.Estado            = new Estado(Int32.Parse(row["id_estado"].ToString()), row["DescripcionEstado"].ToString());
                        orden.ListaDetalleVehiculo.Add(detalleVehiculo);
                    }
                    int idDetalleTrabajo = Int32.Parse(row["id_detalle_vehiculo"].ToString());
                    if (idDetalleTrabajo > 0)
                    {
                        DetalleTrabajo detalleTrabajo = new DetalleTrabajo();
                        detalleTrabajo.IdDetalleTrabajo = idDetalleTrabajo;
                        detalleTrabajo.PrecioTotal      = (float)Double.Parse(row["precio"].ToString());
                        detalleTrabajo.Descripcion      = row["descripcion"].ToString();
                        ProductoRequerido producto = new ProductoRequerido();
                        producto.IdProducto = Int32.Parse(row["id_producto"].ToString());
                        producto.Material   = row["material"].ToString();
                        producto.Pedido     = Int32.Parse(row["pedido"].ToString());
                        producto.Precio     = (float)Double.Parse(row["PrecioProducto"].ToString());
                        detalleTrabajo.ListaProductosRequeridos.Add(producto);
                        orden.ListaDetallesTrabajo.Add(detalleTrabajo);
                    }



                    dictionary.Add(id, orden);
                } // if
            }     // for
            return(dictionary.Values.ToList <OrdenTrabajo>());
        }         // GetAllMovies