Example #1
0
        private void DistributeSalaries(IDepartment currentDepartment, decimal salary, int decreaseIndex)
        {
            decimal currentManagerSalary = salary * (decreaseIndex) / 100;

            foreach (IEmployee currentEmployee in currentDepartment.Employees)
            {
                if (currentEmployee is IManager)
                {
                    currentEmployee.Salary = currentManagerSalary;
                }
                else if (currentEmployee is ICleaningLady || currentEmployee is IChiefTelephoneOfficer)
                {
                    decimal currentCleaningLadySalary = salary * (decreaseIndex - 3) / 100;
                    currentEmployee.Salary = currentCleaningLadySalary;
                }
                else if (currentEmployee is ISalesman)
                {
                    decimal currentSalesmanSalary = salary * (decreaseIndex + 1.5m - 1) / 100;
                    currentEmployee.Salary = currentSalesmanSalary;
                }
                else
                {
                    decimal currentRegularSalary = salary * (decreaseIndex - 1) / 100;
                    currentEmployee.Salary = currentRegularSalary;
                }
            }

            foreach (IDepartment subDepartment in currentDepartment.SubDepartments)
            {
                DistributeSalaries(subDepartment, salary, decreaseIndex - 1);
            }
        }
        public QueryableCollectionsTests()
        {
            var connectionString = ConnectionString + "StoreName=SimpleCollectionFilter_" + DateTime.UtcNow.Ticks;
            _context = new MyEntityContext(connectionString);
            var gardening = _context.Skills.Create();
            gardening.Name = "Gardening";
            var painting = _context.Skills.Create();
            painting.Name = "Painting";
            var carpentry = _context.Skills.Create();
            carpentry.Name = "Carpentry";

            _dept = _context.Departments.Create();
            _dept.Name = "Department99";
            var andy = _context.Persons.Create();
            andy.Name = "Andy";
            andy.Skills.Add(gardening);
            andy.Skills.Add(painting);
            andy.Skills.Add(carpentry);

            var arnold = _context.Persons.Create();
            arnold.Name = "Arnold";
            arnold.Skills.Add(painting);

            var bert = _context.Persons.Create();
            bert.Name = "Bert";
            _dept.Persons.Add(andy);
            _dept.Persons.Add(bert);
            _context.SaveChanges();
        }
        public bool Delete(IDepartment department)
        {
            var departmentId = department.Id;
            foreach (var employee in _employeeService.GetByDepartmentId(departmentId))
                _employeeService.DeleteEmployee(employee.Id);

            return _departmentRepository.DeleteDepartment(departmentId);
        }
        /// <summary>
        /// Adds the department.
        /// </summary>
        /// <param name="department">The department.</param>
        public void AddDepartment(IDepartment department)
        {
            Argument.IsNotNull("department", department);

            lock (_departments)
            {
                _departments.Add(department);
            }
        }
        /// <summary>
        /// Deletes the department.
        /// </summary>
        /// <param name="department">The department.</param>
        public void DeleteDepartment(IDepartment department)
        {
            Argument.IsNotNull("department", department);

            lock (_departments)
            {
                _departments.Remove(department);
            }
        }
Example #6
0
 public TreeNode FindNode(IDepartment department, TreeNode rootNode)
 {
     foreach (TreeNode node in rootNode.Nodes)
     {
         if (node.Tag.Equals(department)) return node;
         TreeNode next = FindNode(department, node);
         if (next != null) return next;
     }
     return null;
 }
 public bool Update(IDepartment department)
 {
     var repDepartment = _departmentRepository.GetDepartmentById(department.Id);
     if (repDepartment == null)
     {
         return false;
     }
     else
     {
         repDepartment.Name = department.Name;
         repDepartment.ParentId = department.ParentDepartmentId;
         return _departmentRepository.UpdateDepartment(repDepartment);
     }
 }
Example #8
0
        public async Task Add_Department()
        {
            IDepartment dep = GetInMemoryRepository();
            Department  o   = new Department()
            {
                Id           = 1,
                Name         = "Lit",
                CreatedDate  = DateTime.UtcNow,
                ModifiedDate = DateTime.UtcNow
            };

            dep.Add(o);
            await dep.SaveChangesAsync();

            int x = await dep.CountDepartmentAsync();

            Assert.Equal(1, x);
        }
