public ProjectWindowViewModel(ChildWindow aChildWindow, ProjectWindowType aProductWindowType, ProjectEntity aProjectEntity)
        {
            childWindow = aChildWindow;
            ProjectEntity = aProjectEntity;
            if (!String.IsNullOrWhiteSpace(ProjectEntity.ManufactureNumber))
            {
                Title = "生产令号:" + ProjectEntity.ManufactureNumber;
            }
            else
            {
                Title = "添加";
            }

            projectWindowType = aProductWindowType;
            if (projectWindowType == ProjectWindowType.Modify)
            {
                IsModify = true;
                IsAdd = false;
            }
            else if (projectWindowType == ProjectWindowType.ADD)
            {
                IsAdd = true;
                IsModify = true;
            }
            else if (projectWindowType == ProjectWindowType.View)
            {
                IsAdd = false;
                IsModify = false;
            }

            OnOK = new DelegateCommand(OnOKCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
        }
        //private ProjectEntity ProjectEntity;
        public PlanSetRemindDayWindow(ProjectEntity aProjectEntity)
        {
            InitializeComponent();

            //ProjectEntity = aProjectEntity;
            aProjectEntity.StartRemindEdit();
            this.DataContext = aProjectEntity;
        }
 public DeleteProjectWindowViewModel(ChildWindow aChildWindow, ProjectEntity aProjectEntity)
 {
     childWindow = aChildWindow;
     ProjectEntity = aProjectEntity;
     OnOK = new DelegateCommand(OnOKCommand);
     OnCancel = new DelegateCommand(OnCancelCommand);
     Title = "删除生产项目:" + aProjectEntity.ProjectName;
 }
        public SetContractNumberWindowViewModel(ChildWindow aChileWindow, ProjectEntity aProjectEntity)
        {
            childWindow = aChileWindow;
            ProjectEntity = aProjectEntity;

            OnOK = new DelegateCommand(OnOKCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
        }
        public PlanListHistoryWindow(string aTitle, ObservableCollection<PlanListViewModel> aPlanListViewModelList,
            PlanExtraEntity aPlanExtraEntity, PlanTraceViewModel aPlanTraceViewModel, ProjectEntity aProjectEntity,
            string aLastPlanVersiontId)
        {
            InitializeComponent();
            this.Title = aTitle;
            this.planListViewModelList = aPlanListViewModelList;
            this.planExtraEntity = aPlanExtraEntity;
            this.PlanTraceViewModel = aPlanTraceViewModel;
            this.projectEntity = aProjectEntity;
            this.versionComboBox.ItemsSource = projectEntity.PlanVersionDictionary;
            this.versionComboBox.IsEnabled = projectEntity.HasHistory;
            this.versionComboBox.SelectedValuePath = "Key";
            this.versionComboBox.DisplayMemberPath = "Key";
            this.versionComboBox.SelectedValue = aLastPlanVersiontId;
            this.LastPlanVersiontId = aLastPlanVersiontId;
            this.SelectVersionId = aLastPlanVersiontId;

            if (null == aPlanExtraEntity)
            {
                this.planListTabControl.Margin = new Thickness(2, 2, 2, 2);
                this.planListTabControl.SetValue(Canvas.ZIndexProperty, 3);
                this.planExtraGrid.SetValue(Canvas.ZIndexProperty, 1);
            }
            else
            {
                this.planExtraGrid.DataContext = planExtraEntity;
            }

            Dictionary<string, int> accomplishRateDictionary = new Dictionary<string, int>();
            foreach (PlanListViewModel item in planListViewModelList)
            {
                PlanListTraceDataGrid planListDataGrid = new PlanListTraceDataGrid(item, null != planExtraEntity);
                AddTabItem(item.Title, planListDataGrid as UserControl);

                decimal tatal = 0;
                decimal accomplish = 0;
                foreach (PlanEntity planEntity in item.PlanList)
                {
                    tatal += planEntity.Weight;
                    if (planEntity.AccomplishDate.HasValue && planEntity.Score.HasValue)
                    {
                        accomplish += planEntity.Score.Value;
                    }
                }
                decimal resultValue = (0 == tatal) ? 0 : accomplish / tatal;
                int resultInt = Convert.ToInt16(Convert.ToDouble(resultValue) * 100);
                accomplishRateDictionary.Add(item.Title, resultInt);
            }

            PlanListEvaluateResultChart planListEvaluateResultChart = new PlanListEvaluateResultChart(accomplishRateDictionary);
            AddTabItem("完成率", planListEvaluateResultChart as UserControl);
        }
        public ImportImportantPartRejesterWindowViewModel(ChildWindow aChildWindow, Dictionary<String, ProjectEntity> aProjectEntityDictionary, ProductDomainContext aProductDomainContext, Dictionary<int, UserEntity> aDictionaryUser, ProjectEntity aProjectEntity)
        {
            childWindow = aChildWindow;
            ProjectEntityDictionary = aProjectEntityDictionary;
            ProductContext = aProductDomainContext;
            DictionaryUser = aDictionaryUser;
            ProjectEntity = aProjectEntity;

            ImportantPartRejesterEntityList = new ObservableCollection<ImportantPartRejesterEntity>();

            OnImport = new DelegateCommand(OnImportCommand);
            OnDownloadTemp = new DelegateCommand(OnDownloadTempCommand);
            OnCancel = new DelegateCommand(OnCancelCommand);
            OnOK = new DelegateCommand(OnOKCommand);
        }
        private void LoadOperationProjectCompleted(LoadOperation<project> aLoadOperation)
        {
            projectRecentUpdateList.Clear();
            DateTime currentDateTime = DateTime.Now;
            foreach (project projectItem in aLoadOperation.Entities)
            {
                if (!projectItem.plan_update_date.HasValue)
                {
                    continue;
                }

                TimeSpan difference = projectItem.plan_update_date.Value - currentDateTime;
                if (difference.Days >= 7)
                {
                    continue;
                }

                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = projectItem;
                projectEntity.Update();
                projectEntity.Project = null;
                projectRecentUpdateList.Add(projectEntity);
            }

            planManagerDomainContext.plans.Clear();

            planSource = new EntityList<plan>(planManagerDomainContext.plans);
            planLoader = new DomainCollectionViewLoader<plan>(
                LoadPlanEntities,
                LoadOperationPlanCompleted);
            planView = new DomainCollectionView<plan>(planLoader, planSource);
            using (planView.DeferRefresh())
            {
                planView.MoveToFirstPage();
            }
        }
        private void LoadOperationPlanCompleted(LoadOperation<plan> aLoadOperation)
        {
            planRemindList.Clear();
            App app = Application.Current as App;
            planRemindList = new ObservableCollection<PlanEntity>();
            if (null != app.UserInfo)
            {
                string userName = app.UserInfo.UserName;

                IEnumerable<string> project_responsibles_MN =
                                                      from c in productDomainContext.project_responsibles
                                                      where c.responsible_persionName == app.UserInfo.UserName
                                                      || (app.UserInfo.IsManager ? c.department_id == app.UserInfo.DepartmentID : false)
                                                      select c.manufacture_number;

                if (0 != project_responsibles_MN.Count())
                {
                    foreach (string itemMN in project_responsibles_MN)
                    {
                        IEnumerable<project> projects =
                                                      from c in planManagerDomainContext.projects
                                                      where c.manufacture_number == itemMN
                                                      select c;
                        if (0 == projects.Count())
                        {
                            continue;
                        }

                        project projectInfo = projects.First<project>();
                        if (string.IsNullOrEmpty(projectInfo.plan_version_id)
                            || (projectInfo.isdelete.HasValue && projectInfo.isdelete.Value))
                        {
                            continue;
                        }
                        ProjectEntity projectDetail = new ProjectEntity();
                        projectDetail.Project = projectInfo;
                        projectDetail.Update();

                        UserRemindEntity lUserRemindEntity;
                        if (UserRemindEntityDicationary.TryGetValue(projectDetail.ManufactureNumber, out lUserRemindEntity))
                        {
                            projectDetail.UserRemindEntity = lUserRemindEntity;
                        }

                        IEnumerable<string> respUserName = from c in productDomainContext.project_responsibles
                                                           where c.manufacture_number == itemMN && c.department_id == app.UserInfo.DepartmentID
                                                           select c.responsible_persionName;

                        String respUserNameString = respUserName.First();

                        IEnumerable<plan> plans;
                        if (app.UserInfo.DepartmentID != 1000)
                        {
                            plans = from c in planManagerDomainContext.plans
                                    where c.manufacture_number == itemMN && c.department_id == app.UserInfo.DepartmentID
                                              && c.version_id == projectInfo.plan_version_id
                                    select c;
                        }
                        else
                        {
                            plans = from c in planManagerDomainContext.plans
                                    where c.manufacture_number == itemMN && c.version_id == projectInfo.plan_version_id
                                    select c;
                        }
                        //IEnumerable<plan> plans = from c in planManagerDomainContext.plans
                        //                          where c.manufacture_number == itemMN && c.department_id == app.UserInfo.DepartmentID
                        //                                    && c.version_id == projectInfo.plan_version_id
                        //                          select c;
                        foreach (plan planItem in plans)
                        {
                            if (planItem.accomplish_date.HasValue)
                            {
                                continue;
                            }

                            int remindDay = ("设计节点" == planItem.sheet_name) ? projectDetail.RemindDayDesign :
                                (("采购节点" == planItem.sheet_name) ? projectDetail.RemindDayPurchase : projectDetail.RemindDayProduce);

                            Nullable<DateTime> targetDateTime = planItem.target_date_adjustment2.HasValue ? planItem.target_date_adjustment2.Value :
                                                (planItem.target_date_adjustment1.HasValue ? planItem.target_date_adjustment1.Value : planItem.target_date);

                            if (!targetDateTime.HasValue)
                            {
                                continue;
                            }

                            DateTime currentDateTime = DateTime.Now;
                            TimeSpan difference = targetDateTime.Value - currentDateTime;

                            if (difference.Days > remindDay)
                            {
                                continue;
                            }

                            PlanEntity planEntity = new PlanEntity();
                            planEntity.Plan = planItem;
                            planEntity.Update();
                            planEntity.Plan = null;
                            planEntity.PlanRemindDay = remindDay;
                            planEntity.ProjectName = projectInfo.project_name;
                            planEntity.TargetDate = targetDateTime.Value;
                            planEntity.RespUserName = respUserNameString;
                            string getDepartmentName;
                            if (departmentIdNameDictionary.TryGetValue(planEntity.DepartmentId, out getDepartmentName))
                            {
                                planEntity.DepartmentName = getDepartmentName;
                            }
                            planRemindList.Add(planEntity);
                        }
                    }
                }
            }
            UpdateChanged("planRemindList");
            IsBusy = false;
        }
 private void OnRefashCommand()
 {
     selectProjectEntity = null;
     //ProductEntityList.Clear();
     //ProjectResponsibleEntityList.Clear();
     using (this.CollectionProjectView.DeferRefresh())
     {
         this.projectView.MoveToFirstPage();
     }
     (OnFirstImport as DelegateCommand).RaiseCanExecuteChanged();
     (OnSmallChange as DelegateCommand).RaiseCanExecuteChanged();
     (OnImportAndChange as DelegateCommand).RaiseCanExecuteChanged();
 }
        private void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectEntityDictionary.Clear();
            LoadOperation loadOperation = sender as LoadOperation;
            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectEntityDictionary.Add(projectEntity.ManufactureNumber, projectEntity);
            }

            this.productSource = new EntityList<ProductManager.Web.Model.product>(this.ProductDomainContext.products);
            this.productLoader = new DomainCollectionViewLoader<ProductManager.Web.Model.product>(
                this.LoadProductEntities,
                this.LoadOperationProductCompleted);
            this.productView = new DomainCollectionView<ProductManager.Web.Model.product>(this.productLoader, this.productSource);
            using (this.productView.DeferRefresh())
            {
                this.productView.MoveToFirstPage();
            }
        }
 public void LoadData()
 {
     IsBusy = true;
     ProductDomainContext = new ProductDomainContext();
     SystemManageDomainContext = new SystemManageDomainContext();
     selectProjectEntity = null;
     ProjectFilesEntityList.Clear();
     LoadOperation<ProductManager.Web.Model.department> loadOperationDepartment =
         SystemManageDomainContext.Load<ProductManager.Web.Model.department>(SystemManageDomainContext.GetDepartmentQuery());
     loadOperationDepartment.Completed += loadOperationDepartment_Completed;
 }
        private void OnImportCommand()
        {
            ProjectImportEntityList.Clear();

            OpenFileDialog lOpenFile = new OpenFileDialog();

            lOpenFile.Filter = "Excel (*.xls)|*.xls";

            Dictionary<String, int> lHeaderDictionary = new Dictionary<String, int>();

            if (lOpenFile.ShowDialog() == true)
            {
                ProjectImportEntityList.Clear();

                try
                {
                    FileStream fs = lOpenFile.File.OpenRead();
                    Workbook book = Workbook.Open(fs);

                    foreach (KeyValuePair<int, Row> rowPair in book.Worksheets[0].Cells.Rows)
                    {
                        if (rowPair.Key == 0)
                        {
                            try
                            {
                                foreach (KeyValuePair<int, Cell> cellPair in rowPair.Value)
                                {
                                    lHeaderDictionary.Add(cellPair.Value.StringValue, cellPair.Key);
                                }
                            }
                            catch (System.Exception ex)
                            {
                                Message.ErrorMessage("表头重复或超出范围!");
                                break;
                            }
                            continue;
                        }

                        ProjectEntity lProjectEntity = new ProjectEntity();
                        lProjectEntity.Project = new ProductManager.Web.Model.project();
                        // 生产令号
                        int lManufactureNumberColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("生产令号", out lManufactureNumberColumn)
                                && -1 != lManufactureNumberColumn
                                && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lManufactureNumberColumn)))
                            {
                                lProjectEntity.ManufactureNumber = cell.StringValue;
                            }
                        }

                        // 项目名称
                        int lProjectNameColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("项目名称", out lProjectNameColumn)
                                && -1 != lProjectNameColumn
                                && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lProjectNameColumn)))
                            {
                                lProjectEntity.ProjectName = cell.StringValue;
                            }
                        }

                        //型号
                        int lModelNumberColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("型号", out lModelNumberColumn)
                                && -1 != lModelNumberColumn
                                && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lModelNumberColumn)))
                            {
                                lProjectEntity.ModelNumber = cell.StringValue;
                            }
                        }

                        //备注
                        int lRemarkColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("备注", out lRemarkColumn)
                                && -1 != lRemarkColumn
                                && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lRemarkColumn)))
                            {
                                lProjectEntity.Remark = cell.StringValue;
                            }
                        }

                        //年份
                        int lYearNumberColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("年份", out lYearNumberColumn)
                                && -1 != lYearNumberColumn
                                && Cell.EmptyCell != (cell = rowPair.Value.GetCell(lYearNumberColumn)))
                            {
                                lProjectEntity.YearNumber = Convert.ToInt32(cell.StringValue);
                            }
                        }

                        lProjectEntity.RecordDate = DateTime.Now;
                        lProjectEntity.DUpdate();

                        if (lProjectEntity.ManufactureNumber.Length == 0)
                        {
                            Message.ErrorMessage("生产令号不能为空 在第 " + rowPair.Key + " 行!");
                            break;
                        }

                        ProjectEntity lProjectEntityTemp;
                        if (ProjectEntityDictionary.TryGetValue(lProjectEntity.ManufactureNumber, out lProjectEntityTemp))
                        {
                            Message.ErrorMessage("生产令号" + lProjectEntity.ManufactureNumber + "重复 在第 " + rowPair.Key + " 行!");
                            break;
                        }

                        ProjectImportEntityList.Add(lProjectEntity);

                        //ProjectEntityDictionary.Add(lProjectEntity.ManufactureNumber, lProjectEntity);
                        //ProductContext.projects.Add(lProjectEntity.Project);
                    }

                }
                catch (System.Exception ex)
                {
                    Message.ErrorMessage(ex.Message);
                }
            }
        }
 public FreezeProjectWindow(ProjectEntity aProjectEntity)
 {
     InitializeComponent();
     this.DataContext = new FreezeProjectWindowViewModel(this, aProjectEntity);
 }
 public void LoadData()
 {
     IsBusy = true;
     SystemManageDomainContext = new SystemManageDomainContext();//.RejectChanges();
     ProductDomainContext = new ProductDomainContext();//.RejectChanges();
     ProductDomainContextForFile = new ProductDomainContext();//.RejectChanges();
     ProductDomainContext.PropertyChanged -= ProductDomainContext_PropertyChanged;
     ProductDomainContext.PropertyChanged += ProductDomainContext_PropertyChanged;
     selectProjectEntity = null;
     projectView = null;
     productView = null;
     projectResponsibleView = null;
     ProductEntityList.Clear();
     ProjectResponsibleEntityList.Clear();
     LoadOperation<ProductManager.Web.Model.department> loadOperationDepartment =
         SystemManageDomainContext.Load<ProductManager.Web.Model.department>(SystemManageDomainContext.GetDepartmentQuery());
     loadOperationDepartment.Completed += loadOperationDepartment_Completed;
 }
 private void OnAddCommand()
 {
     AddProjectEntity = new ProjectEntity();
     AddProjectEntity.RecordDate = DateTime.Now;
     AddProjectEntity.YearNumber = DateTime.Now.Year;
     AddProjectEntity.ProjectEntityDictionary = ProjectEntityDictionary;
     AddProjectEntity.Project = new ProductManager.Web.Model.project();
     ProjectWindow projectWindow = new ProjectWindow(ProjectWindowType.ADD, AddProjectEntity);
     projectWindow.Closed += AddProjectClosed;
     projectWindow.Show();
 }
        private void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectEntityDictionary.Clear();

            LoadOperation loadOperation = sender as LoadOperation;
            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectEntityDictionary.Add(projectEntity.ManufactureNumber, projectEntity);
            }

            LoadOperation<ProductManager.Web.Model.user> loadOperationUser =
                SystemManageDomainContext.Load<ProductManager.Web.Model.user>(SystemManageDomainContext.GetUserQuery());
            loadOperationUser.Completed += loadOperationUser_Completed;
        }
        private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
        {
            ProjectEntityList.Clear();
            UserProjectCount = 0;
            foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.ProjectEntityDictionary = ProjectEntityDictionary;
                projectEntity.Update();

                UserProjectEntity lUserProjectEntity;
                if (UserProjectEntityDictionary.TryGetValue(projectEntity.ManufactureNumber, out lUserProjectEntity))
                {
                    projectEntity.UserProjectEntity = lUserProjectEntity;
                    projectEntity.SetIsUserProject(true);
                }

                projectEntity.UserProjectEntityDictionary = UserProjectEntityDictionary;
                projectEntity.ProductManagersViewModel = this;
                projectEntity.ProductDomainContext = ProductDomainContext;
                if (IsUserProject && !projectEntity.IsUserProject)
                {
                    continue;
                }
                ProjectEntityList.Add(projectEntity);
                UserProjectCount++;
            }
            if (aLoadOperation.TotalEntityCount != -1)
            {
                this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
            }
            UpdateChanged("ProjectEntityList");
            UpdateChanged("RecorderCount");
            this.IsBusy = false;
        }
        void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectEntityDictionary.Clear();
            LoadOperation loadOperation = sender as LoadOperation;

            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEnttiy = new ProjectEntity();
                projectEnttiy.Project = project;
                projectEnttiy.Update();
                ProjectEntityDictionary.Add(projectEnttiy.ManufactureNumber, projectEnttiy);
            }

            LoadOperation<ProductManager.Web.Model.department> loadOperationDepartment =
                SystemManageDomainContext.Load<ProductManager.Web.Model.department>(SystemManageDomainContext.GetDepartmentQuery());
            loadOperationDepartment.Completed += loadOperationDepartment_Completed_Dictionary;
        }
 public ImportImportantPartWindow(Dictionary<string, ProjectEntity> aProjectEntityDictionary, ProductDomainContext aProductDomainContext, Dictionary<int, UserEntity> aDictionaryUser, ProjectEntity aProjectEntity)
 {
     InitializeComponent();
     this.DataContext = new ImportImportantPartWindowViewModel(this, aProjectEntityDictionary, aProductDomainContext, aDictionaryUser, aProjectEntity);
 }
        void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectList.Clear();
            LoadOperation loadOperation = sender as LoadOperation;
            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectList.Add(projectEntity);
            }

            UpdateChanged("ProjectList");
            IsBusy = false;
        }
        private void OnRefashCommand()
        {
            selectProjectEntity = null;

            using (this.CollectionProjectView.DeferRefresh())
            {
                this.projectView.MoveToFirstPage();
            }
        }
 public ProjectWindow(ProjectWindowType aProductWindowType, ProjectEntity aProjectEntity)
 {
     InitializeComponent();
     this.DataContext = new ProjectWindowViewModel(this, aProductWindowType, aProjectEntity);
 }
 private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
 {
     ProjectEntityList.Clear();
     ProjectFilesEntityList.Clear();
     foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
     {
         ProjectEntity projectEntity = new ProjectEntity();
         projectEntity.Project = project;
         projectEntity.Update();
         ProjectEntityList.Add(projectEntity);
     }
     if (aLoadOperation.TotalEntityCount != -1)
     {
         this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
     }
     UpdateChanged("ProjectEntityList");
     UpdateChanged("CollectionProjectView");
     UpdateChanged("ProjectFilesEntityList");
     UpdateChanged("RecorderCount");
     this.IsBusy = false;
 }
        private bool GetPorjectPlanList(ProjectEntity item, ref ObservableCollection<PlanEntity> planList)
        {
            bool rturnValue = false;
            IEnumerable<string> sheetNames = from c in planManagerDomainContext.plans
                                             where c.manufacture_number == item.ManufactureNumber
                                                && c.version_id == item.PlanVersionID
                                             select c.sheet_name;
            if (sheetNames.Count() > 0)
            {
                ObservableCollection<string> differentSheets = new ObservableCollection<string>();
                foreach (string value in sheetNames)
                {
                    if (null == value || differentSheets.Contains(value))
                    {
                        continue;
                    }
                    differentSheets.Add(value);
                    IEnumerable<plan> selectedPlans = from c in planManagerDomainContext.plans
                                                      where c.manufacture_number == item.ManufactureNumber
                                                        && c.version_id == item.PlanVersionID
                                                        && c.sheet_name == value
                                                      select c;
                    foreach (plan planItem in selectedPlans)
                    {
                        PlanEntity planEntity = new PlanEntity();
                        planEntity.Plan = planItem;
                        string getDepartmentName = string.Empty;
                        planEntity.Update();
                        planEntity.ProjectName = item.ProjectName;
                        if (departmentIdNameDictionary.TryGetValue(planEntity.DepartmentId, out getDepartmentName))
                        {
                            planEntity.DepartmentName = getDepartmentName;
                        }
                        planList.Add(planEntity);
                    }
                }

                rturnValue = true;
            }
            return rturnValue;
        }
 private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
 {
     ProjectEntityList.Clear();
     foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
     {
         ProjectEntity projectEntity = new ProjectEntity();
         projectEntity.Project = project;
         projectEntity.Update();
         ProjectEntityList.Add(projectEntity);
     }
     IsBusy = false;
 }
        private bool GetPorjectPlanList(ProjectEntity item, string aPlanVersionId, bool aIsSetable,
            ref Dictionary<string, ObservableCollection<PlanEntity>> aPlanListDictionary, 
            ref Dictionary<string, int> aModuleIndexDictionary)
        {
            bool rturnValue = false;
            IEnumerable<string> sheetNames = from c in planManagerDomainContext.plans
                                             where c.manufacture_number == item.ManufactureNumber.TrimEnd()
                                                && c.version_id == aPlanVersionId
                                             select c.sheet_name;
            if (sheetNames.Count() > 0)
            {
                ObservableCollection<string> differentSheets = new ObservableCollection<string>();
                foreach(string originalValue in sheetNames)
                {
                    if (null == originalValue)
                    {
                        continue;
                    }
                    string value = originalValue;

                    if ("设计完成节点" == value)
                    {
                        value = "设计节点";
                    }
                    else if ("采购完成节点" == value)
                    {
                        value = "采购节点";
                    }
                    else if ("生产完成节点" == value)
                    {
                        value = "生产节点";
                    }

                    if (differentSheets.Contains(value))
                    {
                        continue;
                    }

                    differentSheets.Add(value);

                    IEnumerable<plan> selectedPlans = from c in planManagerDomainContext.plans
                                                      where c.manufacture_number == item.ManufactureNumber.TrimEnd()
                                                        && c.version_id == aPlanVersionId
                                                        && c.sheet_name == originalValue
                                                      select c;
                    if (selectedPlans.Count() > 0)
                    {
                        if(!aModuleIndexDictionary.Keys.Contains(value))
                        {
                            aModuleIndexDictionary.Add(value, 0);
                        }

                        if (!aPlanListDictionary.Keys.Contains(value))
                        {
                            aPlanListDictionary.Add(value, new ObservableCollection<PlanEntity>());
                        }

                        if (selectedPlans.First().order_date.HasValue)
                        {
                            aModuleIndexDictionary[value] = 1;
                        }

                        ObservableCollection<PlanEntity> planList = aPlanListDictionary[value];
                        foreach (plan planItem in selectedPlans)
                        {
                            PlanEntity planEntity = new PlanEntity();
                            planEntity.Plan = planItem;
                            string getDepartmentName = string.Empty;
                            planEntity.Update();
                            planEntity.ProjectName = item.ProjectName;
                            planEntity.PlanRemindDay = ("设计节点" == planItem.sheet_name) ? item.RemindDayDesign :
                                (("采购节点" == planItem.sheet_name) ? item.RemindDayPurchase : item.RemindDayProduce);
                            planEntity.IsSetable = aIsSetable;
                            if (departmentIdNameDictionary.TryGetValue(planEntity.DepartmentId, out getDepartmentName))
                            {
                                planEntity.DepartmentName = getDepartmentName;
                            }
                            planList.Add(planEntity);
                        }
                    }
                }

                rturnValue = true;
            }
            return rturnValue;
        }
        private void LoadOperationProjectCompleted(LoadOperation<project> aLoadOperation)
        {
            ProjectList.Clear();
            foreach (project project in aLoadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                if (!String.IsNullOrEmpty(projectEntity.PlanVersionID))
                {
                    IEnumerable<plan_extra> plan_extras = from c in planManagerDomainContext.plan_extras
                                                          where c.version_id == projectEntity.PlanVersionID
                                                            && c.manufacture_number == projectEntity.ManufactureNumber
                                                          select c;
                    if (0 != plan_extras.Count())
                    {
                        plan_extra planExtra = plan_extras.First<plan_extra>();
                        projectEntity.CompileUserName = planExtra.compile_user_name;
                        projectEntity.CompileDate = planExtra.compile_date;
                    }

            //                     IEnumerable<string> planVersions = from c in planManagerDomainContext.plans
            //                                                           where c.manufacture_number == projectEntity.ManufactureNumber
            //                                                           select c.version_id;
                    if (!string.IsNullOrEmpty(project.plan_version_id))
                    {
            //                         projectEntity.PlanVersionDictionary = new Dictionary<string, string>();
            //                         foreach (string item in planVersions)
            //                         {
            //                             if (projectEntity.PlanVersionDictionary.ContainsKey(item))
            //                             {
            //                                 continue;
            //                             }
            //                             projectEntity.PlanVersionDictionary.Add(item, item);
            //                         }
                        projectEntity.HasHistory = true;
                    }
                }

                UserProjectEntity lUserProjectEntity;
                if (UserProjectEntityDictionary.TryGetValue(projectEntity.ManufactureNumber, out lUserProjectEntity))
                {
                    projectEntity.UserProjectEntity = lUserProjectEntity;
                    projectEntity.SetIsUserProject(true);
                }

                projectEntity.UserProjectEntityDictionary = UserProjectEntityDictionary;
                if (IsUserProject && !projectEntity.IsUserProject)
                {
                    continue;
                }

                UserRemindEntity lUserRemindEntity;
                if (UserRemindEntityDicationary.TryGetValue(projectEntity.ManufactureNumber, out lUserRemindEntity))
                {
                    projectEntity.UserRemindEntity = lUserRemindEntity;
                }

                projectEntity.PlanManagerDomainContext = planManagerDomainContext;

                ProjectList.Add(projectEntity);
            }
            if (aLoadOperation.TotalEntityCount != -1)
            {
                this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
            }
            UpdateChanged("ProjectList");
            this.IsBusy = false;
        }
 private void OnRefashCommand()
 {
     selectProjectEntity = null;
     selectedProjectList = null;
     //ProductEntityList.Clear();
     //ProjectResponsibleEntityList.Clear();
     using (this.CollectionProjectView.DeferRefresh())
     {
         this.projectView.MoveToFirstPage();
     }
 }
 public SetContractNumberWindow(ProjectEntity aProjectEntity)
 {
     InitializeComponent();
     this.DataContext = new SetContractNumberWindowViewModel(this, aProjectEntity);
 }
        private void LoadOperationProjectCompleted(LoadOperation<ProductManager.Web.Model.project> aLoadOperation)
        {
            ResponsiblePersonEntityList.Clear();
            ProjectEntityDictionary.Clear();

            foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
            {
                ProjectEntity lProjectEntity = new ProjectEntity();
                lProjectEntity.Project = project;
                lProjectEntity.Update();
                ProjectEntityDictionary.Add(lProjectEntity.ManufactureNumber, lProjectEntity);
            }

            using (projectResponsibleView.DeferRefresh())
            {
                projectResponsibleView.MoveToFirstPage();
            }
        }