private void DeleteBtn_Click(object sender, RoutedEventArgs e) { if (SheetDataGrid.SelectedItem == null) { return; } MessageBoxResult mr = MessageBox.Show("删除该订单后不可恢复,确认删除?", "删除订单", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (mr == MessageBoxResult.OK) { FuncPasswordWindow funcPDWindows = new FuncPasswordWindow(dataManager.CurUserName); funcPDWindows.Owner = App.Current.MainWindow; if (funcPDWindows.ShowDialog() == true) { SheetInfo info = SheetDataGrid.SelectedItem as SheetInfo; if (SheetDeal.DeleteSheetInfo(info.ID)) { int index = dataManager.AllSheetList.ToList().FindIndex(sheet => sheet.ID == info.ID); if (index > -1) { dataManager.AllSheetList.RemoveAt(index); } } } } }
private SalaryProcedureInfoWrap GetSalaryProcedureInfo(SalaryInfo salaryInfo, ref bool isUpdateTotalPrice) { SalaryProcedureInfoWrap salaryProcedureInfoWrap = new SalaryProcedureInfoWrap() { EmployeeName = salaryInfo.EmployeeName, DepartmentName = salaryInfo.DepartmentName, CurrentDate = new DateTime(salaryInfo.Year, salaryInfo.Month, 1) }; ObservableCollection <ProcedureInfo> CurProcedureInfoList = null; foreach (SheetInfo sheetInfo in dataManager.AllSheetList) { //结单了 if (sheetInfo.SettleDate == null) { continue; } //本月内 DateTime dateValue = sheetInfo.SettleDate.Value; if (dateValue.Year == salaryInfo.Year && dateValue.Month == salaryInfo.Month) { CurProcedureInfoList = SheetDeal.GetAllProcedureInfo(sheetInfo.ID); if (CurProcedureInfoList == null) { continue; } CurProcedureInfoList.ToList().ForEach(procedureInfo => { //该人参与该流程 if (procedureInfo.EmployeeID == salaryInfo.EmployeeID) { salaryProcedureInfoWrap.TotalPrice += procedureInfo.Price; salaryProcedureInfoWrap.SalaryProcedureInfoList.Add(new SalaryProcedureInfo { SheetID = sheetInfo.ID, SettleDate = dateValue, BSType = sheetInfo.BSType, Customer = sheetInfo.Customer, ProcedureName = procedureInfo.ProcedureName, Price = procedureInfo.Price }); } }); } } if (salaryInfo.Commission != salaryProcedureInfoWrap.TotalPrice) { isUpdateTotalPrice = true; salaryInfo.Commission = salaryProcedureInfoWrap.TotalPrice; } return(salaryProcedureInfoWrap); }
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; } }