Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello people and programming gurus, :)

 

I was browsing thru the web for an illusive solution to my school project which is C# based, when i stumbled upon this programming forum. I've "Googled" numerous times for a solution to my problem but to no avail. The result always shows "idautomation.com" which isn't free. I'm a poor student, there's no way i could pay for that.

 

Though this language (C#) is taught, we are supposed to work on something more challenging and find our own solutions to it.

 

My project is about creating a barcode scanner application that tracks inventory movement. I having been trying to search for a solution to automate the scanning process as in i don't have to hit "Enter" or click on the textbox after or before every scan.

 

So far i'm able to clear the textbox after scanning.

 

Scanner i'm using: CCD USB (EAN13)

 

Pardon me if my problem sounds peanuts to you guys b'cos i'm new to C#. And sorry for tis winding message. If you could PM me, i'll be most glad.

 

Thanks guys.

Posted

Hiya newbie101,

 

I have no experience using barcode scanners but then general idea would be to have a thread running that will "listen" for barcodes being scanned. Once a barcode is detected it would be processed and then the "listening" thread would start to "listen" again.

 

I hope this makes sense.

 

 

Happy Coding :D

 

 

Brent Newbury

Posted

Hi brentnewbury,

 

Thanks for your reply. You are the only one who is bothered to reply me. :cool: Hmmm...seems like a cold forum here... :rolleyes:

 

Anyway, u mentioned "listening" thread? What's this? I'm really new to this language...perhaps u can provide some sample coding for me?

 

Any form of help is always appreciated than none. ;)

  • Administrators
Posted
Do you have any code so far? It is a lot easier for people to help if you do give them something to work with. Also giving a descriptive subject will make it easier for people to identify your problem - not everyone has time to read each and every thread posted.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • *Experts*
Posted

Suggestion: The thread labelled "Need help detecting end of line when reading a barcode" is a good start.

 

Also, showing us that you've got some code working and what you're having trouble with helps us to help you.

 

My experience with barcodes is that it acts exactly like a keyboard. The application will not know the difference between what's being scanned (or when it started) and what's being typed. Maybe your scanner has some mechanism to indicate the end (send a CHR 0 as the last byte). If not, can you assume anything about what's being scanned? Maybe it's always 10 digits. After your textbox reads in 10 chars, have the code process the click. Something like:

// Assume a textbox named txtEntry that's being "read" into
private void txtEntry_TextChanged(object sender, System.EventArgs e)
{
   if(txtEntry.Text.Length == 10)
   {
       // Assume that after 10 chars, you want to save the data or process some function
       btnSave.ProcessClick();
   }
}

 

As PD said, the quality of your post will determine the quality of your response.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Thanks for the replies guys. :D

 

Hmm...being on the internet reaching millions n millions of "connected" people around the world...i guess this website ain't so popular(which i think this forum is great) if it's true that not everyone is free to read threads in this forum....i mean...look at the world's population and no one's free??? No offence but just a thought. I know, the world doesn't revolve around me and nobody owes me anything. :) Just a thought ya?

 

About not giving a quality thread..well..as i've mentioned, i'm truely a newbie in programming and i don't know where to start for my problems. Or maybe my english sucks?? Some of you guys started programming like what....in your teens or earlier...me started alot later in my early 20s. I apologize if my thread's objective ain't clear enough...trying hard to make some sense in my posting. :p

 

Nerseus: I'm still trying out how to configure the CCD barcode scanner with its programming manual that comes with it. But what you suggested is simple yet brilliant. Too bad i'm not smart enough to think of that before u did. I'm located outside America and guess it would be 13 chars since we are using EAN13. I also understand that the barcode scanner works on the same principle as that of the keyboard.

 

What i was tryin to do is to capture data into a database after scanning and deletes the entry if it was scanned a second time.

Pardon for leaving the codes out...Here goes:

 

private void TextBox1_TextChanged(object sender, System.EventArgs e)

