protected void Page_Load(object sender, EventArgs e)
 {
     ///Querystring Block
     ///
     if (Request.QueryString.Count > 0)
     {
         InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter invAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
         string EncID = Request.QueryString["id"];
         int    DecID = Convert.ToInt32(MyEncryption.Decrypt(EncID, "12345678910"));
         MySessionManager.InvAccID = DecID;
         MySessionManager.ClientID = Convert.ToInt32(invAcc.GetClientID(MySessionManager.InvAppID));
         if (Request.QueryString["action"] == "int")
         {
             Page.Title = "Interest Maturity";
         }
         if (Request.QueryString["action"] == "inv")
         {
             Page.Title = "Investment Maturity";
         }
         if (Request.QueryString["action"] == "rol")
         {
             Page.Title = "Roll Over";
         }
     }
     setNotifications();
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int schID = 0;

        if (Request.QueryString["schID"] != null)
        {
            schID = Convert.ToInt32(Request.QueryString["schID"]);
        }

        try
        {
            InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter InvAcc_ = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
            DateTime dt = DateTime.Parse(InvAcc_.GetValueDate(MySessionManager.InvAccID).ToString());
            dt = util.addDaysElapsed(dt, schID);

            InvestmentAccountDSTableAdapters.GetHistoricAccountTableAdapter InvAcc = new InvestmentAccountDSTableAdapters.GetHistoricAccountTableAdapter();
            InvestmentAccountDS.GetHistoricAccountDataTable tblInvAcc = InvAcc.GetHistoryByDate(MySessionManager.InvAccID, dt);

            if (tblInvAcc.Rows.Count > 0)
            {
                if (tblInvAcc[0].IsdatIDNull() == false)
                {
                    datID.Value = tblInvAcc[0].datID.ToString();
                }
                if (tblInvAcc[0].IsdatIntAccruedNull() == false)
                {
                    lblaccruedInt.InnerText = tblInvAcc[0].datIntAccrued.ToString("c").Replace("$", "");
                    dataccint.Value         = tblInvAcc[0].datIntAccrued.ToString();
                }
                else
                {
                    dataccint.Value = "0";
                }
                if (tblInvAcc[0].IsdatInvestmentAmountNull() == false)
                {
                    lblInvAmt.InnerText = tblInvAcc[0].datInvestmentAmount.ToString("c").Replace("$", "");
                    datprincipal.Value  = tblInvAcc[0].datInvestmentAmount.ToString();
                }
                else
                {
                    datprincipal.Value = "0";
                }
                if (tblInvAcc[0].IsdatValueDateNull() == false)
                {
                    lblValueDate.InnerText = tblInvAcc[0].datValueDate.ToString("dd-MM-yyyy");
                }
                if (tblInvAcc[0].IsdatInvestmentNameNull() == false)
                {
                    lblInvName.InnerText = tblInvAcc[0].datInvestmentName.ToString();
                }
            }
        }
        catch (Exception ex) { }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ///Querystring Block
        InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter invAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
        string EncID = Request.QueryString["id"];
        int    DecID = Convert.ToInt32(MyEncryption.Decrypt(EncID, "12345678910"));

        MySessionManager.InvAccID = DecID;
        MySessionManager.ClientID = Convert.ToInt32(invAcc.GetClientID(MySessionManager.InvAppID));


        setNotifications();
    }
    protected void Page_Load(object sender, EventArgs e)
    {


        ///Querystring Block
        InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter invAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
        string EncID = Request.QueryString["id"];
        int DecID = Convert.ToInt32(MyEncryption.Decrypt(EncID, "12345678910"));
        MySessionManager.InvAccID = DecID;
        MySessionManager.ClientID = Convert.ToInt32(invAcc.GetClientID(MySessionManager.InvAppID));


        setNotifications();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int schID = 0;
        decimal val = 0;
        if(Request.QueryString["schID"]!= null){ schID = Convert.ToInt32(Request.QueryString["schID"]);}
        
        try
        {
            InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter InvAcc_ = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
            DateTime dt = DateTime.Parse(InvAcc_.GetValueDate(MySessionManager.InvAccID).ToString());
            dt = util.addDaysElapsed(dt,schID);

            InvestmentAccountDSTableAdapters.GetHistoricAccountTableAdapter InvAcc = new InvestmentAccountDSTableAdapters.GetHistoricAccountTableAdapter();
            InvestmentAccountDS.GetHistoricAccountDataTable tblInvAcc = InvAcc.GetHistoryByDate(MySessionManager.InvAccID,dt);

            if (tblInvAcc.Rows.Count > 0)
            {
                if (Request.QueryString["val"].Length > 0) { val = Convert.ToDecimal(Request.QueryString["val"]); }
                if (tblInvAcc[0].IsdatIDNull()==false) { datID.Value = tblInvAcc[0].datID.ToString(); }
                if (tblInvAcc[0].IsdatIntAccruedNull() == false)
                {
                    lblaccruedInt.InnerText = tblInvAcc[0].datIntAccrued.ToString("c").Replace("$", "");
                    dataccint.Value = tblInvAcc[0].datIntAccrued.ToString();
                }
                else { dataccint.Value = "0"; }
                if (tblInvAcc[0].IsdatInvestmentAmountNull() == false)
                {
                    lblInvAmt.InnerText = tblInvAcc[0].datInvestmentAmount.ToString("c").Replace("$", "");
                    datprincipal.Value = tblInvAcc[0].datInvestmentAmount.ToString();
                }
                if (tblInvAcc[0].IsdatPenaltyNull() == false) 
                {
                    datAmount.Value = tblInvAcc[0].datPenalty.ToString();
                }
                else { datprincipal.Value = "0"; }
                if (tblInvAcc[0].IsdatValueDateNull() == false)
                {lblValueDate.InnerText = tblInvAcc[0].datValueDate.ToString("dd-MM-yyyy");}
                if (tblInvAcc[0].IsdatInvestmentNameNull() == false)
                { lblInvName.InnerText = tblInvAcc[0].datInvestmentName.ToString(); }
                
            }
        }
        catch (Exception ex) { }

    }
 protected void Page_Load(object sender, EventArgs e)
 {
     ///Querystring Block
     ///
     if (Request.QueryString.Count > 0)
     {
         
         InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter invAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
         string EncID = Request.QueryString["id"];
         int DecID = Convert.ToInt32(MyEncryption.Decrypt(EncID, "12345678910"));
         MySessionManager.InvAccID = DecID;
         MySessionManager.ClientID = Convert.ToInt32(invAcc.GetClientID(MySessionManager.InvAppID));
         if (Request.QueryString["action"] == "int") { Page.Title = "Interest Maturity"; }
         if (Request.QueryString["action"] == "inv") { Page.Title = "Investment Maturity"; }
         if (Request.QueryString["action"] == "rol") { Page.Title = "Roll Over"; }
     }
     setNotifications();
 }
    protected void btnOpenAccount_Click(object sender, EventArgs e)
    {
        if (ListofCreditAccounts.Items.Count > 0) {
            int accid = Convert.ToInt32(ListofCreditAccounts.SelectedValue);
            FinancialDSTableAdapters.tbl_VoucherTypesTableAdapter vchTypes = new FinancialDSTableAdapters.tbl_VoucherTypesTableAdapter();
            FinancialDS.tbl_VoucherTypesDataTable vtypes = vchTypes.GetVoucherTypeByName(MySessionManager.VchTypeName);
            if (vtypes.Count > 0)
            {
                if (Convert.ToInt32(vtypes[0].datDebitAccountTypes) == 1)
                {
                    InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter invAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
                    InvestmentAccountDS.GetInvAccountDataTable invAccData = invAcc.GetInvAccount(accid);
                    if (invAccData.Count > 0)
                    {
                        lblInvestmentName.InnerText = invAccData[0].datInvestmentName;
                        lblapplicantName.InnerText = ListofCreditAccounts.SelectedItem.Text;
                        lblInvestmentAmount.InnerText = Convert.ToString(invAccData[0].datInvestmentAmount);

                    }

                }
                else if (Convert.ToInt32(vtypes[0].datDebitAccountTypes) == 2)
                {
                    LoanAccountDSTableAdapters.GetLoanAccountTableAdapter lacc = new LoanAccountDSTableAdapters.GetLoanAccountTableAdapter();
                    LoanAccountDS.GetLoanAccountDataTable ltbl = lacc.GetLoanAccount(accid);
                    if (ltbl.Count > 0) {
                        lblInvestmentName.InnerText = ltbl[0].datClientFullName ;
                        lblapplicantName.InnerText = ListofCreditAccounts.SelectedItem.Text;
                        lblInvestmentAmount.InnerText = Convert.ToString(ltbl[0].datInitialAmount);
                    }
                }
            }

            transactionsPanel.Visible = true;
            VchPanel.Visible = true;
            VchTypeSelPanel.Visible = false;
            MySessionManager.TempTranKey = System.Guid.NewGuid().ToString();
            lblTotal.Text = "";
        }
        
    }
