コード例 #1
0
        public static InstallmentPaymentFormViewModel Create(ITInstallmentRepository installmentRepository, IMEmployeeRepository mEmployeeRepository, string loanCode)
        {
            installmentRepository.DbContext.BeginTransaction();
            InstallmentPaymentFormViewModel viewModel = new InstallmentPaymentFormViewModel();
            TInstallment ins = installmentRepository.GetLastInstallment(loanCode);

            if (ins == null)
            {
                ins = new TInstallment();
            }
            viewModel.installment = ins;
            viewModel.installment.InstallmentPaymentDate = DateTime.Today;
            installmentRepository.DbContext.RollbackTransaction();

            var       listEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.COL.ToString());
            MEmployee employee     = new MEmployee();

            //mCustomer.SupplierName = "-Pilih Supplier-";
            listEmployee.Insert(0, employee);

            var collector = from emp in listEmployee
                            //where emp.DepartmentId.DepartmentName == "COLLECTOR"
                            select new { Id = emp.Id, Name = emp.PersonId != null ? emp.PersonId.PersonName : "-Pilih Kolektor-" };

            viewModel.CollectorList = new SelectList(collector, "Id", "Id", string.Empty);

            return(viewModel);
        }
コード例 #2
0
        public ActionResult Acquittance(FormCollection formCollection, string loanCode)
        {
            string Message = string.Empty;
            bool   Success = true;

            try
            {
                _installmentRepository.DbContext.BeginTransaction();
                TInstallment installment = _installmentRepository.GetLastInstallment(loanCode);

                installment.EmployeeId             = _mEmployeeRepository.Get(formCollection["EmployeeId"]);
                installment.InstallmentPaymentDate = Helper.CommonHelper.ConvertToDate(formCollection["InstallmentPaymentDate"]);
                installment.InstallmentPaid        = Helper.CommonHelper.ConvertToDecimal(formCollection["MustPaid"]);
                installment.InstallmentStatus      = EnumInstallmentStatus.Paid.ToString();
                installment.InstallmentReceiptNo   = formCollection["ReceiptNo"];

                installment.ModifiedBy   = User.Identity.Name;
                installment.ModifiedDate = DateTime.Now;
                installment.DataStatus   = EnumDataStatus.Updated.ToString();
                _installmentRepository.Update(installment);

                _installmentRepository.DbContext.CommitTransaction();


                _loanRepository.DbContext.BeginTransaction();
                //update loan status to Paid when all installment have been paid
                TLoan loan = installment.LoanId;
                loan.LoanStatus = EnumLoanStatus.Paid.ToString();

                loan.ModifiedBy   = User.Identity.Name;
                loan.ModifiedDate = DateTime.Now;
                loan.DataStatus   = EnumDataStatus.Updated.ToString();

                _loanRepository.Update(loan);
                _loanRepository.DbContext.CommitTransaction();

                Success = true;
                Message = "Pelunasan Angsuran Berhasil Disimpan.";
            }
            catch (Exception ex)
            {
                Success = false;
                Message = "Error :\n" + ex.GetBaseException().Message;
                _installmentRepository.DbContext.RollbackTransaction();
            }
            var e = new
            {
                Success,
                Message
            };

            return(Json(e, JsonRequestBehavior.AllowGet));
        }