Hi my name is vishal for past 6 days i have been breaking my head on how to get id(user_id or manager_id) of currently logged in user in my application in c# windows forms with sql server 2008.
So i have a application named:Mini Project which has a login form named:frmLogin.Given below is my c# code of frmLogin:

    namespace Mini_Project
    {
    public partial class frmLogin : Form
    {
    public frmLogin()
    {
    InitializeComponent();
    }
    private void frmLogin_Load(object sender, EventArgs e)
    {
    }
    private bool ManagerUser(string username, string password)
    {
    bool success = false;
    SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;
    cmd.CommandType = CommandType.Text;
    cmd = new SqlCommand("Select @count = Count(*) from [dbo].[ManagerDetail2] where username=@username and password=@password and LoginAttempts< 3", conn);
    cmd.Parameters.AddWithValue("@username", txtUsername.Text);
    cmd.Parameters.AddWithValue("@password", txtPassword.Text);
    cmd.Parameters.AddWithValue("@manager_id", Module.MUser_ID);
    cmd.Parameters.Add("@count", SqlDbType.Int).Direction = ParameterDirection.Output;
    conn.Open();
    cmd.ExecuteNonQuery();
    if (Convert.ToInt32(cmd.Parameters["@count"].Value)>0)
    {
    success = true;
    cmd = new SqlCommand("Update [dbo].[ManagerDetail2] set LoginAttempts=0 where username='" + txtUsername.Text + "'", conn);
    cmd.ExecuteNonQuery();
    }
    else
    {
    success = false;
    cmd = new SqlCommand("Update [dbo].[ManagerDetail2] set LoginAttempts=LoginAttempts+1 where username='" + txtUsername.Text + "'", conn);
    cmd.ExecuteNonQuery();
    }
    conn.Close();
    return success;
    }
    private bool ValidateUser(string username, string password)
    {
    bool success = false;
    SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;
    cmd.CommandType = CommandType.Text;
    cmd = new SqlCommand("Select @count = Count(*) from [dbo].[UserDetail2] where username=@username and password=@password and LoginAttempts< 3", conn);
    cmd.Parameters.AddWithValue("@username", txtUsername.Text);
    cmd.Parameters.AddWithValue("@password", txtPassword.Text);
    cmd.Parameters.AddWithValue("@user_id", Module.User_ID);
    cmd.Parameters.Add("@count", SqlDbType.Int).Direction = ParameterDirection.Output;
    conn.Open();
    cmd.ExecuteNonQuery();
    if (Convert.ToInt32(cmd.Parameters["@count"].Value)>0)
    {
    success = true;
    cmd = new SqlCommand("Update [dbo].[UserDetail2] set LoginAttempts=0 where username='" + txtUsername.Text + "'", conn);
    cmd.ExecuteNonQuery();
    }
    else
    {
    success = false;
    cmd = new SqlCommand("Update [dbo].[UserDetail2] set LoginAttempts=LoginAttempts+1 where username='" + txtUsername.Text + "'", conn);
    cmd.ExecuteNonQuery();
    }
    conn.Close();
    return success;
    }
    private void btnLogin_Click(object sender, EventArgs e)
    {
    if ((txtPassword.Text == "password") && (txtUsername.Text.ToLower() == "admin"))
    {
    Module.AUser_ID=1;
    MDIParent1 h = new MDIParent1();
    h.Show();
    this.Close();
    }
    else
    {
    string username = txtUsername.Text;
    string password = txtPassword.Text;
    bool validUser = ValidateUser(username, password);
    bool validmanager = ManagerUser(username, password);
    if (validUser)
    {
    Module.User_ID = 1;
    MDIParent1 m = new MDIParent1();
    m.Show();
    this.Close();
    }
    if (validmanager)
    {
    Module.MUser_ID = 1;
    MDIParent1 g = new MDIParent1();
    g.Show();
    this.Close();
    }
    else
    {
    MessageBox.Show("Invalid user name or password. Please try tomorow ", "Task", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    txtUsername.Focus();
    }
    }
    }
    private void btnCancel_Click(object sender, EventArgs e)
    {
    Application.Exit();
    }

The above code works with no problem at all!

As you can see i login in to application(Mini Project) using default username:admin and default password:password

Using default username:admin and default password:password i can add new users(Normal users) and managers into my application(Mini Project).

Given below is my c# code of how i add normal users into my application. So i have form for adding normal user named:frmUser.Given below is my c# code of frmUser:

    namespace Mini_Project
    {
    public partial class frmUser : Form
    {
    public frmUser()
    {
    InitializeComponent();
    }
    private void btnCreate_Click(object sender, EventArgs e)
    {
    SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
    if (conn.State != ConnectionState.Open)
    {
    conn.Open();
    }
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;
    cmd.CommandType = CommandType.Text;
    int autoGenId = -1;
    cmd = new SqlCommand("Insert into [dbo].[UserDetail2](user_first_name,user_last_name,user_dob,user_sex,email,username,password,status,row_upd_date,created_by,LoginAttempts)" + "Values(@user_first_name,@user_last_name,@user_dob,@user_sex,@email,@username,@password,@status,GetDate(),@created_by,@LoginAttempts); Select @autoGenId=SCOPE_IDENTITY();", conn);
    cmd.Parameters.AddWithValue("@user_first_name", txtFName.Text);
    cmd.Parameters.AddWithValue("@user_last_name", txtLName.Text);
    cmd.Parameters.AddWithValue("@user_dob", dtDOB.Value);
    if (cboSex.SelectedIndex == 0)
    {
    cmd.Parameters.AddWithValue("@user_sex", "Male");
    }
    else if (cboSex.SelectedIndex == 1)
    {
    cmd.Parameters.AddWithValue("@user_sex", "Female");
    }
    else if (cboSex.SelectedIndex == 2)
    {
    cmd.Parameters.AddWithValue("@user_sex", "Transgender");
    }
    cmd.Parameters.AddWithValue("@email", txtEmailID.Text);
    cmd.Parameters.AddWithValue("@username", txtUsername.Text);
    cmd.Parameters.AddWithValue("@password", txtPassword.Text);
    cmd.Parameters.AddWithValue("@status", 1);
    cmd.Parameters.AddWithValue("@Created_by",Module.MUser_ID);
    cmd.Parameters.AddWithValue("@LoginAttempts", 0);
    cmd.Parameters.Add("@autoGenId", SqlDbType.Int).Direction = ParameterDirection.Output;
    cmd.ExecuteNonQuery();
    autoGenId = Convert.ToInt32(cmd.Parameters["@autoGenId"].Value);
    cmd = new SqlCommand("Update [dbo].[UserDetail2] set LoginAttempts=0 where username='" + txtUsername.Text + "'", conn);
    cmd.ExecuteNonQuery();
    ((MDIParent1)this.MdiParent).updateUserActivities(autoGenId, 1, txtFName.Text + "User detail was added successfully");
    MessageBox.Show("User Detail was added successfully", "Task", MessageBoxButtons.OK, MessageBoxIcon.Information);
    conn.Close();
    this.Close();
    }

The above code works OK as i dont get any compilation or run-time errors.

Given below is my structure of my table:UserDetail2 in sql server 2008:

    ColumnName                               DataType                    AllowNulls
    user_id(auto-increment primary key)        Int                         No
    user_first_name                         nvarchar(50)                   Yes
    user_last_name                          nvarchar(50)                   Yes
    user_dob                                   date                        Yes
    user_sex                                nvarchar(20)                   Yes
    email                                   nvarchar(80)                   Yes
    username                                nvarchar(25)                   Yes
    password                                nvarchar(15)                   Yes
    status                                      bit                        Yes
    row_upd_date                              datetime                     Yes
    created_by                                  Int                        Yes
    LoginAttempts                               Int                        Yes

Given below is my c# code of how i add managers into my application. So i have form for adding managers named:frmManager.Given below is my c# code of frmManager:

    namespace Mini_Project
    {
    public partial class frmManager : Form
    {
    public frmManager()
    {
    InitializeComponent();
    }
    private void btnCreate_Click(object sender, EventArgs e)
    {
    SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
    if (conn.State != ConnectionState.Open)
    {
    conn.Open();
    }
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;
    cmd.CommandType = CommandType.Text;
    int bGenId = -1;
    cmd = new SqlCommand("Insert into [dbo].[ManagerDetail2](manager_first_name,manager_last_name,manager_dob,manager_sex,email,username,password,status,created_by,LoginAttempts,row_upd_date)" + "Values(@manager_first_name,@manager_last_name,@manager_dob,@manager_sex,@email,@username,@password,@status,@created_by,@LoginAttempts,GetDate()); Select @autoGenId=SCOPE_IDENTITY();", conn);
    cmd.Parameters.AddWithValue("@manager_first_name", txtFName.Text);
    cmd.Parameters.AddWithValue("@manager_last_name", txtLName.Text);
    cmd.Parameters.AddWithValue("@manager_dob", dtDOB.Value);
    if (cboSex.SelectedIndex == 0)
    {
    cmd.Parameters.AddWithValue("@manager_sex", "Male");
    }
    else if (cboSex.SelectedIndex == 1)
    {
    cmd.Parameters.AddWithValue("@manager_sex", "Female");
    }
    else if (cboSex.SelectedIndex == 2)
    {
    cmd.Parameters.AddWithValue("@manager_sex", "Transgender");
    }
    cmd.Parameters.AddWithValue("@email", txtEmailID.Text);
    cmd.Parameters.AddWithValue("@username", txtUsername.Text);
    cmd.Parameters.AddWithValue("@password", txtPassword.Text);
    cmd.Parameters.AddWithValue("@status", 1);
    cmd.Parameters.AddWithValue("@Created_by", 1);
    cmd.Parameters.AddWithValue("@LoginAttempts", 0);
    cmd.Parameters.Add("@autoGenId", SqlDbType.Int).Direction = ParameterDirection.Output;
    cmd.ExecuteNonQuery();
    bGenId = Convert.ToInt32(cmd.Parameters["@autoGenId"].Value);
    cmd = new SqlCommand("Update [dbo].[ManagerDetail2] set LoginAttempts=0 where username='" + txtUsername.Text + "'", conn);
    cmd.ExecuteNonQuery();
    ((MDIParent1)this.MdiParent).updateUserActivities(bGenId, 2, txtFName.Text.ToString() + "Manager detail was added successfully");
    MessageBox.Show("Manager Detail was added successfully", "Task", MessageBoxButtons.OK, MessageBoxIcon.Information);
    conn.Close();
    this.Close();
    }
    private void btnCancel_Click(object sender, EventArgs e)
    {
    this.Close();
    }

The above code works OK as i dont get any compilation or run-time errors.

Given below is my structure of my table:ManagerDetail2 in sql server 2008:

    ColumnName                                  DataType              AllowNulls
    manager_id(auto-increment primary key)         Int                   No
    manager_first_name                         nvarchar(50)              Yes
    manager_last_name                          nvarchar(50)              Yes
    manager_dob                                    date                  Yes
    manager_sex                                nvarchar(20)              Yes
    email                                      nvarchar(80)              Yes
    username                                   nvarchar(25)              Yes
    password                                   nvarchar(15)              Yes
    status                                          bit                  Yes
    created_by                                      Int                  Yes
    LoginAttempts                                   Int                  Yes
    row_upd_date                                 datetime                Yes

So i can log into application(Mini Project) using default username:admin and default password:password,or i can also log into my application(Mini Project) using username and password from my tables(either from UserDetail2 or ManagerDetail2).

What i want is how to get user_id or manager_id from currently logged in user/manager value to a global variable in my application(Mini Project) through login form(frmLogin)? Can anyone help me please! Can anyone help me/guide me to get my required result!? Can anyone tell me what modifications must i need to do in my c# code and where? Any help/guidance in solving of this problem would be greatly appreciated!

If you just want the ID of the user logging in why don't you select the ID in the logging in query rather than return the count?

Dear hericles
Thank you for replying to my post/question on such short notice!
The motive/reson behind getting user_id/manager_id of currently logged in user is:So i log into application(Mini Project) using username and password from table:ManagerDetail2 from sql server 2008 in my login form(frmLogin). I have a form named:frmTask which enables managers to assign tasks to users created by them. Given below is my c# code of frmTask:

namespace Mini_Project
{
    public partial class frmTask : Form
    {
        public frmTask()
        {
            InitializeComponent();string manager = ("Select m.manager_id as manager_id,(m.manager_first_name+' '+m.manager_last_name+'|'+right('000'+convert(varchar,m.manager_id),5)) as Name from ManagerDetail2 m where m.status=1");
            DataTable dt = new DataTable();
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            SqlCommand dcr = new SqlCommand(manager, conn);
            dt.Load(dcr.ExecuteReader());
            cboManager.DataSource = dt;
            cboManager.ValueMember = "manager_id";
            cboManager.DisplayMember = "Name";
            cboManager.SelectedValue = 0;
            this.ProjectDropDownList();
            this.StatusFillList();
            }
            private void ProjectDropDownList()
        {
            string project = ("Select p.project_id as project_id,(p.project_name+'|'+right('000'+convert(varchar,p.project_id),5)) as Name from ProjectDetail p where p.status=1");
            DataTable dt = new DataTable();
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            SqlCommand hcr = new SqlCommand(project, conn);
            dt.Load(hcr.ExecuteReader());
            cboProject.DataSource = dt;
            cboProject.ValueMember = "project_id";
            cboProject.DisplayMember = "Name";
            cboProject.SelectedValue = 0;
        }
        private void StatusFillList()
        {
            string status = ("Select Status.status_id as status_id,Status.status_name as Name from Status where Status.stat=1");
            DataTable dt = new DataTable();
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            SqlCommand hcr = new SqlCommand(status, conn);
            dt.Load(hcr.ExecuteReader());
            cboStatus.DataSource = dt;
            cboStatus.ValueMember = "status_id";
            cboStatus.DisplayMember = "Name";
            cboStatus.SelectedValue = 0;
        }
        private void frmTask_Load(object sender, EventArgs e)
        {
         string user=("Select u.user_id as user_id,(u.user_first_name+' '+u.user_last_name+'|'+right('000'+convert(varchar,u.user_id),5)) as Name from UserDetail2 u  where u.status=1 and u.created_by='"+Module.MUser_ID+"'");
            DataTable mt = new DataTable();
            SqlConnection cont = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
            if (cont.State != ConnectionState.Open)
            {
                cont.Open();
            }
            SqlCommand hcr = new SqlCommand(user, cont);
            mt.Load(hcr.ExecuteReader());
            lstUsers.DataSource = mt;
            lstUsers.ValueMember = "user_id";
            lstUsers.DisplayMember = "Name";
            lstUsers.SelectedValue = 0;
        }

So i use username and password from table(ManagerDetail2) in my login form(frmLogin) and enter into my application(Mini Project) as a manager,add new user to application.

The problem i am facing in above code is when enter into form(frmTask) i am getting all the managers(from table:ManagerDetail2) in my combobox(cboManager) and i am also getting all the users(from table:UserDetail2) in my listbox(lstUsers).

What i want is when i enter into application(Mini Project) using username and password(from ManagerDetail2) in login form(frmLogin) and when i enter into form(frmTask) then i want only manager of currently logged in user in my combobox(cboManager) and i want only list of users in my listbox(lstUsers) created by that manager. That is what i want!
Can anyone help me please! Can you guide me on how to achieve my required result? Can you tell me what modifications must i need to do in my c# code and where?! Should i need to add any new field to tables:ManagerDetail2 and UserDetail2? Reply please! I am waiting for your reply! I hope i get a reply!

OK, I think I understand now.
Seeing as you have a direct relation between a user and the manager that created them (created_by) I don't think you need to alter your tables to get what you want.
You will however want to extract from the database the current user's ID if you don't already (I didn't see it in my quick read through).
Then, when the frmTask loads, do a select on the manager's table for the manager with the ID that is in the created_by field of the current user. A join between the two tables will get everything you need in one query.
Once you have the manager's ID run a second query on the user's table to find all users with a created_by that matches that ID.
You will then have one manager in the Manager list and only the users created by that manager in the users list.
Does that make sense? Or do you want an example of the query you will need to do?

Dear hericles thank for replying to my question on such short notice.
My user_id field from table:UserDetail2 and manager_id field from table:ManagerDetail2 are both auto-increment priamry keys(data type:Int) which increase by 1 upon each entry into tables:UserDetail2(field:user_id) and ManagerDetail2(field:manager_id).
Can you show me/guide me what modifications must i need to do in my c# code and where to achieve my required output?
Given below is my c# code of frmLogin(login form):

namespace Mini_Project
{
    public partial class frmLogin : Form
    {
    public frmLogin()
        {
            InitializeComponent();
        }
        private void frmLogin_Load(object sender, EventArgs e)
        {

        }
         private void btnCancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        private bool ManagerUser(string username, string password)
        {
            bool success = false;
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            cmd = new SqlCommand("Select @count = Count(*) from [dbo].[ManagerDetail2] where username=@username and password=@password and LoginAttempts< 3", conn);
            cmd.Parameters.AddWithValue("@username", txtUsername.Text);
            cmd.Parameters.AddWithValue("@password", txtPassword.Text);
            cmd.Parameters.AddWithValue("@manager_id", Module.MUser_ID);
            cmd.Parameters.Add("@count", SqlDbType.Int).Direction = ParameterDirection.Output;
            conn.Open();
            cmd.ExecuteNonQuery();
            if (Convert.ToInt32(cmd.Parameters["@count"].Value)>0)
            {

                success = true;
                cmd = new SqlCommand("Update [dbo].[ManagerDetail2] set LoginAttempts=0 where username='" + txtUsername.Text + "'", conn);
                cmd.ExecuteNonQuery();
            }
            else
            {
                success = false;
                cmd = new SqlCommand("Update [dbo].[ManagerDetail2] set LoginAttempts=LoginAttempts+1 where username='" + txtUsername.Text + "'", conn);
                cmd.ExecuteNonQuery();
            }
            conn.Close();
            return success;
        }
        private bool ValidateUser(string username, string password)
        {
            bool success = false;
            SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Task;Integrated Security=true");
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            cmd = new SqlCommand("Select @count = Count(*) from [dbo].[UserDetail2] where username=@username and password=@password and LoginAttempts< 3", conn);
            cmd.Parameters.AddWithValue("@username", txtUsername.Text);
            cmd.Parameters.AddWithValue("@password", txtPassword.Text);
            cmd.Parameters.AddWithValue("@user_id", Module.User_ID);
            cmd.Parameters.Add("@count", SqlDbType.Int).Direction = ParameterDirection.Output;
            conn.Open();
            cmd.ExecuteNonQuery();
            if (Convert.ToInt32(cmd.Parameters["@count"].Value)>0)
            {

                success = true;
                cmd = new SqlCommand("Update [dbo].[UserDetail2] set LoginAttempts=0 where username='" + txtUsername.Text + "'", conn);
                cmd.ExecuteNonQuery();
            }
            else
            {
                success = false;
                cmd = new SqlCommand("Update [dbo].[UserDetail2] set LoginAttempts=LoginAttempts+1 where username='" + txtUsername.Text + "'", conn);
                cmd.ExecuteNonQuery();
            }
            conn.Close();
            return success;
        }
    }
    private void button1_Click(object sender, EventArgs e)
        {
            if ((txtPassword.Text == "password") && (txtUsername.Text.ToLower() == "admin"))
            {
                Module.AUser_ID=1;
                MDIParent1 h = new MDIParent1();
                h.Show();
                this.Close();
            }
            else
            {
                string username = txtUsername.Text;
                string password = txtPassword.Text;
                bool validUser = ValidateUser(username, password);
                bool validmanager = ManagerUser(username, password);
                frmManager h=new frmManager();
                    if (validUser)
                    {
                        Module.User_ID = 1; ;
                        MDIParent1 m = new MDIParent1();
                        m.Show();
                        this.Close();
                    }
                     if (validmanager)
                    {
                        Module.MUser_ID = 1;
                        MDIParent1 g = new MDIParent1();
                        g.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Invalid user name or password. Please try tomorow ", "Task", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtUsername.Focus();
                    }
                }
            }

After login of normal user/manager is success it goes to mdi parent form.
Given below is my c# code of mdi parent form named:MDIParent1.

namespace Mini_Project
{
    public partial class MDIParent1 : Form
    {
public MDIParent1()
        {
            InitializeComponent();
            if (Module.AUser_ID == 1)
            {
                addNewTaskToolStripMenuItem.Enabled = true;
                addUserToolStripMenuItem1.Enabled = true;
                addManagerToolStripMenuItem.Enabled = true;
                addTaskToolStripMenuItem.Enabled = true;
                exitToolStripMenuItem.Enabled = true;
                checkInUserToolStripMenuItem.Enabled = false;
                tasksToolStripMenuItem.Enabled = true;
                optionsToolStripMenuItem.Enabled = true;
                pendingTaksToolStripMenuItem.Enabled = true;
                completedTasksToolStripMenuItem.Enabled = true;
            }
            frmManager g = new frmManager();
            if (Module.MUser_ID==1)
            {

                addUserToolStripMenuItem1.Enabled = false;
                addManagerToolStripMenuItem.Enabled = true;
                addNewTaskToolStripMenuItem.Enabled = false;
                addTaskToolStripMenuItem.Enabled = true;
                exitToolStripMenuItem.Enabled = true;
                checkInUserToolStripMenuItem.Enabled = false;
                tasksToolStripMenuItem.Enabled = true;
                optionsToolStripMenuItem.Enabled = true;
                pendingTaksToolStripMenuItem.Enabled = true;
                completedTasksToolStripMenuItem.Enabled = true;
            }
            if (Module.User_ID == 1)
            {
                addManagerToolStripMenuItem.Enabled = false;
                addUserToolStripMenuItem1.Enabled = false;
                addNewTaskToolStripMenuItem.Enabled = false;
                addTaskToolStripMenuItem.Enabled = false;
                exitToolStripMenuItem.Enabled = true;
                checkInUserToolStripMenuItem.Enabled = true;
                tasksToolStripMenuItem.Enabled = false;
                optionsToolStripMenuItem.Enabled = false;
                pendingTaksToolStripMenuItem.Enabled = false;
                completedTasksToolStripMenuItem.Enabled = false;
            }
        }
        public SqlConnectionStringBuilder connBuilder;
        public SqlConnection conn;
        private void MDIParent1_Load(object sender, EventArgs e)
        {
            connBuilder = new SqlConnectionStringBuilder();
            connBuilder.InitialCatalog = "DRRS";
            connBuilder.DataSource = "NPD-4\\SQLEXPRESS";
            connBuilder.IntegratedSecurity = true;
            connBuilder.AsynchronousProcessing = true;
            conn = new SqlConnection(connBuilder.ToString());
            conn.Open();  
        }

Given below is c# code of my class named:Module:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mini_Project
{
    class Module
    {
        public static int AUser_ID=0;
        public static int User_ID=0;
        public static int MUser_ID=0;
    }
}

Dear hericles can you show/guide me on what modifications must i need to do in my c# code and where? Can you help me please and fast because i am at risk of losing my job.

Dear hericles
So i get it! Are you telling me i should include a combobox(which contains list of managers) from table:ManagerDetail2 in my form(frmUser) and also add a field named:manager_id of data-type:Int in my table:UserDetail2. So i create/add a normal user to my application(Mini Project) using manager from combobox(which contains list of managers from table:ManagerDetail2) in frmUser and then use manager_id(from tables:UserDetail2 and ManagerDetail2) as a filter when displaying list of users created by that manager in a listbox in frmTask when form(once frmTask loads) is this what you are trying to tell me! Reply please! I am waiting for your reply!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.