Exemplo n.º 1
0
        private void BaseForm_Load(object sender, EventArgs e)
        {
            foreach (Control obj in this.Controls)
            {
                if (obj is CommandButton)
                {
                    CommandButton cmd = (CommandButton)obj;
                    switch (cmd.CommandType)
                    {
                    case CommandButton.enCommandType.Add:
                        cmdAdd = cmd;
                        break;

                    case CommandButton.enCommandType.Edit:
                        cmdEdit = cmd;
                        break;

                    case CommandButton.enCommandType.Delete:
                        cmdDelete = cmd;
                        break;

                    case CommandButton.enCommandType.Save:
                        cmdSave = cmd;
                        break;

                    case CommandButton.enCommandType.Print:
                        cmdPrint = cmd;
                        break;
                    }

                    CheckAuthorization(obj);
                }
            }
        }
Exemplo n.º 2
0
        protected void CheckAuthorization(Control ctrl)
        {
            CommandButton item = (CommandButton)ctrl;

            //else if (SecurityManager.IsAOperator())
            //{
            //    /// operator (add, edit, print)
            //    if (item.CommandType == CommandButton.enCommandType.Save || item.CommandType == CommandButton.enCommandType.Add || item.CommandType == CommandButton.enCommandType.Edit || item.CommandType == CommandButton.enCommandType.Print)
            //        item.Enabled = true;
            //    else
            //        item.Enabled = false;
            //}
            //else if (SecurityManager.IsAdministrator())
            //{
            //    if (item.CommandType == CommandButton.enCommandType.Add)
            //        item.Enabled = false;
            //    else
            //        item.Enabled = true;
            //}
            //else if (SecurityManager.IsManager())
            //{
            //    item.Enabled = true;
            //}

            if (item.CommandType == CommandButton.enCommandType.SearchL || item.CommandType == CommandButton.enCommandType.SearchS || item.CommandType == CommandButton.enCommandType.Close || item.CommandType == CommandButton.enCommandType.No || item.CommandType == CommandButton.enCommandType.Yes)
            {
                item.Enabled = true;
            }
        }