//
    public void paymentschedule()
    {
        decimal amt = 0;
        decimal per = 0;
        DateTime dt = DateTime.Now;
        int term = 0, freq = 0, type = 0;
        try
        {

            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter invApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();

            InvestmentDS.GetInvestmentAppDataTable tblInvApp = invApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (tblInvApp.Rows.Count > 0)
            {
                if (tblInvApp[0].IsdatInvestmentTypeNull() == false) { type = tblInvApp[0].datInvestmentType; }
                if (tblInvApp[0].IsdatInvestmentAmountNull() == false) { amt = tblInvApp[0].datInvestmentAmount; }
                if (tblInvApp[0].IsdatInterestRatePerAnnumNull() == false) {; per = tblInvApp[0].datInterestRatePerAnnum; }
                if (tblInvApp[0].IsdatTermsNull() == false) { term = tblInvApp[0].datTerms; }
                if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false) { freq = Convert.ToInt32(tblInvApp[0].datFrequencyOfInterestPayment); }
                if (tblInvApp[0].IsdatValueDateNull() == false) { dt = tblInvApp[0].datValueDate; }                
                term = converrtterm(term);
                freq = convertfrequency(freq);
                CalculateIntPayment(term, freq, amt, per, dt);


            }

        }
        catch (Exception ex) { }

    }
    /// <summary>
    /// This function displays information about current application being worked
    /// </summary>
    public void showLoanAppInfo()
    {
        mainDSTableAdapters.ClientTableAdapter client = new mainDSTableAdapters.ClientTableAdapter();
        InvestmentDSTableAdapters.GetInvestmentAppTableAdapter invApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
        InvestmentDS.GetInvestmentAppDataTable tblInvApp = invApp.GetInvestmentApp(MySessionManager.InvAppID);
        if (tblInvApp.Rows.Count > 0)
        {
            try
            {
                this.lblapplicantName.InnerText = client.GetClientsName(MySessionManager.ClientID).ToString();
                this.lblClientNo.InnerText = client.GetClientNo(MySessionManager.ClientID).ToString();
                if (tblInvApp[0].IsdatInvestmentAmountNull() == false) { this.lblInvestmentAmount.InnerText = tblInvApp[0].datInvestmentAmount.ToString("c").Replace("$", ""); }
                if (tblInvApp[0].IsdatInvestmentNameNull() == false) { this.lblInvestmentName.InnerText = tblInvApp[0].datInvestmentName.ToString(); }
                if (tblInvApp[0].IsdatTermsNull() == false) { this.lblTerm.InnerText = util.displayValue("opt_terms", tblInvApp[0].datTerms.ToString()) + " days"; }
                if (tblInvApp[0].IsdatApplicationNumberNull() == false) { this.lblAppNo.InnerText = tblInvApp[0].datApplicationNumber.ToString(); }
                if (tblInvApp[0].IsdatValueDateNull() == false) { this.lblValueDate.InnerText = tblInvApp[0].datValueDate.ToString("c").Replace("$", ""); }
                if (tblInvApp[0].IsdatInvestmentTypeNull() == false) { this.lblInvtype.InnerText = util.displayValue("opt_investment_types", tblInvApp[0].datInvestmentType.ToString()); }
                if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false) { this.lblAccInterest.InnerText = tblInvApp[0].datFrequencyOfInterestPayment.ToString(); }

            }
            catch (Exception ex)
            { }
        }

    }
