public void Buy(String productType, GridViewCommandEventArgs e, GridView gridID) { if (e.CommandName == "Buy") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gridID.Rows[index]; String clientID = client.ID; TableCell cellNumber = row.Cells[1]; TextBox numberBox = cellNumber.FindControl("numberToBuy") as TextBox; int number = Convert.ToInt32(numberBox.Text); TableCell cellID = row.Cells[4]; int id = Convert.ToInt32(cellID.Text); try { management.ClientBuy(connectionString, clientsTable, clientID, productType, id, number); LoadData(); } catch //DoubleException exception) { //errorLabel.Text = exception.Message; } } else if (e.CommandName == "Plus") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gridID.Rows[index]; String clientID = client.ID; TableCell cellID = row.Cells[4]; int id = Convert.ToInt32(cellID.Text); try { management.AddOrSubtract(connectionString, clientsTable, clientID, productType, id, true); LoadData(); } catch { //errorLabel.Text = exception.Message; } } else { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gridID.Rows[index]; String clientID = client.ID; TableCell cellID = row.Cells[4]; int id = Convert.ToInt32(cellID.Text); try { management.AddOrSubtract(connectionString, clientsTable, clientID, productType, id, false); LoadData(); } catch { //errorLabel.Text = exception.Message; } } }