Click here to Skip to main content
15,900,616 members
Home / Discussions / C#
   

C#

 
GeneralRe: RegEx Pin
Paul Unsworth6-May-10 23:57
Paul Unsworth6-May-10 23:57 
GeneralRe: RegEx Pin
OriginalGriff7-May-10 0:12
mveOriginalGriff7-May-10 0:12 
AnswerRe: RegEx Pin
OriginalGriff6-May-10 23:57
mveOriginalGriff6-May-10 23:57 
GeneralRe: RegEx Pin
Paul Unsworth7-May-10 0:00
Paul Unsworth7-May-10 0:00 
QuestionGenerate Sequencial Number Pin
Zoomlion6-May-10 22:44
Zoomlion6-May-10 22:44 
AnswerRe: Generate Sequencial Number Pin
OriginalGriff6-May-10 22:47
mveOriginalGriff6-May-10 22:47 
GeneralRe: Generate Sequencial Number Pin
Zoomlion6-May-10 23:03
Zoomlion6-May-10 23:03 
GeneralRe: Generate Sequencial Number Pin
OriginalGriff6-May-10 23:25
mveOriginalGriff6-May-10 23:25 
So, what you are doing is:

1) Read the last record (presumably for this month) from your database.
2) If it doesn't exist, use a default of 1.
3) If it does, strip out the last 6 characters, convert to int, add one to it and use that.
4) Reattach that to the code for this month.

Ignoring that you seem to have a fetish over naming your variables after months of the year, and the "str" prefix is a bit of a waste of time, since half way through you hold integers in them.

What is the bit that is giving you problems? Apart from the whole approach, which is frankly rubbish?

If you must have an item number that is a string, with a date and a sequence number, then:

1) Read the last record.
2) Assume none: set integer default to 0 in variable called nextSequenceNumber
3) If record exists, extract last 6 characters, and parse to int. Store in nextSequenceNumber.
4) Return date code + (nextSequenceNumber + 1).ToString("000000")

Assume the database will contain corrupt data - use TryParse rather than parse, and log any failures. Try to deal with them nicely.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace

C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

GeneralRe: Generate Sequencial Number Pin
Luc Pattyn7-May-10 2:15
sitebuilderLuc Pattyn7-May-10 2:15 
GeneralRe: Generate Sequencial Number Pin
OriginalGriff7-May-10 4:02
mveOriginalGriff7-May-10 4:02 
AnswerRe: Generate Sequencial Number Pin
nagendrathecoder6-May-10 23:04
nagendrathecoder6-May-10 23:04 
AnswerRe: Generate Sequencial Number Pin
Peace ON6-May-10 23:05
Peace ON6-May-10 23:05 
AnswerRe: Generate Sequencial Number Pin
Peace ON6-May-10 23:22
Peace ON6-May-10 23:22 
AnswerRe: Generate Sequencial Number Pin
#realJSOP6-May-10 23:25
professional#realJSOP6-May-10 23:25 
QuestionGenerate Error While Build Dll Pin
Anubhava Dimri6-May-10 21:29
Anubhava Dimri6-May-10 21:29 
AnswerRe: Generate Error While Build Dll Pin
Bernhard Hiller6-May-10 21:40
Bernhard Hiller6-May-10 21:40 
GeneralRe: Generate Error While Build Dll Pin
Anubhava Dimri6-May-10 21:43
Anubhava Dimri6-May-10 21:43 
GeneralRe: Generate Error While Build Dll Pin
Vimalsoft(Pty) Ltd6-May-10 21:56
professionalVimalsoft(Pty) Ltd6-May-10 21:56 
GeneralRe: Generate Error While Build Dll Pin
Anubhava Dimri6-May-10 22:16
Anubhava Dimri6-May-10 22:16 
GeneralRe: Generate Error While Build Dll Pin
Vimalsoft(Pty) Ltd6-May-10 22:31
professionalVimalsoft(Pty) Ltd6-May-10 22:31 
QuestionDataSet to List<> Pin
Illegal Operation6-May-10 17:43
Illegal Operation6-May-10 17:43 
AnswerRe: DataSet to List Pin
Luc Pattyn6-May-10 17:51
sitebuilderLuc Pattyn6-May-10 17:51 
GeneralRe: DataSet to List Pin
Illegal Operation6-May-10 17:55
Illegal Operation6-May-10 17:55 
GeneralRe: DataSet to List Pin
Luc Pattyn6-May-10 18:06
sitebuilderLuc Pattyn6-May-10 18:06 
GeneralRe: DataSet to List Pin
Illegal Operation6-May-10 18:09
Illegal Operation6-May-10 18:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.