Exemplo n.º 3
0
    public void loadInvestmentDetails()
    {
        decimal  amt = 0;
        decimal  per = 0;
        DateTime dt = DateTime.Now;
        int      term = 0, freq = 0, type = 0;

        try
        {
            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter invApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();

            InvestmentDS.GetInvestmentAppDataTable tblInvApp = invApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (tblInvApp.Rows.Count > 0)
            {
                if (tblInvApp[0].IsdatInvestmentNameNull() == false)
                {
                    txtName.Value = tblInvApp[0].datInvestmentName.ToString();
                }
                if (tblInvApp[0].IsdatInvestmentTypeNull() == false)
                {
                    ddlType.SelectedValue = tblInvApp[0].datInvestmentType.ToString(); type = tblInvApp[0].datInvestmentType;
                }
                if (tblInvApp[0].IsdatInvestmentAmountNull() == false)
                {
                    txtInvestmentAmt.Value = tblInvApp[0].datInvestmentAmount.ToString(); amt = tblInvApp[0].datInvestmentAmount;
                }
                if (tblInvApp[0].IsdatModeOfRepaymentNull() == false)
                {
                    ddlModeOfInv.SelectedValue = tblInvApp[0].datModeOfRepayment.ToString();
                }
                if (tblInvApp[0].IsdatInterestRatePerAnnumNull() == false)
                {
                    txtRatePerAnnum.Value = tblInvApp[0].datInterestRatePerAnnum.ToString(); per = tblInvApp[0].datInterestRatePerAnnum;
                }
                if (tblInvApp[0].IsdatTermsNull() == false)
                {
                    ddlTerms.SelectedValue = tblInvApp[0].datTerms.ToString(); term = tblInvApp[0].datTerms;
                }
                if (tblInvApp[0].IsdatFundsNull() == false)
                {
                    txtFunds.Value = tblInvApp[0].datFunds.ToString();
                }
                if (tblInvApp[0].IsdatVerifiedNull() == false)
                {
                    ddlVerifed.SelectedValue = tblInvApp[0].datVerified.ToString();
                }
                if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false)
                {
                    ddlFrequencyInt.SelectedValue = tblInvApp[0].datFrequencyOfInterestPayment.ToString(); freq = Convert.ToInt32(tblInvApp[0].datFrequencyOfInterestPayment);
                }
                this.editskip.Value = "2";
                term = converrtterm(term);
                freq = convertfrequency(freq);
                CalculateIntPayment(term, freq, amt, per, dt);
            }
        }
        catch (Exception ex) { }
    }
 public void showLoanAppInfo()
 {
     mainDSTableAdapters.ClientTableAdapter client = new mainDSTableAdapters.ClientTableAdapter();
     InvestmentDSTableAdapters.GetInvestmentAppTableAdapter invApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
     InvestmentDS.GetInvestmentAppDataTable tblInvApp = invApp.GetInvestmentApp(MySessionManager.InvAppID);
     if (tblInvApp.Rows.Count > 0)
     {
         try
         {
             this.lblapplicantName.InnerText = client.GetClientsName(MySessionManager.ClientID).ToString();
             this.lblClientNo.InnerText      = client.GetClientNo(MySessionManager.ClientID).ToString();
             if (tblInvApp[0].IsdatInvestmentAmountNull() == false)
             {
                 this.lblInvestmentAmount.InnerText = tblInvApp[0].datInvestmentAmount.ToString("c").Replace("$", "");
             }
             if (tblInvApp[0].IsdatInvestmentNameNull() == false)
             {
                 this.lblInvestmentName.InnerText = tblInvApp[0].datInvestmentName.ToString();
             }
             if (tblInvApp[0].IsdatTermsNull() == false)
             {
                 this.lblTerm.InnerText = util.displayValue("opt_terms", tblInvApp[0].datTerms.ToString()) + " days";
             }
             if (tblInvApp[0].IsdatApplicationNumberNull() == false)
             {
                 this.lblAppNo.InnerText = tblInvApp[0].datApplicationNumber.ToString();
             }
             if (tblInvApp[0].IsdatValueDateNull() == false)
             {
                 this.lblValueDate.InnerText = tblInvApp[0].datValueDate.ToString("c").Replace("$", "");
             }
             if (tblInvApp[0].IsdatInvestmentTypeNull() == false)
             {
                 this.lblInvtype.InnerText = util.displayValue("opt_investment_types", tblInvApp[0].datInvestmentType.ToString());
             }
             if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false)
             {
                 this.lblAccInterest.InnerText = tblInvApp[0].datFrequencyOfInterestPayment.ToString();
             }
             if (tblInvApp[0].IsdatValueDateNull() == false)
             {
                 this.lblValueDate.InnerText = tblInvApp[0].datValueDate.ToString("dd-MM-yyyy");
             }
         }
         catch (Exception ex)
         { }
     }
 }
    /// <summary>
    /// Calculate the interest of an application for a certain number of days
    /// It takes the ID of the investment application and the number of days
    /// </summary>
    /// <param name="id">The Investment Application ID </param>
    /// <param name="days">The number of days</param>
    /// <returns>The interest that have been calculated</returns>
    public decimal calc_interest(int id, int days)
    {
        decimal interest = 0;
        decimal intRate  = 0;
        decimal amt      = 0;

        InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
        InvestmentDS.GetInvestmentAppDataTable tblInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);

        if (tblInvApp.Rows.Count > 0)
        {
            intRate = tblInvApp[0].datInterestRatePerAnnum;
            amt     = tblInvApp[0].datInvestmentAmount;
        }
        interest = ((amt * intRate) / 36500) * days;
        return(interest);
    }
