private void InitUIList() { needAddList = new ObservableCollection <EmployeeInfo>(); needUpdateList = new ObservableCollection <EmployeeInfo>(); //添加职务、部门及在职状态选择列表 AlgorithmClass.InitEmployeeSelectionList(dataManager.AllEmployeeList, dataManager.AllPostList, dataManager.AllDepartmentList, AlgorithmClass.GetWorkStatusList()); AllEmployeeList = AlgorithmClass.DeepClone <ObservableCollection <EmployeeInfo> >(dataManager.AllEmployeeList); lcv = new ListCollectionView(AllEmployeeList); lcv.Filter = Fitter_TextChanged; lcv.Refresh(); SaveBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); RestoreBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); PrintBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); EmployeeDataGrid.ItemsSource = lcv; }
private void OperationTypeList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (OperationTypeList.SelectedItem == null) { return; } switch ((OperationType)(((DictionaryEntry)(OperationTypeList.SelectedValue)).Key)) { case OperationType.Scan: if (SheetDataGrid.SelectedValue != null) { SheetDetailGrid.SetBinding(Grid.DataContextProperty, new Binding("SelectedValue") { Source = SheetDataGrid }); } UpdateProcefureInfo(); break; case OperationType.Edit: sheetInfoForEdit = AlgorithmClass.DeepClone <SheetInfo>(SheetDataGrid.SelectedItem as SheetInfo); SheetDetailGrid.DataContext = sheetInfoForEdit; procedureInfoListForEdit = AlgorithmClass.DeepClone <ObservableCollection <ProcedureInfo> >(CurProcedureInfoList); ProcedureDataGrid.ItemsSource = procedureInfoListForEdit; bopInfoListForEdit = AlgorithmClass.DeepClone <ObservableCollection <SheetBOPInfo> >(CurBOPInfoList); BOPDataGrid.ItemsSource = bopInfoListForEdit; if (procedureInfoListForEdit.Count == CurSelectionProcedureInfoList.Count) { AddRowBtn.IsEnabled = false; } else { AddRowBtn.IsEnabled = true; } break; case OperationType.New: BSTypeTextBlock.Text = ""; sheetInfoForNew = new SheetInfo(); SheetDetailGrid.DataContext = sheetInfoForNew; procedureInfoListForNew = new ObservableCollection <ProcedureInfo>(); ProcedureDataGrid.ItemsSource = procedureInfoListForNew; AddRowBtn.IsEnabled = true; bopInfoListForNew = new ObservableCollection <SheetBOPInfo>(); BOPDataGrid.ItemsSource = bopInfoListForNew; break; } }
private bool DoSave() { bool isSaved = false; if (needAddList.Count != 0) { appLog.Info("Insert New Item.needAddList.Count = " + needAddList.Count); //执行插入 foreach (SalaryInfo info in needAddList) { int insertID = 0; if (SalaryDeal.InsertSalaryInfo(info, ref insertID)) { info.ID = insertID; } else { return(false); } } needAddList.Clear(); isSaved = true; } if (needUpdateList.Count != 0) { //执行更新 appLog.Info("Update New Item.needAddList.Count = " + needUpdateList.Count); foreach (SalaryInfo info in needUpdateList) { if (!SalaryDeal.UpdateSalaryInfo(info)) { return(false); } } needUpdateList.Clear(); isSaved = true; } if (isSaved) { dataManager.AllSalaryList = AlgorithmClass.DeepClone <ObservableCollection <SalaryInfo> >(AllSalaryList); } return(isSaved); }
private void InitUIList() { appLog.Info("InitUIList..."); needAddList = new ObservableCollection <SalaryInfo>(); needUpdateList = new ObservableCollection <SalaryInfo>(); //添加雇员选择列表 appLog.Info("Add EmployeeList..."); AlgorithmClass.InitSalarySelectionList(dataManager.AllSalaryList, dataManager.AllEmployeeList, dataManager.AllDepartmentList, AlgorithmClass.GetWorkStatusList()); AllSalaryList = AlgorithmClass.DeepClone <ObservableCollection <SalaryInfo> >(dataManager.AllSalaryList); lcv = new ListCollectionView(AllSalaryList); lcv.GroupDescriptions.Add(new PropertyGroupDescription("DepartmentName")); lcv.Filter = Fitter_TextChanged; lcv.Refresh(); //刷新当前页面上的所有收支 // FlushCurrentViewAllCommission(); AddBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv }); ClearBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); SaveBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); RestoreBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); ViewBSBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); PrintBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); FlushAllBtn.SetBinding(Button.IsEnabledProperty, new Binding("IsEmpty") { Source = lcv, Converter = new BoolConverter() }); SalaryDataGrid.ItemsSource = lcv; }
private SalaryInfo Do_GetSalaryProcedureInfo(SalaryInfo salaryInfo, ref SalaryProcedureInfoWrap salaryProcedureInfoWrap) { if (salaryInfo == null) { return(null); } bool isUpdateTotalPrice = false; salaryProcedureInfoWrap = GetSalaryProcedureInfo(salaryInfo, ref isUpdateTotalPrice); if (isUpdateTotalPrice) { SalaryDeal.UpdateSalaryInfo(salaryInfo); dataManager.AllSalaryList = AlgorithmClass.DeepClone <ObservableCollection <SalaryInfo> >(AllSalaryList); } return(salaryInfo); }
private void SheetDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (SheetDataGrid.SelectedItem == null || IsSavingEdit == true) { return; } switch ((OperationType)(((DictionaryEntry)(OperationTypeList.SelectedValue)).Key)) { case OperationType.Scan: UpdateProcefureInfo(); break; case OperationType.Edit: UpdateProcefureInfo(); sheetInfoForEdit = AlgorithmClass.DeepClone <SheetInfo>(SheetDataGrid.SelectedItem as SheetInfo); SheetDetailGrid.DataContext = sheetInfoForEdit; procedureInfoListForEdit = CurProcedureInfoList.Count == 0 ? new ObservableCollection <ProcedureInfo>() : AlgorithmClass.DeepClone <ObservableCollection <ProcedureInfo> >(CurProcedureInfoList); ProcedureDataGrid.ItemsSource = procedureInfoListForEdit; bopInfoListForEdit = CurBOPInfoList.Count == 0 ? new ObservableCollection <SheetBOPInfo>() : AlgorithmClass.DeepClone <ObservableCollection <SheetBOPInfo> >(CurBOPInfoList); BOPDataGrid.ItemsSource = bopInfoListForEdit; if (procedureInfoListForEdit.Count == CurSelectionProcedureInfoList.Count) { AddRowBtn.IsEnabled = false; } else { AddRowBtn.IsEnabled = true; } break; } }
private bool DoSave(ref string msg) { bool isSaved = false; if (needAddList.Count != 0) { //执行插入 foreach (EmployeeInfo info in needAddList) { if (!CheckEmployeeInfoIsValid(info)) { msg = "新增项或被编辑项的信息不完整,保存失败。"; return(false); } int insertID = 0; if (EmployeeDeal.InsertEmployeeInfo(info, ref insertID)) { info.ID = insertID; } else { msg = "数据创建失败,请重试!"; return(false); } } needAddList.Clear(); isSaved = true; } if (needUpdateList.Count != 0) { //执行更新 foreach (EmployeeInfo info in needUpdateList) { if (!CheckEmployeeInfoIsValid(info)) { msg = "新增项或被编辑项的信息不完整,保存失败。"; return(false); } if (!EmployeeDeal.UpdateEmployeeInfo(info)) { msg = "数据更新失败,请重试!"; return(false); } } needUpdateList.Clear(); isSaved = true; } if (isSaved) { dataManager.AllEmployeeList = AlgorithmClass.DeepClone <ObservableCollection <EmployeeInfo> >(AllEmployeeList); } if (isSaved) { msg = "数据保存完成!"; } else { msg = "不存在需要保存项!"; } return(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; } }
private bool Do_Save(ref string msg) { ObservableCollection <BOPInfo> needUpdateList = null; BOPInfo tempInfo = null; bool isNeedUpdate = CheckedIsNeedSave(ref tempInfo, ref needUpdateList, (BOPType)(((DictionaryEntry)(BOPTypeList.SelectedValue)).Key)); if (tempInfo != null) { if (!CheckBOPInfoIsValid(tempInfo)) { msg = "新增项或被编辑项的信息不完整,保存失败。"; return(false); } //插入操作 int newID = 0; if (BOPDeal.InsertBOPInfo(tempInfo, ref newID)) { tempInfo.ID = newID; dataManager.AllBOPList.Add(tempInfo); } else { msg = "数据创建失败,请重试!"; return(false); } } if (needUpdateList.Count != 0) { //更新操作 foreach (BOPInfo info in needUpdateList) { if (!CheckBOPInfoIsValid(tempInfo)) { msg = "新增项或被编辑项的信息不完整,保存失败。"; return(false); } if (BOPDeal.UpdateBOPInfo(info)) { int index = dataManager.AllBOPList.ToList().FindIndex(bop => bop.ID == info.ID); if (index > -1) { dataManager.AllBOPList.RemoveAt(index); dataManager.AllBOPList.Insert(index, AlgorithmClass.DeepClone <BOPInfo>(info)); } } else { msg = "数据更新失败,请重试!"; return(false); } } } if (isNeedUpdate) { msg = "数据保存完成!"; } else { msg = "不存在需要保存项!"; } return(true); }