|
hi,
in my MDI application suppose i have combo on one of my child form and now i want to populate that combo with all the form name whether any form is closed or opened.how can i do this by c# code. i search Google but found nothing. please help me with code.
thanks
tbhattacharjee
|
|
|
|
|
You'd need to use reflection to search through all the classes in your application, and check to see if it was a form or not. If it's a form, you can then retrieve the IsMdiContainer property and see if it's true or not - if it's true, then this is the MDI parent.
|
|
|
|
|
Hi there
i want to install some fonts; when i detect it is deleted. my code works fine on XP. but in win7 it is deleted immediately. i think it is beacause of UAC and use fileiopermission and demand with no lock. even i use right click run as administrator. so any suggestion is appreciated. sorry for my English.
Best wishes
|
|
|
|
|
The modern way of thinking is a single app should not be allowed to perform actions that (could) have effects on other apps, so Vista/Windows7 will not allow you to add or remove fonts. If you must, the UAC will kick in.
If you need the extra font(s) inside your app only, there probably is a solution based on System.Drawing.Text.PrivateFontCollection class. You'll have to Google for details and examples. And I expect it may not work for printing, I don't really know.
|
|
|
|
|
hi Luc,
thanks for your answer. but we use PrivateFontCollection before and it has several performance issues.
Best regards
|
|
|
|
|
Hi guys,
I have a Table (TableTest ) in a Database (database1 ) in SQLExpress 2008.
I wanna to call a method in C# whenever something is inserted in the Table.
Could you please guide me?
It would be great if you post a sample code.
Thanks.
|
|
|
|
|
I normally use a SqlNotification to accomplish this. Take a look here[^].
|
|
|
|
|
I am building a WEBSERVICE that will listen for PUSH NOTIFICATION from MS Exchange. What I was hoping to do is use the Query Notifications capability too be notified of changes to to specific data in SQL Server.
1. How specific are the SqlNotificationEventArgs that are raised to the dependency?
2. Could/Would it tell me anything specific about the event that triggered the notification? Insert/Update/delete and the primary key of the item?
Thanks
|
|
|
|
|
Hi To All,
Please help me to solve my problem.
I am A Window Application developer. I am Developing a Attendance Calculation Software. I have InTime And OutTime of Employee's. Every Thing is Working fine. The Only thing That I Cannot Calculate is OT i.e. OverTime of Employee.
I am not getting The exact Result. I have shift time like 9:00 AM To 6:00 PM.
I am Unable to calculate the OT if Employees Shift Ends On Next Day. For Example :
If Shift End Time Is 6:00 PM And Employee Shift Ends At 12:00 AM Or After 12:00 AM Then It Gives Me Incorrect Answer.
I am Unable to Resolve This Problem. Please Help Me.
Thanks & Regards
Sanket Patil.
.
|
|
|
|
|
Too easy. Look at the DateTime and TimeSpan classes. Use something like
DateTime start = new DateTime(... ... ...);
DateTime finish = new DateTime(... ... ...);
TimeSpan worked = finish - start;
then pull worked apart as you need.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Hi Perter_in_2780,
Thanks for Your Reply. But Still I am getting Incorrect Result. I have only Time. When I convert the Out Time in datetime Then Both the Time that is employees out time and shift out time has default date as todays date and if the Emd Time Of Employee is 12:00 AM and Shift Out Time ois 6:00 PM Then Iam Getting the Result is 17.00 in TimeSpan.
Which I dont want. I want Result as 6:00. Iam unable to calculate time difference in case when time is from PM to AM.
Thanks & Regards
Sanket Patil
.
|
|
|
|
|
You need to include at least part of the date in start and end DateTime's. The dates can be "made up", like this:
DateTime start = new DateTime(2000, 1, 1, 18, 0, 0);
DateTime finish = new DateTime(2000, 1, 2, 9, 0, 0);
TimeSpan worked = finish - start;
... That should come out at 15 hours.
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Check this[^] out.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi Abhinav s,
Thanks for your reply But I am Not Getting The Solution if its night shift.
Thanks And Regards
Sanket Patil
.
|
|
|
|
|
For the night shift split the calc in 2 start to 24:00, 00:00 to finish. Decide which calc to use based on the start time or if the end time is less than the start time. Os as others have suggested add the date to the start/end variables.
Bloody hell this is simple stuff, try thinking.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This is exactly why you store start and end date and not just time.
If you stored:
start date = 2010-09-12 20:00:00
end date = 2010-09-13 07:00:00
then you would have no problem.
Go back and fix your model/database before you continue with incorrect data storage.
|
|
|
|
|
Hi,
there are only two cases that could work well:
1.
you have date AND time information, not just time. Then a TimeSpan calculated as the difference of two DateTime values is perfect.
2.
you only have time information, but you also know the context enforces something. In your case it would be: the time worked is anywhere between 0 and 24 hours. So, calculate the difference in any way you see fit (even with TimeSpan=DateTime-DateTime where both DateTimes have the same or no date), then enforce your boundary conditions: if the TimeSpan is less than zero, add 24 hours.
|
|
|
|
|
Hello coders,
I am new so please go easy
OK, my application has a licensed state that is either 1)Valid 2)Trial 3)Invalid or 4)Expired
I will have an object (class) called license to handel this, along with the main form of my app.
Now I have a few questions.
1)How should I represent the available options?
Should I use enum licinse_state { trial, full etc
or simply set the property in the relevent function to a string
e.g
if(license is a full one)
string license_state = "FULL"
return license_state
2)What functions should go in the license class, what in the main form?
3) If I have a form to get the serial number, should this be called from my main form, then the serial number passed into my license class, or should I invoke the license class from my main form and then call the serial dialog from the license class?
Bit confused about what to put where, and what to call from what!
Thank you!
|
|
|
|
|
Hi
1.
yes, a limited number of possible values is exactly what enum is aiming at.
BTW: don't use strings for anything but text; if you are performing logic operations, use bools (not "true" and "false" strings); if you are counting, use integers (not "one", "two", "three" strings).
2.
it is good practice to separate actual things from user interaction things; the former are "business objects", the latter constitutes your GUI ("Graphical User Interface"). The properties, the logical expiration, the encryption, etc. that are associated with a license, all fit in a License class. Whatever you decide (now or later) to either look at a license, or to enter/edit license information, is completely separate from the license itself. You may end up having several products, all dealing with licenses based on one and the same License, but having different means to view and edit a License.
So design a License class, and a LicenseEntryForm class. The latter will use an instance of the former to store and operate on the license data.
3.
No, your License class should not hold any GUI stuff (see #2), it does not know the first thing about the user. For all it knows, the user may speak French or Vietnamese.
It is a bit confusing at first, you will get used to it.
You may have to read up on properties (don't make data members public!), possibly also on events and delegates.
|
|
|
|
|
stephen.darling wrote: 1)How should I represent the available options?
IMO, enums are an indicator that there is an underlying problem with you class structure (others will disagree with me on this point [edit - see Luc Pattyn's response above]).
For example:
- Expired - can it be determined from an expiry date? If so set an expiry date property and have a read-only
IsExpired property - Trial - create a boolean
IsTrial property - Invalid - Why would you issue an invalid license? If you really do need this, you could have an
IsValid property instead, preferably this would be read-only and determined from the object state (e.g. is expired and is trial, or some other combination of "rules".
Doing this would allow you to have an expired trial license and expired normal license. Another way to factor out the enum is to create a subclass per state, but I don't think this suits your problem well.
stephen.darling wrote: 2)What functions should go in the license class, what in the main form
Anything relating to the function of the license should go in the License class, e.g. if the license can be extended (i.e. it's expiry date moved later), this should handled in the License class. The form should only deal with showing the information to the user and calling the License class's methods. In the example I gave, you might have a button to extend the license by a year. In this case, the button event handler is in the form, but it would call the code on the License class to do the actual update (remember that anything long-lived, such as database or service calls should be done on another thread). The separates the concerns of what the application does out from how it interacts with the user. To start with this will seem like a pain, but as the application grows your life will be made easier.
stephen.darling wrote: If I have a form to get the serial number, should this be called from my main form, then the serial number passed into my license class, or should I invoke the license class from my main form and then call the serial dialog from the license class?
Ideally, the License class should get the serial number, called by the form. You need to clarify what the form to get the serial number actually adds before I can help with this more fully.[Edit] Although I might look like I contradict Luc on this matter, I agree that the GUI should not do license stuff, and the license model should not do GUI stuff! I think it is probably the responsibility of the License class to get its serial, but this is dependant upon the work the UI needs to do to get the serial number.
Like Luc said, it is confusing, but with experience you'll get the hang of it, at least you spotted this problem beforehand, unlike far too many others ...
ragnaroknrol The Internet is For Porn[^]
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
To follow on from them...
Full and Trial could be determined from the absence or presence of an expiration date (or an expiration date of MaxValue) (perhaps use MinValue to indicate invalid ::shrug:: ).
And, as they said, how you represent it inside the license class will differ from how it's presented to the user.
|
|
|
|
|
Thank you very much for all the excellent advice!
Could I just clarify the following.
I have my main form, the main app that runs first.
2) When the form loads, It needs to check for the license
3) If the user simply leavs the serial number field blank, it runs in a trial mode.
So, I have the following
1)Main form
2)License dialog form
3)License class
So, do I...
Run showdialog() in the mainform()
then load the serial from that using dialog.result() == OK (etc)
then create a license using:
license lic = new license();
then check it...
lic.checklicnese(string from above dialog)
Have I got this right?
Thank you again
Steve
|
|
|
|
|
Maybe have it start out in trial mode and have a menu option to allow the user to register a licence. Clicking the menu item would cause the ShowDialog. If the dialog is canceled, you would continue in trial mode.
0) If the expiration is MaxValue: full functionality.
1) If the expiration is in the future: trial functionality.
2) Otherwise: no functionality (other than register and exit).
|
|
|
|
|
Hi, I'm looking for the most logical way of taking screenshots of multiple clients(say 20-30 PCs) from a server simultaneously. What I plan to do is below, your valuable comments are very welcomed
1- server sends request to clients simultaneously
2- Clients take the screenshots, serialize and sends to server
3- server shows them all on a form with reduced size (if better,clients can take reduced screenshots in the beginning)
Thanks!
|
|
|
|
|
And your problem is?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|