Example #9
0
        public override IList <IUser> GetUsers(SysProcessParticipant part, SysProcessInstance pi, SysActivityInstance ai)
        {
            IDepartment department = this.GetDepartment(part, pi, ai);

            if (department == null)
            {
                throw new ApplicationException("在参与人中未找到指定部门");
            }
            IUser departmentManager = base._orgProxy.GetDepartmentManager(department.Department_ID);

            if (departmentManager == null)
            {
                throw new ApplicationException("在指定部门中未找到指定部门经理");
            }
            return(new List <IUser> {
                departmentManager
            });
        }
Example #10
0
        public IDepartment CreateDepartment()
        {
            IDepartment department = null;

            switch (dbType)
            {
            case "SqlServer": department = new SqlServerDepartment();
                break;

            case "Access": department = new AccessDepartment();
                break;

            default:
                break;
            }

            return(department);
        }
Example #11
0
        public bool updateDepartment(string depID, string name, string hodID, string newDepID, string newName, string newhodID)
        {
            IDepartment Dep = this.DepartmentList.FirstOrDefault(dep => dep.DepartmentID == depID.Trim());

            if (hodID is null)
            {
                IStaff hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(newhodID));
                this.StaffList.Remove(hod);
                hod.isHOD = 1;
                this.StaffList.Add(hod);
                DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD);
                DepartmentList.Remove(Dep);
                Dep.HeadOfDepartmentID = newhodID;
                DepartmentList.Add(Dep);
                DataLayer.UpdateDepartmentInDB(hod, Dep, depID);
            }
            else
            {
                IStaff hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(hodID));
                // Remove department and hod from their lists //
                this.DepartmentList.Remove(Dep);
                this.StaffList.Remove(hod);

                // Add them back with changes //
                hod.isHOD = 0;
                DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD);
                this.StaffList.Add(hod);

                hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(newhodID));
                this.StaffList.Remove(hod);
                hod.isHOD = 1;
                this.StaffList.Add(hod);
                DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD);

                Dep.DepartmentID       = newDepID;
                Dep.HeadOfDepartmentID = newhodID;
                Dep.Name = newName;
                this.DepartmentList.Add(Dep);

                DataLayer.UpdateDepartmentInDB(hod, Dep, depID);
            }

            return(true);
        }
Example #12
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            IFactory factory = new AccessFactory();

            IUser user = factory.GetUserObj();

            IDepartment department = factory.GetDepartmentObj();

            user.AddUser(new User());

            user.GetUserById(1);

            department.AddDepartment(new Department());

            department.GetById(1);

            Console.ReadKey();
        }
Example #13
0
 /// <summary>
 /// Constructor to Inject Service Dependecies
 /// </summary>
 /// <param name="agent"></param>
 /// <param name="department"></param>
 /// <param name="emailNotification"></param>
 /// <param name="membership"></param>
 /// <param name="membershipUpgrade"></param>
 /// <param name="order"></param>
 /// <param name="packingSlip"></param>
 /// <param name="packingSlipRoyaltyDep"></param>
 /// <param name="payment"></param>
 /// <param name="product"></param>
 /// <param name="shipping"></param>
 /// <param name="user"></param>
 /// <param name="videoSubscription"></param>
 public PaymentController(IAgent agent, IDepartment department, IEmailNotification emailNotification,
                          IMembership membership, IMembershipUpgrade membershipUpgrade, IOrder order, IPackingSlip packingSlip,
                          IPackingSlipRoyaltyDep packingSlipRoyaltyDep, IPayment payment, IProduct product, IShipping shipping,
                          IUser user, IVideoSubscription videoSubscription)
 {
     _agent                 = agent;
     _department            = department;
     _emailNotification     = emailNotification;
     _membership            = membership;
     _membershipUpgrade     = membershipUpgrade;
     _order                 = order;
     _packingSlip           = packingSlip;
     _packingSlipRoyaltyDep = packingSlipRoyaltyDep;
     _payment               = payment;
     _product               = product;
     _shipping              = shipping;
     _user = user;
     _videoSubscription = videoSubscription;
 }
