/// <summary> /// 删除记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void BtnDelClickAsync(object sender, RoutedEventArgs e) { if (RecordDataGrid.SelectedItem is Lib.MemberScore SelectedRec) { if (AppFuns.ShowMessage($"确认要删除 {SelectedRec.Score}得分吗?", Caption: "确认", showYesNo: true)) { ExcuteResult excuteResult = await DataMemberScoreRepository.DeleteRecord(SelectedRec.Id); if (excuteResult.State == 0) { _PageViewModel.MemberScores.Remove(SelectedRec); } else { AppFuns.ShowMessage(excuteResult.Msg, Caption: "失败"); } } } }
/// <summary> /// 新增记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void BtnAddClickAsync(object sender, RoutedEventArgs e) { Lib.MemberScore NewRecord = new Lib.MemberScore() { OccurDate = DateTime.Now, UpDateTime = DateTime.Now, MemberId = _PageViewModel.CurMember.Id, MemberIndex = _PageViewModel.CurMember.OrderIndex, Member = _PageViewModel.CurMember, ScoreUnitName = AppSet.LoginUser.UnitName, UserId = AppSet.LoginUser.Id }; PageScoreInputWin AddWin = new PageScoreInputWin(NewRecord); AddWin.Owner = AppSet.AppMainWindow; if (AddWin.ShowDialog().Value) { ExcuteResult excuteResult = await DataMemberScoreRepository.AddRecord(NewRecord); if (excuteResult != null) { if (excuteResult.State == 0) { NewRecord.Id = excuteResult.Tag; _PageViewModel.MemberScores.Add(NewRecord); } else { AppFuns.ShowMessage(excuteResult.Msg, Caption: "失败"); } } else { AppFuns.ShowMessage("数据输入不正确!", Caption: "失败"); } } }
/// <summary> /// 查询数据 /// </summary> /// <returns></returns> public async Task SearchRecords() { if (string.IsNullOrWhiteSpace(SearchCondition.MemberId)) { return; } //1.先查询用户信息 List <Lib.MemberInfoEntity> TempMembers = await DataMemberRepository.ReadMembers(new MemberSearch() { Id = SearchCondition.MemberId }).ConfigureAwait(false); if (TempMembers != null && TempMembers.Count > 0) { CurMember = TempMembers[0]; } if (CurMember == null) { AppFuns.ShowMessage("未找到此用户信息!"); return; } if (SearchCondition != null) { List <Lib.MemberScore> MemberScoreList = await DataMemberScoreRepository.GetRecords(SearchCondition); App.Current.Dispatcher.Invoke(() => { MemberScores.Clear(); MemberScoreList?.ToList().ForEach(e => { e.Member = CurMember; MemberScores.Add(e); }); }); } }