Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All
Hi! I have developed a Windows Based Application by using C# and SQL Server 2005. In my application I created many child form to insert and modify data. Amongst those forms I created a form "Company Details" to insert data like "Company's Name, Company Owner, Address , Email Id" etc. to the database. When the user will install and run this application for first time, 'Company Details' form should be loaded first, after inserting required data the 'Company Details' form should be deleted until reinstallation. I am unable to do this. Please someone help.
Posted
Comments
The_Inventor 16-Apr-13 5:15am    
Sounds like user registration to me. If you are using the same form for data entry into a database, as well, then perhaps a enum {usertype, userlevel, ...} check might be in order as well, but always clear any form first. You can chose to store the data within the main program database. Each company that you deal with, you create a new database, and do company entry with that same form.

So add a configuration file entry: "FirstRun" and defaulkt it to true.
Check it when your application starts, and if true, deal with your initial setup stuff. Then set it to false.

It's easy to do:
Open your project Properties in the Solution Explorer, and double click on "Settings.settings"

Create a new setting with the following properties:
Name  FirstRun
Type  bool
Scope User
Value

This will persist the value to the application settings file.

Add the following to your main Form constructor or Shown Event handler:
C#
if (Properties.Settings.Default.FirstRun)
    {
    // do your config
    Properties.Settings.Default.FirstRun = false;
    Properties.Settings.Default.Save();
    }
 
Share this answer
 
Comments
Espen Harlinn 13-Apr-13 6:43am    
That's one way to do it ;)
Maciej Los 13-Apr-13 7:12am    
+5
If the tables caontaining the 'Company Details' are empty execute the 'initialization procedure' - if not, you have a 'normal' start of your application.

Regards
Espen Harlinn
 
Share this answer
 
Comments
Maciej Los 13-Apr-13 7:13am    
+5
Espen Harlinn 13-Apr-13 7:13am    
Thank you, Maciej :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900