示例#1
0
        private void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            var rb = (RadioButton)sender;

            if (pnlInfo.Controls.Count > 0)
            {
                pnlInfo.Controls.Remove(_userContrl);
            }

            // ReSharper disable once RedundantCheckBeforeAssignment
            if (_userContrl != null)
            {
                _userContrl = null;
            }

            var name = rb.Name;

            switch (name)
            {
            case "rbUserInfo":
                _userContrl = new UcUserInfoCtrl()
                {
                    Dock = DockStyle.Fill
                };



                _users = _usersBll.GetUsers();
                if (_users.Count > 0)
                {
                    BindUserList(_users);
                }

                break;

            case "rbRoleInfo":
                break;

            case "rbPermissionInfo":
                break;
            }

            if (_userContrl == null)
            {
                return;
            }

            pnlInfo.Controls.Add(_userContrl);

            _userContrl.ReadConfig();
        }
        /// <summary>
        /// 绑定用户控件至界面
        /// </summary>
        /// <param name="name">点击的节点名称</param>
        private void BindUserControl(string name)
        {
            switch (name)
            {
            case "System":
            case "General":
                if (m_UserControl != null && m_UserControl.GetType() == typeof(UcGeneralCtrl))
                {
                    return;
                }

                if (pnlControl.Controls.Count > 0)
                {
                    pnlControl.Controls.Remove(m_UserControl);
                }

                m_UserControl = new UcGeneralCtrl
                {
                    Dock = DockStyle.Fill
                };
                break;

            case "DataBase":
                if (pnlControl.Controls.Count > 0)
                {
                    pnlControl.Controls.Remove(m_UserControl);
                }

                m_UserControl = new UcDataBaseCtrl
                {
                    Dock = DockStyle.Fill
                };
                break;

            case "Users":
                if (pnlControl.Controls.Count > 0)
                {
                    pnlControl.Controls.Remove(m_UserControl);
                }

                m_UserControl = new UcUserPermissionCtrl
                {
                    Dock = DockStyle.Fill
                };
                break;

            case "Save":
            case "ShareDirectory":
                if (pnlControl.Controls.Count > 0)
                {
                    pnlControl.Controls.Remove(m_UserControl);
                }

                m_UserControl = null;
                break;

            case "FTP":
                if (pnlControl.Controls.Count > 0)
                {
                    pnlControl.Controls.Remove(m_UserControl);
                }

                m_UserControl = null;
                break;

            case "Pictures":
            case "PictureInfo":
                if (pnlControl.Controls.Count > 0)
                {
                    pnlControl.Controls.Remove(m_UserControl);
                }

                m_UserControl = null;
                break;

            case "Hardware":
            case "Imaging":
                if (pnlControl.Controls.Count > 0)
                {
                    pnlControl.Controls.Remove(m_UserControl);
                }

                m_UserControl = null;
                break;
            }

            if (m_UserControl != null)
            {
                pnlControl.Controls.Add(m_UserControl);

                m_UserControl.ReadConfig();
            }
        }