Эх сурвалжийг харах

添加自定义Checkbox的权限控制

章政 8 жил өмнө
parent
commit
6e12f04632

+ 44 - 1
UAS-MES/PublicMethod/GlobalEventsHandler.cs

@@ -1,6 +1,7 @@
 using System.Windows.Forms;
 using UAS_MES.CustomControl.ButtonUtil;
 using UAS_MES.CustomControl.ClickPicBox;
+using UAS_MES.CustomControl.CustomCheckBox;
 using UAS_MES.CustomControl.TextBoxWithIcon;
 using UAS_MES.Entity;
 
@@ -31,7 +32,7 @@ namespace UAS_MES.PublicMethod
             //通过句柄去获取具体触发事件的控件
             Control c = Control.FromHandle(m.HWnd);
             //可进行数据操作的控件需要进行权限的判断,结合WM_LBUTTONDOWN对按钮进行判断
-            if (c != null && m.Msg == WM_LBUTTONDOWN && (c is NormalButton || c is DeleteButton || c is Button || c is ClickPicBox || c is SearchTextBox))
+            if (c != null && m.Msg == WM_LBUTTONDOWN && (c is NormalButton || c is DeleteButton || c is Button || c is ClickPicBox || c is SearchTextBox||c is CustomCheckBox))
             {
                 //获取控件的类型
                 return CheckControlPower(c);
@@ -339,6 +340,48 @@ namespace UAS_MES.PublicMethod
                         }
                     }
                     break;
+                case "CustomCheckBox":
+                    if ((c as CustomCheckBox).Power != null)
+                    {
+                        LogManager.DoLog(c.FindForm().Text + "窗体" + "输入框【" + c.Text + "】");
+                        switch ((c as CustomCheckBox).Power.ToString().ToUpper())
+                        {
+                            case "IFREAD":
+                                if (SystemInf.Caller[c.FindForm().Tag.ToString()]["IFREAD"])
+                                    return false;
+                                else
+                                {
+                                    MessageBox.Show("没有读取数据的权限", "提示", messButton, messIcon);
+                                    return true;
+                                }
+                            case "IFWRITE":
+                                if (SystemInf.Caller[c.FindForm().Tag.ToString()]["IFWRITE"])
+                                    return false;
+                                else
+                                {
+                                    MessageBox.Show("没有修改数据的权限", "提示", messButton, messIcon);
+                                    return true;
+                                }
+                            case "IFDELETE":
+                                if (SystemInf.Caller[c.FindForm().Tag.ToString()]["IFDELETE"])
+                                    return false;
+                                else
+                                {
+                                    MessageBox.Show("没有删除数据的权限", "提示", messButton, messIcon);
+                                    return true;
+                                }
+                            case "IFSPECIAL":
+                                if (SystemInf.Caller[c.FindForm().Tag.ToString()]["IFSPECIAL"])
+                                    return false;
+                                else
+                                {
+                                    MessageBox.Show("此操作需要特殊权限", "提示", messButton, messIcon);
+                                    return true;
+                                }
+                            default: break;
+                        }
+                    }
+                    break;
                 default: break;
             }
             return false;