| | |
| | | using DevExpress.XtraBars; |
| | | using DevExpress.XtraEditors; |
| | | using Gs.DevApp.Models; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace Gs.DevApp.UserControl |
| | | { |
| | | public partial class ToolBarMenu : DevExpress.XtraEditors.XtraUserControl |
| | | { |
| | | public bool isSetBtn { get; set; } |
| | | |
| | | public List<string> actions { get; set; } |
| | | /// <summary> |
| | | /// 新增 |
| | | /// </summary> |
| | |
| | | this.btnEsc.ItemClick += BtnEsc_ItemClick; |
| | | this.btnRole.ItemClick += BtnRole_ItemClick; |
| | | initialization(); |
| | | List<string> lst = new List<string>(); |
| | | foreach (BarItem item in barManager1.Items) |
| | | { |
| | | if (item is BarLargeButtonItem largeButtonItem) |
| | | { |
| | | lst.Add(item.Caption); |
| | | } |
| | | |
| | | |
| | | private void initialization() { |
| | | } |
| | | this.actions = lst; |
| | | } |
| | | protected override void OnCreateControl() |
| | | { |
| | | base.OnCreateControl(); |
| | | if (this.Parent != null) |
| | | { |
| | | getNamespace(); |
| | | } |
| | | } |
| | | private void initialization() |
| | | { |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(btnAdd.Name); |
| | | lst.Add(btnEdit.Name); |
| | | lst.Add(btnLoad.Name); |
| | | lst.Add(btnDel.Name); |
| | | lst.Add(btnRole.Name); |
| | | setBtn(lst); |
| | | |
| | | } |
| | | |
| | | private void BtnEsc_ItemClick(object sender, ItemClickEventArgs e) |
| | |
| | | lst.Add(btnEdit.Name); |
| | | lst.Add(btnLoad.Name); |
| | | lst.Add(btnDel.Name); |
| | | lst.Add(btnRole.Name); |
| | | setBtn(lst); |
| | | if (btnEscClick != null) |
| | | { |
| | |
| | | if (btnSaveClick != null) |
| | | { |
| | | btnSaveClick(this, e); |
| | | if (isSetBtn == true) { |
| | | if (isSetBtn == true) |
| | | { |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(btnAdd.Name); |
| | | lst.Add(btnEdit.Name); |
| | |
| | | |
| | | if (btnLoadClick != null) |
| | | { |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(btnRole.Name); |
| | | setBtn(lst); |
| | | //List<string> lst = new List<string>(); |
| | | //lst.Add(btnRole.Name); |
| | | //setBtn(lst); |
| | | btnLoadClick(this, e); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据命名空间,读取该窗体下面的按钮集合 |
| | | /// </summary> |
| | | private void getNamespace() |
| | | { |
| | | string _formNamespace = ""; |
| | | Control parentControl = this; |
| | | while (parentControl.Parent != null) |
| | | { |
| | | if (parentControl.Parent is Form parentForm) |
| | | { |
| | | Type formType = parentForm.GetType(); |
| | | _formNamespace = formType.FullName; |
| | | break; |
| | | } |
| | | parentControl = parentControl.Parent; |
| | | } |
| | | var _obj = new |
| | | { |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid, |
| | | orgGuid = LoginInfoModel.CurrentUser.LoginOrgGuid, |
| | | formNamespace = _formNamespace, |
| | | }; |
| | | string strReturn = ""; |
| | | try |
| | | { |
| | | strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListByUserOrgSpace", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<DataTable> dd = UtilityHelper.GetNoPageTableByJson(strReturn); |
| | | DataTable dt = dd.rtnData; |
| | | foreach (BarItem item in barManager1.Items) |
| | | { |
| | | if (item.Caption == "取消" || item.Caption == "刷新" || item.Caption == "保存") |
| | | { |
| | | item.Visibility = BarItemVisibility.Always; |
| | | continue; |
| | | } |
| | | bool exists = dt.AsEnumerable().Any(row => row.Field<string>("name") == item.Caption); |
| | | if (exists == false) |
| | | item.Visibility = BarItemVisibility.Never; |
| | | else |
| | | item.Visibility = BarItemVisibility.Always; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |