using DevExpress.XtraEditors;
|
using Gs.DevApp.Models;
|
using Gs.DevApp.ToolBox;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
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;
|
}
|
|
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;
|
}
|
var _obj = new
|
{
|
guid = rowGuid,//主建
|
};
|
string json = JsonConvert.SerializeObject(_obj);
|
string strReturn = "";
|
try
|
{
|
strReturn= UtilityHelper.HttpPost("", "MenuAction/DeleteModel", json);
|
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
|
{
|
SysMenuAdd frm = new SysMenuAdd("");
|
frm.ShowDialog();
|
}
|
|
private void getTree()
|
{
|
Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "idx", "desc", "", "");
|
string json = JsonConvert.SerializeObject(pgq);
|
string strReturn = "";
|
try
|
{
|
strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListPage", json);
|
ReturnModel<PageListModel> 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.Radio;
|
// 设置不关联选择
|
//tlMenu.OptionsSelection.MultiSelect = true;
|
//// tlMenu.OptionsSelection.MaintainState = false; // 关键设置
|
//this.tlMenu.OptionsBehavior.AllowIndeterminateCheckState = true;
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
|
}
|
|
}
|
}
|