username@email.com
2025-05-15 6fe02a16e55f17e45a3997171e1b2284d45af25b
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL;
using CY.Model;
using CY.Infrastructure.Common;
using System.Data;
 
namespace CY.WebForm.Pages.personnel
{
    //吴辉
    //修改员工负责区域
    public partial class CCManageAddress : BasePage
    {
        Sys_CitySiteBLL bll_Sys_CitySiteBLL = null;
        OA_StaffBLL bll_OA_StaffBLL = null;
 
        public static string treeHtml = "";  //树形参数
        public string CheckedHtml = "";  //选中值
 
        //实例化
        public CCManageAddress()
        {
            bll_Sys_CitySiteBLL = new Sys_CitySiteBLL();
            bll_OA_StaffBLL = new OA_StaffBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetCheckedHtml();
                InitialData();
            }
        }
 
        public void GetCheckedHtml()
        {
            Model.OA_Staff m_OA_Staff = bll_OA_StaffBLL.GetModelByKeyid(Request["keyid"].ToInt32());
            if (m_OA_Staff != null)
            {
                CheckedHtml = "-";
                string[] MangeCountryS = m_OA_Staff.ManageCountry.Trim(',').Split(',');
                foreach (var item in MangeCountryS)
                {
                    CheckedHtml += (item + "-");
                }
                string[] MangeCountryS1 = m_OA_Staff.ManageCountry1.Trim(',').Split(',');
                foreach (var item in MangeCountryS1)
                {
                    CheckedHtml += (item + "-");
                }
            }
        }
 
        //获取遍历结果
        public void InitialData()
        {
 
            treeHtml = "{GetMenuRoleId:'0', id: 99999, parentId: 900009, name: '全国', open: true },";
 
            List<Sys_CitySite> m_ProvinceList = bll_Sys_CitySiteBLL.SelectAllNextModel(0, 0, 1) as List<Sys_CitySite>;
            foreach (var m_Province in m_ProvinceList)
            {
                treeHtml = treeHtml + "{GetMenuRoleId:'0', id: " + m_Province.Keyid + ", parentId: 99999, name: '" + m_Province.Name + "' },";
 
                List<Sys_CitySite> m_CityList = bll_Sys_CitySiteBLL.SelectAllNextModel(m_Province.Keyid, 0, 2) as List<Sys_CitySite>;
                foreach (var m_City in m_CityList)
                {
                    treeHtml = treeHtml + "{GetMenuRoleId:'0', id: " + m_City.Keyid + ", parentId: " + m_City.ProvinceId + ", name: '" + m_City.Name + "' },";
 
                    List<Sys_CitySite> m_CountryList = bll_Sys_CitySiteBLL.SelectAllNextModel(m_Province.Keyid, m_City.Keyid, 3) as List<Sys_CitySite>;
                    foreach (var m_Country in m_CountryList)
                    {
                        treeHtml = treeHtml + "{GetMenuRoleId:'" + m_Province.Keyid + "-" + m_City.Keyid + "-" + m_Country.Keyid + "-', id: " + m_Country.Keyid + ", parentId: " + m_Country.CityId + ", name: '" + m_Country.Name + "' },";
                    }
                }
            }
            treeHtml = treeHtml.Trim(',');
        }
 
        //保存角色权限
        protected void btn_SaveRole_Click(object sender, EventArgs e)
        {
            try
            {
                string Roles = Request["hideRoles"].ToString2();
                string[] RolesArry = Roles.Split(',');
                Dictionary<string, string> MenusJionRole = new Dictionary<string, string>();
                string Province = ",";
                string City = ",";
                string Country = ",";
                string Country1 = ",";
                int i = 0;
                foreach (var itemRole in RolesArry)
                {
                    string MenuAll = itemRole.Trim('-');
                    string[] MenuAllArry = MenuAll.Split('-');
                    if (Province.IndexOf(("," + MenuAllArry[0] + ",")) < 0)
                        Province += (MenuAllArry[0] + ",");
                    if (City.IndexOf(("," + MenuAllArry[1] + ",")) < 0)
                        City += (MenuAllArry[1] + ",");
                    if (Country.Length < 7800)
                    {
                        Country += (MenuAllArry[2] + ",");
                    }
                    else
                    {
                        Country1 += (MenuAllArry[2] + ",");
                    }
                    i++;
                }
                Province = Province.Trim(',');
                City = City.Trim(',');
                Country = Country.Trim(',');
                Model.OA_Staff m_OA_Staff = bll_OA_StaffBLL.GetModelByKeyid(Request["keyid"].ToInt32());
                m_OA_Staff.ManageProvince = Province;
                m_OA_Staff.ManageCity = City;
                m_OA_Staff.ManageCountry = Country;
                m_OA_Staff.ManageCountry1 = Country1;
 
                bool result = bll_OA_StaffBLL.UpdateModel(m_OA_Staff);
                if (result)
                {
                    InitialData();
                    JavaScript.MessageBox("保存成功", this, true, true);
                }
                else
                    JavaScript.MessageBox("操作失败", this);
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
    }
}