private void ToolstGuardar_Click(object sender, EventArgs e) { try { if (ValidarT()) { if (UP == true) { Factura entidad = new Factura(); FacturaBl actualizar = new FacturaBl(); } if (UP == false) { FacturaBl fac = new FacturaBl(); Factura entidad = new Factura(); DetalleFacturaBl dtf = new DetalleFacturaBl(); DetalleFacturas entidf = new DetalleFacturas(); ProductosBl pb = new ProductosBl(); Productos pd = new Productos(); // entidad.ID_Producto = ID; entidad.Fecha = Convert.ToDateTime(toolStripStatusLabel1.Text); entidad.Forma_Pago = CbxForamPago.Text; entidad.Vendedor = Usu.ToString(); entidad.Total = double.Parse(LblTotaApagar.Text); entidad.Id_Cliente = Id_Cliente; fac.RegFactura(entidad); foreach (DataGridViewRow row in dgvDetalleF.Rows) { entidf.Monto = Convert.ToDouble(row.Cells["Precio_Producto"].Value); entidf.Cantidad = Convert.ToInt16(row.Cells["Fecha"].Value); entidf.Itbis = Convert.ToDouble(row.Cells["Generales"].Value); entidf.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value); var dt = fac.ObtenerIDFactura(Id_Cliente, Convert.ToDouble(LblTotaApagar.Text)); var Id1 = dt.Rows[0]["ID_Factura"]; entidf.ID_Factura = Convert.ToInt16(Id1); ID_Factura = Convert.ToInt16(Id1); pd.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value);; pd.Inventario = Convert.ToInt16(row.Cells["Fecha"].Value); pb.ActualizarInventario(pd); dtf.RegDetalleFactura(entidf); } // dgvClientes.Update(); // LlenarGrid(); MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information); ToolstNuevo.PerformClick(); if (MessageBox.Show("¿Desea imprimir la factura? ", "Imprimir", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { tsImprimir.PerformClick(); } else { return; } } } else { MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error); if (string.IsNullOrWhiteSpace(TxtProducto.Text)) { errorProvider1.SetError(TxtProducto, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtCliente.Text)) { errorProvider1.SetError(TxtCliente, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(CbxForamPago.Text)) { errorProvider1.SetError(CbxForamPago, "Este Campo es requerido"); } } } catch (Exception) { throw; } }
public void Add(Producto productoToAdd) { Productos.Add(productoToAdd); Count++; }
private int searchText() { resetConsole(); Console.Write("Text to search: "); string text = Console.ReadLine().ToLower(); Console.WriteLine("From this file or begining? file/begining"); string index = Console.ReadLine(); Console.WriteLine("Stop when finding a product o when finish? finding/finish"); string stop = Console.ReadLine(); int actualPos = 1; List <int> foundPositions = new List <int>(); if (index == "file") { actualPos = Index; } bool find = false; do { Producto productoActual = Productos.Get(actualPos); if (productoActual.Codigo.ToString().ToLower().Contains(text) || productoActual.Descripcion.ToLower().Contains(text) || productoActual.Categoria.ToLower().Contains(text) || productoActual.PrecioVenta.ToString().ToLower().Contains(text) || productoActual.PrecioCompra.ToString().ToLower().Contains(text) || productoActual.Stock.ToString().ToLower().Contains(text) || productoActual.StockMinimo.ToString().ToLower().Contains(text)) { if (stop == "finding") { find = true; } foundPositions.Add(actualPos); } if (!find && actualPos < Productos.Count) { actualPos++; } } while (!find && actualPos < Productos.Count); if (foundPositions.Count > 1) { Console.Write("Found at positions: "); Console.Write(foundPositions[0]); for (int i = 1; i < foundPositions.Count; i++) { Console.Write(", " + foundPositions[i]); } Console.WriteLine(); Console.WriteLine("Press enter to return"); Console.ReadLine(); return(Index); } return(actualPos); }
private void drawActualProduct() { resetConsole(); string line = new string('-', Console.WindowWidth); string emptyLine = new string(' ', Console.WindowWidth - 2); string helpLine1 = "1-Anterior 2-Posterior 3-Número 4-Buscar " + "5-Añadir 6-Modificar B-Borrar"; string helpLine2 = "7-Listados F1-Ayuda 0-Terminar"; string topLine = "Productos (ficha actual: " + Index + "/" + Productos.Count + ")"; string date = (DateTime.Now.Date + "").Substring(0, 11) + " " + (DateTime.Now.Date + "").Substring(11); //Cuadrado de arriba Console.SetCursorPosition(0, 0); Console.Write(line); Console.Write("|" + emptyLine + "|"); Console.Write(line); Console.SetCursorPosition(1, 1); Console.Write(topLine); Console.SetCursorPosition(Console.WindowWidth / 2, 1); Console.Write(date); //Cuerpo del programa Console.SetCursorPosition(0, 4); Console.Write("Codigo: "); Console.CursorLeft = 15; Console.WriteLine(checkVacio(Productos.Get(Index).Codigo)); Console.WriteLine(); Console.Write("Descripcion: "); Console.CursorLeft = 15; Console.WriteLine(checkVacio(Productos.Get(Index).Descripcion)); Console.Write("Categoria: "); Console.CursorLeft = 15; Console.WriteLine(checkVacio(Productos.Get(Index).Categoria)); Console.WriteLine(); Console.Write("Precio Venta: "); Console.CursorLeft = 15; Console.WriteLine(checkVacio(Productos.Get(Index).PrecioVenta)); Console.Write("Precio Compra: "); Console.CursorLeft = 15; Console.WriteLine(checkVacio(Productos.Get(Index).PrecioCompra)); Console.WriteLine(); Console.Write("Stock: "); Console.CursorLeft = 15; Console.WriteLine(checkVacio(Productos.Get(Index).Stock)); Console.Write("Stock mínimo: "); Console.CursorLeft = 15; Console.WriteLine(checkVacio(Productos.Get(Index).StockMinimo)); //Parte de abajo Console.SetCursorPosition(0, Console.WindowHeight - 4); Console.Write(line); Console.SetCursorPosition(Console.WindowWidth / 2 - (helpLine1.Length / 2), Console.WindowHeight - 3); Console.WriteLine(helpLine1); Console.SetCursorPosition(Console.WindowWidth / 2 - (helpLine2.Length / 2), Console.WindowHeight - 2); Console.WriteLine(helpLine2); Console.ResetColor(); }
private void ToolstGuardar_Click(object sender, EventArgs e) { try { if (Validar()) { if (UP == true) { Productos entidad = new Productos(); ProductosBl actualizar = new ProductosBl(); if (ID < 1) { MessageBox.Show("Debe seleccionar un registro valido antes de actualizar." + " Por favor seleccione un registro en la pestaña de busqueda que desea actualizar " + "y vuelva a intentarlo.", "Error de eliminación", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { DateTime Fecha = DateTime.Today; entidad.ID_Producto = ID; entidad.Descripcion_Producto = TxtDescPro.Text; entidad.Precio_Compra = double.Parse(TxtPCompra.Text); entidad.Precio_Venta = double.Parse(TxtPVenta.Text); entidad.Inventario = Convert.ToInt32(TxtInventario.Text); //string fecha= dateTimePicker1.Value.ToString("yyyy-MM-dd"); entidad.Fecha_Entrada = Convert.ToDateTime(Fecha.ToString("yyyy-MM-dd")); //entidad.ID_Proveedor = int.Parse(CbxProveedor.SelectedValue.ToString()); actualizar.ActualizarProductos(entidad); MessageBox.Show("Registro Actualizado.", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information); UP = false; return; } } if (UP == false) { ProductosBl Pro = new ProductosBl(); Productos entidad = new Productos(); //if (TxtApellido.Text == string.Empty) // TxtApellido.Text = null; //if (TxtDireccion.Text == string.Empty) // TxtDireccion.Text = null; //if (TxtTelefono.Text == string.Empty) // TxtTelefono.Text = null; //if (TxtApellido.Text == string.Empty) // TxtApellido.Text = null; //if (txtSaldoActual.Text == string.Empty) // txtSaldoActual.Text = "0.0"; //float SaldoIn = float.Parse(txtSaldoInicial.Text); //float SaldoAct = float.Parse(txtSaldoActual.Text); DateTime Fecha = DateTime.Today; // entidad.ID_Producto = ID; entidad.Descripcion_Producto = TxtDescPro.Text; entidad.Precio_Compra = double.Parse(TxtPCompra.Text); entidad.Precio_Venta = double.Parse(TxtPVenta.Text); entidad.Inventario = Convert.ToInt32(TxtInventario.Text); entidad.ID_Proveedor = int.Parse(CbxProveedor.SelectedValue.ToString()); entidad.ID_Proveedor = int.Parse(CbxProveedor.SelectedValue.ToString()); entidad.Fecha_Entrada = Convert.ToDateTime(Fecha.ToString("yyyy-MM-dd")); Pro.RegProducto(entidad); // dgvClientes.Update(); // LlenarGrid(); MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information); ToolstNuevo.PerformClick(); } } else { MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error); if (string.IsNullOrWhiteSpace(TxtDescPro.Text)) { errorProvider1.SetError(TxtDescPro, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtPCompra.Text)) { errorProvider1.SetError(TxtPCompra, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtInventario.Text)) { errorProvider1.SetError(TxtInventario, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtPVenta.Text)) { errorProvider1.SetError(TxtPVenta, "Este Campo es requerido"); } } } catch (Exception) { throw; } }