public static PaymentViewModel Create(EnumPaymentType paymentType, ITPaymentRepository tPaymentRepository, ITPaymentDetRepository tPaymentDetRepository) { PaymentViewModel viewModel = new PaymentViewModel(); TPayment p = new TPayment(); p.SetAssignedIdTo(Guid.NewGuid().ToString()); p.PaymentDate = DateTime.Today; p.PaymentDesc = string.Empty; p.PaymentType = paymentType.ToString(); viewModel.Payment = p; viewModel.Title = string.Format("Pembayaran {0}", paymentType.ToString()); //get label text switch (paymentType) { case EnumPaymentType.Piutang: viewModel.CashAccountLabel = "Deposit ke : "; break; case EnumPaymentType.Hutang: viewModel.CashAccountLabel = "Deposit dari : "; break; } return(viewModel); }
public static PaymentViewModel Create(EnumPaymentType paymentType, ITPaymentRepository tPaymentRepository, ITPaymentDetRepository tPaymentDetRepository, IMSupplierRepository mSupplierRepository, IMCustomerRepository mCustomerRepository, IMCostCenterRepository mCostCenterRepository) { PaymentViewModel viewModel = new PaymentViewModel(); TPayment p = new TPayment(); p.SetAssignedIdTo(Guid.NewGuid().ToString()); p.PaymentDate = DateTime.Today; p.PaymentDesc = string.Empty; p.PaymentType = paymentType.ToString(); viewModel.Payment = p; viewModel.Title = string.Format("Pembayaran {0}", paymentType.ToString()); IList <MCostCenter> list = mCostCenterRepository.GetAll(); MCostCenter costCenter = new MCostCenter(); costCenter.CostCenterName = "-Pilih Cost Center-"; list.Insert(0, costCenter); viewModel.CostCenterList = new SelectList(list, "Id", "CostCenterName"); //get label text switch (paymentType) { case EnumPaymentType.Piutang: viewModel.CashAccountLabel = "Deposit ke : "; //fill cust var values = from MCustomer cust in mCustomerRepository.GetAll() select new { Id = cust.Id, Name = cust.PersonId != null ? cust.PersonId.PersonName : "-Pilih Konsumen-" }; viewModel.TransByList = new SelectList(values, "Id", "Name"); break; case EnumPaymentType.Hutang: viewModel.CashAccountLabel = "Deposit dari : "; IList <MSupplier> listAcc = mSupplierRepository.GetAll(); MSupplier supplier = new MSupplier(); supplier.SupplierName = "-Pilih Supplier-"; listAcc.Insert(0, supplier); viewModel.TransByList = new SelectList(listAcc, "Id", "SupplierName"); break; } return(viewModel); }
public static TransactionPayment AddTransactionPayment(this Transaction currentTransaction, EnumPaymentType paymentType, decimal amount, DateTime timeStamp, DateTime datePaid, string notes) { TransactionPayment newTransactionPayment = new TransactionPayment(); newTransactionPayment.GUID = Guid.NewGuid().ToString(); newTransactionPayment.TransactionID = currentTransaction.TransactionID; newTransactionPayment.PaymentType = paymentType.ToString(); newTransactionPayment.Amount = amount; newTransactionPayment.TimeStamp = timeStamp; newTransactionPayment.DatePaid = datePaid; newTransactionPayment.Notes = notes; newTransactionPayment.Transaction = currentTransaction; return(newTransactionPayment); }
private ActionResult SavePayment(EnumPaymentType paymentType, TPayment paymentVM, FormCollection formCollection, bool isDelete) { string Message = string.Empty; bool Success = true; try { _tPaymentRepository.DbContext.BeginTransaction(); //check first TPayment payment = _tPaymentRepository.Get(formCollection["Id"]); if (!isDelete) { bool isEdit = false; if (payment == null) { isEdit = false; //if payment = new TPayment(); payment.SetAssignedIdTo(Guid.NewGuid().ToString()); payment.CreatedDate = DateTime.Now; payment.CreatedBy = User.Identity.Name; payment.DataStatus = Enums.EnumDataStatus.New.ToString(); } else { isEdit = true; payment.ModifiedDate = DateTime.Now; payment.ModifiedBy = User.Identity.Name; payment.DataStatus = Enums.EnumDataStatus.Updated.ToString(); } payment.PaymentDate = paymentVM.PaymentDate; payment.PaymentDesc = paymentVM.PaymentDesc; payment.PaymentStatus = paymentVM.PaymentStatus; payment.PaymentType = paymentType.ToString(); SavePayment(payment, formCollection, isEdit); } else { //if (tr != null) //{ // //do delete // DeleteTransaction(tr, addStock, calculateStock); //} } _tPaymentRepository.DbContext.CommitTransaction(); TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success; if (!isDelete) { Message = "Data berhasil disimpan."; } else { Message = "Data berhasil dihapus."; } } catch (Exception ex) { Success = false; if (!isDelete) { Message = "Data gagal disimpan."; } else { Message = "Data gagal dihapus."; } Message += "Error : " + ex.GetBaseException().Message; _tPaymentRepository.DbContext.RollbackTransaction(); TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Failed; } var e = new { Success, Message }; return(Json(e, JsonRequestBehavior.AllowGet)); }