Naeem Khan

Naeem Khan

  • 889
  • 782
  • 790.9k

Text Box event for Barcode Scanner using Windows Application

Aug 5 2015 1:52 AM
Hello friends,
 
I m using code for barcode saccning . i m reteriving data from database when text box fill by accession no but i dont have any idea which event should i used for it.. if do you have any idea then plz reply me ASAP..
 
 
private void stock_verification()
{
Boolean found = false;
foreach (DataGridViewRow row in gv_show_details.Rows)
{
if (row.Cells[0].Value.ToString() == txt_accession_no.Text)
{
found = true;
MessageBox.Show("Book already exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
txt_accession_no.Text = "";
txt_accession_no.Focus();
break;
}
}
if (!found)
{
try
{
MySqlConnection con = new MySqlConnection(StartUp.database);
con.Open();
MySqlCommand cmd = new MySqlCommand("call ps_stock_verification_books('" + txt_accession_no.Text + "')", con);
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
gv_show_details.Rows.Add();
gv_show_details.Rows[i].Cells[0].Value = dr[0].ToString();
gv_show_details.Rows[i].Cells[1].Value = dr[1].ToString();
gv_show_details.Rows[i].Cells[2].Value = dr[2].ToString();
gv_show_details.Rows[i].Cells[3].Value = dr[3].ToString();
gv_show_details.Rows[i].Cells[4].Value = dr[4].ToString();
gv_show_details.Rows[i].Cells[5].Value = dr[5].ToString();
gv_show_details.Rows[i].Cells[6].Value = dr[6].ToString();
i++;
}
lbl_number_of_bboks.Text = "Number of Books : " + gv_show_details.RowCount;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
 
private void txt_accession_no_Validating(object sender, CancelEventArgs e)
{
stock_verification();
txt_accession_no.Focus();
txt_accession_no.Text = "";

Answers (1)