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; }
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 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); }
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; }
public PlanListTraceWindow(string aTitle, ObservableCollection <PlanListViewModel> aPlanListViewModelList, PlanExtraEntity aPlanExtraEntity, PlanTraceViewModel aPlanTraceViewModel) { InitializeComponent(); this.Title = aTitle; this.planListViewModelList = aPlanListViewModelList; this.planExtraEntity = aPlanExtraEntity; this.PlanTraceViewModel = aPlanTraceViewModel; if (null == aPlanExtraEntity) { this.planListTabControl.Margin = new Thickness(2, 2, 2, 2); this.planListTabControl.SetValue(Canvas.ZIndexProperty, 3); this.planExtraGrid.SetValue(Canvas.ZIndexProperty, 1); this.QuestionButton.IsEnabled = false; } else { this.planExtraGrid.DataContext = planExtraEntity; ManufactureNumber = aPlanExtraEntity.ManufactureNumber; this.QuestionButton.IsEnabled = true; } 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 PlanListTraceWindow(string aTitle, ObservableCollection<PlanListViewModel> aPlanListViewModelList, PlanExtraEntity aPlanExtraEntity, PlanTraceViewModel aPlanTraceViewModel) { InitializeComponent(); this.Title = aTitle; this.planListViewModelList = aPlanListViewModelList; this.planExtraEntity = aPlanExtraEntity; this.PlanTraceViewModel = aPlanTraceViewModel; if (null == aPlanExtraEntity) { this.planListTabControl.Margin = new Thickness(2, 2, 2, 2); this.planListTabControl.SetValue(Canvas.ZIndexProperty, 3); this.planExtraGrid.SetValue(Canvas.ZIndexProperty, 1); this.QuestionButton.IsEnabled = false; } else { this.planExtraGrid.DataContext = planExtraEntity; ManufactureNumber = aPlanExtraEntity.ManufactureNumber; this.QuestionButton.IsEnabled = true; } 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 PlanListEditWindow(string aTitle, string aOKContent, string aVersionId, ObservableCollection <PlanListViewModel> aPlanListViewModelList, PlanExtraEntity aPlanExtraEntity) { InitializeComponent(); this.Title = aTitle; this.VersionId = aVersionId; this.OKButton.Content = aOKContent; this.planListViewModelList = aPlanListViewModelList; this.planExtraEntity = aPlanExtraEntity; for (int pos = 0; pos < planListViewModelList.Count; ++pos) { PlanListViewModel planListViewModel = planListViewModelList[pos]; AddTabItem(planListViewModel.Title, planListViewModel); } }
public PlanListEvaluateWindow(string aTitle, ObservableCollection<PlanListViewModel> aPlanListViewModelList, Dictionary<string, int> aPlanEvaluateResultDictionary, PlanExtraEntity aPlanExtraEntity) { InitializeComponent(); this.Title = aTitle; this.planListViewModelList = aPlanListViewModelList; this.planEvaluateResultDictionary = aPlanEvaluateResultDictionary; this.planExtraEntity = aPlanExtraEntity; foreach (PlanListViewModel planListViewModel in this.planListViewModelList) { PlanListEvaluateDataGrid planListDataGrid = new PlanListEvaluateDataGrid(planListViewModel, null == this.planExtraEntity); AddTabItem(planListViewModel.Title, planListDataGrid as UserControl); } PlanListEvaluateResultChart planListEvaluateResultChart = new PlanListEvaluateResultChart(aPlanEvaluateResultDictionary); AddTabItem("完成率", planListEvaluateResultChart as UserControl); }
public PlanListEvaluateWindow(string aTitle, ObservableCollection <PlanListViewModel> aPlanListViewModelList, Dictionary <string, int> aPlanEvaluateResultDictionary, PlanExtraEntity aPlanExtraEntity) { InitializeComponent(); this.Title = aTitle; this.planListViewModelList = aPlanListViewModelList; this.planEvaluateResultDictionary = aPlanEvaluateResultDictionary; this.planExtraEntity = aPlanExtraEntity; foreach (PlanListViewModel planListViewModel in this.planListViewModelList) { PlanListEvaluateDataGrid planListDataGrid = new PlanListEvaluateDataGrid(planListViewModel, null == this.planExtraEntity); AddTabItem(planListViewModel.Title, planListDataGrid as UserControl); } PlanListEvaluateResultChart planListEvaluateResultChart = new PlanListEvaluateResultChart(aPlanEvaluateResultDictionary); AddTabItem("完成率", planListEvaluateResultChart as UserControl); }
public PlanListStatisticsWindow(string aTitle, PlanListViewModel aPlanListViewModel, PlanExtraEntity aPlanExtraEntity) { InitializeComponent(); this.Title = aTitle; this.planListViewModel = aPlanListViewModel; this.planExtraEntity = aPlanExtraEntity; if (null == aPlanExtraEntity) { this.planListTabControl.Margin = new Thickness(2, 2, 2, 40); this.planListTabControl.SetValue(Canvas.ZIndexProperty, 3); this.planExtraGrid.SetValue(Canvas.ZIndexProperty, 1); } else { this.planExtraGrid.DataContext = planExtraEntity; } AddTabItem(planListViewModel.Title, planListViewModel); }
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; }
private bool CellToPlanExtraEntity(Row aRow, string aManufactureName, string aFileId, string aRequirement, ref PlanExtraEntity aPlanExtraEntity) { bool returnValue = false; try { Cell cell = aRow.GetCell(aRow.FirstColIndex); if (Cell.EmptyCell != cell) { returnValue = true; string firstValue = cell.StringValue; int pos = -1; string compilationBasisKey = "编制依据:"; string reasonAdjustment1Key = "第一次调整原因:"; string reasonAdjustment2Key = "第二次调整原因:"; string compileUser = "******"; string date = "日期:"; if (-1 != (pos = firstValue.IndexOf(compilationBasisKey))) { if (null == aPlanExtraEntity) { aPlanExtraEntity = new PlanExtraEntity(); aPlanExtraEntity.ManufactureNumber = aManufactureName; aPlanExtraEntity.FileId = aFileId; aPlanExtraEntity.Requirement = aRequirement; } pos += compilationBasisKey.Count(); aPlanExtraEntity.CompilationBasis = firstValue.Substring(pos); aPlanExtraEntity.CompilationBasis = aPlanExtraEntity.CompilationBasis.Trim(); } else if (-1 != (pos = firstValue.IndexOf(reasonAdjustment1Key)) && null != aPlanExtraEntity) { pos += reasonAdjustment1Key.Count(); aPlanExtraEntity.ReasonAdjustment1 = firstValue.Substring(pos); aPlanExtraEntity.ReasonAdjustment1 = aPlanExtraEntity.ReasonAdjustment1.Trim(); } else if (-1 != (pos = firstValue.IndexOf(reasonAdjustment2Key)) && null != aPlanExtraEntity) { pos += reasonAdjustment2Key.Count(); aPlanExtraEntity.ReasonAdjustment2 = firstValue.Substring(pos); aPlanExtraEntity.ReasonAdjustment2 = aPlanExtraEntity.ReasonAdjustment2.Trim(); } else if (-1 != (pos = firstValue.IndexOf(compileUser)) && null != aPlanExtraEntity) { int startRow = aRow.FirstColIndex + 1; Cell compieUserCell = aRow.GetCell(startRow); if (Cell.EmptyCell != compieUserCell && null != compieUserCell.StringValue) { aPlanExtraEntity.CompileUserName = compieUserCell.StringValue.Trim(); } string examineUser = "******"; string approveUser = "******"; for (int column = startRow + 1; column <= aRow.LastColIndex; ++column) { Cell elseCell = aRow.GetCell(column); if (Cell.EmptyCell != elseCell && null != elseCell.StringValue && string.Empty != elseCell.StringValue) { int elsePos = -1; if (-1 != ( elsePos = elseCell.StringValue.IndexOf(examineUser))) { ++column; elseCell = aRow.GetCell(column); if (Cell.EmptyCell != elseCell && null != elseCell.StringValue) { aPlanExtraEntity.ExamineUserName = elseCell.StringValue.Trim(); } } else if (-1 != (elsePos = elseCell.StringValue.IndexOf(approveUser))) { ++column; elseCell = aRow.GetCell(column); if (Cell.EmptyCell != elseCell && null != elseCell.StringValue) { aPlanExtraEntity.ApproveUserName = elseCell.StringValue.Trim(); } } } } } else if (-1 != (pos = firstValue.IndexOf(date)) && null != aPlanExtraEntity) { int startRow = aRow.FirstColIndex + 1; Cell compieDateCell = aRow.GetCell(startRow); if (Cell.EmptyCell != compieDateCell && null != compieDateCell.StringValue && string.Empty != compieDateCell.StringValue) { aPlanExtraEntity.CompileDate = compieDateCell.DateTimeValue; } bool secondSet = false; bool thirdSet = false; for (int column = startRow + 1; column <= aRow.LastColIndex; ++column) { Cell elseCell = aRow.GetCell(column); if (Cell.EmptyCell != elseCell && null != elseCell.StringValue && string.Empty != elseCell.StringValue) { int elsePos = -1; if (-1 != (elsePos = elseCell.StringValue.IndexOf(date))) { ++column; elseCell = aRow.GetCell(column); if (Cell.EmptyCell != elseCell && null != elseCell.StringValue && string.Empty != elseCell.StringValue) { if (!secondSet) { aPlanExtraEntity.ExamineDate = elseCell.DateTimeValue; secondSet = true; } else if (!thirdSet) { aPlanExtraEntity.ApproveDate = elseCell.DateTimeValue; thirdSet = true; } } } } } } else { returnValue = false; } } } catch (Exception e) { } return returnValue; }
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; }
void HistoryListWindow_Closed(object sender, EventArgs e) { PlanListHistoryWindow planListWindow = sender as PlanListHistoryWindow; if (planListWindow.DialogResult == true) { if (null == planListWindow.projectEntity || String.IsNullOrEmpty(planListWindow.SelectVersionId)) { Message.ErrorMessage("无效计划版本"); } else { Dictionary<string, ObservableCollection<PlanEntity>> planListDictionary = new Dictionary<string, ObservableCollection<PlanEntity>>(); Dictionary<string, int> moduleIndexDictionary = new Dictionary<string, int>(); if (GetPorjectPlanList(planListWindow.projectEntity, planListWindow.SelectVersionId, false, ref planListDictionary, ref moduleIndexDictionary)) { if (planListDictionary.Count > 0) { ObservableCollection<PlanListViewModel> planListViewModelList = new ObservableCollection<PlanListViewModel>(); foreach (KeyValuePair<string, ObservableCollection<PlanEntity>> kv in planListDictionary) { PlanListViewModel planListViewModel = new PlanListViewModel(kv.Key, planListDictionary[kv.Key], moduleIndexDictionary[kv.Key], departmentIdNameDictionary); planListViewModel.IsReadOnly = true; planListViewModelList.Add(planListViewModel); } PlanExtraEntity planExtraEntity = null; IEnumerable<plan_extra> plan_extras = from c in planManagerDomainContext.plan_extras where c.version_id == planListWindow.SelectVersionId && c.manufacture_number == planListWindow.projectEntity.ManufactureNumber.TrimEnd() select c; if (0 != plan_extras.Count()) { planExtraEntity = new PlanExtraEntity(); planExtraEntity.PlanExtra = plan_extras.First<plan_extra>(); planExtraEntity.Update(); planExtraEntity.PlanExtra = null; } string title = "历史计划" + planListWindow.projectEntity.ProjectName + " " + planListWindow.projectEntity.ManufactureNumber.TrimEnd() + " " + planListWindow.SelectVersionId + " " + "(红色(超过计划时间);品红(接近计划时间);绿色(按时完成);紫色(超时完成);灰色(无状态))"; PlanListHistoryWindow planListHistoryWindow = new PlanListHistoryWindow(title, planListViewModelList, planExtraEntity, this, planListWindow.projectEntity, planListWindow.SelectVersionId); planListHistoryWindow.Closed += new EventHandler(HistoryListWindow_Closed); planListHistoryWindow.Show(); } } else { string errorMessage = "无相关数据(生产令号:" + planListWindow.projectEntity.ManufactureNumber.TrimEnd() + ",版本号" + planListWindow.SelectVersionId + ")"; Message.ErrorMessage(errorMessage); } } } }
private void ViewSingle() { Dictionary<string, ObservableCollection<PlanEntity>> planListDictionary = new Dictionary<string, ObservableCollection<PlanEntity>>(); Dictionary<string, int> moduleIndexDictionary = new Dictionary<string, int>(); if (GetPorjectPlanList(SelectProjectEntity, SelectProjectEntity.PlanVersionID, true, ref planListDictionary, ref moduleIndexDictionary)) { if (planListDictionary.Count > 0) { ObservableCollection<PlanListViewModel> planListViewModelList = new ObservableCollection<PlanListViewModel>(); foreach (KeyValuePair<string, ObservableCollection<PlanEntity>> kv in planListDictionary) { PlanListViewModel planListViewModel = new PlanListViewModel(kv.Key, planListDictionary[kv.Key], moduleIndexDictionary[kv.Key], departmentIdNameDictionary); planListViewModel.IsReadOnly = true; planListViewModelList.Add(planListViewModel); } 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; } string title = "跟踪计划" + SelectProjectEntity.ProjectName + " " + SelectProjectEntity.ManufactureNumber + " " + SelectProjectEntity.PlanVersionID + " " + "(红色(超过计划时间);品红(接近计划时间);绿色(按时完成);紫色(超时完成);灰色(无状态))"; PlanListTraceWindow planListWindow = new PlanListTraceWindow(title, planListViewModelList, planExtraEntity, this); planListWindow.Closed += new EventHandler(PlanListWindow_Closed); planListWindow.Show(); } } else { string errorMessage = "无相关数据(生产令号:" + SelectProjectEntity.ManufactureNumber.TrimEnd() + ",版本号" + SelectProjectEntity.PlanVersionID + ")"; Message.ErrorMessage(errorMessage); } }
private void OnSmallChangeCommand() { IsBusy = true; if (null == SelectProjectEntity.PlanVersionID || null == SelectProjectEntity.ManufactureNumber || string.Empty == SelectProjectEntity.PlanVersionID || string.Empty == SelectProjectEntity.ManufactureNumber) { Message.ErrorMessage("生产令号或版本号无效"); } else { string newVersionId = SelectProjectEntity.PlanVersionID; // if (!GetNewVersionId(SelectProjectEntity.ManufactureNumber, ref newVersionId)) // { // Message.ErrorMessage("生成新版本号失败"); // IsBusy = false; // return; // } 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 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 == SelectProjectEntity.ManufactureNumber.TrimEnd() && c.version_id == SelectProjectEntity.PlanVersionID && c.sheet_name == originalValue orderby c.sequence_id select c; ObservableCollection<PlanEntity> planList = new ObservableCollection<PlanEntity>(); bool hasOrderDate = false; for (int pos = 0; pos < selectedPlans.Count<plan>(); ++pos) { plan item = selectedPlans.ElementAt(pos); ; PlanEntity planEntity = new PlanEntity(); planEntity.Plan = item; if (item.order_date.HasValue) { hasOrderDate = true; } string getDepartmentName = string.Empty; planEntity.Update(); // planEntity.Plan = null; // planEntity.VersionId = newVersionId; 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.IsChanged = false; planListViewModel.IsReadOnly = false; planListViewModelList.Add(planListViewModel); } } if (planListViewModelList.Count > 0) { string title = "少量修改("; title += SelectProjectEntity.ProjectName; title += " "; title += SelectProjectEntity.ManufactureNumber.TrimEnd(); title += " "; title += newVersionId; 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.VersionId = newVersionId; // planExtraEntity.PlanExtra = null; } PlanListEditWindow planListWindow = new PlanListEditWindow(title, "修改", newVersionId, planListViewModelList, planExtraEntity); planListWindow.ManufactureNumber = SelectProjectEntity.ManufactureNumber; planListWindow.Closed += new EventHandler(PlanListWindow_Closed); planListWindow.Show(); } } else { string errorMessage = "无相关数据(生产令号:" + SelectProjectEntity.ManufactureNumber.TrimEnd() + ",版本号" + SelectProjectEntity.PlanVersionID + ")" + "\r\n"; ; Message.ErrorMessage(errorMessage); } } IsBusy = false; }
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; }
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; }
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; }