473,326 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Employee ID Autogeneration

20
Hi,
i have a windows based aplication in that A field named EmployeeID (textbox) is there.Its value should be autogenerated from the sql server database.
the condition is that
1) The ID should start with A01,A02,........A99
After A99, the next ID should be B01,B02.......so on.


pls give me any suggestion and if possible give me a sample code for reference with records.


Thanks and regards,
Silpa
May 31 '07 #1
3 1126
prabunewindia
199 100+
wait my friend,
i am having some work now.
i will give solution after 2 hrs
Prabu

Hi,
i have a windows based aplication in that A field named EmployeeID (textbox) is there.Its value should be autogenerated from the sql server database.
the condition is that
1) The ID should start with A01,A02,........A99
After A99, the next ID should be B01,B02.......so on.


pls give me any suggestion and if possible give me a sample code for reference with records.


Thanks and regards,
Silpa
May 31 '07 #2
prabunewindia
199 100+
hai friend,

try with this code

Expand|Select|Wrap|Line Numbers
  1. // get the prevID here from table
  2.             string prev=///from table
  3.             string newID="";
  4.             char ch = (prev.ToCharArray())[0];
  5.             int no=Convert .ToInt32 (prev .Substring(1));
  6.             if(no==99)
  7.             {
  8.                 ch++;
  9.             newID =ch.ToString()+"00";//or "01" if u don't need 00
  10.             }
  11.             else if (no<9)
  12.             {
  13.                 no++;
  14.                 newID =ch.ToString ()+"0"+no.ToString ();
  15.             }
  16.             else 
  17.             {
  18.                 no++;
  19.                 newID =ch.ToString ()+no.ToString ();
  20.             }
  21.  
  22.            TextBoxEmpID.Text=newID;
if the table has no row(no employee addded) then directly print A00 or A01

Prabu

Hi,
i have a windows based aplication in that A field named EmployeeID (textbox) is there.Its value should be autogenerated from the sql server database.
the condition is that
1) The ID should start with A01,A02,........A99
After A99, the next ID should be B01,B02.......so on.


pls give me any suggestion and if possible give me a sample code for reference with records.


Thanks and regards,
Silpa
May 31 '07 #3
silpa
20
Hi,
Thankyou very much for helping me by sending the code.

Silpa




hai friend,

try with this code

Expand|Select|Wrap|Line Numbers
  1. // get the prevID here from table
  2.             string prev=///from table
  3.             string newID="";
  4.             char ch = (prev.ToCharArray())[0];
  5.             int no=Convert .ToInt32 (prev .Substring(1));
  6.             if(no==99)
  7.             {
  8.                 ch++;
  9.             newID =ch.ToString()+"00";//or "01" if u don't need 00
  10.             }
  11.             else if (no<9)
  12.             {
  13.                 no++;
  14.                 newID =ch.ToString ()+"0"+no.ToString ();
  15.             }
  16.             else 
  17.             {
  18.                 no++;
  19.                 newID =ch.ToString ()+no.ToString ();
  20.             }
  21.  
  22.            TextBoxEmpID.Text=newID;
if the table has no row(no employee addded) then directly print A00 or A01

Prabu
Jun 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Morten Gulbrandsen | last post by:
USE company; DROP TABLE IF EXISTS EMPLOYEE; CREATE TABLE EMPLOYEE ( # PK SSN CHAR(9) NOT NULL, # FK SUPERSSN CHAR(9), DNO INT NOT NULL DEFAULT 1, CONSTRAINT EMPPK
1
by: Chris Strug | last post by:
Hi, As something of a pet project, I'm looking to develop a tool to track employee holiday (or vacation for those of us in the US) for my company - good for the company (if I get something...
17
by: RSH | last post by:
I am really trying to grasp the concept of OOP as it applies to C#. I am looking at trying to set up a simple Employee Class but I am having trouble conceptualizing what this class should look...
3
by: jhhbr549 | last post by:
Can some help me with this. Please review this code for errors. I can not get it to complie. Here is my Code .. This is an abstract class that is used in conjuntion with 4 other classes.. ...
0
by: mkarki2 | last post by:
I am doing a likned list program in C. I am not really good at it and just started. But I am stuck how to pass structure in the function correctly. this is the driver file #ifndef DRIVER_C...
4
by: Jromero | last post by:
Hi I am getting this error message ...can anyone help me out????? C:\Documents and Settings\Jessica Romero\Desktop\Employee.java:23: cannot find symbol symbol : method...
5
by: varunapj | last post by:
HI , im using mysql express 2005 , Autogeneration of numbers is possible ?
0
by: howkoss | last post by:
Hi, I've been very frustrated for 2 days trying to make this work. I started with a built-in template "Projects" that came with Access 2007. On the "Employee List" I can click on any cell and bring...
4
by: shalini166 | last post by:
Autogeneration is set to particular field.example group code. after i delete or update that rows. the group code is not updated.
1
by: bartholomeus | last post by:
Hello all, I would greatly appreciate suggestions on my following PHP4 problem: In PHP5 this works: $employee = $dom->getElementsByTagName('employee')->item(0); In PHP4 this doesn't work:...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.