| | |
| | | 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; |
| | | |
| | |
| | | public Organization() |
| | | { |
| | | InitializeComponent(); |
| | | ImageList imageList = new ImageList(); |
| | | imageList.Images.Add("icon1", Properties.Resources.usergroup_32x32); |
| | | imageList.Images.Add("icon2", Properties.Resources.user_16x16); |
| | | treeView1.ImageList = imageList; |
| | | this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick; |
| | | getTree(); |
| | | UtilityHelper.SetFont(panel1); |
| | | } |
| | | private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) |
| | | { |
| | | if (string.IsNullOrEmpty(txtName.Text.Trim())) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("名称不能为空!"); |
| | | txtName.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txtConPeople.Text.Trim())) |
| | | { |
| | | 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.SelectedValue.ToString(); |
| | | var _obj = new |
| | | { |
| | | guid = lbGuid.Text.Trim(),//主建 |
| | | upGuid = _upGuid,//上级的主建 |
| | | name = txtName.Text.Trim(),//名称 |
| | | conPeople = txtConPeople.Text,//联系人 |
| | | conTel = txtConPeople.Text,//联系电话 |
| | | status = txtStatus.SelectedIndex,//状态 |
| | | }; |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | 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(); } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | private void getTree() |
| | | { |
| | | trv.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", "", ""); |
| | | string json = JsonConvert.SerializeObject(pgq); |
| | | string strReturn = ""; |
| | | try |
| | | { |
| | | strReturn = UtilityHelper.HttpPost("", "Organization/GetListPage", json); |
| | | ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn); |
| | | DataTable dt = dd.rtnData.list; |
| | | DataRow[] drGrp = dt.Select("upGuid=''"); |
| | | DataTable dtComList = new DataTable(); |
| | | dtComList.Columns.Add("guid", typeof(string)); |
| | | dtComList.Columns.Add("name", typeof(string)); |
| | | foreach (DataRow _dy in drGrp) |
| | | { |
| | | dtComList.Rows.Add(_dy["guid"].ToString(), _dy["name"].ToString()); |
| | | TreeNode node = new TreeNode();//定义结点 |
| | | node.Text = _dy["name"].ToString();//为结点赋值 |
| | | node.Name = _dy["guid"].ToString(); |
| | | node.ImageIndex =0; |
| | | DataRow[] drItem = dt.Select("upGuid='" + _dy["guid"].ToString() + "'"); |
| | | foreach (DataRow _dy2 in drItem) |
| | | { |
| | | TreeNode node22 = new TreeNode();//定义结点 |
| | | node22.Text = _dy2["name"].ToString();//为结点赋值 |
| | | node22.Name = _dy2["guid"].ToString(); |
| | | node22.ImageIndex = 1; |
| | | node.Nodes.Add(node22); |
| | | } |
| | | node.ExpandAll(); |
| | | trv.Nodes.Add(node); |
| | | } |
| | | comUp.DataSource = dtComList; |
| | | comUp.DisplayMember = "name"; |
| | | comUp.ValueMember = "guid"; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |