Exemplo n.º 1
0
        public XmlNode crearNodo(Factura factura)
        {
            XmlElement facNodo = documento.CreateElement("Factura");
            facNodo.SetAttribute("Codigo", factura.Codigo.ToString());
            facNodo.SetAttribute("Fecha", factura.Fecha);

            XmlElement nombre = documento.CreateElement("Nombre");
            nombre.InnerText = factura.Nombre;
            facNodo.AppendChild(nombre);

            XmlElement direccion = documento.CreateElement("Dirección");
            direccion.InnerText = factura.Direccion;
            facNodo.AppendChild(direccion);

            XmlElement telefono = documento.CreateElement("Telefono");
            telefono.InnerText = factura.Telefono;
            facNodo.AppendChild(telefono);

            XmlElement detalle = documento.CreateElement("Detalle");

            foreach (Linea linea_factura in factura.Lineas)
            {
                XmlElement linea = documento.CreateElement("linea");
                linea.SetAttribute("Num", linea_factura.Codigo.ToString());

                XmlElement descripcion = documento.CreateElement("descripcion");
                descripcion.InnerText = linea_factura.Descripcion;
                linea.AppendChild(descripcion);

                XmlElement cantidad = documento.CreateElement("cantidad");
                cantidad.InnerText = linea_factura.Cantidad.ToString();
                linea.AppendChild(cantidad);

                XmlElement precio = documento.CreateElement("precio");
                precio.InnerText = linea_factura.Precio.ToString();
                linea.AppendChild(precio);

                XmlElement total = documento.CreateElement("total");
                total.InnerText = linea_factura.Total.ToString();
                linea.AppendChild(total);

                detalle.AppendChild(linea);

            }

            facNodo.AppendChild(detalle);

            XmlElement total_factura = documento.CreateElement("Total");
            total_factura.InnerText = factura.Total.ToString();
            facNodo.AppendChild(total_factura);

            return facNodo;
        }
Exemplo n.º 2
0
 private void btnRegistrar_Click(object sender, EventArgs e)
 {
     Factura Cosas1 = new Factura(); //Tambien podria ser el "Factura Cosas1" en "public partial class Facturador : Form" y luego solo seria escribir el Cosas1= new Factura() (ideal para cuando se usa el mismo objeto en otros botones
       //          totalGral=totalGral + Cosas1.Total(); Esto no sirve
     Cosas1.Art=txtArticulo.Text;
     Cosas1.Cantidad=Convert.ToInt32(txtCantidad.Text);
     Cosas1.Cliente=txtCliente.Text; //No es necesario poner "Convert.ToString" cuando se escribe texto normal
     Cosas1.Nfactura=Convert.ToInt32(txtNumero.Text);
     Cosas1.Precio=Convert.ToDouble(txtPrecio.Text);
     txtTotal.Text=Convert.ToString(Cosas1.Total());
     lblRCantidadVentas.Text=Convert.ToString(cantVentas++);
     lblRTotalGeneral.Text = Convert.ToString(totalGral += Cosas1.Total());
     MessageBox.Show(Convert.ToString(Cosas1.toString()), "Datos que se ingresaron recien", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemplo n.º 3
0
        private void btnCliente_Click(object sender, EventArgs e)
        {
            factura = new Factura();

            txtCodigo.Clear();
            // txtCodigo.Enabled = true;
            txtNombre.Clear();
            
            txtDireccion.Clear();
            txtTelefono.Clear();

            dataGridView1.DataSource = null;
            txtTotal.Clear();

        }
Exemplo n.º 4
0
        public void insertarNodo(Factura factura)
        {
            documento = new XmlDocument();
            if (!File.Exists(fichero))
            {

                XmlDeclaration declaracion = documento.CreateXmlDeclaration("1.0", "UTF-8", null);
                documento.AppendChild(declaracion);
                raiz = documento.CreateElement("Facturas");
                documento.AppendChild(raiz);
            }
            else
            {
                documento.Load(fichero);
                raiz = documento.DocumentElement;
            }

            raiz.AppendChild(crearNodo(factura));

            documento.Save(fichero);
        }
Exemplo n.º 5
0
 public static void Update(Factura c)
 {
     Edit(ListaFactura.IndexOf(c), c);
 }