public MWDataManager.clsDataAccess theSectionsAndName(string ProdMonth, string ForWhom, int WhichLevel)
        {
            int    TheLevel   = 1;
            string TheSection = "";

            MWDataManager.clsDataAccess _theResults = new MWDataManager.clsDataAccess();
            _theResults.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _theResults.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _theResults.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;

            MWDataManager.clsDataAccess _theLevel = new MWDataManager.clsDataAccess();
            _theLevel.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _theLevel.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _theLevel.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _theLevel.SqlStatement       = "select distinct * from section where Prodmonth = " + ProdMonth +
                                           " and sectionid = '" + ForWhom + "'";
            //_theLevel.SqlStatement = "select * from section where Prodmonth = " + ProdMonth +
            //                        " and HierarchicalID = '" + WhichLevel + "'";
            _theLevel.ExecuteInstruction();

            foreach (DataRow s in _theLevel.ResultsDataTable.Rows)
            {
                TheLevel = Convert.ToInt32(s["HierarchicalID"].ToString());
            }

            switch (TheLevel)
            {
            case 1: TheSection = "SectionID_5"; break;

            case 2: TheSection = "SectionID_4"; break;

            case 3: TheSection = "SectionID_3"; break;

            case 4: TheSection = "SectionID_2"; break;

            case 5: TheSection = "SectionID_1"; break;

            case 6: TheSection = "SectionID"; break;
            }

            if (WhichLevel == TMinewasteGlobal.getSystemSettingsProductionInfo(UserCurrentInfo.Connection).MOHierarchicalID - 3)
            {
                _theResults.SqlStatement = "select distinct SectionID_5 As SectionID, NAME_5 As Name from Section_Complete b " +
                                           "Where b.Prodmonth = " + ProdMonth +
                                           " and b." + TheSection + "  = '" + ForWhom + "' order by NAME_5, SectionID_5";
            }

            if (WhichLevel == TMinewasteGlobal.getSystemSettingsProductionInfo(UserCurrentInfo.Connection).MOHierarchicalID - 2)
            {
                _theResults.SqlStatement = "select distinct SectionID_4 As SectionID, NAME_4 As Name from Section_Complete b " +
                                           "Where b.Prodmonth = " + ProdMonth +
                                           " and b." + TheSection + "  = '" + ForWhom + "' order by NAME_4, SectionID_4";
            }

            if (WhichLevel == TMinewasteGlobal.getSystemSettingsProductionInfo(UserCurrentInfo.Connection).MOHierarchicalID - 1)
            {
                _theResults.SqlStatement = "select distinct SectionID_3 As SectionID, NAME_3 As Name from Section_Complete b " +
                                           "Where b.Prodmonth = " + ProdMonth +
                                           " and b." + TheSection + "  = '" + ForWhom + "' order by NAME_3, SectionID_3";
            }

            if (WhichLevel == TMinewasteGlobal.getSystemSettingsProductionInfo(UserCurrentInfo.Connection).MOHierarchicalID)
            {
                _theResults.SqlStatement = "select distinct SectionID_2 As SectionID, NAME_2 As Name from Section_Complete b " +
                                           "Where b.Prodmonth = " + ProdMonth +
                                           " and b." + TheSection + "  = '" + ForWhom + "' order by NAME_2, SectionID_2";
            }

            if (WhichLevel == TMinewasteGlobal.getSystemSettingsProductionInfo(UserCurrentInfo.Connection).MOHierarchicalID + 1)
            {
                _theResults.SqlStatement = "select distinct SectionID_1 As SectionID, NAME_1 As Name from Section_Complete b " +
                                           "Where b.Prodmonth = " + ProdMonth +
                                           " and b." + TheSection + "  = '" + ForWhom + "' order by NAME_1, SectionID_1";
            }
            if (WhichLevel == TMinewasteGlobal.getSystemSettingsProductionInfo(UserCurrentInfo.Connection).MOHierarchicalID + 2)
            {
                _theResults.SqlStatement = "select distinct SectionID As SectionID, NAME As Name from Section_Complete b " +
                                           "Where b.Prodmonth = " + ProdMonth +
                                           " and b." + TheSection + "  = '" + ForWhom + "' order by NAME, SectionID";
            }

            //_theResults.ExecuteInstruction();
            return(_theResults);
        }
        public void SetUserInfo(string UserID, string systemDBTag, string connection)
        {
            try
            {
                string theSectionId = "";
                MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                _dbMan.ConnectionString = TConnections.GetConnectionString(systemDBTag, connection);;
                if (_dbMan.ConnectionString != "")
                {
                    _dbMan.SqlStatement       = String.Format("Select * from tbl_Users where UserID = '{0}'", UserID);
                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;

                    // m_SystemAdminProfile = "System Admin";
                    m_SystemAdminProfile = "1";

                    clsDataResult dataresult = _dbMan.ExecuteInstruction();
                    if (!dataresult.success)
                    {
                        MessageBox.Show(dataresult.Message);
                    }
                    foreach (DataRow dr in _dbMan.ResultsDataTable.Rows)
                    {
                        m_UserID = dr["UserID"].ToString();
                        int    SECTION = 63430;
                        string Sect    = Convert.ToString(SECTION);
                        m_SectionID = Sect; //dr["SectionID"].ToString();
                                            //m_PlanBookSectionID = dr["PlanBookSectionID"].ToString();

                        if (dr["ForecastBook"].ToString() == "Y")
                        {
                            m_ForecastBook = true;
                        }
                        else
                        {
                            m_ForecastBook = false;
                        }

                        if (dr["BackdatedRevisedPlanning"].ToString() == "")
                        {
                            m_BackdatedRevisedPlanning = false;
                        }
                        else
                        {
                            m_BackdatedRevisedPlanning = Convert.ToBoolean(dr["BackdatedRevisedPlanning"]);
                        }

                        m_WPProduction    = dr["WPProduction"].ToString();
                        m_WPSurface       = dr["WPSurface"].ToString();
                        m_WPUnderGround   = dr["WPUnderGround"].ToString();
                        m_WPEditName      = dr["WPEditName"].ToString();
                        m_WPEditAttribute = dr["WPEditAttribute"].ToString();
                        m_WPClassify      = dr["WPClassify"].ToString();

                        m_BookingType = dr["BookingType"].ToString();
                        //m_BackDateBooking = Convert.ToInt32(dr["BackdateBooking"].ToString());
                        m_DaysBackdate = Convert.ToInt32(dr["DaysBackdate"].ToString());
                        //m_ForceBooking = Convert.ToBoolean(dr["ForceBooking"].ToString());
                    }

                    theSectionId = m_SectionID;

                    _dbMan.SqlStatement = "Select HierarchicalID from Section where ProdMonth = " + TMinewasteGlobal.getSystemSettingsProductionInfo(SiteTag).CurrentProductionMonth +
                                          " AND SectionID = '" + theSectionId + "'";
                    _dbMan.ExecuteInstruction();

                    foreach (DataRow dr in _dbMan.ResultsDataTable.Rows)
                    {
                        m_HierarchicalID = Convert.ToInt32(dr["HierarchicalID"].ToString());
                    }

                    // add planning sections
                    _dbMan.SqlStatement = String.Format("SELECT [SectionID] FROM [USERS_SECTION] WHERE UserID = '{0}' and LinkType = 'P'", UserID);
                    _dbMan.ExecuteInstruction();

                    foreach (DataRow dr in _dbMan.ResultsDataTable.Rows)
                    {
                        m_PlanBookSections.Add(dr["SectionID"].ToString());
                    }

                    // add report sections
                    _dbMan.SqlStatement = String.Format("SELECT [SectionID] FROM [USERS_SECTION] WHERE UserID = '{0}' and LinkType = 'R'", UserID);
                    _dbMan.ExecuteInstruction();

                    foreach (DataRow dr in _dbMan.ResultsDataTable.Rows)
                    {
                        m_ReportSections.Add(dr["SectionID"].ToString());
                    }
                }
            }
            catch { }
        }