public async Task <JsonResult> DoEdit([FromBody] SysOrganization entity)
        {
            var jm = new AdminUiCallBack();

            var oldModel = await _sysOrganizationServices.QueryByIdAsync(entity.id);

            if (oldModel == null)
            {
                jm.msg = "不存在此信息";
                return(new JsonResult(jm));
            }
            //事物处理过程开始
            //oldModel.id = entity.id;
            oldModel.parentId             = entity.parentId;
            oldModel.organizationName     = entity.organizationName;
            oldModel.organizationFullName = entity.organizationFullName;
            oldModel.organizationType     = entity.organizationType;
            //oldModel.leaderId = entity.leaderId;
            oldModel.sortNumber = entity.sortNumber;
            oldModel.comments   = entity.comments;
            oldModel.deleted    = entity.deleted;
            //oldModel.createTime = entity.createTime;
            oldModel.updateTime = DateTime.Now;

            //事物处理过程结束
            var bl = await _sysOrganizationServices.UpdateAsync(oldModel);

            jm.code = bl ? 0 : 1;
            jm.msg  = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;

            return(new JsonResult(jm));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取最大编号
        /// </summary>
        private void GetMaxNum()
        {
            var MuxNum = SysOrganization.FindAll().Max(ten => ten.SortIndex);

            Response.Write(MuxNum.GetValueOrDefault() + 5);
            Response.End();
        }
Ejemplo n.º 3
0
        public string SaveSelectNode(string NodeIds, string RoleOrGroupID)
        {
            if (string.IsNullOrEmpty(NodeIds))
            {
                return("0");
            }
            if (!string.IsNullOrEmpty(RoleOrGroupID))
            {
                string[] idList = JsonConvert.DeserializeObject <string[]>(NodeIds);
                var      GrEnt  = SysGroupOrRole.Find(RoleOrGroupID);
                //先删除
                string SQL = "delete from SysOrgRefGroupOrRole where GroupOrRoleID='" + RoleOrGroupID + "'";
                DataHelper.ExecSql(SQL);

                foreach (var item in idList)
                {
                    var OrgEnt = SysOrganization.Find(item);
                    SysOrgRefGroupOrRole Ent = new SysOrgRefGroupOrRole();
                    Ent.OrgID           = OrgEnt.ID;
                    Ent.OrgName         = OrgEnt.Name;
                    Ent.GroupOrRoleID   = GrEnt.ID;
                    Ent.GroupOrRoleName = GrEnt.GroupName;
                    Ent.DoCreate();
                }
            }
            else
            {
                return("0");
            }

            return("1");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 保存组织机构信息
        /// </summary>
        /// <param name="dtos">待保存的组织机构Dto信息</param>
        /// <returns>业务操作结果</returns>
        public async Task <OperationResult> SaveOrganizations(params SysOrganizationDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var addDtos    = dtos.Where(p => p.Id == 0).ToArray();
            var updateDtos = dtos.Where(p => p.Id > 0).ToArray();
            List <SysOrganization> saveOrganizations = new List <SysOrganization>();

            try
            {
                //dto检查委托
                Action <SysOrganizationDto> checkAction = dto =>
                {
                    if (OrganizationRepository.CheckExists(m => m.Name == dto.Name, dto.Id))
                    {
                        throw new Exception("名称为“{0}”的组织机构已存在,不能重复添加。".FormatWith(dto.Name));
                    }
                };

                //dto更新委托
                Func <SysOrganizationDto, SysOrganization, SysOrganization> updateFunc = (dto, entity) =>
                {
                    if (!dto.ParentId.HasValue || dto.ParentId == 0)
                    {
                        entity.Parent = null;
                    }
                    else if (entity.Parent == null || entity.Parent.Id != dto.ParentId)
                    {
                        var             parentId = dto.ParentId.Value;
                        SysOrganization parent   = OrganizationRepository.GetByKey(parentId);
                        if (parent != null)
                        {
                            entity.Parent = parent;
                        }
                    }
                    saveOrganizations.Add(entity);
                    return(entity);
                };

                OrganizationRepository.UnitOfWork.TransactionEnabled = true;
                if (addDtos.Length > 0)
                {
                    OrganizationRepository.Insert(addDtos, checkAction, updateFunc);
                }
                if (updateDtos.Length > 0)
                {
                    OrganizationRepository.Update(updateDtos, checkAction, updateFunc);
                }
                await RoleRepository.UnitOfWork.SaveChangesAsync();

                int[] ids = saveOrganizations.Select(m => m.Id).ToArray();
                //RefreshSysOrganizationsTreePath(ids);
                return(new OperationResult(OperationResultType.Success, "保存成功"));
            }
            catch (Exception e)
            {
                return(new OperationResult(OperationResultType.Error, e.Message));
            }
        }
Ejemplo n.º 5
0
        protected void LoadTreeData()
        {
            //默认加载ParentID为root
            var list = SysOrganization.FindAll().OrderBy(ten => ten.SortIndex).ToArray();
            List <NodeObject> NodeList = GetTree(list.ToArray(), "root");
            string            TreeJson = Razor.DynamicJson.DynamicJsonConvert.SerializeObject(NodeList);

            Response.Write(TreeJson);
            Response.End();
        }
Ejemplo n.º 6
0
 public static void AddDefaultStorage(SysOrganization organization)
 {
     QueryDistribution.LinqOP.Add <Storage>(new Storage
     {
         OrganizationID = organization.ID,
         Name           = "成品仓库",
         CreatorID      = organization.CreatorID,
         CreateTime     = organization.CreateTime
     });
 }
Ejemplo n.º 7
0
        void RadGridView1_RowActivated(object sender, RowEventArgs e)
        {
            SysOrganization o = e.Row.Item as SysOrganization;

            if (o != null && OrganizationSelected != null)
            {
                OrganizationSelected(o);
                this.Close();
            }
        }
        public async Task <JsonResult> DoCreate([FromBody] SysOrganization entity)
        {
            var jm = new AdminUiCallBack();

            var bl = await _sysOrganizationServices.InsertAsync(entity) > 0;

            jm.code = bl ? 0 : 1;
            jm.msg  = (bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure);

            return(new JsonResult(jm));
        }
Ejemplo n.º 9
0
        public string BindRootNode()
        {
            var Ent = SysOrganization.FindFirstByProperties(SysOrganization.Prop_ParentID, "root");

            if (Ent != null)
            {
                // SysOrganization SysOrgEnt = new SysOrganization();
                SysOrganization.BindUserToRootNode(Ent);
            }
            return("1");
        }
Ejemplo n.º 10
0
        private string GetOrgTreeNodeText(SysOrganization org)
        {
            StringBuilder sb = new StringBuilder();

            if (!String.IsNullOrEmpty(org.OrganizationCode))
            {
                sb.Append("[");
                sb.Append(org.OrganizationCode);
                sb.Append("]");
            }
            sb.Append(org.OrganizationName);

            return(sb.ToString());
        }
Ejemplo n.º 11
0
        private void toolStripMenuItemAddRoot_Click(object sender, EventArgs e)
        {
            DlgOrgEdit form = new DlgOrgEdit(null, EditType.AddRoot, this.Action);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                SysOrganization newOrg = form.Organization;
                UltraTreeNode   node   = new UltraTreeNode();
                node.Key  = newOrg.OrganizationId;
                node.Text = GetOrgTreeNodeText(newOrg);
                node.LeftImages.Add(GetImage(newOrg.OrganizationType));
                node.Tag = newOrg;
                ultraTree1.Nodes.Add(node);
            }
        }
Ejemplo n.º 12
0
        public string DeleteData(string ID)
        {
            var Ent = SysOrganization.Find(ID);
            //删除相关联的人员
            var RefEnts = SysOrgUser.FindAllByProperties(SysOrgUser.Prop_OrgID, Ent.ID);

            if (RefEnts.Length > 0)
            {
                foreach (var item in RefEnts)
                {
                    item.DoDelete();
                }
            }
            Ent.DoDelete();
            return("1");
        }
Ejemplo n.º 13
0
        private void toolStripMenuItemUpdate_Click(object sender, EventArgs e)
        {
            UltraTreeNode node = ultraTree1.ActiveNode;

            if (node != null)
            {
                SysOrganization org  = node.Tag as SysOrganization;
                DlgOrgEdit      form = new DlgOrgEdit(org, EditType.Update, this.Action);
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    SysOrganization newOrg = form.Organization;
                    node.Text = newOrg.OrganizationName;
                    node.Tag  = newOrg;
                }
            }
        }
