Пример #1
0
        public virtual bool OnMenuItemCheckCommand(MenuItemCheckEventArgs e)
        {
            bool flag = true;
            MenuItemCheckEventHandler handler = (MenuItemCheckEventHandler)base.Events[MenuItemCheckEvent];

            if (handler != null)
            {
                flag = handler(this, e);
            }
            return(flag);
        }
Пример #2
0
        private void cell_DataBinding(object sender, EventArgs e)
        {
            TableCell   cell            = (TableCell)sender;
            GridViewRow namingContainer = (GridViewRow)cell.NamingContainer;

            if (this.ModuleInfoTable == null)
            {
                this.ModuleInfoTable = ((MyGridView)base.Control).ModuleInfoTable;
                List <OperateModuleInfo> buttonsModule = this.Buttons.GetButtonsModule();
                if (buttonsModule != null)
                {
                    foreach (OperateModuleInfo info in buttonsModule)
                    {
                        this.ModuleInfoTable.Add(info);
                    }
                }
                List <OperateModuleInfo> list2 = ((MyGridView)base.Control).Buttons.GetButtonsModule();
                if (list2 != null)
                {
                    foreach (OperateModuleInfo info in list2)
                    {
                        this.ModuleInfoTable.Add(info);
                    }
                }
            }
            string commandDisabled = ((MyGridView)base.Control).CommandDisabled;

            foreach (OperateModuleInfo info2 in this.ModuleInfoTable)
            {
                bool flag = true;
                if (commandDisabled.IsNoNull() && commandDisabled.Split(new char[] { ',' }).Contains <string>(info2.CommandName))
                {
                    flag = false;
                }
                if (flag)
                {
                    MenuItemCheckEventArgs args = new MenuItemCheckEventArgs(info2.CommandName, namingContainer);
                    flag = ((MyGridView)base.Control).OnMenuItemCheckCommand(args);
                }
                if (flag && info2.MenuField.IsNoNull())
                {
                    string[] strArray  = info2.MenuField.Split(new char[] { '|' });
                    string[] strArray2 = info2.MenuValue.Split(new char[] { '|' });
                    string[] strArray3 = info2.MenuCal.Split(new char[] { '|' });
                    int      length    = strArray.Length;
                    if ((strArray2.Length == length) && (strArray3.Length == length))
                    {
                        for (int i = 0; i < length; i++)
                        {
                            string        item  = DataBinder.Eval(namingContainer.DataItem, strArray[i]).DataConvertString();
                            List <string> list3 = strArray2[i].ConvertListString();
                            string        str8  = strArray3[i];
                            if (str8 != null)
                            {
                                if (!(str8 == "in"))
                                {
                                    if (str8 == "not")
                                    {
                                        goto Label_02AA;
                                    }
                                }
                                else
                                {
                                    flag = list3.IndexOf(item) >= 0;
                                }
                            }
                            goto Label_02BA;
Label_02AA:
                            flag = list3.IndexOf(item) == -1;
Label_02BA:
                            if (!flag)
                            {
                                break;
                            }
                        }
                    }
                }
                if (!flag)
                {
                    LinkButton button = (LinkButton)cell.FindControl(info2.CommandName);
                    if (button != null)
                    {
                        button.Enabled = flag;
                        if (!flag)
                        {
                            button.Attributes.Add("disabled ", "disabled");
                            button.OnClientClick = string.Empty;
                        }
                    }
                }
                else if (this.CommandExpandArgumentFields.IsNoNull() || info2.ClickScriptFun.IsNoNull())
                {
                    Control control = cell.FindControl(info2.CommandName);
                    if (control != null)
                    {
                        if (this.CommandExpandArgumentFields.IsNoNull())
                        {
                            string str3 = string.Empty;
                            foreach (string str4 in this.CommandExpandArgumentFields.Split(new char[] { ',' }))
                            {
                                str3 = str3 + DataBinder.Eval(namingContainer.DataItem, str4).DataConvertString() + ",";
                            }
                            str3 = str3.TrimEndComma();
                            if (control is MenuLinkButton)
                            {
                                ((MenuLinkButton)control).CommandExpandArgument = str3;
                            }
                            else if (control is MenuImageButton)
                            {
                                ((MenuImageButton)control).CommandExpandArgument = str3;
                            }
                        }
                        if (info2.ClickScriptFun.IsNoNull() && (info2.ClickScriptFun.Matches(@"{\w+}", RegexOptions.IgnoreCase).Count > 0))
                        {
                            string onClientClick = "";
                            if (control is MenuLinkButton)
                            {
                                onClientClick = ((MenuLinkButton)control).OnClientClick;
                            }
                            else if (control is MenuImageButton)
                            {
                                onClientClick = ((MenuImageButton)control).OnClientClick;
                            }
                            foreach (Match match in info2.ClickScriptFun.Matches(@"{\w+}", RegexOptions.IgnoreCase))
                            {
                                string str6 = match.Value.TrimStart(new char[] { '{' }).TrimEnd(new char[] { '}' }).Trim();
                                if (!string.IsNullOrWhiteSpace(str6))
                                {
                                    string newValue = DataBinder.Eval(namingContainer.DataItem, str6).DataConvertString();
                                    onClientClick = onClientClick.Replace(match.Value, newValue);
                                }
                            }
                            if (control is MenuLinkButton)
                            {
                                ((MenuLinkButton)control).OnClientClick = onClientClick;
                            }
                            else if (control is MenuImageButton)
                            {
                                ((MenuImageButton)control).OnClientClick = onClientClick;
                            }
                        }
                    }
                }
            }
        }