예제 #2
0
        public List <Categorias> Listar()
        {
            List <Categorias> lista = new List <Categorias>();
            Categorias        c;
            SqlDataReader     lector;

            try
            {
                cmdCategoria.CommandType = CommandType.StoredProcedure;
                cmdCategoria.CommandText = "pa_Categorias_ListasTodos";
                cmdCategoria.Connection  = conn.conectarBD();

                lector = cmdCategoria.ExecuteReader();

                while (lector.Read())
                {
                    c = new Categorias();
                    c.Codcategoria = (string)(lector[0]);
                    c.Descategoria = (string)(lector[1]);
                    lista.Add(c);
                }
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.Message);
            }
            return(lista);
        }
        public string Insertar(DetalleVenta prod)
        {
            string rpta = "";

            try
            {
                cmdDetalleVentas.CommandType = CommandType.StoredProcedure;
                cmdDetalleVentas.CommandText = "pa_detalleventa";
                cmdDetalleVentas.Connection  = conn.conectarBD();
                {
                    cmdDetalleVentas.Parameters.AddWithValue("@codigo", prod.Codigo);
                    cmdDetalleVentas.Parameters.AddWithValue("@cantidad", prod.Cantidad);
                    cmdDetalleVentas.Parameters.AddWithValue("@precio", prod.Precio);
                    cmdDetalleVentas.Parameters.AddWithValue("@subtotal", prod.Subtotal);
                    cmdDetalleVentas.Parameters.AddWithValue("@codproducto", prod.Codproducto);
                }
                int registros;
                registros = cmdDetalleVentas.ExecuteNonQuery();
                if (registros == 1)
                {
                    rpta = "OK";
                }
                else
                {
                    rpta = "Error al Insertar";
                }
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.Message);
            }
            return(rpta);
        }
예제 #4
0
        public string Insertar(Ventas prod)
        {
            string rpta = "";

            try
            {
                cmdVentas.CommandType = CommandType.StoredProcedure;
                cmdVentas.CommandText = "pa_ventas";
                cmdVentas.Connection  = conn.conectarBD();
                {
                    cmdVentas.Parameters.AddWithValue("@codigo", prod.Codigo);
                    cmdVentas.Parameters.AddWithValue("@fecha", prod.Fecha);
                    cmdVentas.Parameters.AddWithValue("@subtotal", prod.Subtotal);
                    cmdVentas.Parameters.AddWithValue("@igv", prod.Igv);
                    cmdVentas.Parameters.AddWithValue("@total", prod.Total);
                    cmdVentas.Parameters.AddWithValue("@cliente", prod.Cliente);
                }
                int registros;
                registros = cmdVentas.ExecuteNonQuery();
                if (registros == 1)
                {
                    rpta = "OK";
                }
                else
                {
                    rpta = "Error al Insertar";
                }
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.Message);
            }
            return(rpta);
        }