hola de nuevo , este estoy checando un programa y me sale este un error que dice:
ha ocurrido un error: system.FormatExeption:input string was not in corret format.
at system.Number.stringToNumber(String str,NumberStyles opcions,NumberBuffer&number,NumberFormatInfo info,
Boolean parseDecimal)
at System.Number.ParseInt32(String s, NUmberStyles style,NumberFormatInfo info)
at System.Int32.parse (string s)
at sumaProductos.Preoductos.listview_Precios_DoubleClick(Objet sender, EventArgs e)
y NO SE QUE HACER AYUDA POR FAVOR!!!
se los agradecere.
le voy a mostrar lo que tengo de codigo que es este:
public partial class Productos : Form
{
BaseDatos bd = new BaseDatos();
public Productos()
{
InitializeComponent();
}
private void Productos_Load(object sender, EventArgs e)
{
LlenarListViewProductos(
"Productos");
}
private void LlenarListViewProductos(string tabla)
{
string sql;
int i;
DataSet ds = new DataSet();
sql =
"select clave,descripcion,precio from " + tabla;
bd.LlenarDataSet(ds, sql);
listView_Precios.Items.Clear();
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
this.listView_Precios.Items.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
this.listView_Precios.Items[this.listView_Precios.Items.Count - 1].SubItems.Add(ds.Tables[0].Rows[i].ItemArray[1].ToString());
this.listView_Precios.Items[this.listView_Precios.Items.Count - 1].SubItems.Add(ds.Tables[0].Rows[i].ItemArray[2].ToString());
}
}
private void listView_Precios_DoubleClick(object sender, EventArgs e)
{
string nombre_producto;
string precio_producto;
int cantidad=0;
// AQUI OBTENGO EL NOMBRE Y EL PRECIO DEL PRODUCTO SELECCIONADO
nombre_producto =
this.listView_Precios.SelectedItems[0].SubItems[1].Text;
precio_producto =
this.listView_Precios.SelectedItems[0].SubItems[2].Text;
// EVALUAMOS SI EL LISTVIEWFACTURA CONTIENE YA ALGUN PRODUCTO FACTURADO
if (listView_Factura.Items.Count == 0)
{
cantidad += 1;
// AGREGAMOS LOS PRODUCTOS AL LISTVIEWFACTURA
ListViewItem item1 = new ListViewItem(cantidad.ToString(), 1);
item1.SubItems.Add(nombre_producto);
item1.SubItems.Add(precio_producto);
listView_Factura.Items.AddRange(
new ListViewItem[] { item1 });
}
else // CUANDO NO ES LA PRIMERA VES QUE SE FACTURA EL PRODUCTO
{
int i;
for ( i = 0; i <= this.listView_Factura.Items.Count - 1 ; i++ )
{
if (this.listView_Factura.Items[i].SubItems[1].Text == nombre_producto)
{
cantidad.ToString().Equals(
this.listView_Factura.Items[i].SubItems[0].ToString());
cantidad += 1;
precio_producto += precio_producto;
ListViewItem item1 = new ListViewItem(cantidad.ToString(), 1);
item1.SubItems.Add(nombre_producto);
item1.SubItems.Add(precio_producto);
break;
}
else // CUANDO ES LA PRIMERA VES QUE SE FACTURA EL PRODUCTO
{
cantidad = 1;
//precio_producto += precio_producto;
ListViewItem item1 = new ListViewItem(cantidad.ToString(), 1);
item1.SubItems.Add(nombre_producto);
item1.SubItems.Add(precio_producto);
listView_Factura.Items.AddRange(
new ListViewItem[] { item1 });
break;
}
}
}
try
{
string sub;
int subtotal;
int total = 0;
// SUMAMOS EL SUBTOTAL
sub = txt_SubTotal.Text;
//OCURRE UNA ECEPCION
subtotal =
int.Parse(txt_SubTotal.Text);
subtotal += subtotal;
txt_SubTotal.Text = subtotal.ToString();
// SUMAMOS EL TOTAL
txt_Total.Text = total.ToString();
}
catch (Exception ex)
{
MessageBox.Show("Ha ocurrido el siguiente error: " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
les agradeceria si me dijeran donde esta el error o los errores ,de antemano mil gracias!!!!!!!!!!!!