public void AddCheque(string id, string amount, string chequeNumber, DateTime date, string remarks, DateTime cheque, string randomKey)
        {
            var BankId = int.Parse(id);
            var Bank = Context.Banks.SingleOrDefault(entity => entity.PartyRoleId == BankId);
            decimal chequeAmount = decimal.Parse(amount);
            DateTime transactionDate = date;

            LoanRestructureForm form = this.CreateOrRetrieve<LoanRestructureForm>();
            //ChequeModel model = new ChequeModel(Bank, chequeAmount, chequeNumber, transactionDate, remarks, cheque);
            //if (form.AvailableCheques.Count() == 0 || form.AvailableCheques.Count() < int.Parse(nfLoanTerm.Text))
            //    form.AddChequesListItem(model);
            //if (form.AvailableCheques.Count() == int.Parse(nfLoanTerm.Text))
            //    btnAddCheque.Disabled = true;
            ChequeModel model = new ChequeModel();
            ChequeModel mod = new ChequeModel();
            List<ChequeModel> chcks = new List<ChequeModel>();
            if (form.RetrieveCheque1(randomKey) != null)
            {
                model = form.RetrieveCheque1(randomKey);
                model.BankId = BankId;
                model.BankName = Bank.PartyRole.Party.Name;
                model.ChequeNumber = chequeNumber;

                mod = form.Cheques1.FirstOrDefault();
                chcks = form.Cheques1;

                storeCheques.DataSource = form.AvailableCheques1;
                storeCheques.DataBind();
            }
            else
            {
                model = form.RetrieveCheque2(randomKey);
                model.BankId = BankId;
                model.BankName = Bank.PartyRole.Party.Name;
                model.ChequeNumber = chequeNumber;

                mod = form.Cheques2.FirstOrDefault();
                chcks = form.Cheques2;

                storeCheques2.DataSource = form.AvailableCheques2;
                storeCheques2.DataBind();
            }

            if (mod.RandomKey == model.RandomKey)
            {
                foreach (var ch in chcks)
                {
                    if (ch.RandomKey != mod.RandomKey)
                    {
                        ch.BankId = mod.BankId;
                        ch.BankName = mod.BankName;
                    }
                }
            }
        }
        public void AddCheque(string id, string amount, string chequeNumber, DateTime date, string remarks, DateTime cheque)
        {
            var BankId = int.Parse(id);
            var Bank = ObjectContext.Banks.SingleOrDefault(entity => entity.PartyRoleId == BankId);
            decimal chequeAmount = decimal.Parse(amount);
            DateTime transactionDate = date;

            LoanApplicationForm form = this.CreateOrRetrieve<LoanApplicationForm>();
            ChequeModel model = new ChequeModel(Bank, chequeAmount, chequeNumber, transactionDate, remarks, cheque);
            form.AddCheque(model);
            storeCheques.DataSource = form.AvailableCheques;
            storeCheques.DataBind();
        }
        protected void btnGenerate_Click(object sender, DirectEventArgs e)
        {
            var today = DateTime.Now;
            LoanRestructureForm oldForm = this.Retrieve<LoanRestructureForm>(ParentResourceGuid);
            LoanRestructureListModel model = oldForm.RetrieveLoanRestructureList(this.hiddenRandomKey.Value.ToString());

            LoanRestructureForm form = this.CreateOrRetrieve<LoanRestructureForm>();
            form.FinancialAccountId = int.Parse(hdnSelectedLoanID.Value.ToString());
            form.CustomerId = int.Parse(hiddenCustomerId.Value.ToString());
            form.ModifiedBy = UserAccount.GetAssociatedEmployee(this.LoginInfo.UserId).PartyRoleId;

            //form.ChangeIcmAccount.RemainingPayments = int.Parse(model.RemainingPayments);
            form.ChangeIcmAccount.NewInterestRate = decimal.Parse(hiddenNewInterestRate.Value.ToString());
            form.ChangeIcmAccount.BalanceToCarryOver = Decimal.Parse(hiddenBalance.Value.ToString());
            form.ChangeIcmAccount.RemainingPayments = int.Parse(nfLoanTerm.Text);
            form.ChangeIcmAccount.NewLoanAmount = form.ChangeInterestAccount.BalanceToCarryOver;
            form.ChangeIcmAccount.Term = form.ChangeIcmAccount.RemainingPayments;
            form.ChangeIcmAmortizationSchedule.Clear();

            form.GenerateChangeIcmAmortizationSchedule(today);

            storeAmortizationSchedule.DataSource = form.ChangeIcmAmortizationSchedule.ToList();
            storeAmortizationSchedule.DataBind();

            int partyRoleId = int.Parse(hiddenCustomerId.Value.ToString());
            var customer = Context.Customers.SingleOrDefault(entity => entity.PartyRoleId == partyRoleId);
            var type = customer.CurrentCustomerCategory.CustomerCategoryType1.Name;

            //if (type == CustomerCategoryType.OthersType.Name)
            //{
            var count = form.RetrieveAssociatedCheques(form.FinancialAccountId).Count();

            if (chkAddChecks.Checked)
            {
                var chequesTemp = form.Cheques;

                form.Cheques.Clear();
                int i = 0;
                foreach (var items in form.ChangeIcmAmortizationSchedule)
                {
                    ChequeModel chequeModel = new ChequeModel();
                    chequeModel.BankName = "";
                    chequeModel.ChequeNumber = "";

                    chequeModel.ChequeDate = items.ScheduledPaymentDate;
                    chequeModel.Status = ChequeStatusType.ReceivedType.Name;
                    chequeModel.TransactionDate = today;
                    chequeModel.Amount = items.TotalPayment;

                    form.AddChequesListItem(chequeModel);
                    i++;
                }

                storeCheques.DataSource = form.AvailableCheques;
                storeCheques.DataBind();

                if (form.AvailableCheques.Count() != 0)
                    grdpnlCheque.Disabled = false;
            }
            else
            {
                form.Cheques.Clear();
                storeCheques.RemoveAll();
                grdpnlCheque.Disabled = true;
            }
            btnAddCheque.Disabled = true;
        }
