Advertisement

11.26.2008 at 10:15AM PST, ID: 23938178 | Points: 500
[x]
Attachment Details

C# Basics Classes

Asked by ziwez0 in .NET, C / C++ / C# Editors and IDEs

Hi, i have a win form and there is certain settings ie username that i user all the time.
1. I first of all check the logged on user is registreted and i get there ID out of the db - Done
2. but how can i easily refer to the id in other forms, classes - Need Help
3.because all i then want to do is on other forms is call string username = UserSettings.UserName, i dont want to send the parameter again, Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
//1. 
class UserSettings
    {
        private static int xUserID;
        private static DateTime xdtLoginTime;
        private static string xUserName;
 
        public UserSettings(String UserName)
// As you can see i need a parmeter
        {
 
            try
            { SQL CODE HERE
               xUserID = SQL Result
               }
catch{}
 public string UserName
        {
            get { return xUserName; }
            set { xUserName = value; }
        }
 
//2.  now on my form I send the parameter
 
 public partial class frmSplash : Form
    {
        private string strUserLogin = Environment.UserDomainName;
        UserSettings SetSettings;
        public frmSplash()
        {
            InitializeComponent();
        }
 
        private void frmSplash_Load(object sender, EventArgs e)
        {
            try
            {
                lblMessage.Text = Environment.UserDomainName;
                SetSettings = new UserSettings(strUserLogin);             
            }
            catch
            {
            }
 
        }
        }
 
   
    }
[+][-]11.26.2008 at 10:56AM PST, ID: 23044605

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.26.2008 at 11:01AM PST, ID: 23044646

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.26.2008 at 11:05AM PST, ID: 23044682

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2008 at 12:10AM PST, ID: 23048275

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2008 at 12:47AM PST, ID: 23048478

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080924-EE-VQP-38 - Hierarchy / EE_QW_3_20080625