private void btnAgregarInsumo_Click(object sender, EventArgs e) { Int32 Cantidad = 0; int Stock = 0; Double Precio = 0; Double Subtotal = 0; if (txt_Nombre.Text == "") { Mensaje("Deb Ingresar un Insumo"); return; } if (txtPrecioVenta.Text == "") { Mensaje("Debe ingresar un precio de venta"); return; } if (txtIngresarStock.Text == "") { Mensaje("Debe ingresar una cantidad para continuar"); return; } Precio = Convert.ToDouble(txtPrecioVenta.Text); string CodInsumo = txtCodigo.Text; string Nombre = txt_Nombre.Text; if (txtCantidad.Text != "") { Stock = Convert.ToInt32(txtCantidad.Text); } if (txtIngresarStock.Text != "") { Cantidad = Convert.ToInt32(txtIngresarStock.Text); } if (Cantidad > Stock) { Mensaje("La cantidad ingresada supera el stock actual"); return; } if (tabla.Buscar(tbVenta, "CodInsumo", CodInsumo) == true) { Mensaje("Ya ingreso el insumo"); return; } Subtotal = Precio * Cantidad; string Val = CodInsumo + ";" + Nombre; Val = Val + ";" + Cantidad.ToString() + ";" + Precio.ToString(); Val = Val + ";" + Subtotal.ToString(); tbVenta = tabla.AgregarFilas(tbVenta, Val); Grilla.DataSource = tbVenta; Double Total = fun.TotalizarColumna(tbVenta, "Subtotal"); txtTotal.Text = Total.ToString(); }
private void btnAgregarInsumo_Click(object sender, EventArgs e) { if (txtCodigo.Text == "") { Mensaje("Debe seleccionar un insumo"); return; } if (txtIngresarStock.Text == "") { Mensaje("Debe ingresar una cantidad de stock"); return; } if (txt_Precio.Text == "") { Mensaje("Debe ingresar un Precio"); return; } if (tabla.Buscar(tbInsumos, "CodInsumo", txtCodigo.Text) == true) { Mensaje("Ya se ha ingresado el repuesto"); return; } Double PrecioVenta = 0; Int32 Cantidad = Convert.ToInt32(txtCantidad.Text); Int32 IngresarCantidad = Convert.ToInt32(txtIngresarStock.Text); Int32 Cantidadtotal = Cantidad + IngresarCantidad; string Nombre = txt_Nombre.Text; double Precio = fun.ToDouble(txt_Precio.Text); double PrecioIva = Precio; if (txtPrecioVenta.Text != "") { PrecioVenta = fun.ToDouble(txtPrecioVenta.Text); } if (chkAplicarIva.Checked == true) { double PorIva = 0.21 * Precio; PrecioIva = PrecioIva + PorIva; PrecioIva = Math.Round(PrecioIva, 0); } string Valores = txtCodigo.Text; Valores = Valores + ";" + Nombre; Valores = Valores + ";" + IngresarCantidad; Valores = Valores + ";" + Cantidadtotal; Valores = Valores + ";" + PrecioIva; Valores = Valores + ";" + PrecioVenta.ToString(); tbInsumos = tabla.AgregarFilas(tbInsumos, Valores); Grilla.DataSource = tbInsumos; Grilla.Columns[3].HeaderText = "Stock Total"; Grilla.Columns[5].HeaderText = "Venta"; Grilla.Columns[0].Visible = false; Grilla.Columns[3].Width = 120; Grilla.Columns[1].Width = 200; }