| | |
| | | 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; |
| | |
| | | InitializeComponent(); |
| | | btnSave.Click += BtnSave_Click; |
| | | btnEsc.Click += BtnEsc_Click; |
| | | txtMenuType.TextChanged += TxtMenuType_TextChanged; |
| | | getTree(); |
| | | lbGuid.Text = guid; |
| | | getModel(); |
| | | } |
| | | |
| | | private void TxtMenuType_TextChanged(object sender, EventArgs e) |
| | | { |
| | | if (txtMenuType.SelectedIndex == 1) |
| | | { |
| | | this.txtFormNamespace.Enabled = true; |
| | | this.txtMenuIco.Enabled = true; |
| | | } |
| | | else |
| | | { |
| | | this.txtFormNamespace.Enabled = false; |
| | | this.txtMenuIco.Enabled = false; |
| | | this.txtFormNamespace.Text = ""; |
| | | this.txtMenuIco.Text = ""; |
| | | } |
| | | } |
| | | |
| | | private void BtnEsc_Click(object sender, EventArgs e) |
| | |
| | | |
| | | private void BtnSave_Click(object sender, EventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(txtMenuName.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("菜单名称不能为空!"); |
| | | txtMenuName.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txtMenuType.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("菜单类型不能为空!"); |
| | | txtMenuType.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txtStatus.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("菜单状态不能为空!"); |
| | | txtStatus.Focus(); |
| | | return; |
| | | } |
| | | string _upGuid = ""; |
| | | TreeListNode focusedNode = txtParentMenuName.Properties.TreeList.FocusedNode; |
| | | if (focusedNode != null) |
| | |
| | | } |
| | | var _obj = new |
| | | { |
| | | guid = "",//主建 |
| | | guid = lbGuid.Text.Trim(),//主建 |
| | | upGuid = _upGuid,//上级的主建 |
| | | name = txtMenuName.Text.Trim(),//名称 |
| | | serialNumber = "",//编号 |
| | | icon = txtMenuIco.Text,//菜单图标 |
| | | status = txtStatus.SelectedIndex,//状态 |
| | | fromPath = txtFormNamespace.Text.Trim(),//窗体路径 |
| | | formPath = txtFormNamespace.Text.Trim(),//窗体路径 |
| | | idx = int.Parse(txtIdx.Value.ToString()),//排序 |
| | | category = txtMenuType.SelectedIndex,//类型 |
| | | }; |
| | | string json = JsonConvert.SerializeObject(_obj); |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | UtilityHelper.HttpPost("", "MenuAction/EditModel", json); |
| | | strJson = UtilityHelper.HttpPost("", "MenuAction/EditModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | if (_rtn.rtnCode > 0) { getTree(); } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | string strReturn = ""; |
| | | try |
| | | { |
| | | strReturn =UtilityHelper.HttpPost("", "MenuAction/GetListPage", json); |
| | | strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListPage", json); |
| | | ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn); |
| | | DataTable dt = dd.rtnData.list; |
| | | txtParentMenuName.Properties.DataSource = dt; |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void getModel() { |
| | | //_AppDomain |
| | | //string json = JsonConvert.SerializeObject(_obj); |
| | | //try |
| | | //{ |
| | | // Utility.HttpPost("", "MenuAction/GetModel", json); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // throw ex; |
| | | //} |
| | | private void getModel() |
| | | { |
| | | if (lbGuid.Text.Length <= 0) return; |
| | | var _obj = new |
| | | { |
| | | guid = lbGuid.Text.Trim(),//主建 |
| | | }; |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "MenuAction/GetModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | txtMenuName.Text = _rtn.rtnData.name; |
| | | txtMenuIco.Text = _rtn.rtnData.icon; |
| | | txtFormNamespace.Text = _rtn.rtnData.formPath; |
| | | txtStatus.SelectedIndex = _rtn.rtnData.status; |
| | | txtMenuType.SelectedIndex = _rtn.rtnData.category; |
| | | txtIdx.Value = _rtn.rtnData.idx; |
| | | // txtParentMenuName.Text = ""; |
| | | } |
| | | else |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |