示例#1
0
        protected void BindTreeView(Guid roleID)
        {
            Dictionary <string, int> selectedIDs = new Dictionary <string, int>();

            if (!string.IsNullOrEmpty(this.PrimaryValue))
            {
                selectedIDs = SPhone_RoleBLL.GetSelectedIDs(roleID);
            }
            this.hdTree.Value = SPhone_RoleBLL.GetTreeValue(selectedIDs);
        }
示例#2
0
        protected override void InitView(SPhone_Role model)
        {
            Dictionary <string, int> selectedIDs = new Dictionary <string, int>();

            if (model != null)
            {
                this.txtRoleName.Text = model.RoleName;
                selectedIDs           = SPhone_RoleBLL.GetSelectedIDs(model.RoleID);
            }
            this.hdTree.Value = SPhone_RoleBLL.GetTreeValue(selectedIDs);
        }
示例#3
0
        protected override void PersistData(SPhone_Role data, bool isCreate)
        {
            using (var db = DCHelper.SPhoneContext())
            {
                if (isCreate)
                {
                    db.SPhone_Role.Add(data);
                }
                else
                {
                    var entity = db.SPhone_Role.FirstOrDefault(item => item.RoleID == data.RoleID);
                    this.UpdateEntity(entity, data);
                }
                db.SaveChanges();


                // 处理关系表
                string                   selectedIDs = this.hdSelectedOrg.Value;
                List <string>            deleteIDs   = new List <string>();
                List <string>            addIDs      = new List <string>();
                Dictionary <string, int> selected    = SPhone_RoleBLL.GetSelectedIDs(selectedIDs);
                Dictionary <string, int> owned       = SPhone_RoleBLL.GetSelectedIDs(data.RoleID);
                // 构造新增/修改的集合
                if (selected != null && selected.Count > 0)
                {
                    addIDs = selected.Keys.ToList().FindAll(id => !owned.ContainsKey(id));
                }
                // 构造删除的集合
                if (owned != null && owned.Count > 0)
                {
                    deleteIDs = owned.Keys.ToList().FindAll(id => !selected.ContainsKey(id));
                }
                PersistData(data.RoleID, deleteIDs, addIDs);
                BindTreeView(data.RoleID);
            }
        }