Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Non-typical way of creating a client ID

Posted on 2013-05-28
Medium Priority
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 43

Accepted Solution

pcelba earned 2000 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 30

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] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

670 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