コード例 #1
0
        public bool delete(String personID, out string message)
        {
            message = "";
            bool issucess = false;

            if (personID == "")
            {
                message = "请选择要删除的用户数据";
            }
            else
            {
                persondao.delete(personID);
                issucess = true;
                message  = "删除成功";
            }
            return(issucess);
        }
コード例 #2
0
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="newUser"></param>
        /// <returns></returns>
        public Status create(CreateUser newUser)
        {
            PersonDAO personDao = Factory.getInstance <PersonDAO>();
            Dictionary <string, object> wherelist = new Dictionary <string, object>();

            PersonVO personVo = new PersonVO();

            personVo.personID         = PersonDAO.getID();
            personVo.personName       = newUser.userName;
            personVo.personDepartment = newUser.userDepartment;
            personVo.personJob        = newUser.userJob;
            //默认密码:"123456"
            personVo.personPassword    = "******";
            personVo.personDescription = newUser.userDescription;
            personVo.personLevel       = newUser.userLevel;

            //如果插入用户失败,返回error
            if (personDao.insert <PersonVO>(personVo) < 0)
            {
                return(Status.NAME_EXIST);
            }

            //如果插入用户角色关联失败,则删除之前添加的数据,并返回error
            Person_RoleDAO person_roleDao = Factory.getInstance <Person_RoleDAO>();

            if (person_roleDao.insert <Person_RoleVO>(
                    new Person_RoleVO
            {
                person_roleID = Person_RoleDAO.getID(),
                personID = personVo.personID,
                roleID = newUser.roleID
            }) < 0)
            {
                personDao.delete(personVo.personID);
                return(Status.NAME_EXIST);
            }

            return(Status.SUCCESS);
        }