private void OnViewAllPlanCommand()
        {
            IsBusy = true;

            ObservableCollection <PlanEntity> planList = new ObservableCollection <PlanEntity>();

            foreach (ProjectEntity item in ProjectList)
            {
                if (null == item.PlanVersionID ||
                    null == item.ManufactureNumber ||
                    string.Empty == item.PlanVersionID ||
                    string.Empty == item.ManufactureNumber)
                {
                    continue;
                }

                GetPorjectPlanList(item, ref planList);
            }

            if (planList.Count > 0)
            {
                PlanListViewModel planListViewModel = new PlanListViewModel("所有项目计划", planList, 0, departmentIdNameDictionary);
                planListViewModel.IsReadOnly = true;
                PlanExtraEntity planExtraEntity = null;

                PlanListStatisticsWindow planListStatisticsWindow = new PlanListStatisticsWindow("查询计划", planListViewModel, planExtraEntity);
                planListStatisticsWindow.Show();
            }

            IsBusy = false;
        }
        private void OnViewSinglePlanCommand()
        {
            IsBusy = true;

            if (null == SelectProjectEntity.PlanVersionID ||
                null == SelectProjectEntity.ManufactureNumber ||
                string.Empty == SelectProjectEntity.PlanVersionID ||
                string.Empty == SelectProjectEntity.ManufactureNumber)
            {
                Message.ErrorMessage("生产令号或版本号无效");
            }
            else
            {
                ObservableCollection <PlanEntity> planList = new ObservableCollection <PlanEntity>();
                if (GetPorjectPlanList(SelectProjectEntity, ref planList))
                {
                    if (planList.Count > 0)
                    {
                        string            title             = SelectProjectEntity.ProjectName + " " + SelectProjectEntity.ManufactureNumber.TrimEnd() + " " + SelectProjectEntity.PlanVersionID;
                        PlanListViewModel planListViewModel = new PlanListViewModel(title, planList, 0, departmentIdNameDictionary);
                        planListViewModel.IsReadOnly = true;
                        PlanExtraEntity          planExtraEntity = null;
                        IEnumerable <plan_extra> plan_extras     = from c in planManagerDomainContext.plan_extras
                                                                   where c.version_id == SelectProjectEntity.PlanVersionID &&
                                                                   c.manufacture_number == SelectProjectEntity.ManufactureNumber.TrimEnd()
                                                                   select c;
                        if (0 != plan_extras.Count())
                        {
                            planExtraEntity           = new PlanExtraEntity();
                            planExtraEntity.PlanExtra = plan_extras.First <plan_extra>();
                            planExtraEntity.Update();
                            planExtraEntity.PlanExtra = null;
                        }

                        PlanListStatisticsWindow planListStatisticsWindow = new PlanListStatisticsWindow("查询计划", planListViewModel, planExtraEntity);
                        planListStatisticsWindow.Show();
                    }
                }
                else
                {
                    string errorMessage = "无相关数据(生产令号:" +
                                          SelectProjectEntity.ManufactureNumber.TrimEnd() +
                                          ",版本号" +
                                          SelectProjectEntity.PlanVersionID
                                          + ")";
                    Message.ErrorMessage(errorMessage);
                }
            }

            IsBusy = false;
        }
Example #3
0
        private void OnEvaluateSingleCommand()
        {
            IsBusy = true;
            if (null == SelectProjectEntity.PlanVersionID ||
                null == SelectProjectEntity.ManufactureNumber ||
                string.Empty == SelectProjectEntity.PlanVersionID ||
                string.Empty == SelectProjectEntity.ManufactureNumber)
            {
                Message.ErrorMessage("生产令号或版本号无效");
            }
            else
            {
                IEnumerable <string> sheetNames = from c in planManagerDomainContext.plans
                                                  where c.manufacture_number == SelectProjectEntity.ManufactureNumber.TrimEnd() &&
                                                  c.version_id == SelectProjectEntity.PlanVersionID
                                                  select c.sheet_name;
                if (sheetNames.Count() > 0)
                {
                    ObservableCollection <PlanListViewModel> planListViewModelList = new ObservableCollection <PlanListViewModel>();
                    Dictionary <string, int> accomplishRateDictionary = new Dictionary <string, int>();
                    foreach (string value in sheetNames)
                    {
                        if (null == value || accomplishRateDictionary.ContainsKey(value))
                        {
                            continue;
                        }
                        IEnumerable <plan> selectedPlans = from c in planManagerDomainContext.plans
                                                           where c.manufacture_number == SelectProjectEntity.ManufactureNumber.TrimEnd() &&
                                                           c.version_id == SelectProjectEntity.PlanVersionID &&
                                                           c.sheet_name == value
                                                           select c;
                        decimal totalValue      = 0;
                        decimal accomplishValue = 0;
                        ObservableCollection <PlanEntity> planList = new ObservableCollection <PlanEntity>();
                        bool hasOrderDate = false;
                        foreach (plan item in selectedPlans)
                        {
                            if (item.weight.HasValue)
                            {
                                totalValue += item.weight.Value;
                                if (item.accomplish_date.HasValue && item.score.HasValue)
                                {
                                    accomplishValue += item.score.Value;
                                }
                            }

                            PlanEntity planEntity = new PlanEntity();
                            planEntity.Plan = item;
                            if (item.order_date.HasValue)
                            {
                                hasOrderDate = true;
                            }
                            string getDepartmentName = string.Empty;
                            planEntity.Update();
                            planEntity.Plan        = null;
                            planEntity.ProjectName = SelectProjectEntity.ProjectName;
                            if (departmentIdNameDictionary.TryGetValue(planEntity.DepartmentId, out getDepartmentName))
                            {
                                planEntity.DepartmentName = getDepartmentName;
                            }
                            planList.Add(planEntity);
                        }

                        decimal resultValue = (0 == totalValue) ? 0 : accomplishValue / totalValue;
                        int     resultInt   = Convert.ToInt16(Convert.ToDouble(resultValue) * 100);
                        accomplishRateDictionary.Add(value, resultInt);

                        if (planList.Count > 0)
                        {
                            int modelIndex = -1;
                            if ("采购节点" == planList[0].SheetName)
                            {
                                if (hasOrderDate)
                                {
                                    modelIndex = 1;
                                }
                                else
                                {
                                    modelIndex = 2;
                                }
                            }
                            else
                            {
                                modelIndex = 0;
                            }

                            PlanListViewModel planListViewModel = new PlanListViewModel(value, planList,
                                                                                        modelIndex, departmentIdNameDictionary);
                            planListViewModel.IsReadOnly = false;
                            planListViewModelList.Add(planListViewModel);
                        }
                    }
                    if (accomplishRateDictionary.Count > 0)
                    {
                        string title = "计划考核(";
                        title += SelectProjectEntity.ProjectName;
                        title += " ";
                        title += SelectProjectEntity.ManufactureNumber;
                        title += ")";

                        PlanExtraEntity          planExtraEntity = null;
                        IEnumerable <plan_extra> plan_extras     = from c in planManagerDomainContext.plan_extras
                                                                   where c.version_id == SelectProjectEntity.PlanVersionID &&
                                                                   c.manufacture_number == SelectProjectEntity.ManufactureNumber.TrimEnd()
                                                                   select c;
                        if (0 != plan_extras.Count())
                        {
                            planExtraEntity           = new PlanExtraEntity();
                            planExtraEntity.PlanExtra = plan_extras.First <plan_extra>();
                            planExtraEntity.Update();
                            planExtraEntity.PlanExtra = null;
                        }

                        PlanListEvaluateWindow planEvaluateResultWindow = new PlanListEvaluateWindow(title, planListViewModelList,
                                                                                                     accomplishRateDictionary, planExtraEntity);
                        planEvaluateResultWindow.Closed += new EventHandler(PlanListWindow_Closed);
                        planEvaluateResultWindow.Show();
                    }
                }
                else
                {
                    string errorMessage = "无相关数据(生产令号:" +
                                          SelectProjectEntity.ManufactureNumber.TrimEnd() +
                                          ",版本号" +
                                          SelectProjectEntity.PlanVersionID
                                          + ")";
                    Message.ErrorMessage(errorMessage);
                }
            }
            IsBusy = false;
        }