Exemplo n.º 6
0
    //
    public void paymentschedule()
    {
        decimal  amt = 0;
        decimal  per = 0;
        DateTime dt = DateTime.Now;
        int      term = 0, freq = 0, type = 0;

        try
        {
            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter invApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();

            InvestmentDS.GetInvestmentAppDataTable tblInvApp = invApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (tblInvApp.Rows.Count > 0)
            {
                if (tblInvApp[0].IsdatInvestmentTypeNull() == false)
                {
                    type = tblInvApp[0].datInvestmentType;
                }
                if (tblInvApp[0].IsdatInvestmentAmountNull() == false)
                {
                    amt = tblInvApp[0].datInvestmentAmount;
                }
                if (tblInvApp[0].IsdatInterestRatePerAnnumNull() == false)
                {
                    ; per = tblInvApp[0].datInterestRatePerAnnum;
                }
                if (tblInvApp[0].IsdatTermsNull() == false)
                {
                    term = tblInvApp[0].datTerms;
                }
                if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false)
                {
                    freq = Convert.ToInt32(tblInvApp[0].datFrequencyOfInterestPayment);
                }
                if (tblInvApp[0].IsdatValueDateNull() == false)
                {
                    dt = tblInvApp[0].datValueDate;
                }
                term = converrtterm(term);
                freq = convertfrequency(freq);
                CalculateIntPayment(term, freq, amt, per, dt);
            }
        }
        catch (Exception ex) { }
    }
    /// <summary>
    /// Loads  the record of the selected application  
    /// </summary>
    public void loadInvSummary()
    {
        try
        {
            mainDSTableAdapters.GetClientInfoTableAdapter client = new mainDSTableAdapters.GetClientInfoTableAdapter();
            mainDS.GetClientInfoDataTable tblClient = client.GetClientInfo(MySessionManager.ClientID);
            if(tblClient.Rows.Count>0)
            {
                if(tblClient[0].IsdatClientNameNull()==false ){lblClientName.InnerText = tblClient[0].datClientName.ToString();}
                if(tblClient[0].IsdatClientNumberNull()==false ){lblClientNo.InnerText = tblClient[0].datClientNumber.ToString();}
                if(tblClient[0].IsdatMobileNumber1Null()==false ){lblMobile1.InnerText = tblClient[0].datMobileNumber1.ToString();}

            
            
            }

            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
            InvestmentDS.GetInvestmentAppDataTable tblInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (tblInvApp.Rows.Count > 0) 
            {
                if (tblInvApp[0].IsdatInvestmentNameNull() == false) { this.lblInvestmentName.InnerText = tblInvApp[0].datInvestmentName.ToString(); }
                if (tblInvApp[0].IsdatInterestRatePerAnnumNull() == false) { this.lblRatePerAnnum.InnerText = tblInvApp[0].datInterestRatePerAnnum.ToString("c").Replace("$",""); }
                if (tblInvApp[0].IsdatInvestmentTypeNull() == false) { this.lblType.InnerText =util.displayValue("opt_investment_types" ,tblInvApp[0].datInvestmentType.ToString()); }
                if (tblInvApp[0].IsdatTermsNull() == false) { this.lblTerms.InnerText =util.displayValue("opt_terms" , tblInvApp[0].datTerms.ToString())+" days"; }
                if (tblInvApp[0].IsdatInvestmentNameNull() == false) { this.lblInvestmentName.InnerText = tblInvApp[0].datInvestmentName.ToString(); }
                if (tblInvApp[0].IsdatModeOfRepaymentNull() == false) { this.lblModeOfInv.InnerText = util.displayValue("opt_payment_modes", tblInvApp[0].datModeOfRepayment.ToString()); }
                if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false) { this.lblFreqPayment.InnerText = util.displayValue("opt_frequencies_investments", tblInvApp[0].datFrequencyOfInterestPayment.ToString()); }
                if (tblInvApp[0].IsdatInvestmentAmountNull() == false) { this.lblAmount.InnerText = tblInvApp[0].datInvestmentAmount.ToString("c").Replace("$",""); }
                if (tblInvApp[0].IsdatValueDateNull() == false) { this.txtValue.Text = tblInvApp[0].datValueDate.ToString("dd-MM-yyyy"); }  
            }
        }
        catch (Exception ex) { }







    }
    protected void Page_Load(object sender, EventArgs e)
    {
        InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
        InvestmentDS.GetInvestmentAppDataTable tblInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);
        
        mTempTableAdapters.GetTransactionDetailsTableAdapter tempHolder = new mTempTableAdapters.GetTransactionDetailsTableAdapter();
        try
        { lblTotal.Text = tempHolder.GetTransTotalAmount(MySessionManager.AppID).ToString(); }
        catch (Exception ex)
        {
            lblTotal.Text = "0.00";
        }
       
        if (tblInvApp.Rows.Count > 0)
        {
            mainDSTableAdapters.ClientTableAdapter client = new mainDSTableAdapters.ClientTableAdapter();
            lbltotalamt.InnerText = tblInvApp[0].datInvestmentAmount.ToString("c").Replace("$", "");
            lbldate.InnerText = DateTime.Now.ToLongDateString();
            lblClient.InnerText = client.GetClientsName(MySessionManager.ClientID).ToString();
            lblbranch.InnerText = util.displayValue("tbl_teams", InvApp.GetInvBranch(MySessionManager.InvAppID).ToString());
        }

        if (!(this.editskip.Value == "2"))
        {

        }
        if (!(Request.QueryString["trdelete"] == null))
        {
            try
            {
                string id = Request.QueryString["trdelete"];
                tempHolder.DeleteTransactionDetails(Convert.ToInt32(id), MySessionManager.AppID);

                Page.Response.Redirect(util.RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "trdelete"));
            }
            catch
            { }
        }
        
    }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
        InvestmentDS.GetInvestmentAppDataTable tblInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);

        mTempTableAdapters.GetTransactionDetailsTableAdapter tempHolder = new mTempTableAdapters.GetTransactionDetailsTableAdapter();
        try
        { lblTotal.Text = tempHolder.GetTransTotalAmount(MySessionManager.AppID).ToString(); }
        catch (Exception ex)
        {
            lblTotal.Text = "0.00";
        }

        if (tblInvApp.Rows.Count > 0)
        {
            mainDSTableAdapters.ClientTableAdapter client = new mainDSTableAdapters.ClientTableAdapter();
            lbltotalamt.InnerText = tblInvApp[0].datInvestmentAmount.ToString("c").Replace("$", "");
            lbldate.InnerText     = DateTime.Now.ToLongDateString();
            lblClient.InnerText   = client.GetClientsName(MySessionManager.ClientID).ToString();
            lblbranch.InnerText   = util.displayValue("tbl_teams", InvApp.GetInvBranch(MySessionManager.InvAppID).ToString());
        }

        if (!(this.editskip.Value == "2"))
        {
        }
        if (!(Request.QueryString["trdelete"] == null))
        {
            try
            {
                string id = Request.QueryString["trdelete"];
                tempHolder.DeleteTransactionDetails(Convert.ToInt32(id), MySessionManager.AppID);

                Page.Response.Redirect(util.RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "trdelete"));
            }
            catch
            { }
        }
    }
    /// <summary>
    /// Loads  the record of the selected application
    /// </summary>
    public void loadInvSummary()
    {
        try
        {
            mainDSTableAdapters.GetClientInfoTableAdapter client = new mainDSTableAdapters.GetClientInfoTableAdapter();
            mainDS.GetClientInfoDataTable tblClient = client.GetClientInfo(MySessionManager.ClientID);
            if (tblClient.Rows.Count > 0)
            {
                if (tblClient[0].IsdatClientNameNull() == false)
                {
                    lblClientName.InnerText = tblClient[0].datClientName.ToString();
                }
                if (tblClient[0].IsdatClientNumberNull() == false)
                {
                    lblClientNo.InnerText = tblClient[0].datClientNumber.ToString();
                }
                if (tblClient[0].IsdatMobileNumber1Null() == false)
                {
                    lblMobile1.InnerText = tblClient[0].datMobileNumber1.ToString();
                }
            }

            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
            InvestmentDS.GetInvestmentAppDataTable tblInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (tblInvApp.Rows.Count > 0)
            {
                if (tblInvApp[0].IsdatInvestmentNameNull() == false)
                {
                    this.lblInvestmentName.InnerText = tblInvApp[0].datInvestmentName.ToString();
                }
                if (tblInvApp[0].IsdatInterestRatePerAnnumNull() == false)
                {
                    this.lblRatePerAnnum.InnerText = tblInvApp[0].datInterestRatePerAnnum.ToString("c").Replace("$", "");
                }
                if (tblInvApp[0].IsdatInvestmentTypeNull() == false)
                {
                    this.lblType.InnerText = util.displayValue("opt_investment_types", tblInvApp[0].datInvestmentType.ToString());
                }
                if (tblInvApp[0].IsdatTermsNull() == false)
                {
                    this.lblTerms.InnerText = util.displayValue("opt_terms", tblInvApp[0].datTerms.ToString()) + " days";
                }
                if (tblInvApp[0].IsdatInvestmentNameNull() == false)
                {
                    this.lblInvestmentName.InnerText = tblInvApp[0].datInvestmentName.ToString();
                }
                if (tblInvApp[0].IsdatModeOfRepaymentNull() == false)
                {
                    this.lblModeOfInv.InnerText = util.displayValue("opt_payment_modes", tblInvApp[0].datModeOfRepayment.ToString());
                }
                if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false)
                {
                    this.lblFreqPayment.InnerText = util.displayValue("opt_frequencies_investments", tblInvApp[0].datFrequencyOfInterestPayment.ToString());
                }
                if (tblInvApp[0].IsdatInvestmentAmountNull() == false)
                {
                    this.lblAmount.InnerText = tblInvApp[0].datInvestmentAmount.ToString("c").Replace("$", "");
                }
                if (tblInvApp[0].IsdatValueDateNull() == false)
                {
                    this.txtValue.Text = tblInvApp[0].datValueDate.ToString("dd-MM-yyyy");
                }
            }
        }
        catch (Exception ex) { }
    }
    /// <summary>
    /// Calculate the interest of an application for a certain number of days
    /// It takes the ID of the investment application and the number of days
    /// </summary>
    /// <param name="id">The Investment Application ID </param>
    /// <param name="days">The number of days</param>
    /// <returns>The interest that have been calculated</returns>
    public decimal calc_interest(int id, int days)
    {
        decimal interest=0;
        decimal intRate=0;
        decimal amt=0;
        InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
        InvestmentDS.GetInvestmentAppDataTable tblInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);

        if (tblInvApp.Rows.Count > 0)
        {
            intRate = tblInvApp[0].datInterestRatePerAnnum;
            amt = tblInvApp[0].datInvestmentAmount;
        }
        interest =((amt*intRate)/36500)*days;
        return interest;
    
    }
    protected void btnFinalize_Click(object sender, EventArgs e)
    {
        try
        {
            ///End the application process.
            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
            InvApp.UpdateApplicationStatus(5, MySessionManager.InvAppID);


            ///Converts the application into an account
            InvestmentDS.GetInvestmentAppDataTable rowInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (rowInvApp.Rows.Count > 0)
            {
                InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter InvAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
                InvAcc.InsertInvAccount(rowInvApp[0].datInvestmentName,
                                        rowInvApp[0].datApplicationNumber,
                                        MySessionManager.ClientID,
                                        rowInvApp[0].datInvestmentType,
                                        rowInvApp[0].datTerms,
                                        rowInvApp[0].datInvestmentAmount,
                                        rowInvApp[0].datInterestRatePerAnnum,
                                        rowInvApp[0].datFrequencyOfInterestPayment,
                                        rowInvApp[0].datModeOfRepayment,
                                        rowInvApp[0].datAdvise,
                                        rowInvApp[0].datValueDate,
                                        rowInvApp[0].datInvestmentAmount,
                                        MySessionManager.CurrentUser.BranchID,
                                        0,
                                        0,
                                        0,
                                        0,
                                        1,
                                        MySessionManager.InvAppID);


                ///Calculates the interest for the days elapsed before creation of the account
                int days = DateDiff(DateTime.Now, rowInvApp[0].datValueDate);
                int term = Convert.ToInt32(util.displayValue("opt_terms",rowInvApp[0].datTerms.ToString()));
                if (days > term)
                    days = term;

                InvestmentAccountDSTableAdapters.GetInterestCalcTableAdapter InvAcc1 = new InvestmentAccountDSTableAdapters.GetInterestCalcTableAdapter();

                if (days > 0)
                {
                    decimal previousInt = calc_interest(MySessionManager.InvAppID, days);

                    ///Insert a new record into the calculation table for the Daily chron-job
                    InvAcc1.InsertInvCalc(MySessionManager.InvAppID.ToString(),
                                          MySessionManager.ClientID,
                                          rowInvApp[0].datApplicationNumber.ToString(),
                                          DateTime.Now.ToShortDateString(),
                                          rowInvApp[0].datInvestmentAmount,
                                          rowInvApp[0].datInterestRatePerAnnum,
                                          days,
                                          term,
                                          previousInt,
                                          previousInt);
                }
                else 
                {
                    
                       // decimal previousInt = calc_interest(MySessionManager.InvAppID, days);

                        ///Insert a new record into the calculation table for the Daily chron-job
                        InvAcc1.InsertInvCalc(MySessionManager.InvAppID.ToString(),
                                              MySessionManager.ClientID,
                                              rowInvApp[0].datApplicationNumber.ToString(),
                                              DateTime.Now.ToShortDateString(),
                                              rowInvApp[0].datInvestmentAmount,
                                              rowInvApp[0].datInterestRatePerAnnum,
                                              0,
                                              term,
                                              0,
                                              0);
                    }
                
                
                }
            
            Response.Redirect("~/pages/invapplications.aspx");

        }
        catch (Exception ex) { }

    }
    public void loadInvestmentDetails()
    {
        decimal amt=0;
         decimal per=0;
        DateTime dt =DateTime.Now;
        int term=0,freq=0,type=0;
        try 
        {

            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter invApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();

            InvestmentDS.GetInvestmentAppDataTable tblInvApp = invApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (tblInvApp.Rows.Count > 0)
            {
                if (tblInvApp[0].IsdatInvestmentNameNull() == false) { txtName.Value = tblInvApp[0].datInvestmentName.ToString(); }
                if (tblInvApp[0].IsdatInvestmentTypeNull() == false) { ddlType.SelectedValue = tblInvApp[0].datInvestmentType.ToString(); type = tblInvApp[0].datInvestmentType; }
                if (tblInvApp[0].IsdatInvestmentAmountNull() == false) { txtInvestmentAmt.Value = tblInvApp[0].datInvestmentAmount.ToString(); amt = tblInvApp[0].datInvestmentAmount; }
                if (tblInvApp[0].IsdatModeOfRepaymentNull() == false) { ddlModeOfInv.SelectedValue = tblInvApp[0].datModeOfRepayment.ToString(); }
                if (tblInvApp[0].IsdatInterestRatePerAnnumNull() == false) { txtRatePerAnnum.Value = tblInvApp[0].datInterestRatePerAnnum.ToString(); per = tblInvApp[0].datInterestRatePerAnnum; }
                if (tblInvApp[0].IsdatTermsNull() == false) { ddlTerms.SelectedValue = tblInvApp[0].datTerms.ToString(); term =tblInvApp[0].datTerms; }
                if (tblInvApp[0].IsdatFundsNull() == false) { txtFunds.Value = tblInvApp[0].datFunds.ToString(); }
                if (tblInvApp[0].IsdatVerifiedNull() == false) { ddlVerifed.SelectedValue = tblInvApp[0].datVerified.ToString(); }
                if (tblInvApp[0].IsdatFrequencyOfInterestPaymentNull() == false) { ddlFrequencyInt.SelectedValue = tblInvApp[0].datFrequencyOfInterestPayment.ToString(); freq = Convert.ToInt32(tblInvApp[0].datFrequencyOfInterestPayment); }
                this.editskip.Value = "2";
                term = converrtterm(term);
                freq = convertfrequency(freq);
                CalculateIntPayment(term,freq,amt,per,dt);
            }
        
        }
        catch (Exception ex) { }

    }
    protected void btnFinalize_Click(object sender, EventArgs e)
    {
        try
        {
            ///End the application process.
            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
            InvApp.UpdateApplicationStatus(5, MySessionManager.InvAppID);


            ///Converts the application into an account
            InvestmentDS.GetInvestmentAppDataTable rowInvApp = InvApp.GetInvestmentApp(MySessionManager.InvAppID);

            if (rowInvApp.Rows.Count > 0)
            {
                InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter InvAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
                InvAcc.InsertInvAccount(rowInvApp[0].datInvestmentName,
                                        rowInvApp[0].datApplicationNumber,
                                        MySessionManager.ClientID,
                                        rowInvApp[0].datInvestmentType,
                                        rowInvApp[0].datTerms,
                                        rowInvApp[0].datInvestmentAmount,
                                        rowInvApp[0].datInterestRatePerAnnum,
                                        rowInvApp[0].datFrequencyOfInterestPayment,
                                        rowInvApp[0].datModeOfRepayment,
                                        rowInvApp[0].datAdvise,
                                        rowInvApp[0].datValueDate,
                                        rowInvApp[0].datInvestmentAmount,
                                        MySessionManager.CurrentUser.BranchID,
                                        0,
                                        0,
                                        0,
                                        0,
                                        1,
                                        MySessionManager.InvAppID);


                ///Calculates the interest for the days elapsed before creation of the account
                int days = DateDiff(DateTime.Now, rowInvApp[0].datValueDate);
                int term = Convert.ToInt32(util.displayValue("opt_terms", rowInvApp[0].datTerms.ToString()));
                if (days > term)
                {
                    days = term;
                }

                InvestmentAccountDSTableAdapters.GetInterestCalcTableAdapter InvAcc1 = new InvestmentAccountDSTableAdapters.GetInterestCalcTableAdapter();

                if (days > 0)
                {
                    decimal previousInt = calc_interest(MySessionManager.InvAppID, days);

                    ///Insert a new record into the calculation table for the Daily chron-job
                    InvAcc1.InsertInvCalc(MySessionManager.InvAppID.ToString(),
                                          MySessionManager.ClientID,
                                          rowInvApp[0].datApplicationNumber.ToString(),
                                          DateTime.Now.ToShortDateString(),
                                          rowInvApp[0].datInvestmentAmount,
                                          rowInvApp[0].datInterestRatePerAnnum,
                                          days,
                                          term,
                                          previousInt,
                                          previousInt);
                }
                else
                {
                    // decimal previousInt = calc_interest(MySessionManager.InvAppID, days);

                    ///Insert a new record into the calculation table for the Daily chron-job
                    InvAcc1.InsertInvCalc(MySessionManager.InvAppID.ToString(),
                                          MySessionManager.ClientID,
                                          rowInvApp[0].datApplicationNumber.ToString(),
                                          DateTime.Now.ToShortDateString(),
                                          rowInvApp[0].datInvestmentAmount,
                                          rowInvApp[0].datInterestRatePerAnnum,
                                          0,
                                          term,
                                          0,
                                          0);
                }
            }

            Response.Redirect("~/pages/invapplications.aspx");
        }
        catch (Exception ex) { }
    }