protected void loadUserList()
        {
            Dictionary <String, userDetails> allUserDetails = BackEndObjects.MainBusinessEntity.getUserDetailsforMainEntitybyIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());


            foreach (KeyValuePair <String, userDetails> kvp in allUserDetails)
            {
                BackEndObjects.userDetails userDetObj = kvp.Value;

                ListItem lt1 = new ListItem();
                lt1.Text  = userDetObj.getUserId();
                lt1.Value = userDetObj.getUserId();

                DropDownList_Users.Items.Add(lt1);
                //DropDownList_Users_Add_Members.Items.Add(lt1);
            }

            ListItem emptyItem = new ListItem();

            emptyItem.Text  = "";
            emptyItem.Value = "";

            DropDownList_Users.Items.Add(emptyItem);
            DropDownList_Users.SelectedValue = "";

            //DropDownList_Users_Add_Members.Items.Add(emptyItem);
            //DropDownList_Users_Add_Members.SelectedValue = "";
        }
        protected void GridView_Dept_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
            {
                GridViewRow gVR = e.Row;

                //BackEndObjects.MainBusinessEntity.getUserDetailsforMainEntitybyIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                Dictionary <String, userDetails> allUserDetails = (Dictionary <String, userDetails>)Cache[Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()];
                if (allUserDetails == null)
                {
                    allUserDetails = BackEndObjects.MainBusinessEntity.getUserDetailsforMainEntitybyIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                    Cache.Insert(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString(), allUserDetails);
                }

                DropDownList DropDown_Users_List = (DropDownList)gVR.Cells[0].FindControl("DropDownList_Dept_Head_Edit");


                foreach (KeyValuePair <String, userDetails> kvp in allUserDetails)
                {
                    BackEndObjects.userDetails userDetObj = kvp.Value;

                    ListItem lt = new ListItem();
                    lt.Text  = userDetObj.getUserId();
                    lt.Value = userDetObj.getUserId();

                    DropDown_Users_List.Items.Add(lt);
                }

                if (!((Label)gVR.Cells[0].FindControl("Label_Head_Edit")).Text.Equals(""))
                {
                    DropDown_Users_List.SelectedValue = ((Label)gVR.Cells[0].FindControl("Label_Head_Edit")).Text;
                }
            }
        }
        protected void fillBasicUserDetailGrid(String userFilterText)
        {
            Dictionary <String, userDetails> userDetDict = BackEndObjects.MainBusinessEntity.
                                                           getUserDetailsforMainEntitybyIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

            DataTable dt = new DataTable();

            dt.Columns.Add("UserName");
            dt.Columns.Add("UserId");
            dt.Columns.Add("Password");
            dt.Columns.Add("EmailId");
            dt.Columns.Add("ContactNo");
            dt.Columns.Add("AccessDet");
            dt.Columns.Add("reportsTo");

            int counter = 0;

            foreach (KeyValuePair <String, userDetails> kvp in userDetDict)
            {
                BackEndObjects.userDetails userObj = kvp.Value;

                bool considerRecord = (userFilterText != null && !userFilterText.Equals(""))? (userObj.getUserId().IndexOf(userFilterText.Trim(), StringComparison.InvariantCultureIgnoreCase) >= 0?true:false):true;

                if (considerRecord)
                {
                    dt.Rows.Add();

                    dt.Rows[counter]["UserName"]  = userObj.getName();
                    dt.Rows[counter]["UserId"]    = userObj.getUserId();
                    dt.Rows[counter]["Password"]  = "";
                    dt.Rows[counter]["EmailId"]   = userObj.getEmailId();
                    dt.Rows[counter]["ContactNo"] = userObj.getContactNo();
                    dt.Rows[counter]["AccessDet"] = userObj.getPrivilege();
                    dt.Rows[counter]["reportsTo"] = userObj.getReportsTo();
                    counter++;
                }
            }

            GridView_User_List.DataSource = dt;
            GridView_User_List.DataBind();
            GridView_User_List.SelectedIndex = -1;
            Session[SessionFactory.ADMIN_PREF_USER_MGMT_BASIC_USER_DET_GRID] = dt;
        }
        protected void Button_Add_To_Dept_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> existingIdListForThisDept = (Dictionary <String, String>)Cache["DeptMembersList"];

            existingIdListForThisDept = (existingIdListForThisDept == null ? new Dictionary <String, String>() : existingIdListForThisDept);

            BackEndObjects.userDetails userObj = userDetails.getUserDetailsbyIdDB(DropDownList_Users_Add_Members.SelectedValue, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            if (userObj.getDeptId() != null && !userObj.getDeptId().Equals(""))
            {
                String deptName = BackEndObjects.DeptDetails.
                                  getDeptDetailsForEntIdAndDeptIdDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString(), userObj.getDeptId()).getDeptName();

                Label_Add_To_Dept_Status.Visible   = true;
                Label_Add_To_Dept_Status.Text      = "The user already part of " + deptName;
                Label_Add_To_Dept_Status.ForeColor = System.Drawing.Color.Red;
            }
            else if (existingIdListForThisDept.ContainsKey(DropDownList_Users_Add_Members.SelectedValue))
            {
                Label_Add_To_Dept_Status.Visible   = true;
                Label_Add_To_Dept_Status.Text      = "User already in the list below";
                Label_Add_To_Dept_Status.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                Dictionary <String, String> whereCls   = new Dictionary <string, string>();
                Dictionary <String, String> targetVals = new Dictionary <string, string>();
                whereCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_BUSINESS_ID, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                whereCls.Add(BackEndObjects.userDetails.USER_DETAILS_COL_USERID, userObj.getUserId());

                targetVals.Add(BackEndObjects.userDetails.USER_DETAILS_COL_DEPT_ID, hdnValueDeptId.Value);

                BackEndObjects.userDetails.updateUserDetailsDB(targetVals, whereCls, DBConn.Connections.OPERATION_UPDATE);
                loadMembersGrid(null);
                Label_Add_To_Dept_Status.Visible = false;
            }
        }