public bool SavePrePay(CommContracts.PatientCardPrePay prePay, ref int prePayID, ref string ErrorMsg) { using (DAL.HisContext ctx = new DAL.HisContext()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CommContracts.PatientCardPrePay, DAL.PatientCardPrePay>(); }); var mapper = config.CreateMapper(); DAL.PatientCardPrePay temp = new DAL.PatientCardPrePay(); temp = mapper.Map <DAL.PatientCardPrePay>(prePay); ctx.PatientCardPrePays.Add(temp); try { ctx.SaveChanges(); prePayID = temp.ID; } catch (Exception ex) { ErrorMsg = ex.Message; return(false); } } return(true); }
private void ReturnBtn_Click(object sender, RoutedEventArgs e) { // 保存退款 if (string.IsNullOrEmpty(this.FeeNumBox.Text)) { return; } if (Math.Round(Decimal.Parse(this.FeeNumBox.Text), 2) < 0) { return; } if (Math.Round(Decimal.Parse(this.BalanceBox.Text), 2) - Math.Round(Decimal.Parse(this.FeeNumBox.Text), 2) < 0) { return; } var vm = this.DataContext as HISGUIPatientCardVM; CommContracts.PatientCardPrePay prePay = new CommContracts.PatientCardPrePay(); prePay.PrePayType = CommContracts.PrePayTypeEnum.退款; prePay.PrePayMoney = Math.Round(Decimal.Parse(this.FeeNumBox.Text), 2); prePay.PrePayWayEnum = (CommContracts.PrePayWayEnum) this.PrePayWayCombo.SelectedItem; prePay.PatientID = vm.CurrentPatient.ID; prePay.UserID = vm.CurrentUser.ID; prePay.CurrentTime = DateTime.Now; CommClient.PatientCardPrePay prePayClient = new CommClient.PatientCardPrePay(); int prePayID = 0; string ErrorMsg = ""; if (prePayClient.SavePrePay(prePay, ref prePayID, ref ErrorMsg)) { CommClient.Patient patientClient = new CommClient.Patient(); vm.CurrentPatient.PatientCardBalance -= Math.Round(Decimal.Parse(this.FeeNumBox.Text), 2); if (patientClient.UpdatePatient(vm.CurrentPatient, ref ErrorMsg)) { MessageBox.Show("OK"); updatePatientsMsg(vm.CurrentPatient.PatientCardNo); } else { vm.CurrentPatient.PatientCardBalance += Math.Round(Decimal.Parse(this.FeeNumBox.Text), 2); prePayClient.DeletePrePay(prePayID); MessageBox.Show("Error:" + ErrorMsg); } } else { MessageBox.Show("Error" + ErrorMsg); } }
public bool SavePrePay(int PatientID, decimal money, int UserID) { CommClient.PatientCardPrePay myd = new CommClient.PatientCardPrePay(); CommContracts.PatientCardPrePay prePay = new CommContracts.PatientCardPrePay(); prePay.PatientID = PatientID; prePay.PrePayMoney = money; prePay.PrePayWayEnum = CommContracts.PrePayWayEnum.现金; prePay.UserID = UserID; prePay.CurrentTime = DateTime.Now; int prePayID = 0; string ErrorMsg = ""; return(myd.SavePrePay(prePay, ref prePayID, ref ErrorMsg)); }
public CommContracts.PatientCardPrePay GetPrePay(int Id) { CommContracts.PatientCardPrePay prePay = new CommContracts.PatientCardPrePay(); using (DAL.HisContext ctx = new DAL.HisContext()) { var query = from t in ctx.PatientCardPrePays where t.ID == Id select t; var config = new MapperConfiguration(cfg => { cfg.CreateMap <DAL.PatientCardPrePay, CommContracts.PatientCardPrePay>(); }); var mapper = config.CreateMapper(); foreach (var tem in query) { prePay = mapper.Map <CommContracts.PatientCardPrePay>(tem); break; } } return(prePay); }
public List <CommContracts.PatientCardPrePay> GetAllPrePay(int PatientID = 0) { List <CommContracts.PatientCardPrePay> list = new List <CommContracts.PatientCardPrePay>(); using (DAL.HisContext ctx = new DAL.HisContext()) { var query = from a in ctx.PatientCardPrePays where (a.PatientID != 0 || (a.PatientID == PatientID)) orderby a.CurrentTime descending select a; foreach (DAL.PatientCardPrePay ass in query) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <DAL.PatientCardPrePay, CommContracts.PatientCardPrePay>(); }); var mapper = config.CreateMapper(); CommContracts.PatientCardPrePay temp = mapper.Map <CommContracts.PatientCardPrePay>(ass); list.Add(temp); } } return(list); }