public FinancialTransactionEdit(DialogMode mode, int?transactionID, int clientID, int?appointmentID, IDialogService dialogService, IMessageBoxService messageService) : base(mode, dialogService, messageService) { SubTitle = "финансовой операции"; if (transactionID.HasValue) { _data = _dc.FinancialTransactions.SingleOrDefault(x => x.ID == transactionID); // _data.ModifiedBy = CurrentUser.ID; _data.ModificationTime = DateTime.Now; } else { var client = _dc.Customers.Single(x => x.ID == clientID); Models.Appointment appointment = null; if (appointmentID.HasValue) { appointment = _dc.Appointments.SingleOrDefault(x => x.ID == appointmentID); } _data = new Models.FinancialTransaction() { Customer = client, Appointment = appointment, TransactionTypeID = (int)TransactionType.Deposit, CreatedBy = CurrentUser.ID, CreationTime = DateTime.Now, Amount = 0m }; _dc.FinancialTransactions.Add(_data); }; }
private void OnDialogPayCommandtExecuting(CancelEventArgs args) { if (Validate()) { if (MessageService.Show(String.Format("Провести операцию оплаты за визит в размере {0:c}?", ToPay), "Регистрация оплаты визита", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var ft = new Models.FinancialTransaction() { Appointment = _data, Customer = _data.Customer, Amount = ToPay, CreatedBy = UserProfileService.CurrentUser.ID, CreationTime = DateTime.Now, TransactionTypeID = (int)TransactionType.Deposit }; _data.StateID = (int)AppointmentState.Completed; _dc.FinancialTransactions.Add(ft); if (_detailsChanged) { _dc.AppointmentDetails.RemoveRange(_data.AppointmentDetails); foreach (var d in Details) { _dc.AppointmentDetails.Add(d); } ; } ; _dc.SaveChanges(); } else { args.Cancel = true; }; } else { args.Cancel = true; } }