private void RemedyList_SelectionChanged(object sender, SelectionChangedEventArgs e) { CommContracts.TherapyDoctorAdvice therapy = TherapyList.SelectedItem as CommContracts.TherapyDoctorAdvice; ShowDetails(therapy); this.SaveBtn.IsEnabled = false; this.DeleteBtn.IsEnabled = true; }
private void ShowDetails(CommContracts.TherapyDoctorAdvice therapy) { if (therapy == null) { return; } List <MyDetail> list = new List <MyDetail>(); foreach (var tem in therapy.TherapyDoctorAdviceDetails) { MyDetail recipeDetail = new MyDetail(); recipeDetail.ID = tem.TherapyID; recipeDetail.Name = tem.Therapy.Name; recipeDetail.SingleDose = tem.AllNum; recipeDetail.Illustration = tem.Remarks; list.Add(recipeDetail); } this.TherapyMsg.Text = therapy.ToString(); this.myTableEdit.SetAllDetails(list); this.myTableEdit.IsEnabled = false; }
public bool SaveTherapy(CommContracts.TherapyDoctorAdvice therapy) { DAL.TherapyDoctorAdvice temp = new DAL.TherapyDoctorAdvice(); using (DAL.HisContext ctx = new DAL.HisContext()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CommContracts.TherapyDoctorAdvice, DAL.TherapyDoctorAdvice>().ForMember(x => x.TherapyDoctorAdviceDetails, opt => opt.Ignore()); }); var mapper = config.CreateMapper(); temp = mapper.Map <DAL.TherapyDoctorAdvice>(therapy); var configDetail = new MapperConfiguration(ctr => { ctr.CreateMap <CommContracts.TherapyDoctorAdviceDetail, DAL.TherapyDoctorAdviceDetail>().ForMember(x => x.Therapy, opt => opt.Ignore()); }); var mapperDetail = configDetail.CreateMapper(); List <CommContracts.TherapyDoctorAdviceDetail> list1 = therapy.TherapyDoctorAdviceDetails; List <DAL.TherapyDoctorAdviceDetail> res = mapperDetail.Map <List <DAL.TherapyDoctorAdviceDetail> >(therapy.TherapyDoctorAdviceDetails);; temp.TherapyDoctorAdviceDetails = res; ctx.TherapyDoctorAdvices.Add(temp); try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
public List <CommContracts.TherapyDoctorAdvice> getAllTherapy(int RegistrationID) { List <CommContracts.TherapyDoctorAdvice> list = new List <CommContracts.TherapyDoctorAdvice>(); using (DAL.HisContext ctx = new DAL.HisContext()) { var query = from t in ctx.TherapyDoctorAdvices where t.RegistrationID == RegistrationID select t; foreach (DAL.TherapyDoctorAdvice th in query) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <DAL.TherapyDoctorAdvice, CommContracts.TherapyDoctorAdvice>(); }); var mapper = config.CreateMapper(); CommContracts.TherapyDoctorAdvice temp = mapper.Map <CommContracts.TherapyDoctorAdvice>(th); list.Add(temp); } } return(list); }
public CommContracts.TherapyDoctorAdvice GetTherapy(int Id) { CommContracts.TherapyDoctorAdvice therapy = new CommContracts.TherapyDoctorAdvice(); using (DAL.HisContext ctx = new DAL.HisContext()) { var query = from t in ctx.TherapyDoctorAdvices where t.ID == Id select t; var config = new MapperConfiguration(cfg => { cfg.CreateMap <DAL.TherapyDoctorAdvice, CommContracts.TherapyDoctorAdvice>(); }); var mapper = config.CreateMapper(); foreach (var tem in query) { therapy = mapper.Map <CommContracts.TherapyDoctorAdvice>(tem); break; } } return(therapy); }
public bool SaveTherapyDoctorAdvice(CommContracts.TherapyDoctorAdvice therapyDoctorAdvice) { CommClient.TherapyDoctorAdvice therapy = new CommClient.TherapyDoctorAdvice(); return(therapy.SaveTherapyDoctorAdvice(therapyDoctorAdvice)); }
public string newTherapy() { CommContracts.TherapyDoctorAdvice therapy = new CommContracts.TherapyDoctorAdvice(); CurrentTherapy = therapy; return(CurrentTherapy.ToString()); }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { List <MyDetail> listDetail = myTableEdit.GetAllDetails(); List <CommContracts.TherapyDoctorAdviceDetail> list = new List <CommContracts.TherapyDoctorAdviceDetail>(); decimal sum = 0.0m; foreach (var tem in listDetail) { CommContracts.TherapyDoctorAdviceDetail recipeDetail = new CommContracts.TherapyDoctorAdviceDetail(); recipeDetail.TherapyID = tem.ID; recipeDetail.AllNum = tem.SingleDose; recipeDetail.Remarks = tem.Illustration; list.Add(recipeDetail); sum += tem.SellPrice * tem.SingleDose; } CommContracts.TherapyDoctorAdvice therapyDoctorAdvice = new CommContracts.TherapyDoctorAdvice(); var vm = this.DataContext as HISGUIDoctorVM; if (vm.IsClinicOrInHospital) { if (vm.CurrentRegistration != null) { therapyDoctorAdvice.RegistrationID = vm.CurrentRegistration.ID; therapyDoctorAdvice.PatientID = vm.CurrentRegistration.PatientID; } } else { if (vm.CurrentInHospital != null) { therapyDoctorAdvice.InpatientID = vm.CurrentInHospital.ID; therapyDoctorAdvice.PatientID = vm.CurrentInHospital.PatientID; } } therapyDoctorAdvice.SumOfMoney = sum; therapyDoctorAdvice.WriteTime = DateTime.Now; if (vm.CurrentUser != null) { therapyDoctorAdvice.WriteDoctorUserID = vm.CurrentUser.ID; } therapyDoctorAdvice.TherapyDoctorAdviceDetails = list; bool?saveResult = vm?.SaveTherapyDoctorAdvice(therapyDoctorAdvice); if (!saveResult.HasValue) { MessageBox.Show("保存失败!"); return; } else if ((bool)saveResult.Value) { MessageBox.Show("保存成功!"); newTherapy(); getAllTherapyList(); } else { MessageBox.Show("保存失败!"); return; } }