Esempio n. 4
0
        private void FillChecks(string type, string randomKey, LoanRestructureForm form)
        {
            List<ChequeModel> chequeList = new List<ChequeModel>();
            ChequeModel model = new ChequeModel();
            ChequeModel mod = new ChequeModel();
            if (type == "splitLoan")
            {
                if (form.RetrieveCheque1(randomKey) != null)
                {
                    model = form.RetrieveCheque1(randomKey);
                    mod = form.Cheques1.FirstOrDefault();
                    chequeList = form.Cheques1;
                    hdnChequeType.Value = 1;
                }
                else
                {
                    model = form.RetrieveCheque2(randomKey);
                    mod = form.Cheques2.FirstOrDefault();
                    chequeList = form.Cheques2;
                    hdnChequeType.Value = 2;
                }
            }
            else
            {
                model = form.RetrieveCheque(randomKey);
                mod = form.Cheques.FirstOrDefault();
                chequeList = form.Cheques;
                hdnChequeType.Value = 0;
            }

            if (model.RandomKey != mod.RandomKey)
            {
                //btnBankBrowse.Hidden = true;
                txtBank.Text = mod.BankName;
                hdnBankID.Value = mod.BankId;
            }
            else if (model.RandomKey == mod.RandomKey)
            {
                hdnBankID.Value = model.BankId;
                txtBank.Text = model.BankName;
            }

            txtAmount.Text = model.Amount.ToString("N");
            dtCheckDate.SelectedDate = model.ChequeDate;
            txtCheckNumber.Text = model.ChequeNumber;
            txtPaymentMethod.Text = PaymentMethodType.PersonalCheckType.Name;
        }
        private void CreateReceiptStatus(Receipt receipt, ChequeModel model, DateTime today)
        {
            ReceiptStatu receiptStatus = new ReceiptStatu();
            receiptStatus.Receipt = receipt;
            receiptStatus.ReceiptStatusType = ReceiptStatusType.OpenReceiptStatusType;
            receiptStatus.Remarks = model.Remarks;
            receiptStatus.TransitionDateTime = today;
            receiptStatus.IsActive = true;

            Context.ReceiptStatus.AddObject(receiptStatus);
        }
        private void CreateChequeStatus(Cheque cheque, ChequeModel model, DateTime today)
        {
            ChequeStatu chequeStatus = new ChequeStatu();
            chequeStatus.Cheque = cheque;
            chequeStatus.ChequeStatusType = ChequeStatusType.ReceivedType;
            chequeStatus.Remarks = model.Remarks;
            chequeStatus.TransitionDateTime = today;
            chequeStatus.IsActive = true;

            Context.ChequeStatus.AddObject(chequeStatus);
        }
        private void ChequeModelPrepareForSave(FinancialAccount financialAccount, PartyRole customerPartyRole, int employeePartyRoleId, DateTime today, ChequeModel model)
        {
            if (model.IsNew)
            {
                var application = financialAccount.Agreement.Application;
                var loanAccount = financialAccount.LoanAccount;

                //new payment
                Payment payment = CreatePayment(customerPartyRole, employeePartyRoleId, model, today);

                //new cheque
                Cheque newCheck = new Cheque();
                newCheck.BankPartyRoleId = model.BankId;
                newCheck.CheckDate = model.ChequeDate;
                newCheck.Payment = payment;

                //new cheque association
                ChequeApplicationAssoc chequeAssoc = new ChequeApplicationAssoc();
                chequeAssoc.Cheque = newCheck;
                chequeAssoc.Application = application;

                //new cheque loan association
                ChequeLoanAssoc chequeLoanAssoc = new ChequeLoanAssoc();
                chequeLoanAssoc.Cheque = newCheck;
                chequeLoanAssoc.LoanAccount = loanAccount;

                //new receipt
                Receipt newReceipt = CreateReceipt(customerPartyRole, payment, model);

                //new receipt payment assoc
                ReceiptPaymentAssoc newReceiptAssoc = CreateReceiptPaymentAssoc(payment, newReceipt);

                //new receipt status
                CreateReceiptStatus(newReceipt, model, today);

                //new cheque status
                CreateChequeStatus(newCheck, model, today);

                Context.Cheques.AddObject(newCheck);
            }
            else if (model.ToBeDeleted)
            {
                //throw new NotImplementedException();
                var payment = Context.Payments.SingleOrDefault(entity => entity.Id == model.PaymentId);
                var receiptPaymentAssoc = Context.ReceiptPaymentAssocs.SingleOrDefault(entity => entity.PaymentId == payment.Id);
                var receipts = receiptPaymentAssoc.Receipt;
                var cheque = Context.Cheques.SingleOrDefault(entity => entity.Id == model.ChequeId && entity.PaymentId == payment.Id);

                var assoc = Context.ChequeApplicationAssocs.SingleOrDefault(entity => entity.ChequeId == cheque.Id);

                Context.ReceiptPaymentAssocs.DeleteObject(receiptPaymentAssoc);
                Context.Receipts.DeleteObject(receipts);
                Context.ChequeApplicationAssocs.DeleteObject(assoc);
                Context.Cheques.DeleteObject(cheque);
                Context.Payments.DeleteObject(payment);
            }
        }
        public Receipt CreateReceipt(PartyRole customerPartyRole, Payment payment, ChequeModel model)
        {
            Receipt newReceipt = new Receipt();
            newReceipt.ReceiptBalance = model.Amount;
            Context.Receipts.AddObject(newReceipt);

            return newReceipt;
        }
        public Payment CreatePayment(PartyRole customerPartyRole, int employeePartyRoleId, ChequeModel model, DateTime today)
        {
            //Payment newPayment = new Payment();
            //newPayment.ProcessedByPartyRoleId = employeePartyRoleId;
            //newPayment.ProcessedToPartyRoleId = customerPartyRole.Id;
            //newPayment.PaymentType = PaymentType.Receipt;
            //newPayment.PaymentMethodType = PaymentMethodType.PersonalCheckType;
            //newPayment.TransactionDate = model.TransactionDate.Date;
            //newPayment.EntryDate = today;
            //newPayment.TotalAmount = model.Amount;
            //newPayment.PaymentReferenceNumber = model.ChequeNumber;

            Payment newPayment = Payment.CreatePayment(today, model.TransactionDate.Date, customerPartyRole.Id,
                                                        employeePartyRoleId, model.Amount, PaymentType.Receipt,
                                                        PaymentMethodType.PersonalCheckType, SpecificPaymentType.LoanPaymentType,
                                                        model.ChequeNumber);

            Context.Payments.AddObject(newPayment);

            return newPayment;
        }
        protected void btnGenerate_Click(object sender, DirectEventArgs e)
        {
            var today = DateTime.Now;
            LoanRestructureForm oldForm = this.Retrieve<LoanRestructureForm>(ParentResourceGuid);
            LoanRestructureListModel model = oldForm.RetrieveLoanRestructureList(this.hiddenRandomKey.Value.ToString());

            LoanRestructureForm form = this.CreateOrRetrieve<LoanRestructureForm>();
            form.FinancialAccountId = int.Parse(hdnSelectedLoanID.Value.ToString());
            form.CustomerId = int.Parse(hiddenCustomerId.Value.ToString());
            form.ModifiedBy = UserAccount.GetAssociatedEmployee(this.LoginInfo.UserId).PartyRoleId;

            FinancialAccount financialAccount = Context.FinancialAccounts.SingleOrDefault(entity => entity.Id == form.FinancialAccountId && entity.Agreement.EndDate == null);
            FinancialAccountProduct financialAccountProduct = financialAccount.FinancialAccountProducts.FirstOrDefault(entity => entity.EndDate == null);
            FinancialProduct product = financialAccountProduct.FinancialProduct;

            var minimumAmount = ProductFeatureApplicability.GetActive(ProductFeature.MinimumLoanableAmountType, product);
            var minimumLoanable = (minimumAmount != null) ? minimumAmount.Value : 0;

            var maximumAmount = ProductFeatureApplicability.GetActive(ProductFeature.MaximumLoanableAmountType, product);
            var maximumLoanable = (maximumAmount != null) ? maximumAmount.Value : 0;

            var bal = Decimal.Parse(hiddenBalance.Value.ToString());
            var additionalAmount = 0M;
            if (!string.IsNullOrEmpty(txtAdditionalAmount.Text))
            {
                additionalAmount = Decimal.Parse(txtAdditionalAmount.Text);

                var totalAmount = bal + additionalAmount;
                if (totalAmount <= maximumLoanable)
                {
                    //form.AdditionalLoanAccount.RemainingPayments = int.Parse(model.RemainingPayments);
                    form.AdditionalLoanAccount.BalanceToCarryOver = Decimal.Parse(hiddenBalance.Value.ToString());
                    form.AdditionalLoanAccount.AdditionalAmount = Decimal.Parse(txtAdditionalAmount.Text);
                    form.AdditionalLoanAccount.LoanReleaseDate = datLoanReleaseDate.SelectedDate;

                    form.AdditionalLoanAmortizationSchedule.Clear();
                    form.GenerateAdditionalLoanAmortizationSchedule(today);

                    storeAmortizationSchedule.DataSource = form.AdditionalLoanAmortizationSchedule.ToList();
                    storeAmortizationSchedule.DataBind();

                    btnSave.Disabled = false;

                    int partyRoleId = int.Parse(hiddenCustomerId.Value.ToString());
                    var customer = Context.Customers.SingleOrDefault(entity => entity.PartyRoleId == partyRoleId);
                    var type = customer.CurrentCustomerCategory.CustomerCategoryType1.Name;

                    //if (type == CustomerCategoryType.OthersType.Name)
                    //{
                    var count = form.RetrieveAssociatedCheques(financialAccount.Id).Count();

                    if (chkAddChecks.Checked)
                    {
                        form.Cheques.Clear();
                        foreach (var items in form.AdditionalLoanAmortizationSchedule)
                        {
                            ChequeModel chequeModel = new ChequeModel();
                            chequeModel.BankName = "";
                            chequeModel.ChequeDate = items.ScheduledPaymentDate;
                            chequeModel.ChequeNumber = "";
                            chequeModel.Status = ChequeStatusType.ReceivedType.Name;
                            chequeModel.TransactionDate = today;
                            chequeModel.Amount = items.TotalPayment;

                            form.AddChequesListItem(chequeModel);
                        }

                        storeCheques.DataSource = form.AvailableCheques;
                        storeCheques.DataBind();

                        if (form.AvailableCheques.Count() != 0)
                            grdpnlCheque.Disabled = false;
                    }
                    else
                    {
                        form.Cheques.Clear();
                        storeCheques.RemoveAll();
                        grdpnlCheque.Disabled = true;
                    }

                    X.MessageBox.Alert("Status", "Amortization schedule successfully generated.").Show();

                }
                else
                {
                    X.MessageBox.Alert("Cannot generate schedule", "New loan amount exceeds the maximum loanable amount. Please specify new additional amount.").Show();
                    btnSave.Disabled = true;
                }
            }
            else
            {
                X.MessageBox.Alert("Cannot generate schedule", "Please specify additional amount.").Show();
            }
        }
        private void Fill()
        {
            LoanRestructureForm form = this.Retrieve<LoanRestructureForm>(ParentResourceGuid);
            LoanRestructureForm newForm = this.CreateOrRetrieve<LoanRestructureForm>();
            newForm.FinancialAccountId = form.FinancialAccountId;
            newForm.FinancialProductId1 = form.FinancialProductId1;
            newForm.FinancialProductId2 = form.FinancialProductId2;
            newForm.CustomerId = form.CustomerId;
            newForm.SplitLoanItemsAccount1 = form.SplitLoanItemsAccount1;
            newForm.SplitLoanItemsAccount2 = form.SplitLoanItemsAccount2;
            newForm.ModifiedBy = form.ModifiedBy;
            hiddenResourceGUID.Value = this.ResourceGuid;

            var today = DateTime.Now;
            newForm.SplitLoanAmortizationSchedule1.Clear();
            newForm.SplitLoanAmortizationSchedule2.Clear();
            newForm.GenerateSplitAccountAmortizationSchedule(today);

            storeAmortizationSchedule.DataSource = newForm.SplitLoanAmortizationSchedule1.ToList();
            storeAmortizationSchedule.DataBind();

            store1.DataSource = newForm.SplitLoanAmortizationSchedule2.ToList();
            store1.DataBind();

            int partyRoleId = form.CustomerId;
            var customer = Context.Customers.SingleOrDefault(entity => entity.PartyRoleId == partyRoleId);
            var type = customer.CurrentCustomerCategory.CustomerCategoryType1.Name;

            //if (type == CustomerCategoryType.OthersType.Name)
            //{
            if (form.SplitLoanItemsAccount1.AddPostDatedChecks)
            {
                grdpnlCheque1.Disabled = false;

                newForm.Cheques1.Clear();
                foreach (var items in newForm.SplitLoanAmortizationSchedule1)
                {
                    ChequeModel chequeModel = new ChequeModel();
                    chequeModel.BankName = "";
                    chequeModel.ChequeDate = items.ScheduledPaymentDate;
                    chequeModel.ChequeNumber = "";
                    chequeModel.Status = ChequeStatusType.ReceivedType.Name;
                    chequeModel.TransactionDate = today;
                    chequeModel.Amount = items.TotalPayment;

                    newForm.AddCheques1(chequeModel);
                }

                storeCheques.DataSource = newForm.AvailableCheques1;
                storeCheques.DataBind();
            }

            if (form.SplitLoanItemsAccount2.AddPostDatedChecks)
            {
                grdpnlCheque2.Disabled = false;

                newForm.Cheques2.Clear();
                foreach (var items in newForm.SplitLoanAmortizationSchedule2)
                {
                    ChequeModel chequeModel = new ChequeModel();
                    chequeModel.BankName = "";
                    chequeModel.ChequeDate = items.ScheduledPaymentDate;
                    chequeModel.ChequeNumber = "";
                    chequeModel.Status = ChequeStatusType.ReceivedType.Name;
                    chequeModel.TransactionDate = today;
                    chequeModel.Amount = items.TotalPayment;

                    newForm.AddCheques2(chequeModel);
                }

                storeCheques2.DataSource = newForm.AvailableCheques2;
                storeCheques2.DataBind();
            }
        }
        private void Fill(LoanRestructureForm form)
        {
            LoanRestructureForm newForm = this.CreateOrRetrieve<LoanRestructureForm>();
            newForm.CustomerId = form.CustomerId;
            newForm.FinancialAccountId = form.FinancialAccountId;
            newForm.FinancialAccountId2 = form.FinancialAccountId2;
            newForm.ConsolidateLoanAccount = form.ConsolidateLoanAccount;
            newForm.ModifiedBy = form.ModifiedBy;
            newForm.FinancialProductId1 = form.FinancialProductId1;

            var today = DateTime.Now;
            newForm.ConsolidateLoanAmortizationSchedule.Clear();
            newForm.GenerateConsolidateLoanAmortizationSchedule(today);

            storeAmortizationSchedule.DataSource = newForm.ConsolidateLoanAmortizationSchedule.ToList();
            storeAmortizationSchedule.DataBind();

            int partyRoleId = newForm.CustomerId;
            var customer = Context.Customers.SingleOrDefault(entity => entity.PartyRoleId == partyRoleId);
            var type = customer.CurrentCustomerCategory.CustomerCategoryType1.Name;

            //if (type == CustomerCategoryType.OthersType.Name)
            //{
                newForm.Cheques.Clear();
                foreach (var items in newForm.ConsolidateLoanAmortizationSchedule)
                {
                    ChequeModel chequeModel = new ChequeModel();
                    chequeModel.BankName = "";
                    chequeModel.ChequeDate = items.ScheduledPaymentDate;
                    chequeModel.ChequeNumber = "";
                    chequeModel.Status = ChequeStatusType.ReceivedType.Name;
                    chequeModel.TransactionDate = today;
                    chequeModel.Amount = items.TotalPayment;

                    newForm.AddChequesListItem(chequeModel);
                }

                storeCheques.DataSource = newForm.AvailableCheques;
                storeCheques.DataBind();

                if (newForm.AvailableCheques.Count() != 0)
                    grdpnlCheque.Disabled = false;
            //}
        }
        protected void btnGenerate_Click(object sender, DirectEventArgs e)
        {
            LoanApplicationForm form = this.CreateOrRetrieve<LoanApplicationForm>();
            form.AmortizationSchedules.Clear();
            form.Cheques.Clear();

            var today = DateTime.Now;

            LoanCalculatorOptions options = new LoanCalculatorOptions();
            options.LoanReleaseDate = datLoanReleaseDate.SelectedDate;
            options.PaymentStartDate = datPaymentStartDate.SelectedDate;
            options.LoanAmount = Convert.ToDecimal(this.nfLoanAmount.Value);
            options.LoanTerm = (int)nfLoanTerm.Number;
            options.LoanTermId = int.Parse(hiddenLoanTermTimeUnitId.Text);
            options.PaymentMode = cmbPaymentMode.SelectedItem.Text;
            options.PaymentModeId = int.Parse(cmbPaymentMode.SelectedItem.Value);
            options.InterestComputationMode = cmbInterestComputationMode.SelectedItem.Text;
            options.InterestRateDescription = cmbInterestRate.SelectedItem.Text;
            options.InterestRate = (decimal)nfInterestRate.Number;
            options.InterestRateDescriptionId = int.Parse(cmbInterestRate.SelectedItem.Value);
            options.PaymentStartDate = datPaymentStartDate.SelectedDate;
            options.LoanReleaseDate = datLoanReleaseDate.SelectedDate;
            options.TermOption = txtTermOption.Text;

            LoanCalculator calculator = new LoanCalculator();
            var models = calculator.GenerateLoanAmortization(options);

            storeAmortizationSchedule.DataSource = models;
            storeAmortizationSchedule.DataBind();

            List<AmortizationScheduleModel> sched = new List<AmortizationScheduleModel>();
            foreach (var item in models)
            {
                form.AddSchedule(item);
                sched.Add(item);
            }

            if (chckCheck.Checked)
            {
                List<ChequeModel> cheque = new List<ChequeModel>();

                foreach (AmortizationScheduleModel model in models)
                {
                    ChequeModel cheques = new ChequeModel();
                    cheques.Amount = model.TotalPayment;
                    cheques.ChequeDate = model.ScheduledPaymentDate;
                    form.AddCheque(cheques);
                    cheque.Add(cheques);
                }

                storeCheques.DataSource = cheque;
                storeCheques.DataBind();
            }
            else if (chckCheck.Checked == false)
            {
                this.SelectionModelCheque.SelectAll();
                grdpnlCheque.DeleteSelected();
                form.Cheques.Clear();
            }

            hdnOnChangeDates.Value = "0";
        }
 public void RetrieveCheque(ChequeModel model)
 {
     txtAmount.Text = model.Amount.ToString();
     txtBank.Text = model.BankName;
     txtCheckNumber.Text = model.ChequeNumber;
     dtCheckDate.SelectedDate = model.ChequeDate;
 }
        public void RetrieveCheque(ChequeModel model)
        {
            txtAmount.Text = model.Amount.ToString();
            txtBank.Text = model.BankName;
            //txtCheckNumber.Text = model.ChequeNumber;
            dtCheckDate.SelectedDate = model.ChequeDate;
            var payment = ObjectContext.Payments.SingleOrDefault(e => e.Id == model.PaymentId);

            if (payment != null)
            {
                txtPaymentMethod.Text = payment.PaymentMethodType.Name;
                txtCheckNumber.Text = payment.PaymentReferenceNumber;
            }
            else
            {
                txtPaymentMethod.Text = PaymentMethodType.PersonalCheckType.Name;
            }
        }