public List <PedidoCotizacion_Articulo> GetListaArticulos(string numero) { try { OpenConnection(); NpgsqlCommand cmdSel = new NpgsqlCommand(" select oc.cantidad,art.nombre " + "from pedido_cotizacion_articulos oc " + "inner join articulos art on oc.id_articulo = art.id " + "where oc.numero_orden = @numero", npgsqlConn); cmdSel.Parameters.Add("@numero", NpgsqlTypes.NpgsqlDbType.Text).Value = numero; NpgsqlDataReader drHerramientas = cmdSel.ExecuteReader(); List <PedidoCotizacion_Articulo> ord_artList = new List <PedidoCotizacion_Articulo>(); while (drHerramientas.Read()) { PedidoCotizacion_Articulo ord_art = new PedidoCotizacion_Articulo(); ord_art.Cantidad = (int)drHerramientas["cantidad"]; // ord_art.Id_Articulo = Convert.ToInt32((Convert.ToString((int)drHerramientas["id_articulo"]))); ord_art.Nombre = (string)drHerramientas["nombre"]; ord_artList.Add(ord_art); } drHerramientas.Close(); /* NpgsqlCommand cmdSelec = new NpgsqlCommand(" select oc.cantidad,serv.descripcion " + * "from pedido_cotizacion_articulos oc " + * "inner join servicios serv on oc.id_articulo = serv.id " + * "where oc.numero_orden = @numero", npgsqlConn); * * cmdSelec.Parameters.Add("@numero", NpgsqlTypes.NpgsqlDbType.Text).Value = numero; * NpgsqlDataReader drServicios = cmdSelec.ExecuteReader(); * * * while (drServicios.Read()) * { * PedidoCotizacion_Articulo ord_art = new PedidoCotizacion_Articulo(); * ord_art.Cantidad = (int)drServicios["cantidad"]; * //ord_art.Id_Articulo = (int)drServicios["id"]; * ord_art.Nombre = (string)drServicios["descripcion"]; * ord_artList.Add(ord_art); * } * drServicios.Close(); */ return(ord_artList); } finally { } }
public void Insertar(PedidoCotizacion_Articulo ocA) { try { OpenConnection(); NpgsqlCommand cmdIns = new NpgsqlCommand("INSERT INTO pedido_cotizacion_articulos(numero_orden,id_articulo,cantidad)" + "values(@numero_orden,@id_articulo,@cantidad)", npgsqlConn); cmdIns.Parameters.Add("@numero_orden", NpgsqlTypes.NpgsqlDbType.Text).Value = ocA.Numero; cmdIns.Parameters.Add("@id_articulo", NpgsqlTypes.NpgsqlDbType.Text).Value = ocA.Id_Articulo; cmdIns.Parameters.Add("@cantidad", NpgsqlTypes.NpgsqlDbType.Integer).Value = ocA.Cantidad; cmdIns.ExecuteNonQuery(); } finally { CloseConnection(); } }
public List <OrdenDeCompra_Articulo> GetArticulosDeOrden(string numero_orden) { try { OpenConnection(); NpgsqlCommand cmdSel = new NpgsqlCommand(" select oc.cantidad,art.nombre,oc.id_articulo,oc.precio_unitario, oc.codigo_proveedor, oc.plazo_entrega, oc.descuento, oc.iva,oc.estado_item, oc.fecha_recibido, oc.cantidad_recibida " + "from orden_compra_articulos oc " + "inner join articulos art on oc.id_articulo = art.id " + "where oc.numero_orden = @numero order by oc.estado_item ASC", npgsqlConn); cmdSel.Parameters.Add("@numero", NpgsqlTypes.NpgsqlDbType.Text).Value = numero_orden; NpgsqlDataReader drHerramientas = cmdSel.ExecuteReader(); List <OrdenDeCompra_Articulo> ord_artList = new List <OrdenDeCompra_Articulo>(); while (drHerramientas.Read()) { PedidoCotizacion_Articulo ord_art = new PedidoCotizacion_Articulo(); ord_art.Id_Articulo = (string)drHerramientas["id_articulo"]; ord_art.Nombre = (string)drHerramientas["nombre"]; ord_art.Precio_unitario = (double)drHerramientas["precio_unitario"]; ord_art.IVA = (double)drHerramientas["iva"]; ord_art.Cantidad = (int)drHerramientas["cantidad"]; ord_art.Cantidad_Recibida = (int)drHerramientas["cantidad_recibida"]; ord_art.Cantidad = ord_art.Cantidad - ord_art.Cantidad_Recibida; ord_art.Descuento = (double)drHerramientas["descuento"]; ord_art.Plazo_entrega = (DateTime)drHerramientas["plazo_entrega"]; ord_art.Precio_Total = (ord_art.Precio_unitario * ord_art.Cantidad); ord_art.Precio_Total = ord_art.Precio_Total - (ord_art.Precio_Total * (ord_art.Descuento / 100)); ord_art.Precio_Total = Math.Round(ord_art.Precio_Total + (ord_art.Precio_Total * (ord_art.IVA / 100)), 2); ord_art.Estado = (string)drHerramientas["estado_item"]; try { ord_art.Fecha_recibido = (DateTime)drHerramientas["fecha_recibido"]; } catch { } try { ord_art.Codigo_proveedor = (string)drHerramientas["codigo_proveedor"]; } catch { } ord_artList.Add(ord_art); } /* * NpgsqlCommand cmdSelec = new NpgsqlCommand(" select oc.cantidad,serv.descripcion,oc.id_articulo,oc.precio_unitario,oc.codigo_proveedor, oc.plazo_entrega, oc.descuento, oc.iva,oc.estado_item " + * "from orden_compra_articulos oc " + * "inner join servicios serv on oc.id_articulo = serv.id " + * "where oc.numero_orden = @numero order by oc.estado_item ASC", npgsqlConn); * cmdSelec.Parameters.Add("@numero", NpgsqlTypes.NpgsqlDbType.Text).Value = numero_orden; * NpgsqlDataReader drServicios = cmdSelec.ExecuteReader(); * * * while (drServicios.Read()) * { * OrdenDeCompra_Articulo ord_art = new OrdenDeCompra_Articulo(); * * ord_art.Id_Articulo = (string)drServicios["id_articulo"]; * ord_art.Precio_unitario = (double)drServicios["precio_unitario"]; * ord_art.Nombre = (string)drServicios["descripcion"]; * ord_art.IVA = (double)drHerramientas["iva"]; * ord_art.Descuento = (double)drHerramientas["descuento"]; * ord_art.Cantidad = (int)drServicios["cantidad"]; * ord_art.Cantidad_Recibida = (int)drHerramientas["cantidad_recibida"]; * ord_art.Cantidad = ord_art.Cantidad - ord_art.Cantidad_Recibida; * ord_art.Plazo_entrega = (DateTime)drHerramientas["plazo_entrega"]; * ord_art.Precio_Total = (ord_art.Precio_unitario * ord_art.Cantidad); * ord_art.Precio_Total = ord_art.Precio_Total - (ord_art.Precio_Total * (ord_art.Descuento / 100)); * ord_art.Precio_Total = Math.Round(ord_art.Precio_Total + (ord_art.Precio_Total * (ord_art.IVA / 100)),2); * ord_art.Estado = (string)drHerramientas["estado_item"]; * try { ord_art.Codigo_proveedor = (string)drServicios["codigo_proveedor"]; } * catch { } * ord_artList.Add(ord_art); * }*/ return(ord_artList); } finally { CloseConnection(); } }