Example #14
0
        public static IDepartment CreateDepartment()
        {
            IDepartment result = null;

            switch (db)
            {
            case "Sqlserver":
                result = new SqlserverDepartment();
                break;

            case "Access":
                result = new AccessDepartment();
                break;

            default:
                break;
            }
            return(result);
        }
Example #15
0
        internal void CalculateNewHealth(IDepartment department)
        {
            var rng      = new Random();
            int rngValue = rng.Next(1, 101);

            if (SicknessLevel == 0 || SicknessLevel == 10)
            {
                return;
            }

            if (rngValue <= department.Risk)
            {
                SicknessLevel++;
            }
            else if (rngValue >= 100 - department.Chance)
            {
                SicknessLevel--;
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            User       user = new User();
            Department dept = new Department();

            //AbstractFactory factory = new SqlServerFactory();
            IFactory factory = new AccessFactory();
            IUser    iu      = factory.CreateUser();

            iu.Insert(user);
            iu.GetUser(1);

            IDepartment id = factory.CreateDepartment();

            id.Insert(dept);
            id.GetDepartment(1);

            Console.Read();
        }
Example #17
0
        static void Main(string[] args)
        {
            User       user = new User();
            Department dept = new Department();

            // 直接得到实际的数据库访问实例,而不存在任何依赖
            IUser iu = DataAccess.CreateUser();

            iu.Insert(user);
            iu.GetUser(1);

            // 直接得到实际的数据库访问实例,而不存在任何依赖
            IDepartment id = DataAccess.CreateDepartment();

            id.Insert(dept);
            id.GetDepartment(1);

            Console.Read();
        }
Example #18
0
        public void UpdateDepartmentTest()
        {
            short       ID         = 1;
            IDepartment department = _dataContext.GetAllDepartments().First(d => d.DepartmentID == 1);

            string testDepartmentName = "testDepartmentName";

            Assert.AreNotEqual(department.Name, testDepartmentName);

            Department testDepartment = new Department(department.DepartmentID, testDepartmentName,
                                                       department.GroupName,
                                                       department.ModifiedDate);

            _dataContext.UpdateDepartment(ID, testDepartment);

            IDepartment updatedDepartment = _dataContext.GetAllDepartments().First(d => d.DepartmentID == 1);

            Assert.AreNotEqual(department, updatedDepartment);
            Assert.AreEqual(testDepartmentName, updatedDepartment.Name);
        }
Example #19
0
        static void Main(string[] args)
        {
            User       user = new User();
            Department dept = new Department();
            // 需要替换为另外一个只需要修改这一句就行了
            // IFactory factory = new AccessFactory();
            IFactory factory = new SqlServerFactry();

            IUser iu = factory.CreateUser();

            iu.Insert(user);
            iu.GetUser(1);

            IDepartment idept = factory.CreateDepartment();

            idept.Insert(dept);
            idept.GetDepartment(1);

            Console.Read();
        }
Example #20
0
        static void Main(string[] args)
        {
            //有兩張資料表 Access跟sqlserver資料庫可以替換
            User       user = new User();
            Department dept = new Department();
            //法1 寫工廠
            //IFactory factory = new AccessFactory();
            IFactory factory = new SqlserverFactory();
            //法2 利用DataAccess 建立實體
            IUser iu = DataAccess.CreateUser(); //factory.CreateUser();

            iu.Insert(user);
            iu.GetUser(1);

            IDepartment ip = DataAccess.CreateDepartment();//factory.CreateDepartment();

            ip.Insert(dept);
            ip.GetDepartment(1);

            Console.ReadKey();
        }
Example #21
0
        private static void Main(string[] args)
        {
            //IFactory factory = new SqlServerFactory();
            IFactory factory = new AccessFactory();

            IUser iu = DataAccess.CreateUser();

            User user = new User();

            iu.Insert(user);
            iu.GetUser(1);

            IDepartment id = DataAccess.CreateDepartment();

            Department department = new Department();

            id.Insert(department);
            id.GetDepartment(1);

            Console.ReadKey(true);
        }
Example #22
0
        static void Main(string[] args)
        {
            User       user       = new User();
            Department department = new Department();

            IFactory factory = new AccessFactory();

            IUser iu = factory.createUser();

            user.Name = "nameA";
            iu.Insert(user);
            iu.getUser(5);

            IDepartment id = factory.createDepartment();

            department.Name = "nameB";
            id.Insert(department);
            id.getDepartment(7);

            Console.Read();
        }
Example #23
0
        private IList <string> GetEmails(IOwner owner)
        {
            IList <string> emails = new List <string>();

            if (owner.Type == OwnerType.Department)
            {
                IDepartment        d       = EntityFactory.GetById <IDepartment>(owner.Id.ToString());
                IList <IOwnerJoin> members = d.GetMembers();
                foreach (IOwnerJoin oj in members)
                {
                    if (oj.Child.Type == OwnerType.User)
                    {
                        if (!String.IsNullOrEmpty(oj.Child.User.UserInfo.Email))
                        {
                            emails.Add(oj.Child.User.UserInfo.Email);
                        }
                    }
                }
            }
            return(emails);
        }
Example #24
0
    public IDepartment[] DepartmentList()
    {
        List <IDepartment> iList = new List <IDepartment>();
        List <Department>  list  = udlc.getDepartmentList();


        foreach (Department dept in list)
        {
            IDepartment idept = new IDepartment();
            idept.DeptCode          = dept.DeptCode;
            idept.DeptName          = dept.DeptName;
            idept.CollectionPoint   = dept.CollectionPoint;
            idept.DeptContactNo     = dept.DeptContactNo;
            idept.DeptCollectionPin = (int)dept.DeptCollectionPin;
            idept.DeptRepCode       = dept.DeptRep;
            idept.DeptRepName       = dept.Employee.EmployeeName;
            iList.Add(idept);
        }

        return(iList.ToArray <IDepartment>());
    }
        public int DeleteDepartment(IDepartment idepartment)
        {
            Database  db         = DatabaseFactory.CreateDatabase("SUPPORTTICKETS");
            string    sqlCommand = "proDepartmentDelete";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@ID_Department", DbType.Int64, idepartment.MasterID);
            db.AddInParameter(dbCommand, "@CancelledUser", DbType.Int64, idepartment.UserCode);
            db.AddInParameter(dbCommand, "@UserCode", DbType.Int64, idepartment.UserCode);
            db.AddInParameter(dbCommand, "@FK_Company", DbType.Int64, idepartment.FK_Company);

            try
            {
                return(Convert.ToInt32(db.ExecuteScalar(dbCommand)));
            }
            catch (SqlException e)
            {
                //UpdateErrorLog(iProduct, e);
                throw e;
            }
        }
Example #26
0
 protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Up")
     {
         IDepartment entity = Department.FindByID(Convert.ToInt32(e.CommandArgument));
         if (entity != null)
         {
             entity.Up();
             gv.DataBind();
         }
     }
     else if (e.CommandName == "Down")
     {
         IDepartment entity = Department.FindByID(Convert.ToInt32(e.CommandArgument));
         if (entity != null)
         {
             entity.Down();
             gv.DataBind();
         }
     }
 }
