protected void btnFinalize_Click(object sender, EventArgs e)
 {
     try
     {
         InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
         InvApp.UpdateApplicationStatus(2, MySessionManager.InvAppID);
         Response.Redirect("~/pages/invapplications.aspx");
     }
     catch (Exception ex) { }
 }
Exemplo n.º 2
0
    protected void btnFinalize_Click(object sender, EventArgs e)
    {
        try
        {
            MySessionManager.cash = 0;
            MySessionManager.bank = 0;
            decimal amtDeductable = 0;
            decimal fees          = 0;
            decimal amt           = 0;
            int     ops           = 0;

            mTempTableAdapters.GetTransactionDetailsTableAdapter tempHolder = new mTempTableAdapters.GetTransactionDetailsTableAdapter();
            mTemp.GetTransactionDetailsDataTable tblTempHolder             = tempHolder.GetInvTempTransactions(MySessionManager.InvAppID);
            LoanDSTableAdapters.FinancialTransactionsTableAdapter fintrans = new LoanDSTableAdapters.FinancialTransactionsTableAdapter();
            int rows = tblTempHolder.Rows.Count;

            for (int i = 0; i < rows; i++)
            {
                int?datDebitAc  = null;
                int?datCreditAc = null;
                if (tblTempHolder[i].datDebit > 0)
                {
                    datDebitAc = tblTempHolder[i].datAccountID;
                    amt        = tblTempHolder[i].datDebit;
                    ops        = 1;
                }
                else if (tblTempHolder[i].datCredit > 0)
                {
                    datCreditAc = tblTempHolder[i].datAccountID;
                    amt         = tblTempHolder[i].datCredit;
                    ops         = 2;
                }
                //
                if (tblTempHolder[i].datPaymentMethod == 1)
                {
                    getAmtForPaymentMode(amt, "cash", ops);
                }
                else if (tblTempHolder[i].datPaymentMethod == 2)
                {
                    getAmtForPaymentMode(amt, "bank", ops);
                }
                fintrans.InsertFinancialTransaction(MySessionManager.InvAppID,
                                                    MySessionManager.ClientID,
                                                    tblTempHolder[i].datAccountID,
                                                    MySessionManager.InvAppID,
                                                    tblTempHolder[i].datDescription,
                                                    batch(),
                                                    tblTempHolder[i].datPaymentMethod,
                                                    MySessionManager.AppBranchID,
                                                    tblTempHolder[i].datCredit,
                                                    tblTempHolder[i].datDebit,
                                                    datCreditAc,
                                                    datDebitAc,
                                                    0,
                                                    MySessionManager.CurrentUser.UserID);
            }
        }
        catch (Exception ex) { }

        //This block of code changes the status of the application
        try
        {
            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
            InvApp.UpdateApplicationStatus(3, MySessionManager.InvAppID);
            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 btnFinalize_Click(object sender, EventArgs e)
    {
        try
        {
            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
            InvApp.UpdateApplicationStatus(2, MySessionManager.InvAppID);
            Response.Redirect("~/pages/invapplications.aspx");

        }
        catch (Exception ex) { }
    }
    protected void btnFinalize_Click(object sender, EventArgs e)
    {
        try
        {
            MySessionManager.cash = 0;
            MySessionManager.bank = 0;
            decimal amtDeductable = 0;
            decimal fees = 0;
            decimal amt = 0;
            int ops = 0;

            mTempTableAdapters.GetTransactionDetailsTableAdapter tempHolder = new mTempTableAdapters.GetTransactionDetailsTableAdapter();
            mTemp.GetTransactionDetailsDataTable tblTempHolder = tempHolder.GetInvTempTransactions(MySessionManager.InvAppID);
            LoanDSTableAdapters.FinancialTransactionsTableAdapter fintrans = new LoanDSTableAdapters.FinancialTransactionsTableAdapter();
            int rows = tblTempHolder.Rows.Count;

            for (int i = 0; i < rows; i++)
            {
                int? datDebitAc = null;
                int? datCreditAc = null;
                if (tblTempHolder[i].datDebit > 0)
                {
                    datDebitAc = tblTempHolder[i].datAccountID;
                    amt = tblTempHolder[i].datDebit;
                    ops = 1;
                }
                else if (tblTempHolder[i].datCredit > 0)
                {
                    datCreditAc = tblTempHolder[i].datAccountID;
                    amt = tblTempHolder[i].datCredit;
                    ops = 2;
                }
                //
                if (tblTempHolder[i].datPaymentMethod == 1)
                {
                    getAmtForPaymentMode(amt, "cash", ops);
                }
                else if (tblTempHolder[i].datPaymentMethod == 2)
                {
                    getAmtForPaymentMode(amt, "bank", ops);
                }
                fintrans.InsertFinancialTransaction(MySessionManager.InvAppID,
                                                    MySessionManager.ClientID,
                                                    tblTempHolder[i].datAccountID,
                                                    MySessionManager.InvAppID,
                                                    tblTempHolder[i].datDescription,
                                                    batch(),
                                                    tblTempHolder[i].datPaymentMethod,
                                                    MySessionManager.AppBranchID,
                                                    tblTempHolder[i].datCredit,
                                                    tblTempHolder[i].datDebit,
                                                    datCreditAc,
                                                    datDebitAc,
                                                    0,
                                                    MySessionManager.CurrentUser.UserID);
            }
                
                 
        }
        catch(Exception ex) { }

        //This block of code changes the status of the application
        try
        {
            InvestmentDSTableAdapters.GetInvestmentAppTableAdapter InvApp = new InvestmentDSTableAdapters.GetInvestmentAppTableAdapter();
            InvApp.UpdateApplicationStatus(3, MySessionManager.InvAppID);
            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) { }
    }