private void btnAlterar_Click(object sender, EventArgs e) { AlteraEstadoCampos(true); AlteraBotoesIncluirAlterarExcluir(false); AlteraBotoesSalvarCancelar(true); acao = OperEnum.ALTERAR; }
private void btnIncluir_Click(object sender, EventArgs e) { AlteraEstadoCampos(true); AlteraBotoesIncluirAlterarExcluir(false); AlteraBotoesSalvarCancelar(true); acao = OperEnum.INCLUIR; LimpaCampos(); }
private void SetGridDefaultOper(Grid grid) { OperEnum formType = OperEnum.Refresh; if (OperCud) { formType = formType | OperEnum.Add | OperEnum.Update | OperEnum.Delete; } else { if (OperAdd) { formType = formType | OperEnum.Add; } if (OperUpdate) { formType |= OperEnum.Update; } if (OperDelete) { formType |= OperEnum.Delete; } } if (OperBatchUpdate) { formType |= OperEnum.BatchUpdate; } if (OperExport) { formType |= OperEnum.ExportExcel; formType |= OperEnum.ExportWord; } if (OperExportExcel) { formType |= OperEnum.ExportExcel; } if (OperExportWord) { formType |= OperEnum.ExportWord; } if (OperImport) { formType |= OperEnum.Import; } if (OperChart) { formType |= OperEnum.Chart; } formType |= OperEnum.Search; formType |= OperEnum.QueryProgram; formType |= OperEnum.View; grid.SetFormType(formType); }
private string GetOperIcon(OperEnum operEnum) { return(operEnum switch { OperEnum.Add => "fa fa-plus-circle purple", OperEnum.BatchUpdate => "fa fa-pencil-square-o", OperEnum.Delete => "fa fa-trash-o red", OperEnum.ExportExcel => "fa fa-file-excel-o green", OperEnum.ExportWord => "fa fa-file-word-o", OperEnum.Import => "fa fa-cloud-upload", OperEnum.QueryProgram => "fa fa-camera", OperEnum.Refresh => "fa fa-refresh green", OperEnum.Search => "fa fa-search orange", OperEnum.Update => "fa fa-pencil blue", OperEnum.View => "fa fa-search-plus grey", _ => "fa fa-bolt" });
public IEnumerable <TreeDataView> GetMenuButtonTree() { var menuButtons = _platformDomain.MenuButtonSet; var tree = GetModuleAndMenuTree(); var mmtor = tree.GetEnumerator(); AddMenuButton(mmtor); return(tree); void AddMenuButton(IEnumerator <TreeDataView> menuEmumertor) { while (menuEmumertor.MoveNext()) { TreeDataView curr = menuEmumertor.Current; if (curr.Children.Any()) { AddMenuButton(curr.Children.GetEnumerator()); } if (curr.Data.IsMenu) { var children = AddOperNode(curr); if (children.Any()) { curr.Children = children.ToList(); } } } } IEnumerable <TreeDataView> AddOperNode(TreeDataView menuNode) { var opers = typeof(OperEnum).EnumItems(_multiLangService); string menuUid = menuNode.Id; if (!_applicationContext.IsAdministrator) { //权限中获取 var roleButtons = _rbacService.GetRoleButtonList(_applicationContext.CurrentRoleUid); if (roleButtons.Any()) { var rbtns = roleButtons.Where(r => r.MenuUid == menuUid); foreach (var btn in rbtns.Where(b => b.ButtonType == FapMenuButtonType.Grid || b.ButtonType == FapMenuButtonType.Tree)) { var button = menuButtons.FirstOrDefault(b => b.MenuUid == btn.MenuUid && b.ButtonID == btn.ButtonId); if (button != null) { string langkey = $"{menuUid}_{button.ButtonID}"; button.Description = _multiLangService.GetMultiLangValue(MultiLanguageOriginEnum.ButtonTag, langkey); TreeDataView toper = new TreeDataView() { Id = button.Fid, Data = new { IsBtn = false, IsMenu = false }, Pid = menuNode.Id, Text = button.Description, Icon = btn.ButtonType == FapMenuButtonType.Grid ? "fa fa-table" : "fa fa-code-fork" }; foreach (var oper in btn.ButtonValue.SplitComma()) { OperEnum operEnum = (OperEnum)oper.ToInt(); TreeDataView tcol = new TreeDataView(); tcol.Id = $"{menuNode.Id}|{button.ButtonType}|{ button.ButtonID }|{oper}"; tcol.Data = new { IsBtn = true, IsMenu = false }; tcol.Pid = toper.Id; tcol.Text = operEnum.Description(); tcol.Icon = GetOperIcon(operEnum); toper.Children.Add(tcol); } yield return(toper); } } var buttons = rbtns.Where(b => b.ButtonType == FapMenuButtonType.Link || b.ButtonType == FapMenuButtonType.Button); foreach (var btn in buttons) { var button = menuButtons.FirstOrDefault(b => b.MenuUid == btn.MenuUid && b.ButtonID == btn.ButtonId); TreeDataView toper = new TreeDataView() { Id = $"{menuNode.Id}|button|{ button.ButtonID }|1", Icon = "fa fa-bolt", Data = new { IsBtn = true, IsMenu = false }, Pid = menuNode.Id, Text = button.Description, }; yield return(toper); } } } else { if (menuButtons.TryGetValue(menuUid, out IEnumerable <FapMenuButton> buttons)) { foreach (var button in buttons) { string langkey = $"{menuUid}_{button.ButtonID}"; button.Description = _multiLangService.GetMultiLangValue(MultiLanguageOriginEnum.ButtonTag, langkey); TreeDataView toper = new TreeDataView() { Id = button.Fid, Data = new { IsBtn = false, IsMenu = false }, Pid = menuNode.Id, Text = button.Description }; if (button.ButtonType == FapMenuButtonType.Grid) { toper.Icon = " fa fa-table"; foreach (var oper in opers) { TreeDataView tcol = new TreeDataView(); tcol.Id = $"{menuNode.Id}|{button.ButtonType}|{ button.ButtonID }|{oper.Key}"; tcol.Data = new { IsBtn = true, IsMenu = false }; tcol.Pid = toper.Id; tcol.Text = oper.Description; tcol.Icon = GetOperIcon(oper.Value.ParseEnum <OperEnum>()); toper.Children.Add(tcol); } } else if (button.ButtonType == FapMenuButtonType.Tree) { toper.Icon = " fa fa-code-fork"; foreach (var oper in opers) { if (oper.Key == (int)OperEnum.Add || oper.Key == (int)OperEnum.Update || oper.Key == (int)OperEnum.Delete || oper.Key == (int)OperEnum.Refresh) { TreeDataView tcol = new TreeDataView(); tcol.Id = $"{menuNode.Id}|{button.ButtonType}|{ button.ButtonID }|{oper.Key}"; tcol.Data = new { IsBtn = true, IsMenu = false }; tcol.Pid = toper.Id; tcol.Text = oper.Description; tcol.Icon = GetOperIcon(oper.Value.ParseEnum <OperEnum>()); toper.Children.Add(tcol); } } } else if (button.ButtonType == FapMenuButtonType.Link || button.ButtonType == FapMenuButtonType.Button) { toper.Id = $"{menuNode.Id}|button|{ button.ButtonID }|1"; toper.Icon = "fa fa-bolt"; toper.Data = new { IsBtn = true, IsMenu = false }; } yield return(toper); } } } } }