public ProjectResponsibleWindowViewModel(ChildWindow aChileWindow, ObservableCollection<DepartmentEntity> aDepartmentEntity, ProjectResponsibleEntity aProjectResponsibleEntity)
        {
            this.childWindow = aChileWindow;
            this.ProjectResponsibleEntity = aProjectResponsibleEntity;
            this.DepartmentList = aDepartmentEntity;

            Title = "生产令号:" + aProjectResponsibleEntity.ManufactureNumber;
            OnOK = new DelegateCommand(OnOKCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
        }
 public ProjectResponsibleWindow(ObservableCollection<DepartmentEntity> aDepartmentEntityList, ProjectResponsibleEntity aProjectResponsibleEntity)
 {
     InitializeComponent();
     this.DataContext = new ProjectResponsibleWindowViewModel(this, aDepartmentEntityList, aProjectResponsibleEntity);
 }
        void OnOkCommand()
        {
            if (linkType == LinkType.LinkProject)
            {
                foreach (ProjectResponsibleEntity lProjectResponsibleEntity in ProjectResponsibleEntityList)
                {
                    foreach (ProjectEntity lProjectEntity in ProjectLinkEntityList)
                    {
                        bool lHasAdd = false;
                        foreach (ProjectResponsibleEntity lProjectResponsibleEntityCheck in  ProjectResponsibleEntityALLList)
                        {
                            if (lProjectResponsibleEntityCheck.ManufactureNumber == lProjectEntity.ManufactureNumber
                                && lProjectResponsibleEntityCheck.DepartmentID == lProjectResponsibleEntity.DepartmentID
                                && lProjectResponsibleEntityCheck.ResponsiblePersionName == lProjectResponsibleEntity.ResponsiblePersionName)
                            {
                                lHasAdd = true;
                                break;
                            }
                        }

                        if (lHasAdd)
                        {
                            continue;
                        }
                        ProjectResponsibleEntity lProjectResponseibleEntity = new ProjectResponsibleEntity();
                        lProjectResponseibleEntity.ProjectResponsible = new ProductManager.Web.Model.project_responsible();

                        lProjectResponseibleEntity.ManufactureNumber = lProjectEntity.ManufactureNumber;
                        lProjectResponseibleEntity.DepartmentID = lProjectResponsibleEntity.DepartmentID;
                        lProjectResponseibleEntity.ResponsiblePersionName = lProjectResponsibleEntity.ResponsiblePersionName;
                        lProjectResponseibleEntity.Descript = lProjectResponsibleEntity.Descript;

                        lProjectResponseibleEntity.DUpdate();
                        ProductDomainContext.project_responsibles.Add(lProjectResponseibleEntity.ProjectResponsible);
                    }
                }

            }
            else if (linkType == LinkType.LinkPerson)
            {
                if (selectProjectResponsibleEntity != null)
                {
                    LinkResponsePersonWindow lLinkResponsePersonWindow = childWidow as LinkResponsePersonWindow;
                    foreach (ProjectResponsibleEntity lSProjectResponsibleEntity in lLinkResponsePersonWindow.projectPersonDataGrid.SelectedItems)
                    {
                        ProjectResponsibleEntity lProjectResponsibleEntity = lSProjectResponsibleEntity;
                        foreach (ProjectEntity lProjectEntity in ProjectLinkEntityList)
                        {
                            bool lHasAdd = false;
                            foreach (ProjectResponsibleEntity lProjectResponsibleEntityCheck in ProjectResponsibleEntityALLList)
                            {
                                if (lProjectResponsibleEntityCheck.ManufactureNumber == lProjectEntity.ManufactureNumber
                                    && lProjectResponsibleEntityCheck.DepartmentID == lProjectResponsibleEntity.DepartmentID
                                    && lProjectResponsibleEntityCheck.ResponsiblePersionName == lProjectResponsibleEntity.ResponsiblePersionName)
                                {
                                    lHasAdd = true;
                                    break;
                                }
                            }

                            if (lHasAdd)
                            {
                                continue;
                            }

                            ProjectResponsibleEntity lProjectResponseibleEntity = new ProjectResponsibleEntity();
                            lProjectResponseibleEntity.ProjectResponsible = new ProductManager.Web.Model.project_responsible();

                            lProjectResponseibleEntity.ManufactureNumber = lProjectEntity.ManufactureNumber;
                            lProjectResponseibleEntity.DepartmentID = lProjectResponsibleEntity.DepartmentID;
                            lProjectResponseibleEntity.ResponsiblePersionName = lProjectResponsibleEntity.ResponsiblePersionName;
                            lProjectResponseibleEntity.Descript = lProjectResponsibleEntity.Descript;

                            lProjectResponseibleEntity.DUpdate();
                            ProductDomainContext.project_responsibles.Add(lProjectResponseibleEntity.ProjectResponsible);
                        }
                    }
                }
            }

            childWidow.DialogResult = true;
        }
        private void LoadOperationProjectResponseCompleted(LoadOperation<ProductManager.Web.Model.project_responsible> aLoadOperation)
        {
            ProjectResponsibleEntityList.Clear();
            foreach (ProductManager.Web.Model.project_responsible projectResponsible in aLoadOperation.Entities)
            {
                ProjectResponsibleEntity projectResponsibleEntity = new ProjectResponsibleEntity();
                projectResponsibleEntity.ProjectResponsible = projectResponsible;
                projectResponsibleEntity.Update();

                DepartmentEntity lDepartmentEntityTemp;
                if (DepartmentEntityDictionary.TryGetValue(projectResponsibleEntity.DepartmentID, out lDepartmentEntityTemp))
                {
                    projectResponsibleEntity.DepartmentName = lDepartmentEntityTemp.DepartmentName;
                }

                if (projectResponsibleEntity.ResponsiblePersionName == null)
                {
                    continue;
                }

                UserEntity lUserEntityTemp;
                if (UserEntityDictionary.TryGetValue(projectResponsibleEntity.ResponsiblePersionName, out lUserEntityTemp))
                {
                    projectResponsibleEntity.UserPhoneNumber = lUserEntityTemp.UserPhoneNumber;
                }

                ProjectResponsibleEntityList.Add(projectResponsibleEntity);
            }
        }
        private void loadOperationProjectReponse_Completed(Object sender, EventArgs e)
        {
            ProjectResponsibleEntityALLList.Clear();
            LoadOperation loadOperation = sender as LoadOperation;
            foreach (ProductManager.Web.Model.project_responsible project_responsible in loadOperation.Entities)
            {
                ProjectResponsibleEntity projectResponsibleEntity = new ProjectResponsibleEntity();
                projectResponsibleEntity.ProjectResponsible = project_responsible;
                projectResponsibleEntity.Update();
                ProjectResponsibleEntityALLList.Add(projectResponsibleEntity);
            }

            using (projectView.DeferRefresh())
            {
                projectView.MoveToFirstPage();
            }
        }
 private void OnAddProjectRespCommand()
 {
     AddProjectResponsibleEntity = new ProjectResponsibleEntity();
     AddProjectResponsibleEntity.ManufactureNumber = SelectProjectEntity.ManufactureNumber;
     AddProjectResponsibleEntity.ProjectResponsible = new ProductManager.Web.Model.project_responsible();
     ProjectResponsibleWindow projectResponsibleWindow = new ProjectResponsibleWindow(DepartmemtList, AddProjectResponsibleEntity);
     projectResponsibleWindow.Closed += AddProductResponsibleClosed;
     projectResponsibleWindow.Show();
 }
 private void LoadOperationProjectResponsibleCompleted(LoadOperation<ProductManager.Web.Model.project_responsible> aLoadOperation)
 {
     ProjectResponsibleEntityList.Clear();
     foreach (ProductManager.Web.Model.project_responsible project_responsible in aLoadOperation.Entities)
     {
         ProjectResponsibleEntity projectResponsibleEntity = new ProjectResponsibleEntity();
         projectResponsibleEntity.ProjectResponsible = project_responsible;
         projectResponsibleEntity.Update();
         DepartmentEntity departmentEntity;
         if (DepartmentDictionary.TryGetValue(projectResponsibleEntity.DepartmentID, out departmentEntity))
         {
             projectResponsibleEntity.DepartmentName = departmentEntity.DepartmentName;
         }
         UserEntity userEntity;
         if (projectResponsibleEntity.ResponsiblePersionName != null)
         {
             if (UserEntityDictionaryName.TryGetValue(projectResponsibleEntity.ResponsiblePersionName, out userEntity))
             {
                 projectResponsibleEntity.UserPhoneNumber = userEntity.UserPhoneNumber;
             }
         }
         ProjectResponsibleEntityList.Add(projectResponsibleEntity);
     }
     if (aLoadOperation.TotalEntityCount != -1)
     {
         this.projectResponsibleView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
     }
     UpdateChanged("ProjectResponsibleEntityList");
     this.IsBusy = false;
 }