Пример #1
0
        /// <summary>
        /// 检查用户可用的功能操作权限
        /// </summary>
        /// <param name="guidFuncId">功能ID</param>
        /// <param name="opCode">操作码</param>
        /// <returns></returns>
        public bool UserHasRightNew(Guid guidFuncId, FeatureButton opCode)
        {
            if (this.CurrentUserIsAdmin)
            {
                return(true);
            }

            List <int> Opcodes = this.GetUserOpCodeNew(guidFuncId);

            foreach (int m in Opcodes)
            {
                if (m <= 0)
                {
                    break;
                }
                int  ia   = (m & (int)opCode);
                bool flag = (m & (int)opCode) == (int)opCode;
                if (!flag && (opCode.Equals(FeatureButton.First) || opCode.Equals(FeatureButton.Last) || opCode.Equals(FeatureButton.Previous) || opCode.Equals(FeatureButton.Next)))
                {
                    int num = 2;
                    flag = ((m & num) == num);
                }
                if (flag)
                {
                    return(flag);
                }
            }
            return(false);
        }
Пример #2
0
 /// <summary>
 /// 没有操作权限
 /// </summary>
 /// <param name="guidFuncId">功能Id</param>
 public void ShowNoRight(string guidFuncId, FeatureButton opCode)
 {
     if (opCode == FeatureButton.None)
     {
         this.ShowNoRight(guidFuncId);
         return;
     }
 }
Пример #3
0
 /// <summary>
 /// 设置工具栏显式功能按钮
 /// </summary>
 /// <param name="btns">功能按钮集合</param>
 public void SetFeatureButton(params FeatureButton[] btns)
 {
     if (btns != null)
     {
         this.DisableButtons();
         for (int i = 0; i < btns.Length; i++)
         {
             FeatureButton code = btns[i];
             this.SetButtonEnableByCode(code, true);
         }
     }
 }
Пример #4
0
 private FeatureButton[] GetValidFeatureButton(FeatureButton[] btns)
 {
     System.Collections.Generic.List <FeatureButton> list = new System.Collections.Generic.List <FeatureButton>();
     if (btns != null && 0 <= btns.Length && this.Mainform != null)
     {
         for (int i = 0; i < btns.Length; i++)
         {
             FeatureButton featureButton = btns[i];
             if (featureButton == FeatureButton.Cancel || featureButton == FeatureButton.Save)
             {
                 list.Add(featureButton);
             }
             else if (featureButton == FeatureButton.Add)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Add))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Approve)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Approve))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Delete)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Delete))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Export)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Export))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Import)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Import))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Modify)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Modify))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Preview)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Preview))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Print)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Print))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Query)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Query))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.UnApprove)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.UnApprove))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.First)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Query))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Previous)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Query))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Next)
             {
                 if (this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Query))
                 {
                     list.Add(featureButton);
                 }
             }
             else if (featureButton == FeatureButton.Last && this.Mainform.UserHasRightNew(sFuncId, FeatureButton.Query))
             {
                 list.Add(featureButton);
             }
         }
     }
     return(list.ToArray());
 }
Пример #5
0
        /// <summary>
        /// 根据操作码设置工具栏按钮
        /// </summary>
        /// <param name="code">操作码</param>
        /// <param name="enabled">是否起用</param>
        public void SetButtonEnableByCode(FeatureButton code, bool enabled)
        {
            if (code <= FeatureButton.Import)
            {
                if (code <= FeatureButton.Cancel)
                {
                    switch (code)
                    {
                    case FeatureButton.Add:
                        this.barAddNew.Enabled = enabled;
                        return;

                    case FeatureButton.Query:
                        this.barQuery.Enabled = enabled;
                        return;

                    case (FeatureButton)3:
                        break;

                    case FeatureButton.Modify:
                        this.barModify.Enabled = enabled;
                        return;

                    default:
                        if (code == FeatureButton.Delete)
                        {
                            this.barDelete.Enabled = enabled;
                            return;
                        }
                        if (code != FeatureButton.Cancel)
                        {
                            return;
                        }
                        this.barCancel.Enabled = enabled;
                        return;
                    }
                }
                else if (code <= FeatureButton.Approve)
                {
                    if (code == FeatureButton.Save)
                    {
                        this.barSave.Enabled = enabled;
                        return;
                    }
                    if (code != FeatureButton.Approve)
                    {
                        return;
                    }
                    this.barApprove.Enabled = enabled;
                    return;
                }
                else
                {
                    if (code == FeatureButton.UnApprove)
                    {
                        this.barUnApprove.Enabled = enabled;
                        return;
                    }
                    if (code != FeatureButton.Import)
                    {
                        return;
                    }
                    this.barImport.Enabled = enabled;
                    return;
                }
            }
            else if (code <= FeatureButton.Print)
            {
                if (code == FeatureButton.Export)
                {
                    this.barExport.Enabled = enabled;
                    return;
                }
                if (code == FeatureButton.Preview)
                {
                    this.barPreview.Enabled = enabled;
                    return;
                }
                if (code != FeatureButton.Print)
                {
                    return;
                }
                this.barPrint.Enabled = enabled;
                return;
            }
            else if (code <= FeatureButton.Previous)
            {
                if (code == FeatureButton.First)
                {
                    this.barFirst.Enabled = enabled;
                    return;
                }
                if (code != FeatureButton.Previous)
                {
                    return;
                }
                this.barPrevious.Enabled = enabled;
                return;
            }
            else
            {
                if (code == FeatureButton.Next)
                {
                    this.barNext.Enabled = enabled;
                    return;
                }
                if (code != FeatureButton.Last)
                {
                    return;
                }
                this.barLast.Enabled = enabled;
            }
        }