Ejemplo n.º 14
0
        private void toolStripMenuItemDelete_Click(object sender, EventArgs e)
        {
            UltraTreeNode node = ultraTree1.ActiveNode;

            if (node != null)
            {
                if (node.Nodes.Count > 0)
                {
                    MetroMessageBox.Show(this, "请先删除下级组织!");
                    return;
                }
                SysOrganization org = node.Tag as SysOrganization;
                if (MetroMessageBox.Show(this, "是否确定删除该组织?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    this.Update(Globals.ORGANIZATION_SERVICE_NAME, "delete", new object[] { org.OrganizationId });
                }
            }
        }
Ejemplo n.º 15
0
        private void toolStripMenuItemAddSub_Click(object sender, EventArgs e)
        {
            UltraTreeNode node = ultraTree1.ActiveNode;

            if (node != null)
            {
                SysOrganization org  = node.Tag as SysOrganization;
                DlgOrgEdit      form = new DlgOrgEdit(org, EditType.AddChild, this.Action);
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    SysOrganization newOrg  = form.Organization;
                    UltraTreeNode   subNode = new UltraTreeNode();
                    subNode.Key  = newOrg.OrganizationId;
                    subNode.Text = GetOrgTreeNodeText(newOrg);
                    subNode.Tag  = newOrg;
                    subNode.LeftImages.Add(GetImage(newOrg.OrganizationType));
                    node.Nodes.Add(subNode);
                }
            }
        }
