Exemple #1
0
        public override void Add()
        {
            if (Context != null && FocusedEntity != null && Context.CurrentStore != null)
            {
                List <Domain.StoreToWorld> lst = null;
                lst = swController.GetListByStoreId(Context.CurrentStore.ID);

                if (lst.Count == 0)
                {
                    lst = ClientEnvironment.StoreToWorldService.FindAllForStore(Context.CurrentStore.ID);
                    swController.AddList(lst);
                }

                using (FormAssignEmployeeToWorld assignform = new FormAssignEmployeeToWorld())
                {
                    Domain.Employee empl = Context.CurrentEmployee;

                    EmployeeRelation relation = new EmployeeRelation();

                    relation.EmployeeID   = empl.ID;
                    relation.EmployeeName = empl.FullName;
                    relation.WorldID      = 0;

                    if (FocusedEntity != null)
                    {
                        relation.WorldID   = FocusedEntity.WorldID;
                        relation.BeginTime = FocusedEntity.BeginTime;
                        if (relation.BeginTime < DateTime.Today)
                        {
                            relation.BeginTime = DateTime.Today;
                        }
                        relation.EndTime = FocusedEntity.EndTime;
                        if (relation.BeginTime > relation.EndTime)
                        {
                            relation.EndTime = Contract.DateTimeSql.SmallDatetimeMax;
                        }
                    }

                    Context.CurrentRelation = relation;
                    assignform.SetWorldList(swController.GetListByStoreId(Context.CurrentStore.ID));
                    assignform.Entity = Context;



                    if (assignform.ShowDialog() == DialogResult.OK)
                    {
                        LoadEmployeeRelation();

                        if (Context.Relations != null)
                        {
                            Domain.Employee employee = ClientEnvironment.EmployeeService.GetEmployeeByID(empl.ID, DateTime.Now);
                            if (Context.EmployeeList != null && employee != null)
                            {
                                Context.EmployeeList.SetEntity(employee);
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        public List <StoreToWorld> GetStoreWorldList(long storeid)
        {
            List <StoreToWorld> lst = _swController.GetListByStoreId(storeid);

            if (lst.Count == 0)
            {
                lst = ClientEnvironment.StoreToWorldService.FindAllForStore(storeid);
                _swController.AddList(lst);
            }
            return(lst);
        }