private void Btn_remGrid_Click(object sender, EventArgs e) { double subtotal = 0; int cantidad = 0; if (Dgv_factura.Rows.Count - 1 > 0) { cantidad = Int32.Parse(Dgv_factura.Rows[seleccionado].Cells[1].Value.ToString()); cantidad--; cantidadProducto++; try { logicaConsulta.aumentarInventario(Dgv_factura.Rows[seleccionado].Cells[0].Value.ToString()); } catch { MessageBox.Show("Fallo al Actualizar Inventario", "Facturacion", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (cantidad < 1) { Dgv_factura.Rows.RemoveAt(seleccionado); } else { Dgv_factura.Rows[seleccionado].Cells[1].Value = cantidad; Dgv_factura.Rows[seleccionado].Cells[4].Value = cantidad * Double.Parse(Dgv_factura.Rows[seleccionado].Cells[3].Value.ToString()); } for (int i = 0; i < Dgv_factura.Rows.Count - 1; i++) { subtotal += Double.Parse(Dgv_factura.Rows[i].Cells[4].Value.ToString()); } Txt_subtotalGeneral.Text = "Q. " + String.Format("{0:0.00}", subtotal); Txt_total.Text = "Q. " + String.Format("{0:0.00}", subtotal); int registros = Dgv_factura.Rows.Count - 1; Txt_registros.Text = registros.ToString(); } else { MessageBox.Show("No hay filas en la Tabla!", "Facturacion", MessageBoxButtons.OK, MessageBoxIcon.Error); } }