| | |
| | | using DevExpress.XtraTreeList.Nodes; |
| | | using DevExpress.XtraTreeList; |
| | | using DevExpress.XtraTreeList.Nodes; |
| | | using Gs.DevApp.Models; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | |
| | | this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; |
| | | this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1; |
| | | this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick; |
| | | tlMenu.DoubleClick += TlMenu_DoubleClick; |
| | | GetTree(); |
| | | GetDownList(); |
| | | // txt_category.TextChanged += Txt_category_TextChanged; |
| | | tlMenu.MouseDoubleClick += TlMenu_MouseDoubleClick; |
| | | getTree(); |
| | | getDownList(); |
| | | getActionList(); |
| | | } |
| | | private void TlMenu_DoubleClick(object sender, EventArgs e) |
| | | |
| | | /// <summary> |
| | | /// 菜单类型改变事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void Txt_category_TextChanged(object sender, EventArgs e) |
| | | { |
| | | TreeListNode clickedNode = this.tlMenu.FocusedNode; |
| | | if (clickedNode.FirstNode == null) { |
| | | string rowGuid = clickedNode.GetValue("guid").ToString(); |
| | | GetModel(rowGuid, false, 999); |
| | | if (txt_category.SelectedIndex == 1) |
| | | { |
| | | this.txt_formPath.Enabled = true; |
| | | this.txt_icon.Enabled = true; |
| | | } |
| | | else |
| | | { |
| | | this.txt_formPath.Enabled = false; |
| | | this.txt_icon.Enabled = false; |
| | | this.txt_formPath.Text = ""; |
| | | this.txt_icon.Text = ""; |
| | | MsgHelper.ShowError(txt_formPath.Enabled.ToString()); |
| | | MsgHelper.ShowError(txt_icon.Enabled.ToString()); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 双击行事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void TlMenu_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) |
| | | { |
| | | TreeListHitInfo info = tlMenu.CalcHitInfo(e.Location); |
| | | if (info.Node != null) |
| | | { |
| | | TreeListNode clickedNode = this.tlMenu.FocusedNode; |
| | | if (clickedNode.FirstNode == null) |
| | | { |
| | | string rowGuid = clickedNode.GetValue("guid").ToString(); |
| | | getModel(rowGuid, false, 999); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | { |
| | | guid = rowGuid,//主建 |
| | | }; |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "MenuAction/DeleteModel", JsonConvert.SerializeObject(_obj)); |
| | | string strJson = UtilityHelper.HttpPost("", "MenuAction/DeleteModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | if (_rtn.rtnCode > 0) { GetTree(); } |
| | | if (_rtn.rtnCode > 0) { getTree(); } |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) |
| | | { |
| | | UtilityHelper.ChangeTab(xtraTabControl1, 0); |
| | | GetTree(); |
| | | getTree(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 修改事件 |
| | | /// </summary> |
| | |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | GetModel(rowGuid, true, 1); |
| | | |
| | | getModel(rowGuid, true, 1); |
| | | } |
| | | /// <summary> |
| | | /// 新增事件 |
| | |
| | | return; |
| | | } |
| | | string _upGuid = txt_upGuid.EditValue.ToString(); |
| | | if (txt_category.SelectedIndex == 2 && string.IsNullOrEmpty(_upGuid)) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("按钮类型必须选择父级菜单!"); |
| | | txt_status.Focus(); |
| | | return; |
| | | } |
| | | var _obj = new |
| | | { |
| | | guid = lbGuid.Text.Trim(),//主建 |
| | |
| | | idx = int.Parse(txt_idx.Value.ToString()),//排序 |
| | | category = txt_category.SelectedIndex,//类型 |
| | | }; |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "MenuAction/EditModel", JsonConvert.SerializeObject(_obj)); |
| | | string strJson = UtilityHelper.HttpPost("", "MenuAction/EditModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | if (_rtn.rtnCode > 0) |
| | |
| | | } |
| | | } |
| | | |
| | | private void 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); |
| | | string strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListPage", json); |
| | | ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn); |
| | | DataTable dt = dd.rtnData.list; |
| | | this.tlMenu.DataSource = dt; |
| | |
| | | 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) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void GetModel(string strGuid, bool isEdit, int tabIdx) |
| | | private void getModel(string strGuid, bool isEdit, int tabIdx) |
| | | { |
| | | if (string.IsNullOrEmpty(strGuid)) |
| | | { |
| | |
| | | { |
| | | guid = strGuid,//主建 |
| | | }; |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "MenuAction/GetModel", JsonConvert.SerializeObject(_obj)); |
| | | string strJson = UtilityHelper.HttpPost("", "MenuAction/GetModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void GetDownList() |
| | | private void getDownList() |
| | | { |
| | | Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "idx", "asc", "", " and category=1"); |
| | | string json = JsonConvert.SerializeObject(pgq); |
| | | string strReturn = ""; |
| | | try |
| | | { |
| | | strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListPage", json); |
| | | string strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListPage", json); |
| | | ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn); |
| | | DataTable dt = dd.rtnData.list; |
| | | txt_upGuid.Properties.TreeList.KeyFieldName = "guid"; |
| | |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | private void getActionList() |
| | | { |
| | | txt_name.Properties.Items.AddRange(toolBarMenu1.actions); |
| | | } |
| | | } |
| | | } |