Example #27
0
        static void Main(string[] args)
        {
            USer       uSer       = new USer();
            Department department = new Department();
            //Ifactory factory = new sqlServerFactory();

            //IUser iu = factory.CreateUser();

            IUser iu = DataAccess.CreateUser();

            iu.Insert(uSer);
            iu.GetUser(1);

            //IDepartment id = factory.CreatDepartment();

            IDepartment id = DataAccess.CreateDepartment();

            id.Insert(department);
            id.GetDepartment(1);

            Console.Read();
        }
        public override IList <IUser> GetUsers(SysProcessParticipant part, SysProcessInstance pi, SysActivityInstance ai)
        {
            if (part == null)
            {
                throw new ArgumentNullException("part");
            }
            if (part.Param_Participant == null)
            {
                throw new ApplicationException("部门角色参与人未指定基于参与人");
            }
            if (!part.Param_RoleId.HasValue)
            {
                throw new ApplicationException("未指定参与人的角色");
            }
            SysProcessParticipant participant = part.Param_Participant;
            IDepartment           department  = null;

            if (participant.FunctionType == 3)
            {
                department = new SpecDepartmentFunc(base._context).GetDepartment(participant, pi, ai);
            }
            else if (participant.FunctionType == 2)
            {
                department = new StartDepartmentFunc(base._context).GetDepartment(pi);
            }
            else if (participant.FunctionType == 5)
            {
                department = new ParentDepartmentFunc(base._context).GetDepartment(participant, pi, ai);
            }
            else
            {
                if (participant.FunctionType != 10)
                {
                    throw new ApplicationException("在DepartmentRoleFunc的GetUsers中FunctionType有误!");
                }
                department = new SpecialLevelParentDeptFunc(base._context).GetDepartment(participant, pi, ai);
            }
            return(base._orgProxy.GetDepartmentRoleUsers(department.Department_ID, part.Param_RoleId.Value));
        }
