private void btnAgregar_Click(object sender, EventArgs e) { if (Accion.Equals(1)) { this.Hide(); /*encabezado factura*/ Factura fac = new Factura(); fac.Id = this.id; fac.Nombre = this.nombre; fac.Rol = this.rol; /*encabezado*/ fac.IdCliente = Convert.ToInt32(txtCodigo.Text); fac.NombreCliente = txtNombre.Text; fac.Documento = txtCantidad.Text; fac.Direccion1 = txtPrecio.Text; fac.Telefono1 = txtDecuento.Text; fac.Tipo = txtTipo.Text; fac.NumeroFact = this.numeroFact; /*detalle*/ fac.Idproducto = this.idproductoVenta; fac.NombreProducto = this.nombreProducto; fac.Cantidad = this.cantidadVendidad; fac.Descuento = this.descuento; fac.PrecioVenta = this.precioVenta; fac.Totalproducto = this.totalproducto; fac.SubTotal = this.subTotal; fac.Codigo1 = this.Codigo; fac.Show(); } else { if (this.accion.Equals(4)) {/*cambio de cliente */ if (txtCodigo.Text.Equals("")) { MessageBox.Show("Seleccione el cliente nuevo"); } else { try { DialogResult dialogo = MessageBox.Show("Decea Cambiar de Cliente", "Cambio", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogo == DialogResult.Yes) { modelo.CambioCliente cc = new modelo.CambioCliente(); cc.Idfactura = this.idfact; cc.CodCliente1 = Convert.ToInt32(txtCodigo.Text); cc.facCamClien(); if (cc.Msg.Equals("Se cambio el cliente")) { MessageBox.Show(cc.Msg); } else { MessageBox.Show(cc.Msg); } } else { return; } } catch (Exception ex) { Console.WriteLine(ex); } this.Hide(); ActuFactu ff = new ActuFactu(); ff.IdFact = this.idfact; ff.Accion = this.accion; ff.Show(); } } else { if (txtDecuento.Text.Equals("") || txtCantidad.Text.Equals("")) { MessageBox.Show("Dijite la cantidad y el Descuento"); } else { int p = Convert.ToInt32(txtCantidad.Text); if (p > cantidad) { MessageBox.Show("La cantidad ingresada es mayor a la que ay en el Inventario"); } else { if (this.accion.Equals(5)) { try { DialogResult dialogo = MessageBox.Show("Decea Agregar el Producto", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogo == DialogResult.Yes) { /*para actualizar la factura */ modelo.CambioCliente ccc = new modelo.CambioCliente(); ccc.Idfactura = this.idfact; ccc.Idproducto = Convert.ToInt32(txtCodigo.Text); ccc.PrecioVenta = Convert.ToDouble(txtPrecio.Text); ccc.Cantidad = Convert.ToInt32(txtCantidad.Text); ccc.Descuento = Convert.ToDouble(txtDecuento.Text); Double s, d, dd; d = Convert.ToDouble(txtDecuento.Text) / 100; s = Convert.ToInt32(txtCantidad.Text) * Convert.ToDouble(txtPrecio.Text); dd = s * d; s = s - dd; ccc.Totalproducto = s; this.sub = this.sub + s; this.iva = this.sub * 0.13; this.total = this.sub + this.iva; ccc.Sub1 = this.sub; ccc.Iva = this.iva; ccc.Total = this.total; ccc.cambioTotal(); if (ccc.Msg.Equals("Producto agregado ")) { MessageBox.Show(ccc.Msg); } else { MessageBox.Show(ccc.Msg); } } else { return; } } catch (Exception ex) { Console.WriteLine(ex); } this.Hide(); ActuFactu ff = new ActuFactu(); ff.IdFact = this.idfact; ff.Accion = this.accion; ff.Show(); } else { int con = idproductoVenta.Count; if (con.Equals(0)) { idproductoVenta.Add(Convert.ToInt32(txtCodigo.Text)); nombreProducto.Add(txtNombre.Text); CantidadVendidad.Add(Convert.ToInt32(txtCantidad.Text)); Double desc = Convert.ToDouble(txtDecuento.Text) / 100; descuento.Add(Convert.ToDouble(txtDecuento.Text)); PrecioVenta.Add(Convert.ToDouble(txtPrecio.Text)); Double tott = Convert.ToDouble(txtPrecio.Text) * Convert.ToInt32(txtCantidad.Text); Double dessprod = tott * desc; tott = tott - dessprod; this.subTotal = subTotal + tott; totalproducto.Add(tott); Codigo.Add(cod); this.Hide(); Factura factu = new Factura(); factu.Id = this.id; factu.Nombre = this.nombre; factu.Rol = this.rol; factu.Idproducto = this.idproductoVenta; factu.NombreProducto = this.nombreProducto; factu.Cantidad = this.cantidadVendidad; factu.Descuento = this.descuento; factu.PrecioVenta = this.precioVenta; factu.Totalproducto = this.totalproducto; factu.SubTotal = this.subTotal; factu.Codigo1 = this.Codigo; /*par el cliente*/ factu.IdCliente = this.idCliente; factu.NombreCliente = this.nombreCliente; factu.Documento = this.documento; factu.Direccion1 = this.Direccion; factu.Telefono1 = this.Telefono; factu.Tipo = this.tipo; /*la factura*/ factu.NumeroFact = this.numeroFact; factu.Show(); } else { Codigo.Add(cod); idproductoVenta.Add(Convert.ToInt32(txtCodigo.Text)); nombreProducto.Add(txtNombre.Text); CantidadVendidad.Add(Convert.ToInt32(txtCantidad.Text)); Double desc = Convert.ToDouble(txtDecuento.Text) / 100; descuento.Add(Convert.ToDouble(txtDecuento.Text)); PrecioVenta.Add(Convert.ToDouble(txtPrecio.Text)); Double tott = Convert.ToDouble(txtPrecio.Text) * Convert.ToInt32(txtCantidad.Text); this.subTotal = subTotal + tott; Totalproducto.Add(tott); this.Hide(); Factura factu = new Factura(); factu.Id = this.id; factu.Nombre = this.nombre; factu.Rol = this.rol; factu.Idproducto = this.idproductoVenta; factu.NombreProducto = this.nombreProducto; factu.Cantidad = this.cantidadVendidad; factu.Descuento = this.descuento; factu.PrecioVenta = this.precioVenta; factu.Totalproducto = this.totalproducto; factu.SubTotal = this.subTotal; factu.Codigo1 = this.Codigo; /*par el cliente*/ factu.IdCliente = this.idCliente; factu.NombreCliente = this.nombreCliente; factu.Documento = this.documento; factu.Direccion1 = this.Direccion; factu.Telefono1 = this.Telefono; factu.Tipo = this.tipo; factu.NumeroFact = this.numeroFact; factu.Show(); } } } } } } }
private void btnRegresar_Click(object sender, EventArgs e) { if (Accion.Equals(1)) { this.Hide(); /*encabezado factura*/ Factura fac = new Factura(); fac.Id = this.id; fac.Nombre = this.nombre; fac.Rol = this.rol; /*encabezado*/ fac.IdCliente = this.idCliente; fac.NombreCliente = this.nombreCliente; fac.Documento = this.documento; fac.Direccion1 = this.Direccion; fac.Telefono1 = this.Telefono; fac.Tipo = this.tipo; fac.NumeroFact = this.numeroFact; fac.Codigo1 = this.Codigo; /*detalle*/ fac.Idproducto = this.idproductoVenta; fac.NombreProducto = this.nombreProducto; fac.Cantidad = this.cantidadVendidad; fac.Descuento = this.descuento; fac.PrecioVenta = this.precioVenta; fac.Totalproducto = this.totalproducto; fac.SubTotal = this.subTotal; fac.Show(); } else { if (this.accion.Equals(4)) { this.Hide(); ActuFactu actu = new ActuFactu(); actu.Id = this.id; actu.Nombre = this.nombre; actu.Rol = this.rol; actu.IdFact = this.idfact; actu.Accion = this.accion; actu.Show(); } else { if (this.accion.Equals(5)) { this.Hide(); ActuFactu actu = new ActuFactu(); actu.Id = this.id; actu.Nombre = this.nombre; actu.Rol = this.rol; actu.IdFact = this.idfact; actu.Accion = this.accion; actu.Show(); } else { this.Hide(); /*encabezado factura*/ Factura fac = new Factura(); fac.Id = this.id; fac.Nombre = this.nombre; fac.Rol = this.rol; /*encabezado*/ fac.IdCliente = this.idCliente; fac.NombreCliente = this.nombreCliente; fac.Documento = this.documento; fac.Direccion1 = this.Direccion; fac.Telefono1 = this.Telefono; fac.Tipo = this.tipo; fac.NumeroFact = this.numeroFact; fac.Codigo1 = this.Codigo; /*detalle*/ fac.Idproducto = this.idproductoVenta; fac.NombreProducto = this.nombreProducto; fac.Cantidad = this.cantidadVendidad; fac.Descuento = this.descuento; fac.PrecioVenta = this.precioVenta; fac.Totalproducto = this.totalproducto; fac.SubTotal = this.subTotal; fac.Show(); } } } }
static void Main(string[] args) { Cliente persona1 = new Cliente() { Identificacion = "3050364227", Nombre = "Kevin Mero", Direccion = "Jaramijo", Telefono = 0987866879, }; List <Producto> listaproductos = new List <Producto>() { new Producto() { Codigo = "001", Descripcion = "Cafe", Precio = 1, }, new Producto() { Codigo = "002", Descripcion = "Leche", Precio = 1 }, new Producto() { Codigo = "003", Descripcion = "Azucar", Precio = 0.50 }, new Producto() { Codigo = "004", Descripcion = "Pan", Precio = 1 }, new Producto() { Codigo = "005", Descripcion = "Tacos", Precio = 5 }, new Producto() { Codigo = "006", Descripcion = "Suavitel", Precio = 2 }, new Producto() { Codigo = "007", Descripcion = "Pinoclin", Precio = 1 }, new Producto() { Codigo = "008", Descripcion = "Escoba", Precio = 5 }, new Producto() { Codigo = "009", Descripcion = "Mapo", Precio = 3 }, new Producto() { Codigo = "010", Descripcion = "Toalla", Precio = 5 } }; List <productoFactura> listaProductoFacturas = new List <productoFactura>() { new productoFactura() { //Cafe Cantidad = 2, }, new productoFactura() { //Leche Cantidad = 4 }, new productoFactura() { //Azucar Cantidad = 2 }, new productoFactura() { //Pan Cantidad = 3 }, new productoFactura() { //Tacos Cantidad = 2 }, new productoFactura() { //Suavitel Cantidad = 5 }, new productoFactura() { //Pinoclin Cantidad = 2 }, new productoFactura() { //Escoba Cantidad = 2 }, new productoFactura() { //Mapo Cantidad = 1 }, new productoFactura() { //Toalla Cantidad = 1, } }; Factura factura = new Factura() { Numero = "000-000-001", Fecha = new DateTime(2019, 10, 30), Descuento = 3 }; Console.Write("Numero: {0} \t\t", factura.Numero); Console.WriteLine("Fecha: {0} \t\t", factura.Fecha); Console.WriteLine("*****************************************************************************************"); Console.WriteLine("Cliente: {0} - Consumidor Final", persona1.Identificacion); Console.WriteLine("*****************************************************************************************"); Console.Write("Codigo \t\t"); Console.Write("Descripcion \t\t"); Console.Write("Cantidad \t\t"); Console.Write("PVP \t\t"); Console.WriteLine("Subtotal"); foreach (Producto item in listaproductos) { Console.Write(item.Codigo + "\t\t"); Console.Write(item.Descripcion + "\t\t\t"); Console.Write(item.Cantidad1 + "\t\t\t"); Console.Write(item.Precio + "\t\t\t"); Console.WriteLine(item.Subtotal12); } Console.WriteLine("*****************************************************************************************"); Console.WriteLine("\t\t\t\t\t\t\t\t\t Subtotal: {0}", factura.Subtotal); Console.WriteLine("\t\t\t\t\t\t\t\t\t Descuento: {0}", factura.Descuento); Console.WriteLine("\t\t\t\t\t\t\t\t\t Subtotal-Descuento: {0}", factura.SubtotalDescuento); Console.WriteLine("\t\t\t\t\t\t\t\t\t IVA: {0}", factura.IVA); Console.WriteLine("\t\t\t\t\t\t\t\t\t Total: {0}", factura.Total); Console.ReadKey(); }