Пример #1
0
        /// <summary>
        /// 将人员关联到根节点
        /// </summary>
        /// <param name="RootEnt"></param>
        /// <returns></returns>
        public static int BindUserToRootNode(SysOrganization RootEnt)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                //删除
                string SQL = "delete from SysOrgUser where OrgID='" + RootEnt.ID + "' ";
                Razor.DataHelper.ExecSql(SQL);

                var Arrs = SysUser.FindAll();
                SQL = "insert into SysOrgUser values('{0}','{1}','{2}','{3}','{4}');";
                StringBuilder strb = new StringBuilder();
                //添加
                foreach (var item in Arrs)
                {
                    //SysOrgUser Ent = new SysOrgUser();
                    //Ent.OrgID = RootEnt.ID;
                    //Ent.OrgName = RootEnt.Name;
                    //Ent.UserID = item.ID;
                    //Ent.UserName = item.Name;
                    //Ent.Create();
                    string ExeSql = string.Format(SQL, Guid.NewGuid().ToString(), RootEnt.ID, RootEnt.Name, item.ID, item.Name);
                    strb.Append(ExeSql);
                }
                Razor.DataHelper.ExecSql(strb.ToString());
                trans.VoteCommit();
            }
            return(1);
        }
Пример #2
0
        /// <summary>
        /// 批量删除操作
        /// </summary>
        public static void DoBatchDelete(params object[] args)
        {
            SysOrganization[] tents = SysOrganization.FindAll(Expression.In("ID", args));

            foreach (SysOrganization tent in tents)
            {
                tent.DoDelete();
            }
        }