南骏 池
2024-09-01 fc1b563df6d0405a24e7898c997bd52472ae9154
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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.Threading.Tasks;
using System.Windows.Forms;
 
namespace Gs.DevApp.DevFrm.User
{
    public partial class Organization : DevExpress.XtraEditors.XtraForm
    {
        public Organization()
        {
            InitializeComponent();
            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.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,//状态
            };
            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);
            }
        }
    }
}