This is a program to show several products through the arrangement of objects. What happens is that when I am adding products with their respective attributes, I get an error saying "The input string does not have the correct format" pointing to this part that belongs to the Insert button:
private void btnInsertar_Click(object sender, EventArgs e)
{
**producto.Ingresadatos(int.Parse(txtCodigo.Text), txtNombre.Text, double.Parse(txtCantidad.Text),txtUMedida.Text,double.Parse(txtCosto.Text));**
txtCodigo.Clear(); txtNombre.Clear(); txtCantidad.Clear(); txtUMedida.Clear(); txtCosto.Clear();txtCodigo.Focus();
}
This is the class code:
int i, I,c1,c2,codigo;
string nombre, unidadMe,salida;
double costo,cantidad,cantMax,cantMin;
Producto[] prod = new Producto[20];
public void Ingresadatos(int cod,string nom,double cant,string uniMe,double cos)
{
prod[i] = new Producto();
prod[i].codigo = cod;
prod[i].nombre = nom;
prod[i].cantidad = cant;
prod[i].unidadMe = uniMe;
prod[i].costo = cos;
}
public string Listar()
{
i++; I = i;
for (i=0;i<I;i++)
{
salida+= " " + prod[i].codigo + " " + prod[i].nombre +
" " + prod[i].cantidad +" "+ prod[i].unidadMe + " " + prod[i].costo + "\r\n";
}
return salida;
}