using Gs.DevApp.Models; using Gs.DevApp.ToolBox; using Newtonsoft.Json; using System; using System.Data; namespace Gs.DevApp.DevFrm.User { public partial class SysMenu : DevExpress.XtraEditors.XtraForm { public SysMenu() { InitializeComponent(); getTree(); this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick; this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick; this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick; this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; } private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) { getTree(); } private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e) { String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid")); if (string.IsNullOrEmpty(rowGuid)) { ToolBox.MsgHelper.Warning("请先选择你要删除的行!"); return; } SysMenuAdd frm = new SysMenuAdd(rowGuid); frm.ShowDialog(); } private void ToolBarMenu1_btnDelClick(object sender, EventArgs e) { String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid")); if (string.IsNullOrEmpty(rowGuid)) { ToolBox.MsgHelper.Warning("请先选择你要删除的行!"); return; } if (!MsgHelper.AskQuestion("你选择了【" + tlMenu.FocusedNode.GetValue("name") + "】,确定删除吗?")) { return; } var _obj = new { guid = rowGuid,//主建 }; string strJson = ""; try { strJson = UtilityHelper.HttpPost("", "MenuAction/DeleteModel", JsonConvert.SerializeObject(_obj)); ReturnModel _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); if (_rtn.rtnCode > 0) { getTree(); } ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); } catch (Exception ex) { ToolBox.MsgHelper.Warning("提示:" + ex.Message); } } private void ToolBarMenu1_btnAddClick(object sender, EventArgs e) { SysMenuAdd frm = new SysMenuAdd(""); frm.UpdateParent += Frm_UpdateParent; frm.ShowDialog(); } private void Frm_UpdateParent(object sender, UpdateParentEventArgs e) { getTree(); } private void getTree() { Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "idx", "asc", "", ""); string json = JsonConvert.SerializeObject(pgq); string strReturn = ""; try { strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListPage", json); ReturnModel dd = UtilityHelper.GetTableByJson(strReturn); DataTable dt = dd.rtnData.list; this.tlMenu.DataSource = dt; this.tlMenu.KeyFieldName = "guid"; this.tlMenu.ParentFieldName = "upGuid"; this.tlMenu.Tag = "name"; this.tlMenu.EndUpdate(); this.tlMenu.ExpandAll(); tlMenu.OptionsView.CheckBoxStyle = DevExpress.XtraTreeList.DefaultNodeCheckBoxStyle.Default; // 设置不关联选择 //tlMenu.OptionsSelection.MultiSelect = true; //tlMenu.OptionsSelection.MaintainState = false; // 关键设置 //this.tlMenu.OptionsBehavior.AllowIndeterminateCheckState = true; } catch (Exception ex) { ToolBox.MsgHelper.Warning("提示:" + ex.Message); } } } }