Example #1
0
 protected virtual void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState, int rowIndex)
 {
     string[] RowOperateCommandArray;
     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);
             }
         }
     }
     if (this.ModuleInfoTable.Count > 0)
     {
         MenuLinkButton button;
         string         commandHidden     = ((MyGridView)base.Control).CommandHidden;
         string         rowOperateCommand = ((MyGridView)base.Control).RowOperateCommand;
         Guid           guid = Guid.NewGuid();
         cell.Attributes.Add("class", "tbdOperateMenu");
         Literal child = new Literal {
             Text = string.Format("<ol id=\"ol{0}\">", rowIndex)
         };
         cell.Controls.Add(child);
         foreach (OperateModuleInfo info2 in from s in this.ModuleInfoTable
                  orderby s.SortIndex
                  select s)
         {
             if ((!rowOperateCommand.IsNoNull() || !rowOperateCommand.Split(new char[] { ',' }).Contains <string>(info2.CommandName)) && (commandHidden.IsNull() || !commandHidden.Split(new char[] { ',' }).Contains <string>(info2.CommandName)))
             {
                 Literal literal2 = new Literal {
                     Text = "<li>"
                 };
                 cell.Controls.Add(literal2);
                 button = new MenuLinkButton {
                     ID = info2.CommandName
                 };
                 if (!string.IsNullOrEmpty(info2.ImageUrl))
                 {
                     button.Style.Value = string.Format("background-image: url({0});", info2.ImageUrl);
                 }
                 if (!string.IsNullOrEmpty(info2.ImageCss))
                 {
                     button.CssClass = button.CssClass + (button.CssClass.IsNoNull() ? " " : "") + info2.ImageCss;
                 }
                 button.Text            = info2.ModuleName;
                 button.CommandName     = info2.CommandName;
                 button.CommandArgument = ((MyGridView)base.Control).DataKeys[rowIndex].Value.ToString();
                 if (!string.IsNullOrEmpty(info2.ClickScriptFun))
                 {
                     button.OnClientClick = "try{return " + info2.ClickScriptFun + ";}catch(e){return true;}";
                 }
                 cell.Controls.Add(button);
                 Literal literal3 = new Literal {
                     Text = "</li>"
                 };
                 cell.Controls.Add(literal3);
             }
         }
         Literal literal4 = new Literal {
             Text = "</ol>"
         };
         cell.Controls.Add(literal4);
         if (!rowOperateCommand.IsNull())
         {
             Literal literal5 = new Literal {
                 Text = "<span class='tbdOperate'>"
             };
             cell.Controls.Add(literal5);
             OperateType operateType = ((MyGridView)base.Control).OperateType;
             RowOperateCommandArray = rowOperateCommand.Split(new char[] { ',' });
             foreach (OperateModuleInfo info2 in from s in this.ModuleInfoTable
                      where RowOperateCommandArray.Contains <string>(s.CommandName)
                      orderby s.SortIndex
                      select s)
             {
                 if (commandHidden.IsNull() || !commandHidden.Split(new char[] { ',' }).Contains <string>(info2.CommandName))
                 {
                     if (operateType == OperateType.TxtButton)
                     {
                         button = new MenuLinkButton {
                             ID              = info2.CommandName,
                             Text            = info2.ModuleName,
                             CommandName     = info2.CommandName,
                             CommandArgument = ((MyGridView)base.Control).DataKeys[rowIndex].Value.ToString()
                         };
                         if (!string.IsNullOrEmpty(info2.ClickScriptFun))
                         {
                             button.OnClientClick = "try{return " + info2.ClickScriptFun + ";}catch(e){return true;}";
                         }
                         cell.Controls.Add(button);
                     }
                     else
                     {
                         MenuImageButton button2 = new MenuImageButton {
                             ID = info2.CommandName
                         };
                         if (commandHidden.IsMatch(info2.CommandName))
                         {
                             button2.Enabled = false;
                         }
                         button2.ImageUrl        = info2.ImageUrl;
                         button2.ToolTip         = info2.ModuleName;
                         button2.CommandName     = info2.CommandName;
                         button2.CommandArgument = ((MyGridView)base.Control).DataKeys[rowIndex].Value.ToString();
                         if (!string.IsNullOrEmpty(info2.ClickScriptFun))
                         {
                             button2.OnClientClick = "try{return " + info2.ClickScriptFun + ";}catch(e){return true;}";
                         }
                         cell.Controls.Add(button2);
                     }
                 }
             }
             Literal literal6 = new Literal {
                 Text = "</span>"
             };
             cell.Controls.Add(literal6);
         }
     }
 }
Example #2
0
 protected virtual void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState, int rowIndex)
 {
     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);
             }
         }
     }
     if (this.ModuleInfoTable.Count > 0)
     {
         string commandHidden = ((MyGridView)base.Control).CommandHidden;
         Guid   guid          = Guid.NewGuid();
         cell.Attributes.Add("class", "tbdOperate");
         foreach (OperateModuleInfo info2 in from s in this.ModuleInfoTable
                  orderby s.SortIndex
                  select s)
         {
             if (commandHidden.IsNull() || !commandHidden.Split(new char[] { ',' }).Contains <string>(info2.CommandName))
             {
                 if (this.OperateType == WTF.Controls.OperateType.TxtButton)
                 {
                     MenuLinkButton child = new MenuLinkButton {
                         ID              = info2.CommandName,
                         Text            = info2.ModuleName,
                         CommandName     = info2.CommandName,
                         CommandArgument = ((MyGridView)base.Control).DataKeys[rowIndex].Value.ToString()
                     };
                     if (!string.IsNullOrEmpty(info2.ClickScriptFun))
                     {
                         child.OnClientClick = "try{return " + info2.ClickScriptFun + ";}catch(e){return true;}";
                     }
                     cell.Controls.Add(child);
                 }
                 else
                 {
                     MenuImageButton button2 = new MenuImageButton {
                         ID = info2.CommandName
                     };
                     if (commandHidden.IsMatch(info2.CommandName))
                     {
                         button2.Enabled = false;
                     }
                     button2.ImageUrl        = info2.ImageUrl;
                     button2.ToolTip         = info2.ModuleName;
                     button2.CommandName     = info2.CommandName;
                     button2.CommandArgument = ((MyGridView)base.Control).DataKeys[rowIndex].Value.ToString();
                     if (!string.IsNullOrEmpty(info2.ClickScriptFun))
                     {
                         button2.OnClientClick = "try{return " + info2.ClickScriptFun + ";}catch(e){return true;}";
                     }
                     cell.Controls.Add(button2);
                 }
             }
         }
     }
 }