using Yw.WinFrmUI; namespace HStation.WinFrmUI.Auth { public partial class MenuMgrMainPanel : DocumentPage { public MenuMgrMainPanel() { InitializeComponent(); GetData(); } Yw.BLL.ProjectMenu _sever = new Yw.BLL.ProjectMenu(); List _AllMenu = new List(); public async void GetData() { var AllMenu = await this._sever.GetByProjectID(0); _AllMenu.Clear(); foreach (var menus in AllMenu) { var menu = new HStation.WinFrmUI.Auth.MenuViewModel(menus); _AllMenu.Add(menu); } //Yw.Vmo.ProjectMenu a = new Yw.Vmo.ProjectMenu(); //a.ID = 1; //a.Name = "aa"; //a.Description = "aa"; //a.Permission = "aa"; //a.IsHide = true; //a.ParentID = 0; //Yw.Vmo.ProjectMenu b = new Yw.Vmo.ProjectMenu(); //b.ID = 2; //b.Name = "aa"; //b.Description = "aa"; //b.Permission = "aa"; //b.IsHide = true; //b.ParentID = 1; //_AllMenu.Add(a); //_AllMenu.Add(b); treeList.Nodes.Clear(); treeList.KeyFieldName = "ID"; treeList.ParentFieldName = "ParentID"; bindingSourceMenu.DataSource = _AllMenu; this.bindingSourceMenu.ResetBindings(false); } //添加 private void AddMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var dlg = new AddMenuDlg(); if (dlg.ShowDialog() != DialogResult.OK) { return; } GetData(); } //编辑 private void EditMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var dlg = new UpdataMenuDlg(); var currentVm = this.treeList.GetCurrentViewModel(_AllMenu); //var a =currentVm.ErpCode; if (currentVm == null) { MessageBoxHelper.ShowWarning("请选择数据行"); return; } var CurrentVm = currentVm.ConvertToProjectMenu(currentVm); dlg.SetMenuData(CurrentVm); if (dlg.ShowDialog() != DialogResult.OK) { return; } GetData(); } //删除 private void DeleteMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { } private void treeList_CustomUnboundColumnData(object sender, DevExpress.XtraTreeList.TreeListCustomColumnDataEventArgs e) { if (e.Column == treeListColumnType) { var employee = e.Row as HStation.Vmo.EmployeeMain; var Type = e.Row as HStation.WinFrmUI.Auth.MenuViewModel; if (Type == null) { MessageBox.Show("错误!"); return; } if (Type.Type == 0) { e.Value = "菜单"; } else if (Type.Type == 1) { e.Value = "目录"; } else if (Type.Type == 2) { e.Value = "功能点"; } else { MessageBox.Show("Type传入值错误!"); return; } } if (e.Column == treeListColumnWeight) { var Weight = e.Row as HStation.WinFrmUI.Auth.MenuViewModel; if (Weight == null) { MessageBox.Show("错误!"); return; } if (Weight.Weight == Yw.Auth.eAuthWeight.Normal) { e.Value = "普通"; } else if (Weight.Weight == Yw.Auth.eAuthWeight.Admin) { e.Value = "管理"; } else if (Weight.Weight == Yw.Auth.eAuthWeight.System) { e.Value = "系统"; } else { MessageBox.Show("Weight传入值错误!"); return; } } } } }