| | |
| | | using DevExpress.XtraEditors; |
| | | using Gs.DevApp.Models; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace Gs.DevApp.DevFrm.User |
| | |
| | | public Organization() |
| | | { |
| | | InitializeComponent(); |
| | | this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick; |
| | | this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick; |
| | | this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick; |
| | | this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; |
| | | this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1; |
| | | this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick; |
| | | tlMenu.DoubleClick += TlMenu_DoubleClick; |
| | | getTree(); |
| | | UtilityHelper.SetFont(panel1); |
| | | } |
| | | private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) |
| | | |
| | | private void TlMenu_DoubleClick(object sender, EventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(txtName.Text.Trim())) |
| | | TreeNode clickedNode = tlMenu.SelectedNode; |
| | | if (clickedNode.FirstNode == null) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("名称不能为空!"); |
| | | txtName.Focus(); |
| | | string rowGuid = clickedNode.Name.ToString(); |
| | | getModel(rowGuid, false, 999); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 取消事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnEscClick(object sender, EventArgs e) |
| | | { |
| | | UtilityHelper.ChangeTab(xtraTabControl1, 0); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e) |
| | | { |
| | | TreeNode clickedNode = tlMenu.SelectedNode; |
| | | if (clickedNode.FirstNode != null) |
| | | return; |
| | | string rowGuid = clickedNode.Name.ToString(); |
| | | if (string.IsNullOrEmpty(rowGuid)) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请先选择你要删除的行!"); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txtConPeople.Text.Trim())) |
| | | if (!MsgHelper.AskQuestion("你选择了【" + clickedNode.Text + "】,确定删除吗?")) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("联系人不能为空!"); |
| | | txtConPeople.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txtConPeople.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("联系电话不能为空!"); |
| | | txtConPeople.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txtConTel.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("状态不能为空!"); |
| | | txtConTel.Focus(); |
| | | return; |
| | | } |
| | | string _upGuid = comUp.Text.Trim().Length > 0 ? comUp.SelectedValue.ToString() : ""; |
| | | var _obj = new |
| | | { |
| | | guid = lbGuid.Text.Trim(),//主建 |
| | | upGuid = _upGuid,//上级的主建 |
| | | name = txtName.Text.Trim(),//名称 |
| | | conPeople = txtConPeople.Text,//联系人 |
| | | conTel = txtConPeople.Text,//联系电话 |
| | | status = txtStatus.SelectedIndex,//状态 |
| | | guid = rowGuid,//主建 |
| | | }; |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "Organization/EditModel", JsonConvert.SerializeObject(_obj)); |
| | | strJson = UtilityHelper.HttpPost("", "Organization/DeleteModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | if (_rtn.rtnCode > 0) { getTree(); } |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) |
| | | { |
| | | UtilityHelper.ChangeTab(xtraTabControl1, 0); |
| | | getTree(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 修改事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e) |
| | | { |
| | | TreeNode clickedNode = tlMenu.SelectedNode; |
| | | //if (clickedNode.FirstNode != null) |
| | | // return; |
| | | string rowGuid = clickedNode.Name.ToString(); |
| | | if (string.IsNullOrEmpty(rowGuid)) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | getModel(rowGuid, true, 1); |
| | | } |
| | | /// <summary> |
| | | /// 新增事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnAddClick(object sender, EventArgs e) |
| | | { |
| | | UtilityHelper.ChangeTab(xtraTabControl1, 1); |
| | | lbGuid.Text = ""; |
| | | UtilityHelper.CleanValue(this.panel1.Controls, true); |
| | | } |
| | | /// <summary> |
| | | /// 保存事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) |
| | | { |
| | | toolBarMenu1.isSetBtn = false; |
| | | if (string.IsNullOrEmpty(txt_factory.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("名称不能为空!"); |
| | | txt_factory.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txt_name.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("名称不能为空!"); |
| | | txt_name.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txt_conPeople.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("联系人不能为空!"); |
| | | txt_conPeople.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txt_conTel.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("联系电话不能为空!"); |
| | | txt_conTel.Focus(); |
| | | return; |
| | | } |
| | | if (txt_isStatus.SelectedIndex <= 0) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("状态不能为空!"); |
| | | txt_isStatus.Focus(); |
| | | return; |
| | | } |
| | | string _upGuid = txt_upGuid.Text.Trim().Length > 0 ? txt_upGuid.SelectedValue.ToString() : ""; |
| | | var _obj = new |
| | | { |
| | | guid = lbGuid.Text.Trim(),//主建 |
| | | upGuid = _upGuid,//上级的主建 |
| | | name = txt_name.Text.Trim(),//名称 |
| | | conPeople = txt_conPeople.Text,//联系人 |
| | | conTel = txt_conPeople.Text,//联系电话 |
| | | isStatus = txt_isStatus.SelectedIndex,//状态 |
| | | factory = txt_factory.Text,//组织编号 |
| | | }; |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", "Organization/EditModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | if (_rtn.rtnCode > 0) { getTree(); } |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | lbGuid.Text = _rtn.rtnData; |
| | | toolBarMenu1.isSetBtn = true; |
| | | UtilityHelper.ChangeEnable(this.panel1.Controls, false); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | |
| | | private void getTree() |
| | | { |
| | | trv.Nodes.Clear(); |
| | | tlMenu.Nodes.Clear(); |
| | | ImageList imageList = new ImageList(); |
| | | imageList.Images.Add("icon1", Properties.Resources.publicfix_32x32); |
| | | imageList.Images.Add("icon2", Properties.Resources.user_16x16); |
| | | trv.ImageList = imageList; |
| | | Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "name", "desc", "", ""); |
| | | tlMenu.ImageList = imageList; |
| | | PageQueryModel pgq = new PageQueryModel(1, 999999, "name", "desc", "", ""); |
| | | string json = JsonConvert.SerializeObject(pgq); |
| | | string strReturn = ""; |
| | | try |
| | | { |
| | | strReturn = UtilityHelper.HttpPost("", "Organization/GetListPage", json); |
| | | string strReturn = UtilityHelper.HttpPost("", "Organization/GetListPage", json); |
| | | ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn); |
| | | DataTable dt = dd.rtnData.list; |
| | | DataRow[] drGrp = dt.Select("upGuid=''"); |
| | | DataRow[] drGrp = dt.Select("upGuid='' or upguid is null"); |
| | | DataTable dtComList = new DataTable(); |
| | | dtComList.Columns.Add("guid", typeof(string)); |
| | | dtComList.Columns.Add("name", typeof(string)); |
| | |
| | | node.Nodes.Add(node22); |
| | | } |
| | | node.ExpandAll(); |
| | | trv.Nodes.Add(node); |
| | | tlMenu.Nodes.Add(node); |
| | | } |
| | | comUp.DataSource = dtComList; |
| | | comUp.DisplayMember = "name"; |
| | | comUp.ValueMember = "guid"; |
| | | txt_upGuid.DataSource = dtComList; |
| | | txt_upGuid.DisplayMember = "name"; |
| | | txt_upGuid.ValueMember = "guid"; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void getModel(string strGuid, bool isEdit, int tabIdx) |
| | | { |
| | | if (string.IsNullOrEmpty(strGuid)) |
| | | { |
| | | ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | UtilityHelper.ChangeTab(xtraTabControl1, tabIdx); |
| | | var _obj = new |
| | | { |
| | | guid = strGuid,//主建 |
| | | }; |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", "Organization/GetModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | dynamic dy = _rtn.rtnData; |
| | | lbGuid.Text = strGuid; |
| | | UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit); |
| | | } |
| | | else |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |