private async void CheckControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { TeacherCheckModel selectCheckMoney = gvMoney.SelectedItem as TeacherCheckModel; IAsyncProxy <ITeacherService> teacherServiceProxy = await Task.Run(() => ServiceHelper.GetTeacherService()); bool res = await teacherServiceProxy.CallAsync(t => t.CheckMonthMoney(this.teacherId, selectCheckMoney.month, selectCheckMoney.money, GlobalObjects.currentLoginUser)); if (res == true) { await DialogManager.ShowMessageAsync(this, UIResources.MsgInfo, "教师" + this.TeacherName + "的" + selectCheckMoney.month + "月费用结算成功!", MessageDialogStyle.Affirmative, null); } }
public IList <TeacherCheckModel> GetCheckMonthMoney(int id) { IList <TeacherCheckModel> teacherCheckModelList = new List <TeacherCheckModel>(); try { //根据教师id获取所有未结算上课记录,并计算所有课时需要结算金额总和 Repository <class_record> recordDal = _unitOfWork.GetRepository <class_record>(); IEnumerable <class_record> records = recordDal.Find(r => r.teacher_id == id && r.is_checked == 0).Entities.OrderBy(cr => cr.class_schedule.real_date); IEnumerable <class_record> assistantRecords = recordDal.Find(r => r.assistant_id == id && r.assistant_is_checked == 0).Entities.OrderBy(cr => cr.class_schedule.real_date); string month = ""; foreach (class_record cr in records) { if (!month.Equals(cr.class_schedule.real_date.ToString("yyyyMM"))) { //当前处理月份为新月份,需要增加对象 TeacherCheckModel tcm = new TeacherCheckModel(); tcm.month = cr.class_schedule.real_date.ToString("yyyyMM"); teacherCheckModelList.Add(tcm); month = cr.class_schedule.real_date.ToString("yyyyMM"); } teacherCheckModelList.Last().money += cr.amount_receivable.Value * cr.teacher_check_rate; } foreach (class_record cr in assistantRecords) { bool hascheckmodel = false; for (int i = 0; i < teacherCheckModelList.Count; i++) { if (teacherCheckModelList[i].month.Equals(cr.class_schedule.real_date.ToString("yyyyMM"))) { hascheckmodel = true; teacherCheckModelList[i].money += cr.amount_receivable.Value * cr.assistant_check_rate.Value; break; } } if (hascheckmodel == false) { //该月没有获得数据,则需要新增 TeacherCheckModel tcm = new TeacherCheckModel(); tcm.month = cr.class_schedule.real_date.ToString("yyyyMM"); tcm.money += cr.amount_receivable.Value * cr.assistant_check_rate.Value; teacherCheckModelList.Add(tcm); } } return(teacherCheckModelList); } catch (RepositoryException rex) { string msg = rex.Message; string reason = rex.StackTrace; throw new FaultException <LCFault> (new LCFault(msg), reason); } catch (Exception ex) { string msg = ex.Message; string reason = ex.StackTrace; throw new FaultException <LCFault> (new LCFault(msg), reason); } }