Example #29
0
 protected virtual IList <IUser> GetMembers(IDepartment department)
 {
     if (string.IsNullOrEmpty(RoleName) || RoleName == SysConfig.DefaultUserRole)
     {
         return(department.Member.ToList());
     }
     else
     {
         IList <IUser> result = new List <IUser>();
         try
         {
             IRole role = department.Roles.FirstOrDefault(r => r.RoleType.Name == RoleName);
             if (role != null)
             {
                 result = role.Members.ToList();
             }
             if (ShowDeptType == ShowDepartmentType.RoleDepartment)
             {
                 foreach (var u in result)
                 {
                     u.DepartmentId = department.Id;
                 }
             }
         }
         catch (InvalidOperationException invalidEx)
         {
             throw new InvalidOperationException(String.Format("获取角色{0}的成员时出错:{1}。", this.RoleName, invalidEx.Message), invalidEx);
         }
         catch (Exception ex)
         {
             throw new Exception(String.Format("获取角色{0}的成员时出错:{1}。", this.RoleName, ex.Message), ex);
         }
         if (result.Count == 0 && department.Parent != null && AutoResolvParent)
         {
             return(GetMembers(department.Parent));
         }
         return(result);
     }
 }
Example #30
0
        static void Main(string[] args)
        {
            User       user = new User();
            Department dept = new Department();

            // IFactory factory = new SqlServerFactory();
            IFactory factory = new AccessFactory();
            IUser    iu      = factory.CreateUser();

            iu.Insert(user);
            iu.GetUser(1);

            IDepartment id = factory.CreateDepartment();

            id.Insert(dept);
            id.GetDepartment(1);

            Console.WriteLine(ConfigurationSettings.AppSettings["DB"]);


            Console.ReadKey();
        }
Example #31
0
        public void SetUp()
        {
            ctx = new Context(typeof(IDatabase));

            using (var ws = ctx.OpenWorkspace <IDatabase>(IsolationLevel.Exclusive))
            {
                IDatabase database = ws.Data;

                database.Departments = ws.New <ICollection <IDepartment> >();
                database.Students    = ws.New <ICollection <IStudent> >();
                database.University  = ws.New <IUniversity>();

                database.University.Name = "1st University";

                IDepartment historyDepartment = ws.New <IDepartment>();
                historyDepartment.Name = "History";
                IDepartment archaeologyDepartment = ws.New <IDepartment>();
                archaeologyDepartment.Name          = "Archaeology";
                archaeologyDepartment.SubDepartment = ws.New <IDepartment>();

                historyDepartment.SubDepartment = archaeologyDepartment;

                database.Departments.Add(historyDepartment);

                ICollection <IDepartment> tempDepartments = ws.New <ICollection <IDepartment> >();
                tempDepartments.Add(historyDepartment);

                database.University.Departments = tempDepartments;

                IStudent student = ws.New <IStudent>();
                student.StudentID  = 12345;
                student.Name       = "John Connor";
                student.Department = archaeologyDepartment;

                database.Students.Add(student);

                ws.Commit();
            }
        }
