using DevExpress.XtraEditors;
|
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;
|
using Gs.DevApp.ToolBox;
|
using Gs.DevApp.Models;
|
using DevExpress.XtraTreeList.Nodes;
|
namespace Gs.DevApp.DevFrm.User
|
{
|
public partial class SysMenuAdd : DevExpress.XtraEditors.XtraForm
|
{
|
public SysMenuAdd(string guid)
|
{
|
InitializeComponent();
|
btnSave.Click += BtnSave_Click;
|
btnEsc.Click += BtnEsc_Click;
|
getTree();
|
lbGuid.Text = guid;
|
}
|
|
private void BtnEsc_Click(object sender, EventArgs e)
|
{
|
this.Dispose();
|
}
|
|
private void BtnSave_Click(object sender, EventArgs e)
|
{
|
string _upGuid = "";
|
TreeListNode focusedNode = txtParentMenuName.Properties.TreeList.FocusedNode;
|
if (focusedNode != null)
|
{
|
_upGuid = focusedNode.GetValue("guid").ToString();
|
}
|
var _obj = new
|
{
|
guid = "",//主建
|
upGuid = _upGuid,//上级的主建
|
name = txtMenuName.Text.Trim(),//名称
|
serialNumber = "",//编号
|
icon = txtMenuIco.Text,//菜单图标
|
status = txtStatus.SelectedIndex,//状态
|
fromPath = txtFormNamespace.Text.Trim(),//窗体路径
|
idx = int.Parse(txtIdx.Value.ToString()),//排序
|
category = txtMenuType.SelectedIndex,//类型
|
};
|
string json = JsonConvert.SerializeObject(_obj);
|
try
|
{
|
UtilityHelper.HttpPost("", "MenuAction/EditModel", json);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
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;
|
txtParentMenuName.Properties.DataSource = dt;
|
txtParentMenuName.Properties.DisplayMember = "name";
|
txtParentMenuName.Properties.DisplayMember = "name";
|
txtParentMenuName.Properties.TreeList.KeyFieldName = "guid";
|
txtParentMenuName.Properties.TreeList.ParentFieldName = "upGuid";
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
|
}
|
|
private void getModel() {
|
//_AppDomain
|
//string json = JsonConvert.SerializeObject(_obj);
|
//try
|
//{
|
// Utility.HttpPost("", "MenuAction/GetModel", json);
|
//}
|
//catch (Exception ex)
|
//{
|
// throw ex;
|
//}
|
}
|
}
|
}
|