Ejemplo n.º 16
0
 public SysOrganizationBO(SysOrganization organization)
 {
     this.ID          = organization.ID;
     this.Name        = organization.Name;
     this.Code        = organization.Code;
     this.ParentID    = organization.ParentID;
     this.TypeId      = organization.TypeId;
     this.Flag        = organization.Flag;
     this.AreaID      = organization.AreaID;
     this.ProvienceID = organization.ProvienceID;
     this.CityID      = organization.CityID;
     this.Address     = organization.Address;
     this.Telephone   = organization.Telephone;
     this.Linkman     = organization.Linkman;
     this.Description = organization.Description;
     CreateTime       = organization.CreateTime;
     CreatorID        = organization.CreatorID;
     Latitude         = organization.Latitude;
     Longitude        = organization.Longitude;
     MapCityName      = organization.MapCityName;
 }
Ejemplo n.º 17
0
        public string SaveData(string Record)
        {
            //    Server.HtmlDecode();
            SysOrganization Ent = JSON.Deserialize <SysOrganization>(Record);

            if (string.IsNullOrEmpty(Ent.ParentID))
            {
                Ent.ParentID = "root";
            }
            if (string.IsNullOrEmpty(Ent.ID))
            {
                Ent.DoCreate();
                //保存Path,包含本身ID
                Ent.Path = Ent.Path + "/" + Ent.ID;
                Ent.DoUpdate();
            }
            else
            {
                Ent.Update();
            }
            return(Ent.ID);
        }
Ejemplo n.º 18
0
        protected void OrgTreeData()
        {
            string        TreeNodeID = Request["TreeNodeID"] + "";
            List <string> SltIds     = new List <string>();

            if (!string.IsNullOrEmpty(TreeNodeID))
            {
                var Ents = SysOrgRefGroupOrRole.FindAllByProperty("GroupOrRoleID", TreeNodeID);
                foreach (var item in Ents)
                {
                    SltIds.Add(item.OrgID);
                }
            }

            var list = SysOrganization.FindAll().OrderBy(ten => ten.SortIndex).ToArray();
            List <NodeObject> NodeList = GetOrgTree(list.ToArray(), SltIds, "root");
            string            TreeJson = Razor.DynamicJson.DynamicJsonConvert.SerializeObject(NodeList);

            TreeJson = TreeJson.Replace("check", "checked");
            Response.Write(TreeJson);
            Response.End();
        }
