|
Thanks Luc,
This was the first thing that I thought as well, but I am not supposed to make changes to db model at this later stage in project.
|
|
|
|
|
then the only way left is to scan the existing coded names, find the most recent one, and "increment" it.
I once did an IncrementString() method, which basically scans a string right-to-left for digits; replaces '0' by '1', or '1' by '2', or...; up to '9' by '0' which sets a carry, meaning you have to repeat the process for the next (R-to-L) digit. This way, there is no need to explicitly extract the number. It does rely on having some other means of finding the most recent coded name though.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
i was trying to do something like this as well..
stuck with how to pass a string as seperator in split function..!! frustrating syntax error
|
|
|
|
|
FEMDEV wrote: stuck with how to pass a string as seperator in split function.
It may not be necessary to do this.
According to the MSDN documentation for Int32.TryParse()[^]
When this method returns, contains the 32-bit signed integer value equivalent to the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null, is not of the correct format, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized.
.
I didn't think that it worked like that, however, it says that it does.
From the int returned you will know how many characters to use in a String.Replace() call to insert the new value.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Sorry Henry, it does not work as the text seems to suggest. The string has to contain a number, nothing but a number, that is.
int.Parse("123abc") does throw a FormatException, int.TryParse("123abc", out i) does return false. ditto for "abc123".
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I thought that was how it worked. Couldn't test it as the machine I'm using at the moment doesn't have VS on it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
VS is the first thing I install on any PC I touch!
And do you really need VS to test a single method? Notepad.exe + csc.exe are a mighty pair.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Shhhh! It's not my PC.
Luc Pattyn wrote: Notepad.exe + csc.exe are a mighty pair
If both were on this thing (and if I'd thought of it, which is doubtful) I might have.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Notepad should be there, unless it got removed.
csc.exe is part of .NET, of which some versions are always present on Vista/Win7 AFAIK.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Use a regex: "(?<name>[a-zA-Z]+)(?<number>\d*)" splits it into the Name and any number.
private Regex splitNameAndNumber = new Regex(
"(?<Name>[a-zA-Z]+)(?<Number>\\d*)",
RegexOptions.ExplicitCapture
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
or use a new separator such as '#', or a fixed number of digits, or just locate the first digit using IndexOfAny(), or...
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
You can tell .NET is a Microsoft product - a dozen different ways to do the same thing (none of them that obvious when you are getting started!)
It took me ages to work out how to format a floppy in Win95, then I found about six in as many minutes...
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
Lyuc is right in saying that's pretty much you're last option. But, what he didn't say is that this method will also get slower and slower as you add more and more ID's to scan. The solution works, but it isn't scalable. You may want to take this information back and say that "it can be done, but..."
|
|
|
|
|
I am trying to find a way to gather image data from many windows and doing mouse movements and clicks on each window to advance the windows without the need to focus on each window. Problem with my current code is that unless all the windows are viewable, it only takes an image of the top window and only sends mouse commands to the top window. Being able to do either image capturing or mouse commands on windows out of focus would be a huge help.
I could provide the code snipet of what I currently use, but I doubt it is even possible to convert what I have to something with this functionality.
Thanks for any help.
|
|
|
|
|
You can make use of the SendMessage method to send messages to the inactive window. Here[^] is thread with the similar code. Might help.
|
|
|
|
|
Hello,
I'm developing database applications in C#. Normally for small group of people. So far so good.
I like to implement security. Login plus that the application is responding on the user (group) that logged in.
What is the most practical approach to implement security?
Arjen Groeneveld
|
|
|
|
|
You can make use of role based security in your application. Have a predefined set of roles. Assign them the rights as needed. Then assign each user to a particular role.
This[^] might help.
|
|
|
|
|
Hi Danish
Can you give me some more detail about role based security.
For example, how to define the roles and how to link for example the buttons to these roles?
What I see as most difficult is how to intermix the enabling and disabling of buttons and menu options depending on the security roles in combination with the "normal" button enabling and disabling business logic.
Gr Arjen
|
|
|
|
|
When you are authenticating the user, at that point of time you should check the role the user belongs to. Once you get the role, enable/disable the controls. As far as enabling disable of the controls based on the business rules goes, that would happen on some user action after he logs in. So that would not interfere.
Here[^] is another article that might be useful.
|
|
|
|
|
This might get you started:
User Login For WinForm Applications[^]
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I want know how to keep records of copied files to an external disk,such as USB? does anyone know how to achieve this in coding? Which kind of API s can we used to do this?
|
|
|
|
|
you could use log4net and log either to a file or a database everytime you do a copy ...
is that the sort of thing you mean ?
'g'
|
|
|
|
|
petta1000 wrote: I want know how to keep records of copied files to an external disk,such as USB?
There's no filter or event that fires for all copy-actions.
Do you want to log copy-actions initiated by your own application? If so, you'd need to write a message yourself.
Do you want to keep an eye on a folder on that external drive? A FileSystemWatcher perhaps?
Can you explain in more detail what it is that you're trying to achieve?
I are Troll
|
|
|
|
|
I want to keep and eye on all the files that are copying to a USB media. Whenever file copy operation perform, I want to check whether those are copying a USB device or not. If they are copying to a USB device, details of those file transfers should be logged.
|
|
|
|
|
petta1000 wrote: I want to keep and eye on all the files that are copying to a USB media.
Might be doable using a CopyHook[^].
I are Troll
|
|
|
|