public void FillFinancialProductDetails1(int financialProductId)
        {
            hiddenProductId1.Value = financialProductId;
            FinancialProduct product = FinancialProduct.GetById(financialProductId);
            this.txtLoanProductName1.Text = product.Name;

            var minimumTerm = ProductFeatureApplicability.GetActive(ProductFeature.MinimumLoanTermType, product);
            var minimumLoanTerm = (minimumTerm != null) ? minimumTerm.LoanTerm.LoanTermLength : 0;

            var maximumTerm = ProductFeatureApplicability.GetActive(ProductFeature.MaximumLoanTermType, product);
            var maximumLoanTerm = (maximumTerm != null) ? maximumTerm.LoanTerm.LoanTermLength : 0;

            hiddenLoanTermTimeUnitId1.Value = minimumTerm.LoanTerm.UomId;
            this.cmbUnit1.SelectedItem.Value = minimumTerm.LoanTerm.UomId.ToString();
            this.cmbUnit1.ReadOnly = true;

            //txtTerm.MinValue = minimumLoanTerm;
            txtTerm.MaxValue = maximumLoanTerm;
            txtTerm.ReadOnly = false;
            txtTerm.Number = txtTerm.Number;

            if (txtTerm.Number == 0)
            {
                btnGenerate.Hidden = true;
                btnSave.Hidden = false;
            }
            else
            {
                btnGenerate.Hidden = false;
                btnSave.Hidden = true;
            }

            var collateralRequirements = from pfa in
                                             ProductFeatureApplicability.GetAllActive(ProductFeatureCategory.CollateralRequirementType, product)
                                         select new ProductFeatureApplicabilityModel(pfa);

            var interestComputationModes = from pfa in
                                               ProductFeatureApplicability.GetAllActive(ProductFeatureCategory.InterestComputationModeType, product)
                                           select new ProductFeatureApplicabilityModel(pfa);

            var methodOfChargingInterests = from pfa in
                                                ProductFeatureApplicability.GetAllActive(ProductFeatureCategory.MethodofChargingInterestType, product)
                                            where pfa.ProductFeatureId != ProductFeature.DiscountedInterestType.Id
                                            select new ProductFeatureApplicabilityModel(pfa);

            cmbPaymentMode1.SelectedIndex = 3;
            cmbPaymentMode1.ReadOnly = true;

            CollateralRequirementStore.DataSource = collateralRequirements;
            CollateralRequirementStore.DataBind();
            cmbCollateralRequirement1.SelectedIndex = 0;

            InterestComputationModeStore.DataSource = interestComputationModes;
            InterestComputationModeStore.DataBind();
            cmbInterestComputationMode1.SelectedIndex = 0;

            MethodOfChargingInterestStore.DataSource = methodOfChargingInterests;
            MethodOfChargingInterestStore.DataBind();
            cmbMethodOfChargingInterest1.SelectedIndex = 0;

            var loanReleaseDate = DateTime.Today.AddMonths(-1);
            var paymentMode = UnitOfMeasure.MonthlyType.Name;

            var dtManager1 = new DateTimeOperationManager(paymentMode, loanReleaseDate);
            datPaymentStartDate.SelectedDate = dtManager1.Increment();
        }
        public void Retrieve(int id)
        {
            var loanApplication = LoanApplication.GetById(id);

            LoanApprovalForm form = this.CreateOrRetrieve<LoanApprovalForm>();
            form.Retrieve(loanApplication.ApplicationId);

            hdnCustomerID.Value = form.CustomerPartyRoleId;
            var loanTerm = UnitOfMeasure.GetByID(form.LoanTermUomId);
            this.nfLoanTerm.FieldLabel = string.Format("Loan Term ({0})", loanTerm.Name);
            var dateManager = new DateTimeOperationManager(form.PaymentModeName, datLoanReleaseDate.SelectedDate);
            datPaymentStartDate.SelectedDate = dateManager.Increment();

            var product = FinancialProduct.GetById(form.FinancialProductId);

            var minimumTerm = ProductFeatureApplicability.GetActive(ProductFeature.MinimumLoanTermType, product);
            var minimumLoanTerm = (minimumTerm != null) ? minimumTerm.LoanTerm.LoanTermLength : 0;

            var maximumTerm = ProductFeatureApplicability.GetActive(ProductFeature.MaximumLoanTermType, product);
            var maximumLoanTerm = (maximumTerm != null) ? maximumTerm.LoanTerm.LoanTermLength : 0;

            nfLoanAmount.Text = form.LoanAmount.ToString("N");
            nfLoanTerm.Text = loanApplication.LoanTermLength.ToString();

            SetAllInterestComputationModes(form);

            var agr = ObjectContext.Agreements.SingleOrDefault(entity => entity.ApplicationId == loanApplication.ApplicationId);
            var sched = ObjectContext.AmortizationSchedules.SingleOrDefault(entity => entity.AgreementId == agr.Id);
            datLoanReleaseDate.SelectedDate = sched.LoanReleaseDate;
            datPaymentStartDate.SelectedDate = sched.PaymentStartDate;

            form.LoanAmount = decimal.Parse(nfLoanAmount.Text);
            form.LoanTerm = Convert.ToInt32(nfLoanTerm.Text);
            form.PaymentStartDate = sched.PaymentStartDate;
            form.LoanReleaseDate = sched.LoanReleaseDate;
            form.ClearAndGenerateSchedule();

            storeAmortizationSchedule.DataSource = form.AmortizationSchedules;
            storeAmortizationSchedule.DataBind();

            PartyRole borrower = PartyRole.GetById(form.CustomerPartyRoleId);
            var formDetail = FormDetail.GetByLoanAppIdAndType(int.Parse(hdnSelectedLoanID.Value.ToString()), FormType.SPAType);
            EnableDisableControls(borrower.Party);
        }
        public bool setPaymentDate()
        {
            int id = Convert.ToInt32(hdnSelectedLoanID.Value);
            var loanApplication = LoanApplication.GetById(id);
            var paymentMode = UnitOfMeasure.GetByID(loanApplication.PaymentModeUomId);
            var dateManager = new DateTimeOperationManager(paymentMode.Name, datLoanReleaseDate.SelectedDate.AddMonths(-1));
            datPaymentStartDate.SelectedDate = dateManager.Increment();

            return true;
        }
 public bool setPaymentDate()
 {
     if (string.IsNullOrWhiteSpace(this.txtLoanProductName.Text) == false)
     {
         var dateManager = new DateTimeOperationManager(cmbPaymentMode.SelectedItem.Text, datLoanReleaseDate.SelectedDate);
         datPaymentStartDate.SelectedDate = dateManager.Increment();
         return true;
     }
     else
         return false;
 }