private void UpdateProcefureInfo() { if (SheetDataGrid.SelectedItem == null) { return; } SheetInfo sheetInfo = SheetDataGrid.SelectedItem as SheetInfo; //获取该单所对应的流程信息 CurProcedureInfoList = SheetDeal.GetAllProcedureInfo(sheetInfo.ID); //获取跟单员 sheetInfo.Follower = AlgorithmClass.GetFollowers(CurProcedureInfoList); BsTypeInfo bsTypeInfo = dataManager.AllBsTypeList.Where(type => type.TypeName == sheetInfo.BSType).FirstOrDefault(); //获取该单中业务类型的全部流程信息 供选择更改 CurSelectionProcedureInfoList = AlgorithmClass.GetSelectionProcedureInfoList(bsTypeInfo.ProcedurePrice); CurProcedureInfoList.ToList().ForEach(info => info.SelectionProcedureInfoList = CurSelectionProcedureInfoList); CurBOPInfoList = SheetDeal.GetAllSheetBOPInfo(sheetInfo.ID); TotalTextBlock.Text = AlgorithmClass.GetBOPTotal(CurBOPInfoList).ToString(); //绑定 ProcedureDataGrid.ItemsSource = CurProcedureInfoList; BOPDataGrid.ItemsSource = CurBOPInfoList; if (CurProcedureInfoList.Count == CurSelectionProcedureInfoList.Count) { AddRowBtn.IsEnabled = false; } else { AddRowBtn.IsEnabled = true; } }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { switch ((OperationType)(((DictionaryEntry)(OperationTypeList.SelectedValue)).Key)) { case OperationType.Edit: if (!CheckSheetIsValid(SheetDataGrid.SelectedItem as SheetInfo)) { MessageBox.Show("请检查该单必填信息是否完整。", "信息不完整", MessageBoxButton.OK, MessageBoxImage.Warning); return; } bool IsChanged = AlgorithmClass.CheckIsChanged <SheetInfo>(SheetDataGrid.SelectedItem as SheetInfo, sheetInfoForEdit); //单信息 if (IsChanged == true) { IsSavingEdit = true; if (SheetDeal.UpdateSheetInfo(sheetInfoForEdit) == true) { //获得所有跟单员 sheetInfoForEdit.Follower = AlgorithmClass.GetFollowers(procedureInfoListForEdit); int index = dataManager.AllSheetList.ToList().FindIndex(sheet => sheet.ID == sheetInfoForEdit.ID); dataManager.AllSheetList.RemoveAt(index); dataManager.AllSheetList.Insert(index, AlgorithmClass.DeepClone <SheetInfo>(sheetInfoForEdit)); SheetDataGrid.SelectedIndex = index; } else { MessageBox.Show("单保存失败,请重试!", "操作失败", MessageBoxButton.OK, MessageBoxImage.Error); IsSavingEdit = false; return; } } //流程信息 string procedureMap = AlgorithmClass.GetProcedureMap(procedureInfoListForEdit); if (procedureMap != AlgorithmClass.GetProcedureMap(CurProcedureInfoList)) { IsSavingEdit = true; if (SheetDeal.UpdateProcedureMap(sheetInfoForEdit.ID, procedureMap) == false) { MessageBox.Show("流程信息保存失败,请重试!", "操作失败", MessageBoxButton.OK, MessageBoxImage.Error); IsSavingEdit = false; return; } } //收支信息 string bopMap = AlgorithmClass.GetBOPMap(bopInfoListForEdit); if (bopMap != AlgorithmClass.GetBOPMap(CurBOPInfoList)) { IsSavingEdit = true; if (SheetDeal.UpdateSheetBOPMap(sheetInfoForEdit.ID, bopMap) == false) { MessageBox.Show("收支信息保存失败,请重试!"); IsSavingEdit = false; return; } } if (IsSavingEdit == true) { MessageBox.Show("数据更新成功!"); IsSavingEdit = false; } break; case OperationType.New: if (!CheckSheetIsValid(sheetInfoForNew)) { MessageBox.Show("请检查该单必填信息是否完整。", "信息不完整", MessageBoxButton.OK, MessageBoxImage.Warning); return; } int insertID = 0; IsSavingEdit = true; //单信息 if (SheetDeal.InsertSheetInfo(sheetInfoForNew, ref insertID) == true) { sheetInfoForNew.ID = insertID; sheetInfoForNew.Follower = AlgorithmClass.GetFollowers(procedureInfoListForNew); dataManager.AllSheetList.Add(AlgorithmClass.DeepClone <SheetInfo>(sheetInfoForNew)); } else { MessageBox.Show("新单创建失败,请重试!"); IsSavingEdit = false; return; } IsSavingEdit = false; //流程信息 if (SheetDeal.InsertProcedureMap(sheetInfoForNew.ID, AlgorithmClass.GetProcedureMap(procedureInfoListForNew)) == false) { MessageBox.Show("流程信息创建失败,请重试!", "操作失败", MessageBoxButton.OK, MessageBoxImage.Error); return; } //收支信息 if (SheetDeal.InsertSheetBOPMap(sheetInfoForNew.ID, AlgorithmClass.GetBOPMap(bopInfoListForNew)) == false) { MessageBox.Show("收支信息创建失败,请重试!", "操作失败", MessageBoxButton.OK, MessageBoxImage.Error); return; } sheetInfoForNew = new SheetInfo(); SheetDetailGrid.DataContext = sheetInfoForNew; procedureInfoListForNew.Clear(); bopInfoListForNew.Clear(); MessageBox.Show("新单创建成功!"); break; } }