Non-typical way of creating a client ID

Posted on 2013-05-28
Last Modified: 2013-05-28
C# Windows Form.  When we create a new client ID for our client table, we would like to be able to select a valid code from the codes table and then have the sytem generate the unique 3 character sequence for the code.  For instance, 2 valid codes are 10 (reinsureance company) and 20 (other company).  In our current Visual FoxPro system the user can type 10 in the text box or click the pickbox icon to the right of the text box to select 10 from the list of valid codes.  Either action triggers a system routine that generates the next 3 characters and displays it in the text box.  Example:  for the code of 10, the next available 3 digits are 463, so the new client ID would be 10463.  I am new to C# and cannot find a simple way to do this to emulate the current routine in Visual FoxPro.
Question by:joycekinzler
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 42

Accepted Solution

pcelba earned 500 total points
ID: 39201210
You should ask moderator to add C# forum to your question.

IMHO there is no need to transfer existing Visual FoxPro application to C#. The cost of staying in VFP is almost none. VFP apps will run another 15 years whereas the technology can change significantly so you'll think what to do with this C# app soon... And what's more in 15 years? Virtual machines will be as fast as todays hardware so today's applications will run unchanged. Yes, the UI will change and user needs will move probably.

Visual FoxPro is still the best tool to develop desktop applications on Windows platform. Client-server is also the target topology for FoxPro. Of course, if you need internet or mobile application then you should think about the switch to another platform.

To port the VFP app into a cloud would also be an option - see

Author Closing Comment

ID: 39201385
This is an encouraging response.  Our current FoxPro product has taken 20 years to evolve to the great product that we have right now.  We have already taken the steps to move all our data to SQL server and to depend on FoxPro remote views and stored procedures to manage the data throughout the system.  What a bummer to have to start all over with a new UI.  I appreciate your words -- they have certainly got me thinking. Thank you!
LVL 12

Expert Comment

ID: 39201391
IMHO there is no need to transfer existing Visual FoxPro application to C#.

I will second Pavel's comment with a caveat...

There are GENERALLY no FUNCTIONAL needs to transfer existing Visual FoxPro application to C#.

Typically the incentive to change application development languages is due to Business Requirements not Functional Requirements.  
If so, then you cannot get around it - although you might try to 'educate' those creating the Business Requirements to the possible 'holes' in their reasoning.
But if others FORCE the change, then go ahead and get on board.

However it is quite often that those 'Forcing' the change are doing so because they don't really fully understand the power and capabilities of Visual Foxpro - or they are somehow prejudiced (misguidedly so) against it.

Alternatively (as Pavel has mentioned) if you need to migrate your application to the web, other issues might come into play.

Good Luck,
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39203712
Is the problem really to concatenate two parts of a number in C#? If that is already causing you headaches, then how do you cope with programming overall?

Now, I don't want to be cynical about it, but you have to explain what is really the problem. The surface of the problem you show is no problem. I would rather do this within the database, anyway. And the best thing in SQL Server would be two seperate fields companytypeID and companyNo, and have a computed field companyID with the value being  companytypeID*1000+companyNo.

And to calculate the next companyNo you do

declare @companyno int;
Select @companyno = Max(companyno)+1 from companies where companytypeID=10;

Doing that in an instead of insert trigger you intercept creation of any new record and automate creation of the companyno, then do insert into companies (....,companyno,...) values (...,@companyno,...), even simpler doing that in a stored procedure you can call it as default value expression for companyno and return @companyno.

I'm not sure if there even is a way to have a sequence per group.

And overall you're giving an example why IDs should always be surrogate keys and not be composed of meaningful ids or other fields. It's totally ok to make the companytype an attribute of the company, but that's a normal foreign key to a companytype table. And you may from time to time need to know the number of companies of a certain type, but you don't need the comanyno as a business information, do you? To list companies in the historical order of you working with them, store a datetime of the insert of the company.

So your problem simply is a wrong database design, if I'm very strict about it.

I do also use barcode numbers composed of two or three detail infos, that are then extracted from a barcode scan to reidentify data, eg a certain test sample. But that composed number then is done out of barcode restriction (EAN12 for example, not yet QR), and not used as primary key.

Bye, Olaf.

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wanted to share this with fellow Experts, who might not know. How often have you wanted to learn something, only to be set back by either restrictions imposed on "trial" or "evaluation" software?  How often have you had to rebuild a home networ…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question