Sql Server in C# using Bindingsource

Asked

Viewed 118 times

2

I am on a project where I have a sale screen. When making a sale, a method checks if the customer has an account. If he doesn’t have one, he creates one for himself, so far so good. But if the client already owns this account, he needs to change the data only. But when will I change the data using BindingSource, it alters by DataGridView and is changing the first record only.

I need a filter that takes the name of the customer to be changed, and automatically it puts me in the line of the datagridview of this customer that will already be registered. I tried that but it didn’t work.

String searchValue = txtNome.Text;

int rowIndex = -1;
foreach (DataGridViewRow row in dgvFicha.Rows)
{
  if (row.Cells[2].Value.ToString().Equals(searchValue))
  {
     rowIndex = row.Index;
     break;
  }
}
  • Can provide more details?

  • Do you need to automatically update customer data after saving a new sale with an existing customer? If you can provide more data it would be good.

  • Hello, yes I do because when a new sale is made I need to change the customer’s debit in his account. But I have already solved the problem. I’ll post the code to see how I did it.

  • Hello I already solved the problem, I managed to put a code that checks if the customer who is in the sale is the same as the datagridview, if it is not he jumps to the next record, then when the condition is satisfied he stops and writes in the bank the information.

  • while (txtNomeVerificar.Text != txtNome.Text)
 {
 this.fichaBindingSource.MoveNext();
 txtNomeVerificar.Text = dgvFicha.CurrentRow.Cells[1].Value.ToString();
 }

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.