Exemplo n.º 8
0
    protected void btnOpenAccount_Click(object sender, EventArgs e)
    {
        if (ListofCreditAccounts.Items.Count > 0)
        {
            int accid = Convert.ToInt32(ListofCreditAccounts.SelectedValue);
            FinancialDSTableAdapters.tbl_VoucherTypesTableAdapter vchTypes = new FinancialDSTableAdapters.tbl_VoucherTypesTableAdapter();
            FinancialDS.tbl_VoucherTypesDataTable vtypes = vchTypes.GetVoucherTypeByName(MySessionManager.VchTypeName);
            if (vtypes.Count > 0)
            {
                if (Convert.ToInt32(vtypes[0].datCreditAccountTypes) == 1)
                {
                    InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter invAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
                    InvestmentAccountDS.GetInvAccountDataTable invAccData             = invAcc.GetInvAccount(accid);
                    if (invAccData.Count > 0)
                    {
                        lblInvestmentName.InnerText   = invAccData[0].datInvestmentName;
                        lblapplicantName.InnerText    = ListofCreditAccounts.SelectedItem.Text;
                        lblInvestmentAmount.InnerText = Convert.ToString(invAccData[0].datInvestmentAmount);
                    }
                }
                else if (Convert.ToInt32(vtypes[0].datCreditAccountTypes) == 2)
                {
                    LoanAccountDSTableAdapters.GetLoanAccountTableAdapter lacc = new LoanAccountDSTableAdapters.GetLoanAccountTableAdapter();
                    LoanAccountDS.GetLoanAccountDataTable ltbl = lacc.GetLoanAccount(accid);
                    if (ltbl.Count > 0)
                    {
                        lblInvestmentName.InnerText   = ltbl[0].datClientFullName;
                        lblapplicantName.InnerText    = ListofCreditAccounts.SelectedItem.Text;
                        lblInvestmentAmount.InnerText = Convert.ToString(ltbl[0].datInitialAmount);
                    }
                }
            }

            transactionsPanel.Visible    = true;
            VchPanel.Visible             = true;
            VchTypeSelPanel.Visible      = false;
            MySessionManager.TempTranKey = System.Guid.NewGuid().ToString();
            lblTotal.Text = "";
        }
    }
    protected void gvClients_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        mainDSTableAdapters.ClientTableAdapter client = new mainDSTableAdapters.ClientTableAdapter();

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int terms = 0;
            InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter InvAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
            InvestmentAccountDS.GetInvAccountDataTable tblInvAcc = InvAcc.GetInvAccount(Convert.ToInt32(gvClients.DataKeys[e.Row.RowIndex].Value));
            string   enpValue = MyEncryption.Encrypt(this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString(), "12345678910");
            DateTime dt       = DateTime.Parse(gvClients.DataKeys[e.Row.RowIndex]["datValueDate"].ToString());
            e.Row.Cells[0].Text = client.GetClientsName(Convert.ToInt32(gvClients.DataKeys[e.Row.RowIndex]["datClientID"].ToString())).ToString();
            e.Row.Cells[4].Text = util.displayValue("opt_investment_types", gvClients.DataKeys[e.Row.RowIndex]["datInvestmentType"].ToString());
            terms = Convert.ToInt32(util.displayValue("opt_terms", gvClients.DataKeys[e.Row.RowIndex]["datFrequencyOfInterestPayment"].ToString()));
            int   freq    = Convert.ToInt32(gvClients.DataKeys[e.Row.RowIndex]["datFrequencyOfInterestPayment"].ToString());
            Panel ItemBox = new Panel();
            ItemBox.Attributes.Add("id", "div" + this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString());
            ItemBox.Attributes.Add("id", "div" + this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString());
            ItemBox.Attributes.Add("class", "ItemContainer");
            ItemBox.Style.Add("display", "none");
            string htmlContent = "<div class='col-md-9' style='padding-top:0'><label> Matured Interest(s) </label><br/>";
            if (tblInvAcc[0].dat30 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=30&val=" + tblInvAcc[0].dat30.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 30).ToString("dd/MM/yyyy") + "</a> <br/>";
            }
            if (tblInvAcc[0].dat60 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=60&val=" + tblInvAcc[0].dat60.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 60).ToString("dd/MM/yyyy") + "</a> <br/>";
            }
            if (tblInvAcc[0].dat91 > 0 && freq == 2)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=91&val=" + tblInvAcc[0].dat91.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 90).ToString("dd/MM/yyyy") + "</a> <br/>";
            }
            if (tblInvAcc[0].dat121 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=121&val=" + tblInvAcc[0].dat121.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 121).ToString("dd/MM/yyyy") + "</a> <br/>";
            }
            if (tblInvAcc[0].dat151 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=151&val=" + tblInvAcc[0].dat151.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 151).ToString("dd/MM/yyyy") + "</a> <br/>";
            }
            if (tblInvAcc[0].dat182 > 0 && freq == 3)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=182&val=" + tblInvAcc[0].dat182.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 182).ToString("dd/MM/yyyy") + "</a> <br/>";
            }
            if (tblInvAcc[0].dat212 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=212&val=" + tblInvAcc[0].dat212.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 212).ToString("dd/MM/yyyy") + "  </a> <br/>";
            }
            if (tblInvAcc[0].dat242 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/iinterestmaturity.aspx?id=" + enpValue + "&schID=242&val=" + tblInvAcc[0].dat242.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 242).ToString("dd/MM/yyyy") + "  </a> <br/>";
            }
            if (tblInvAcc[0].dat273 > 0 && freq == 2)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=273&val=" + tblInvAcc[0].dat273.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 273).ToString("dd/MM/yyyy") + "  </a> <br/>";
            }
            if (tblInvAcc[0].dat303 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=303&val=" + tblInvAcc[0].dat303.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 303).ToString("dd/MM/yyyy") + "  </a> <br/>";
            }
            if (tblInvAcc[0].dat333 > 0 && freq == 1)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=333&val=" + tblInvAcc[0].dat333.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 303).ToString("dd/MM/yyyy") + "  </a> <br/>";
            }
            if (tblInvAcc[0].dat364 > 0 && freq == 4)
            {
                htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=364&val=" + tblInvAcc[0].dat364.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 364).ToString("dd/MM/yyyy") + "  </a> <br/>";
            }
            htmlContent += "</div>";

            Literal ItemContent = new Literal();
            ItemContent.Text = htmlContent;
            ItemBox.Controls.Add(ItemContent);

            HyperLink hyp = new HyperLink();
            hyp.NavigateUrl = "javascript:showinfo('div" + this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString() + "')";
            hyp.Text        = e.Row.Cells[0].Text;
            e.Row.Cells[0].Controls.Add(hyp);
            e.Row.Cells[0].Controls.Add(ItemBox);

            //HyperLink clientProfile = (HyperLink)e.Row.FindControl("hyperClientProfile");
            //HyperLink Inv = (HyperLink)e.Row.FindControl("hyperInv");
        }
    }
    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) { }

    }
    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) { }
    }
    protected void gvClients_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        mainDSTableAdapters.ClientTableAdapter client = new mainDSTableAdapters.ClientTableAdapter();

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
             int terms=0;
             InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter InvAcc = new InvestmentAccountDSTableAdapters.GetInvAccountTableAdapter();
             InvestmentAccountDS.GetInvAccountDataTable tblInvAcc = InvAcc.GetInvAccount(Convert.ToInt32(gvClients.DataKeys[e.Row.RowIndex].Value));
             string enpValue = MyEncryption.Encrypt(this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString(), "12345678910");
             DateTime dt =DateTime.Parse(gvClients.DataKeys[e.Row.RowIndex]["datValueDate"].ToString());
             e.Row.Cells[0].Text = client.GetClientsName(Convert.ToInt32(gvClients.DataKeys[e.Row.RowIndex]["datClientID"].ToString())).ToString();
             e.Row.Cells[4].Text = util.displayValue("opt_investment_types", gvClients.DataKeys[e.Row.RowIndex]["datInvestmentType"].ToString());
             terms = Convert.ToInt32(util.displayValue("opt_terms", gvClients.DataKeys[e.Row.RowIndex]["datFrequencyOfInterestPayment"].ToString()));
             int freq = Convert.ToInt32(gvClients.DataKeys[e.Row.RowIndex]["datFrequencyOfInterestPayment"].ToString());
             Panel ItemBox = new Panel();
             ItemBox.Attributes.Add("id", "div" + this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString());
             ItemBox.Attributes.Add("id", "div" + this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString());
             ItemBox.Attributes.Add("class", "ItemContainer");
             ItemBox.Style.Add("display", "none");
             string htmlContent = "<div class='col-md-9' style='padding-top:0'><label> Matured Interest(s) </label><br/>";
             if (tblInvAcc[0].dat30 > 0 && freq == 1)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=30&val=" + tblInvAcc[0].dat30.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 30).ToString("dd/MM/yyyy") + "</a> <br/>";   
             }
             if (tblInvAcc[0].dat60 > 0 && freq == 1)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=60&val=" + tblInvAcc[0].dat60.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 60).ToString("dd/MM/yyyy") + "</a> <br/>";
             }
             if (tblInvAcc[0].dat91 > 0 && freq == 2)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=91&val=" + tblInvAcc[0].dat91.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 90).ToString("dd/MM/yyyy") + "</a> <br/>";
             }
             if (tblInvAcc[0].dat121 > 0 && freq == 1)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=121&val=" + tblInvAcc[0].dat121.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 121).ToString("dd/MM/yyyy") + "</a> <br/>";
             }
             if (tblInvAcc[0].dat151 > 0 && freq == 1)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=151&val=" + tblInvAcc[0].dat151.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 151).ToString("dd/MM/yyyy") + "</a> <br/>";
             }
             if (tblInvAcc[0].dat182 > 0 && freq == 3)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=182&val=" + tblInvAcc[0].dat182.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 182).ToString("dd/MM/yyyy") + "</a> <br/>";
             }
             if (tblInvAcc[0].dat212 > 0 && freq == 1)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=212&val=" + tblInvAcc[0].dat212.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 212).ToString("dd/MM/yyyy") + "  </a> <br/>";
             }
             if (tblInvAcc[0].dat242 > 0 && freq ==1)
             {
                 htmlContent += "<a href=../pages/invaccount/iinterestmaturity.aspx?id=" + enpValue + "&schID=242&val=" + tblInvAcc[0].dat242.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 242).ToString("dd/MM/yyyy") + "  </a> <br/>";
             }
             if (tblInvAcc[0].dat273 > 0 && freq == 2)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=273&val=" + tblInvAcc[0].dat273.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 273).ToString("dd/MM/yyyy") + "  </a> <br/>";
             }
             if (tblInvAcc[0].dat303 > 0 && freq == 1)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=303&val=" + tblInvAcc[0].dat303.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 303).ToString("dd/MM/yyyy") + "  </a> <br/>";
             }
             if (tblInvAcc[0].dat333 > 0 && freq == 1)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=333&val=" + tblInvAcc[0].dat333.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 303).ToString("dd/MM/yyyy") + "  </a> <br/>";
             }
             if (tblInvAcc[0].dat364 > 0 && freq == 4)
             {
                 htmlContent += "<a href=../pages/invaccount/interestmaturity.aspx?id=" + enpValue + "&schID=364&val=" + tblInvAcc[0].dat364.ToString() + ">Int. Maturity for " + addDaysElapsed(dt, 364).ToString("dd/MM/yyyy") + "  </a> <br/>";
             }
             htmlContent += "</div>";

             Literal ItemContent = new Literal();
             ItemContent.Text = htmlContent;
             ItemBox.Controls.Add(ItemContent);

             HyperLink hyp = new HyperLink();
             hyp.NavigateUrl = "javascript:showinfo('div" + this.gvClients.DataKeys[e.Row.RowIndex].Value.ToString() + "')";
             hyp.Text = e.Row.Cells[0].Text;
             e.Row.Cells[0].Controls.Add(hyp);
             e.Row.Cells[0].Controls.Add(ItemBox);
             
            //HyperLink clientProfile = (HyperLink)e.Row.FindControl("hyperClientProfile");
             //HyperLink Inv = (HyperLink)e.Row.FindControl("hyperInv");

        }
    }