Example #32
0
        static void Main(string[] args)
        {
            //抽象工厂模式

            User user = new User();

            IFactory factory = new SqlserverFactory();
            Iuser    ur      = factory.CreateUser();

            ur.Inser(user);

            ur.GetUser("");

            factory = new AccessFactory();

            ur = factory.CreateUser();

            ur.Inser(user);

            ur.GetUser("");


            IDepartment dt = factory.CreateDepartment();

            dt.Insert(new Department()
            {
                Name = "马化腾", ID = "1234567"
            });
            dt.getDepartment("");


            ur = DataAccess.CreateUser();
            ur.Inser(new User()
            {
                Id = "654789", Name = "李彦宏"
            });
            ur.GetUser("");
            Console.Read();
        }
Example #33
0
        public void SetUp()
        {
            ctx = new Context(typeof(IDatabase));

            using (var ws = ctx.OpenWorkspace <IDatabase>(IsolationLevel.Exclusive))
            {
                IDatabase database = ws.Data;

                IPerson customer = ws.New <IPerson>();
                customer.Age  = 20;
                customer.Name = "Indiana Jones Jr.";
                IPerson custFather = ws.New <IPerson>();
                custFather.Age  = 50;
                custFather.Name = "Indiana Jones";
                IPerson custMother = ws.New <IPerson>();
                custMother.Age  = 45;
                custMother.Name = "Anna Mary Jones";
                customer.Father = custFather;
                customer.Mother = custMother;
                database.Person = customer;

                IDepartment historyDepartment = ws.New <IDepartment>();
                historyDepartment.Name = "History";
                IDepartment archaeologyDepartment = ws.New <IDepartment>();
                archaeologyDepartment.Name      = "Archaeology";
                historyDepartment.SubDepartment = archaeologyDepartment;
                database.Department             = historyDepartment;

                IEmployee manager = ws.New <IEmployee>();
                manager.Name = "Manager 1";
                IEmployee worker = ws.New <IEmployee>();
                worker.Name       = "Worker 1";
                worker.Manager    = manager;
                database.Employee = worker;

                ws.Commit();
            }
        }
Example #34
0
        public bool addDepartment(string depID, string name, string hodID)
        {
            IDepartment duplicateDep = this.DepartmentList.FirstOrDefault(dep => dep.DepartmentID == depID.Trim());

            if (duplicateDep != null)
            {
                return(false);
            }
            else
            {
                IStaff newHOD = null;
                if (hodID.Equals("null"))
                {
                    newHOD = null;
                }

                else
                {
                    newHOD = this.StaffList.FirstOrDefault(hod => hod.UserID == hodID.Trim());
                    this.StaffList.Remove(newHOD);
                    newHOD.isHOD = 1;
                    this.StaffList.Add(newHOD);
                    DataLayer.updateStaffMemberToOrFromHODinDB(newHOD, newHOD.isHOD);
                }

                try
                {
                    IDepartment theDep = UserFactory.GetDepartment(depID, name, hodID);
                    DepartmentList.Add(theDep);
                    DataLayer.addNewDepartmentToDB(theDep);
                    return(true);
                }
                catch (System.Exception excep)
                {
                    return(false);
                }
            }
        }
Example #35
0
        protected virtual IDepartment GetBaseDepartment(IWorkflowContext context)
        {
            IDepartment baseDept = null;

            if (IsParallel)
            {
                if (context.CurrentTask == null || string.IsNullOrEmpty(context.CurrentTask.ParallelInfo))
                {
                    throw new ArgumentNullException("并行内求解需要有并行信息keyInfo");
                }
                baseDept = DBContext <IDepartment> .Instance.Get(context.CurrentTask.ParallelInfo);
            }
            if (baseDept == null && !string.IsNullOrEmpty(DeptName))
            {
                baseDept = DBContext <IDepartment> .Instance.FirstOrDefault(o => o.Name.Equals(DeptName, StringComparison.OrdinalIgnoreCase));
            }
            if (baseDept == null)
            {
                if (BaseActor == null)
                {
                    BaseActor = new FlowActor()
                    {
                        FlowUser = FlowActorType.Creator
                    };
                }
                BaseActor.Owner = Owner;
                var users = BaseActor.Resolve(context);
                if (users.Count > 0)
                {
                    baseDept = users.First().Department;
                }
            }
            if (baseDept == null)
            {
                throw new Exception("基准部门求解失败!");
            }
            return(baseDept);
        }