Ejemplo n.º 19
0
        public string RefUserToOrg(string Json, string PID)
        {
            var OrgEnt = SysOrganization.Find(PID);
            var Ents   = JSON.Deserialize <SysUser[]>(Json);

            foreach (var item in Ents)
            {
                //去除重复
                int a = SysOrgUser.GetCount(Expression.Sql("UserID='" + item.ID + "' and OrgID='" + OrgEnt.ID + "'"));
                if (a > 0)
                {
                    continue;
                }

                SysOrgUser OrgUsr = new SysOrgUser();
                OrgUsr.OrgID    = OrgEnt.ID;
                OrgUsr.OrgName  = OrgEnt.Name;
                OrgUsr.UserID   = item.ID;
                OrgUsr.UserName = item.Name;
                OrgUsr.DoCreate();
            }
            return("1");
        }
Ejemplo n.º 20
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            SysOrganization org = null;

            switch (_type)
            {
            case EditType.AddRoot:
            case EditType.AddChild:
                org = new SysOrganization();
                org.OrganizationId   = BipGuid.Guid;
                org.OrganizationCode = txtOrgCode.Text.Trim();
                org.OrganizationName = txtOrgName.Text.Trim();
                org.OrganizationType = cmbOrgType.Value.ToString();
                org.Remark           = txtRemark.Text.Trim();
                org.ParentId         = _org != null ? _org.OrganizationId : null;
                this.Update(SERVICE_NAME, "add", new object[] { org });
                this.Organization = org;
                break;

            case EditType.Update:
                org = _org;
                org.OrganizationCode = txtOrgCode.Text.Trim();
                org.OrganizationName = txtOrgName.Text.Trim();
                org.OrganizationType = cmbOrgType.Value.ToString();
                org.Remark           = txtRemark.Text.Trim();
                this.Update(SERVICE_NAME, "update", new object[] { org });
                break;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 21
0
 public OrganizationShowOnMap(SysOrganization organization)
     : base(organization)
 {
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 获取机构的所有角色
 /// </summary>
 /// <returns>角色集合</returns>
 public static List <SysRole> GetAllRoles(this SysOrganization org)
 {
     return(GetRolesOfOrgnization(org.ID));
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 获取机构的所有用户
 /// </summary>
 /// <returns>用户集合</returns>
 public static List <SysUser> GetAllUsers(this SysOrganization org)
 {
     return(GetUsersOfOrgnization(org.ID));
 }
Ejemplo n.º 24
0
        public string SaveSelectNode(string NodeIds, string RefID, string TabIndex)
        {
            if (string.IsNullOrEmpty(NodeIds))
            {
                return("0");
            }
            if (!string.IsNullOrEmpty(RefID))
            {
                string[] idList = JsonConvert.DeserializeObject <string[]>(NodeIds);
                switch (TabIndex)
                {
                case "0":
                {
                    //先删除
                    string SQL = "delete from SysOrgAuth where OrgID='" + RefID + "'";
                    DataHelper.ExecSql(SQL);

                    var GrEnt = SysOrganization.Find(RefID);
                    foreach (var item in idList)
                    {
                        var OrgEnt = DataModel.SysModule.Find(item);
                        //创建
                        SysOrgAuth Ent = new SysOrgAuth();
                        Ent.OrgID      = GrEnt.ID;
                        Ent.OrgName    = GrEnt.Name;
                        Ent.ModuleID   = OrgEnt.ID;
                        Ent.ModuleName = OrgEnt.Name;
                        Ent.DoCreate();
                    }
                }
                break;

                case "1":
                {
                    //先删除
                    string SQL = "delete from SysGroupAuth where GroupID='" + RefID + "'";
                    DataHelper.ExecSql(SQL);

                    var GrEnt = SysGroupOrRole.Find(RefID);
                    foreach (var item in idList)
                    {
                        var OrgEnt = DataModel.SysModule.Find(item);
                        //创建
                        SysGroupAuth Ent = new SysGroupAuth();
                        Ent.GroupID    = GrEnt.ID;
                        Ent.GroupName  = GrEnt.GroupName;
                        Ent.ModuleID   = OrgEnt.ID;
                        Ent.ModuleName = OrgEnt.Name;
                        Ent.DoCreate();
                    }
                }
                break;

                case "2":
                {
                    //先删除
                    string SQL = "delete from SysUserAuth where UserID='" + RefID + "'";
                    DataHelper.ExecSql(SQL);

                    var GrEnt = SysUser.Find(RefID);
                    foreach (var item in idList)
                    {
                        var OrgEnt = DataModel.SysModule.Find(item);
                        //创建
                        SysUserAuth Ent = new SysUserAuth();
                        Ent.UserID     = GrEnt.ID;
                        Ent.UserName   = GrEnt.Name;
                        Ent.ModuleID   = OrgEnt.ID;
                        Ent.ModuleName = OrgEnt.Name;
                        Ent.DoCreate();
                    }
                }
                break;
                }
            }
            else
            {
                return("0");
            }
            return("1");
        }
Ejemplo n.º 25
0
 public DlgOrgEdit(SysOrganization organization, EditType type, BipAction action)
     : this(organization, type)
 {
     this.Action = action;
 }
Ejemplo n.º 26
0
 public DlgOrgEdit(SysOrganization organization, EditType type)
 {
     _type = type;
     _org  = organization;
     InitializeComponent();
 }
 public int Insert(SysOrganization sysOrganization)
 {
     return(SysOrganizationRepository.Insert(sysOrganization));
 }
 public int Update(SysOrganization sysOrganization)
 {
     return(SysOrganizationRepository.Update(sysOrganization));
 }
Ejemplo n.º 29
0
        /// <summary>
        /// 保存角色信息信息
        /// </summary>
        /// <param name="dtos">待保存的角色DTO信息</param>
        /// <returns>业务操作结果</returns>
        public async Task <OperationResult> SaveRoles(params SysRoleDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var addDtos    = dtos.Where(p => p.Id == 0).ToArray();
            var updateDtos = dtos.Where(p => p.Id > 0).ToArray();

            try
            {
                //dto检查委托
                Action <SysRoleDto> checkAction = dto =>
                {
                    if (dto.OrganizationId.HasValue)
                    {
                        if (RoleRepository.CheckExists(m => m.Name == dto.Name && m.Organization != null && m.Organization.Id == dto.OrganizationId.Value, dto.Id))
                        {
                            throw new Exception("同组织机构中名称为“{0}”的角色已存在,不能重复添加。".FormatWith(dto.Name));
                        }
                    }
                    else if (RoleRepository.CheckExists(m => m.Name == dto.Name && m.Organization == null, dto.Id))
                    {
                        throw new Exception("无组织机构的名称为的角色已存在,不能重复添加".FormatWith(dto.Name));
                    }
                };

                //dto更新委托
                Func <SysRoleDto, SysRole, SysRole> updateFunc = (dto, entity) =>
                {
                    if (dto.OrganizationId.HasValue && dto.OrganizationId.Value > 0)
                    {
                        SysOrganization organization = OrganizationRepository.GetByKey(dto.OrganizationId.Value);
                        if (organization == null)
                        {
                            throw new Exception("要加入的组织机构不存在。");
                        }
                        entity.Organization = organization;
                    }
                    else
                    {
                        entity.Organization = null;
                    }
                    return(entity);
                };

                RoleRepository.UnitOfWork.TransactionEnabled = true;
                if (addDtos.Length > 0)
                {
                    RoleRepository.Insert(addDtos, checkAction, updateFunc);
                }
                if (updateDtos.Length > 0)
                {
                    RoleRepository.Update(updateDtos, checkAction, updateFunc);
                }
                await RoleRepository.UnitOfWork.SaveChangesAsync();

                return(new OperationResult(OperationResultType.Success, "保存成功"));
            }
            catch (Exception e)
            {
                return(new OperationResult(OperationResultType.Error, e.Message));
            }
        }
Ejemplo n.º 30
0
 void win_OrganizationSelected(SysOrganization organization)
 {
     txtCodeName.Text = "[" + organization.Code + "]" + organization.Name;
     IDValue          = organization.ID;
     _isUserEdited    = false;
 }