private void calcularPromedioMuestras() { List <double> valoresUnitarios = new List <double>(); List <double> valoresTotales = new List <double>(); foreach (DataGridViewRow d in this.dgvExistencias.Rows) { valoresUnitarios.Add(double.Parse(d.Cells[2].Value.ToString())); } foreach (DataGridViewRow d in this.dgvExistencias.Rows) { valoresTotales.Add(double.Parse(d.Cells[3].Value.ToString())); } NegocioMuestra negE = new NegocioMuestra(); double promedioUnit = negE.calcularPromedio(valoresUnitarios); double promedioTotal = negE.calcularPromedio(valoresTotales); foreach (DataGridViewRow d in this.dgvExistencias.Rows) { d.Cells[4].Value = promedioUnit; } foreach (DataGridViewRow d in this.dgvExistencias.Rows) { d.Cells[5].Value = promedioTotal; } }
private void btnAgregar_Click(object sender, EventArgs e) { if (this.txtValorUnitario.Text.Trim().Equals("")) { MessageBox.Show(this, "¡Ingrese el valor unitario!", "Error, falta informacion"); return; } if (this.txtCantidad.Text.Trim().Equals("")) { MessageBox.Show(this, "¡Ingrese la cantidad!", "Error, falta informacion"); return; } if (this.cmbBodega.SelectedIndex == 0) { MessageBox.Show(this, "Seleccione la bodega", "Error, falta informacion"); return; } NegocioMuestra negE = new NegocioMuestra(); Muestra mu = new Muestra(); mu.CANTIDAD = int.Parse(this.txtCantidad.Text.Trim()); mu.VALORINGRESOCLP = int.Parse(this.txtValorUnitario.Text.Trim()); mu.BODEGA = this.cmbBodega.SelectedItem.ToString(); negE.agregarMuestra(producto, mu);; MessageBox.Show(this, "Se añadieron: " + mu.CANTIDAD + "\n" + producto.NOMBRE + "\nA un Precio de: " + mu.VALORINGRESOCLP, "¡Exito!"); cargarMuestras(); this.txtCantidad.Text = ""; this.txtValorUnitario.Text = ""; }
private void cargarMuestras() { NegocioMuestra negE = new NegocioMuestra(); List <Muestra> lista = negE.getMuestras(producto); this.dgvExistencias.Rows.Clear(); foreach (Muestra m in lista) { this.dgvExistencias.Rows.Add(m.FECHAINGRESO, m.CANTIDAD, m.VALORINGRESOCLP, (m.CANTIDAD * m.VALORINGRESOCLP), m.BODEGA); } }
private void cargarActivosGrid() { NegocioCuenta negC = new NegocioCuenta(); NegocioMuestra negE = new NegocioMuestra(); List <Object[]> lista = negE.getAllActivos(); this.dgvActivos.Rows.Clear(); foreach (Object[] ob in lista) { ob[4] = negC.getNombreCuenta(ob[4].ToString()) + " (" + ob[4] + ")"; this.dgvActivos.Rows.Add(ob[0], ob[1], ob[2], ob[3], ob[4], ob[5], ob[6], ob[7], ob[8]); } }
private void btnAgregar_Click(object sender, EventArgs e) { NegocioMuestra negM = new NegocioMuestra(); NegocioProducto neg = new NegocioProducto(); if (neg.existeProducto(this.txtCodigo.Text.Trim(), this.txtPrelude.Text.Trim()) == false) { MessageBox.Show(this, "no se encuentra el repuesto", "Error, falta informacion"); return; } if (this.btnAgregar.Text.Equals("Modificar")) { String datosl = ""; datosl = this.txtCantidad.Text.Trim(); Modulo.ingresarOrdenTrabajo.modRepuesto(datosl); this.Dispose(); } if (this.btnAgregar.Text.Equals("Agregar")) { if (this.txtCodigo.Text.Trim().Equals("") && this.txtPrelude.Text.Trim().Equals("")) { MessageBox.Show(this, "Ingrese al menos un codigo", "Error, falta informacion"); return; } if (this.txtCantidad.Text.Trim().Equals("")) { MessageBox.Show(this, "Ingrese la cantidad del repuesto", "Error, falta informacion"); return; } String[] datos = new String[4]; Producto p = new Producto(); if (this.txtCodigo.Text.Trim().Equals("")) { datos[0] = ""; datos[1] = this.txtPrelude.Text.Trim(); p = neg.getProductoPrelude(this.txtPrelude.Text.Trim()); if (negM.hayProductoEnMuestra(p) == false) { MessageBox.Show(this, "No se puede agregar el repuesto, no hay existencias en inventario", "Error, falta informacion"); return; } datos[3] = negM.getValorPromedioPrelude(this.txtPrelude.Text.Trim()).ToString(); } if (this.txtPrelude.Text.Trim().Equals("")) { datos[1] = ""; datos[0] = this.txtCodigo.Text.Trim(); p = neg.getProductoMcelroy(this.txtCodigo.Text.Trim()); if (negM.hayProductoEnMuestra(p) == false) { MessageBox.Show(this, "No se puede agregar el repuesto, no hay existencias en inventario", "Error, falta informacion"); return; } datos[3] = negM.getValorPromedioMcelroy(this.txtCodigo.Text.Trim()).ToString(); } datos[2] = this.txtCantidad.Text.Trim(); Modulo.ingresarOrdenTrabajo.addRepuesto(datos, p); this.Dispose(); } }