private void Filtrar(object sender, EventArgs e) { try { IList <Entity.ProductoViewModel> listaProductosFiltro; using (var service = new Service.ProductoService()) { if (this.tb_filtro.Text == "") { listaProductosFiltro = productos; } else { listaProductosFiltro = service.FiltrarProductos(tb_filtro.Text); } dg_productos.CargarGrid(listaProductosFiltro); DecorarGrid(); } } catch (Exception ex) { MessageBox.Show("Ocurrio un error: " + ex.Message + "Inner Exception: " + ex.InnerException, APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btn_modificar_Click(object sender, EventArgs e) { using (var service = new Service.ProductoService()) { try { Model.Producto producto = new Model.Producto(); validaDatos = ValidarValores(validaDatos); if (validaDatos.EsValido) { producto = ObtenerValores(); producto.Id_Producto = productoSeleccionado.ID; service.ModificarProducto(producto); MessageBox.Show("Datos del producto " + this.tb_modelo.Text + " modificados exitosamente", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Join(" \n", validaDatos.MensajesDeError), APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { throw; } } }
private void btn_guardar_Click(object sender, EventArgs e) { using (var service = new Service.ProductoService()) { try { Model.Producto producto = new Model.Producto(); validaDatos = ValidarValores(validaDatos); if (validaDatos.EsValido) { producto = ObtenerValores(); var IdCliente = service.GuardarProducto(producto); MessageBox.Show("Modelo " + producto.Modelo + " agregado exitosmente", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); Controles.ActivarBotones(this.ToolStrip1.Items); Controles.LimpiarControles(this.Controls); productos = service.ObtenerTodos(); dg_productos.CargarGrid(productos); this.btn_cancelar.Visible = false; } else { MessageBox.Show(string.Join(" \n", validaDatos.MensajesDeError), APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("Ocurrió un error, Por favor intente nuevamente", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void ValidarMaximos(object sender, DataGridViewCellEventArgs e) { double tipoCambio = Convert.ToDouble(this.tb_tipoCambio.Text); int idProducto = Convert.ToInt32(dg_orden.Rows[e.RowIndex].Cells[0].Value); double precioEnFactura = Convert.ToDouble(dg_orden.Rows[e.RowIndex].Cells[3].Value); int cantidadEnFactura = Convert.ToInt32(dg_orden.Rows[e.RowIndex].Cells[2].Value); using (var service = new Service.ProductoService()) { var producto = service.FiltrarPorID(idProducto); if (cantidadEnFactura > producto.Stock) { MessageBox.Show("No hay suficiente inventario del producto: " + producto.Modelo, APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); dg_orden.Rows[e.RowIndex].Cells[2].Value = producto.Stock; dg_orden.Rows[e.RowIndex].Cells[12].Value = producto.Stock * precioEnFactura; dg_orden.EndEdit(); } else { dg_orden.Rows[e.RowIndex].Cells[3].Value = precioEnFactura * tipoCambio; dg_orden.Rows[e.RowIndex].Cells[12].Value = cantidadEnFactura * precioEnFactura * tipoCambio; double total = 0; foreach (DataGridViewRow articulo in dg_orden.Rows) { var subtotal = Convert.ToDouble(articulo.Cells[12].Value); total = total + subtotal; } this.tb_total.Text = total.ToString(); } } }
private void ObtenerProductos() { using (var service = new Service.ProductoService()) { productos = service.ObtenerTodos(); dg_productos.CargarGrid(productos); } }
private void Productos_Load(object sender, EventArgs e) { using (var service = new Service.ProductoService()) { productos = service.ObtenerTodos(); dg_productos.CargarGrid(productos); DecorarGrid(); } }
private void btn_actualizar_Click(object sender, EventArgs e) { using (var service = new Service.ProductoService()) { try { Controles.LimpiarControles(this.Controls); productos = service.ObtenerTodos(); dg_productos.CargarGrid(productos); this.btn_cancelar.Visible = false; } catch (Exception) { MessageBox.Show("Ocurrió un error, Por favor intente nuevamente", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void Iniciar() { IList <Entity.ProductoViewModel> listaProductosFiltro; using (var service = new Service.ProductoService()) { if (this.tb_modelo.Text == "") { listaProductosFiltro = productos; } else { listaProductosFiltro = service.FiltrarProductos(tb_modelo.Text); } dg_productos.CargarGrid(listaProductosFiltro); DecorarGrid(); } }