public static void ImprimirTabla() { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("TIPO_PAGO", typeof(string)), new DataColumn("CANTIDAD_ARTICULOS", typeof(int)), new DataColumn("SUBTOTAL", typeof(string)), new DataColumn("IVA", typeof(string)), new DataColumn("TOTAL", typeof(string)) }); var row = dt.NewRow(); row["TIPO_PAGO"] = "EFECTIVO"; row["CANTIDAD_ARTICULOS"] = CantidadDeArticulos; row["SUBTOTAL"] = "$ " + subtotal; row["IVA"] = "$ " + iva; row["TOTAL"] = "$ " + total; dt.Rows.Add(row); ExtensionDataTable.PrintToConsole(dt); }
public static void Cobrar_Producto(DataTable dt, string codeBar, int quantity) { Console.Clear(); Producto p = new Producto(); string CodBar = string.Empty; int resp; do { Console.Clear(); Console.Write("\nCodigo de Barras: "); CodBar = Console.ReadLine(); BuscarProducto(CodBar, dt); ExtensionDataTable.PrintToConsole(dt); Console.WriteLine("\n"); ImprimirTabla(); Console.WriteLine("\n¿Desea Ingresar otro Articulo?\n" + "1.- Si\n" + "2.- No"); resp = Convert.ToInt32(Console.ReadLine()); } while (resp == 1); if (resp == 2) { Console.Clear(); string msgError = string.Empty; Venta v = new Venta(); v.Sucursal = "Gral Escobedo"; v.Fecha = DateTime.Now; v.Importe = total; v.CantidadDeArticulos = CantidadDeArticulos; v.Caja = "1"; msgError = BusinessLogicLayer.VentaBLL.RealizarVenta(v); if (string.IsNullOrEmpty(msgError)) { int saleId = BusinessLogicLayer.VentaBLL.UltimoRegistro(); if (saleId > 0) { foreach (DataRow row in dt.Rows) { Detalle_Venta d = new Detalle_Venta(); d.IdVenta = saleId; d.IdProducto = Convert.ToInt32(BusinessLogicLayer.ProductoBLL.ProductoCodigoId(row["Codigo Barras"].ToString())); d.Cantidad = Convert.ToInt32(row["Cantidad"].ToString()); d.Total = Convert.ToDouble(row["Total"].ToString()); bool isCheked = BusinessLogicLayer.Detalle_VentaBLL.insertar(d); codeBar = row["Codigo Barras"].ToString(); quantity = 1; BusinessLogicLayer.ProductoBLL.ModificarInventarioVenta(codeBar, quantity); if (isCheked) { Console.WriteLine("\n\tCOMPRA REALIZADA"); Console.WriteLine("\n\tREGRESE PRONTO LO ESTAREMOS ESPERANDO"); Console.WriteLine(""); } } } } else { Console.WriteLine(msgError); Console.ReadLine(); } } }