Example #36
0
        public static void OnSaving(IWorkHistory wh, IObjectSpace obspace)
        {
            //Imp Company
            if (!String.IsNullOrEmpty(wh.ImpCompany))
            {
                ICompany company = obspace.FindObject <ICompany>(new BinaryOperator("TitleOfCompany", wh.ImpCompany));

                wh.Company = company;
            }

            // Imp Department
            if (!String.IsNullOrEmpty(wh.ImpDepartment))
            {
                IDepartment department = obspace.FindObject <IDepartment>(new BinaryOperator("TitleOfDepartment", wh.ImpDepartment));

                wh.Department = department;
            }

            // Imp Position

            if (!String.IsNullOrEmpty(wh.ImpPosition))
            {
                IPosition position = obspace.FindObject <IPosition>(new BinaryOperator("TitleOfPosition", wh.ImpPosition));

                wh.Position = position;
            }


            // Imp ID Number


            if (!String.IsNullOrEmpty(wh.ImpIDNumber))
            {
                IEmployee employee = obspace.FindObject <IEmployee>(new BinaryOperator("IDNumber", wh.ImpIDNumber));

                wh.Employee = employee;
            }
        }
Example #37
0
        static void Main(string[] args)
        {
            User       user = new User(1, "YoChen");
            Department dept = new Department(1, "開發部");

            //IFactory factory = new SqlServerFactory();
            //IFactory factory = new AccessFactory();
            //IUser userServer = factory.CreateUser();
            //IDepartment deptServer = factory.CreateDepartment();

            IUser       iuser = DataAccess.CreateUser();
            IDepartment idept = DataAccess.CreateDepartment();

            iuser.Insert(user);
            iuser.GetUser(1);

            Console.WriteLine();

            idept.Insert(dept);
            idept.GetDepartment(1);

            Console.ReadLine();
        }
Example #38
0
 public Inspector( string name, IDepartment department, ManagementStyle managementStyle )
     : base(name)
 {
     Department = department;
     ManagementStyle = managementStyle;
 }
Example #39
0
        protected static bool CodeIsValid(IObjectSpace os, XPClassInfo classInfo, IDepartment department, String code)
        {
            var reg = DBNumerator.GetNumerator(os, classInfo, department);

            var regexMask = DBNumerator.GetDevexpressRegex(reg);
            if (String.IsNullOrEmpty(regexMask))
            {
                return true;
            }
            var regex = new Regex(regexMask);

            return regex.IsMatch(code);
        }
Example #40
0
 protected static bool CodeIsValid(IObjectSpace os, ITypeInfo typeInfo, IDepartment department, String code)
 {
     return CodeIsValid(os, XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary.GetClassInfo(typeInfo.Type), department, code);
 }
Example #41
0
 public virtual IGovernment AddDepartment( IDepartment department )
 {
     Departments.Add( department );
     return this;
 }
Example #42
0
 public static IList<IPatient> Get_RegisteredPatient(IDepartment department, IObjectSpace objectSpace)
 {
     var criteria = CriteriaOperator.Parse("[Department] = ?", department);
     return objectSpace.GetObjects<IPatient>(criteria);
 }
Example #43
0
 public static IEmployee NewEmployee(this IEntitySession session, string name, string jobTitle, IEmployee reportsTo = null, IDepartment department = null)
 {
     var emp = session.NewEntity<IEmployee>();
       emp.Name = name;
       emp.JobTitle = jobTitle;
       emp.ReportsTo = reportsTo;
       emp.Department = department;
       return emp;
 }
Example #44
0
 public HomeController(IPerson person,IDepartment depart)
 {
     this.person = person;
     this.depart = depart;
 }
Example #45
0
 public void Clean(IDepartment departmentToBeCleaned)
 {
     throw new NotImplementedException();
 }
