Example #1
0
        public void EditarLinea(int id, ENLinped l)
        {
            SqlConnection a = new SqlConnection(cadenaConexion());

            try
            {
                a.Open();
                SqlCommand com = new SqlCommand("UPDATE linped SET IdPedido =" + l.IdPedido + ", Idarticulo =" + l.IdArticulo + ", Nombre ='" + l.Nombre + "', Descripcion ='" + l.Descripcion + "', Cantidad =" + l.Cantidad + " , Precio =" + l.Precio + ", Total = " + l.Total +  " WHERE Id =" + id, a);
                com.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                a.Close();
            }
        }
Example #2
0
        public void NuevaLinea(ENLinped l)
        {
            SqlConnection a = new SqlConnection(cadenaConexion());

            try
            {
                a.Open();
                SqlCommand com = new SqlCommand("INSERT INTO linped (IdPedido, Idarticulo, Nombre, Descripcion, Cantidad, Precio, Total) VALUES (" + l.IdPedido + ", " + l.IdArticulo + ", '" + l.Nombre + "', '" + l.Descripcion + "', " + l.Cantidad + ", " + l.Precio + ", " + l.Total + ")", a);
                com.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                a.Close();

            }
        }
Example #3
0
        public ArrayList ObtenerLineasPedido(int idPedido)
        {
            ArrayList lineas = new ArrayList();
            SqlConnection a = new SqlConnection(cadenaConexion());
            try
            {
                a.Open();
                SqlCommand com = new SqlCommand("Select * from linped WHERE IdPedido =" + idPedido, a);
                SqlDataReader dr = com.ExecuteReader();

                while (dr.Read())
                {
                    ENLinped l = new ENLinped();

                    l.Id = int.Parse(dr["Id"].ToString());
                    l.IdPedido = int.Parse(dr["IdPedido"].ToString());
                    l.IdArticulo = int.Parse(dr["Idarticulo"].ToString());
                    l.Nombre = dr["Nombre"].ToString();
                    l.Descripcion = dr["Descripcion"].ToString();
                    l.Cantidad = int.Parse(dr["Cantidad"].ToString());
                    l.Precio = float.Parse(dr["Precio"].ToString());
                    l.Total = float.Parse(dr["Total"].ToString());

                    lineas.Add(l);
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            finally
            {
                a.Close();
            }

            return lineas;
        }