Example #4
0
        private void OnExportPlanCommand()
        {
            IsBusy = true;

            if (null == SelectProjectEntity.PlanVersionID ||
                null == SelectProjectEntity.ManufactureNumber ||
                string.Empty == SelectProjectEntity.PlanVersionID ||
                string.Empty == SelectProjectEntity.ManufactureNumber)
            {
                Message.ErrorMessage("生产令号或版本号无效");
            }
            else
            {
                IEnumerable <string> sheetNames = from c in planManagerDomainContext.plans
                                                  where c.manufacture_number == SelectProjectEntity.ManufactureNumber.TrimEnd() &&
                                                  c.version_id == SelectProjectEntity.PlanVersionID
                                                  select c.sheet_name;
                if (sheetNames.Count() > 0)
                {
                    ObservableCollection <PlanListViewModel> planListViewModelList = new ObservableCollection <PlanListViewModel>();
                    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 == SelectProjectEntity.ManufactureNumber.TrimEnd() &&
                                                           c.version_id == SelectProjectEntity.PlanVersionID &&
                                                           c.sheet_name == value
                                                           select c;
                        ObservableCollection <PlanEntity> planList = new ObservableCollection <PlanEntity>();
                        bool hasOrderDate = false;
                        foreach (plan item in selectedPlans)
                        {
                            PlanEntity planEntity = new PlanEntity();
                            planEntity.Plan = item;
                            if (item.order_date.HasValue)
                            {
                                hasOrderDate = true;
                            }
                            string getDepartmentName = string.Empty;
                            planEntity.Update();
                            planEntity.ProjectName = SelectProjectEntity.ProjectName;
                            if (departmentIdNameDictionary.TryGetValue(planEntity.DepartmentId, out getDepartmentName))
                            {
                                planEntity.DepartmentName = getDepartmentName;
                            }
                            planList.Add(planEntity);
                        }
                        if (planList.Count > 0)
                        {
                            int modelIndex = -1;
                            if ("采购节点" == planList[0].SheetName)
                            {
                                if (hasOrderDate)
                                {
                                    modelIndex = 1;
                                }
                                else
                                {
                                    modelIndex = 2;
                                }
                            }
                            else
                            {
                                modelIndex = 0;
                            }

                            PlanListViewModel planListViewModel = new PlanListViewModel(value, planList,
                                                                                        modelIndex, departmentIdNameDictionary);
                            planListViewModel.IsReadOnly = true;
                            planListViewModelList.Add(planListViewModel);
                        }
                    }
                    if (planListViewModelList.Count > 0)
                    {
                        PlanExtraEntity          planExtraEntity = null;
                        IEnumerable <plan_extra> plan_extras     = from c in planManagerDomainContext.plan_extras
                                                                   where c.version_id == SelectProjectEntity.PlanVersionID &&
                                                                   c.manufacture_number == SelectProjectEntity.ManufactureNumber.TrimEnd()
                                                                   select c;
                        if (0 != plan_extras.Count())
                        {
                            planExtraEntity           = new PlanExtraEntity();
                            planExtraEntity.PlanExtra = plan_extras.First <plan_extra>();
                            planExtraEntity.Update();
                            planExtraEntity.PlanExtra = null;
                        }
                        PlanListEditWindow planListWindow = new PlanListEditWindow("计划导出", "导出", SelectProjectEntity.PlanVersionID,
                                                                                   planListViewModelList, planExtraEntity);
                        planListWindow.ManufactureNumber = SelectProjectEntity.ManufactureNumber;
                        planListWindow.Closed           += new EventHandler(PlanListWindow_Closed);
                        planListWindow.Show();
                    }
                }
                else
                {
                    string errorMessage = "无相关数据(生产令号:" +
                                          SelectProjectEntity.ManufactureNumber.TrimEnd() +
                                          ",版本号" +
                                          SelectProjectEntity.PlanVersionID
                                          + ")";
                    Message.ErrorMessage(errorMessage);
                }
            }

            IsBusy = false;
        }