Example #46
0
 public static DBNumerator GetNumerator(IObjectSpace os, ITypeInfo typeInfo, IDepartment department)
 {
     return GetNumerator(os, XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary.GetClassInfo(typeInfo.Type), department);
 }
Example #47
0
        public static DBNumerator GetNumerator(IObjectSpace os, XPClassInfo classInfo, IDepartment department)
        {
            if (os == null)
            {
                throw new InvalidOperationException("Missing session");
            }
            if (classInfo == null)
            {
                throw new InvalidOperationException("Missing class type");
            }
            DBNumerator reg = null;
            while ((classInfo != null ? classInfo.IsPersistent : false) && reg == null)
            {
                reg = os.FindObject<DBNumerator>(CriteriaOperator.Parse(/*"TargetType = ? and Department = ?"*/"TargetType = ?", classInfo.ClassType, department));

                if (reg == null)
                {
                    reg = os.FindObject<DBNumerator>(CriteriaOperator.Parse(/*"TargetType = ? and Department is null"*/"TargetType = ?", classInfo.ClassType));
                }
                classInfo = classInfo.BaseClass;
            }

            if (reg == null)
            {
                reg = os.FindObject<DBNumerator>(CriteriaOperator.Parse(/*"TargetType = ? and Department is null"*/"TargetType = ?", typeof(ISerialDataObject)));
            }

            return reg;
        }
Example #48
0
        //A help method which displays the department tree
        private void DFS(IDepartment department, int index)
        {
            Console.WriteLine("{0}->{1}", new string(' ', index), department.Name);

            foreach (IDepartment subDepartment in department.SubDepartments)
            {
                DFS(subDepartment, index + 1);
            }
        }
Example #49
0
        public static void OnDeleting(IDepartment department, IObjectSpace objectSpace)
        {
            if (department.allowTodel == false)
            {
                throw new UserFriendlyException(DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions", "SecuredObjectDelAttempt"));
            }
            var employee = Get_Employees(department, objectSpace);
            if (employee != null)
            {
                if (employee.Count>0)
                {
                    throw new UserFriendlyException(DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Messages", "RelatedObjectsDelWarning"));
                }
            }

            var patient = Get_RegisteredPatient(department, objectSpace);
            if (patient != null)
            {
                if (patient.Count > 0)
                {
                    throw new UserFriendlyException(DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Messages", "RelatedObjectsDelWarning"));
                }
            }

            var examination = Get_RegisteredExamination(department, objectSpace);
            if (examination != null)
            {
                if (examination.Count > 0)
                {
                    throw new UserFriendlyException(DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Messages", "RelatedObjectsDelWarning"));
                }
            }
        }
Example #50
0
 public void AddDepartment(IDepartment departmentToBeAdded)
 {
     this.departments.Add(departmentToBeAdded);
 }
Example #51
0
 public static void AfterConstruction(IDepartment department, IObjectSpace objectSpace)
 {
     department.allowTodel = true;
     var organization = objectSpace.FindObject<IOrganization>(null);
     if (organization != null)
     {
         department.Organization = organization;
     }
 }
Example #52
0
 public Drone( string name, IDepartment department, ManagementStyle managementStyle )
     : base(name)
 {
     Department = department;
     ManagementStyle = managementStyle;
 }
Example #53
0
 public static IList<Employee> Get_Employees(IDepartment department, IObjectSpace objectSpace)
 {
     var criteria = CriteriaOperator.Parse("[Department] = ?", department);
     return objectSpace.GetObjects<Employee>(criteria);
 }
Example #54
0
 public void SetDepartment(IDepartment hospital)
 {
     _department = hospital;
 }
Example #55
0
 public PayCommand(IDepartment department)
 {
     _department = department;
 }
Example #56
0
 private TreeNode CreateNode(IDepartment department)
 {
     var treeNode = new TreeNode(department.Name);
     treeNode.Tag = department;
     foreach (var subDepartment in _departmentService.GetByParentId(department.Id))
     {
         treeNode.Nodes.Add(CreateNode(subDepartment));
     }
     return treeNode;
 }