{

 

SqlConnection conn = new SqlConnection();

SqlCommand comm = new SqlCommand();

try

{

conn.ConnectionString = "data source=(local);initial catalog=databaseName;"+

"integrated security=true;";

conn.Open();

comm.Connection = conn;

 

comm.CommandText = "select * from tableName where

columnName=@1stItem";

comm.Parameters.Add("@1stItem", TextBox1.Text);

SqlDataReader dr = comm.ExecuteReader();

bool replicate=false;

 

while (dr.Read())

{

replicate=true;

}

dr.Close();

if (replicate)

{

//delete if duplicate

comm.CommandText= "delete tableName where columnName=@1stItem";

int deleted=comm.ExecuteNonQuery();

if (deleted>0)

lblStatus.Text="The item deleted from database.";

}

else

{

//insert values

comm.CommandText= "insert into tableName(columnName)

values (@iItem)";

comm.Parameters.Add("@iItem", TextBox1.Text);

int rowsInsert= comm.ExecuteNonQuery();

if (rowsInsert>0)

lblStatus.Text=TextBox1.Text+" Inserted.";

else

lblStatus.Text="no";

}

}

catch (SqlException ex)

{

lblError.Text = ex.Message;

}

finally

{

conn.Close();

}

 

if (IsPostBack)

TextBox1.Text="";

}

 

 

Sorry for lousy indentation of the codes. I'm now trying how to automate the scanning process without any buttons or clicking on the web form. I will try with Nerseus's suggestion meanwhile.

  • 1 month later...
Posted
Thanks for the replies guys. :D

 

Hmm...being on the internet reaching millions n millions of "connected" people around the world...i guess this website ain't so popular(which i think this forum is great) if it's true that not everyone is free to read threads in this forum....i mean...look at the world's population and no one's free??? No offence but just a thought. I know, the world doesn't revolve around me and nobody owes me anything. :) Just a thought ya?

 

About not giving a quality thread..well..as i've mentioned, i'm truely a newbie in programming and i don't know where to start for my problems. Or maybe my english sucks?? Some of you guys started programming like what....in your teens or earlier...me started alot later in my early 20s. I apologize if my thread's objective ain't clear enough...trying hard to make some sense in my posting. :p

 

Nerseus: I'm still trying out how to configure the CCD barcode scanner with its programming manual that comes with it. But what you suggested is simple yet brilliant. Too bad i'm not smart enough to think of that before u did. I'm located outside America and guess it would be 13 chars since we are using EAN13. I also understand that the barcode scanner works on the same principle as that of the keyboard.

 

What i was tryin to do is to capture data into a database after scanning and deletes the entry if it was scanned a second time.

Pardon for leaving the codes out...Here goes:

 

private void TextBox1_TextChanged(object sender, System.EventArgs e)

{

 

SqlConnection conn = new SqlConnection();

SqlCommand comm = new SqlCommand();

try

{

conn.ConnectionString = "data source=(local);initial catalog=databaseName;"+

"integrated security=true;";

conn.Open();

comm.Connection = conn;

 

comm.CommandText = "select * from tableName where

columnName=@1stItem";

comm.Parameters.Add("@1stItem", TextBox1.Text);

SqlDataReader dr = comm.ExecuteReader();

bool replicate=false;

 

while (dr.Read())

{

replicate=true;

}

dr.Close();

if (replicate)

{

//delete if duplicate

comm.CommandText= "delete tableName where columnName=@1stItem";

int deleted=comm.ExecuteNonQuery();

if (deleted>0)

lblStatus.Text="The item deleted from database.";

}

else

{

//insert values

comm.CommandText= "insert into tableName(columnName)

values (@iItem)";

comm.Parameters.Add("@iItem", TextBox1.Text);

int rowsInsert= comm.ExecuteNonQuery();

if (rowsInsert>0)

lblStatus.Text=TextBox1.Text+" Inserted.";

else

lblStatus.Text="no";

}

}

catch (SqlException ex)

{

lblError.Text = ex.Message;

}

finally

{

conn.Close();

}

 

if (IsPostBack)

TextBox1.Text="";

}

 

 

Sorry for lousy indentation of the codes. I'm now trying how to automate the scanning process without any buttons or clicking on the web form. I will try with Nerseus's suggestion meanwhile.

 

 

If you haven't already solved this, you may find that the scanner can be setup with both preambe and postamble, what this means is that you can assign characters to be added to the front and back of the barcode when it is scanned and before it is transmitted to the PC. The scanner will act as a keyboard input, so therefore if you set the focus to a textbox initially, scanning a barcode with a postamb Carriage Return should automatically accept the barcode.

 

Hope that helps

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...