public double[,] loadpplanValues(int AppID)
    {
        LoanDSTableAdapters.PaymentPlanTableAdapter pplan = new LoanDSTableAdapters.PaymentPlanTableAdapter();
        LoanDS.PaymentPlanDataTable tblpplan = pplan.GetPaymentPlan(AppID);

        double[,] pplanValue = new double[tblpplan.Rows.Count, 5];
        try
        {
            if (tblpplan.Rows.Count > 0)
            {
                for (int i = 0; i < tblpplan.Rows.Count; i++)
                {
                    pplanValue[i, 0] = Convert.ToDouble(tblpplan[i].datBalanceBF.ToString());
                    pplanValue[i, 1] = Convert.ToDouble(tblpplan[i].datInterest1.ToString());
                    pplanValue[i, 2] = Convert.ToDouble(tblpplan[i].datPrincipalComponent.ToString());
                    pplanValue[i, 3] = Convert.ToDouble(tblpplan[i].datMonthlyPayment.ToString());
                    pplanValue[i, 4] = Convert.ToDouble(tblpplan[i].datOutstanding.ToString());
                }
            }
            else
            {
            }
        }
        catch (Exception ex)
        {}


        return(pplanValue);
    }
    public void AddPaymentPlan()
    {
        LoanDSTableAdapters.PaymentPlanTableAdapter plan = new LoanDSTableAdapters.PaymentPlanTableAdapter();

        LoanDS.PaymentPlanDataTable tbl = new LoanDS.PaymentPlanDataTable();

        LoanDS.PaymentPlanRow datarow;


        long AppID = MySessionManager.AppID;



        int i = 0;

        DeletePaymentPlan();

        foreach (HtmlTableRow row in this.TABLE1.Rows)
        {

            string labelstring = "lblMonth";

            string newlbl = labelstring + i.ToString();
            Control ctrl = null;


            if (i > 1)
            {
                if (row.Cells.Count > 0)
                    ctrl = row.Cells[1].Controls[0];
            }
            if (ctrl != null)
            {
                if (i > 1)
                {

                   datarow = tbl.NewPaymentPlanRow();



                    datarow.datApplicationID  = MySessionManager .AppID;
                    datarow.datMonth = Convert.ToDateTime(((Label)row.Cells[0].Controls[0]).Text);
                    datarow.datMonthIndex = Convert.ToInt32(i - 1);
                    datarow.datMonthlyPayment = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text);
                    datarow.datOutstanding = Utility.ConvertToDecimal(((TextBox)row.Cells[6].Controls[0]).Text);
                    datarow.datInterest1 = Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text);
                    datarow.datBalanceBF = Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text);
                    datarow.datPrincipalComponent = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text) - Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text);
                    tbl.Rows.Add(datarow);

                    plan.InsertPaymentPlan( Convert.ToDateTime(datarow.datMonth),
                                            Convert.ToDecimal(datarow.datBalanceBF),
                                            Convert.ToDecimal(datarow.datInterest1),
                                            Convert.ToDecimal(datarow.datMonthlyPayment),
                                            Convert.ToDecimal("0.0"),
                                            Convert.ToDecimal(datarow.datPrincipalComponent.ToString()),
                                            Convert.ToDecimal(datarow.datOutstanding.ToString()),
                                            MySessionManager.AppID,
                                            Convert.ToInt32(datarow.datMonthIndex.ToString()));


                }
            }

            i++;

            
        }



    }
    public void AddPaymentPlan()
    {
        LoanDSTableAdapters.PaymentPlanTableAdapter plan = new LoanDSTableAdapters.PaymentPlanTableAdapter();

        LoanDS.PaymentPlanDataTable tbl = new LoanDS.PaymentPlanDataTable();

        LoanDS.PaymentPlanRow datarow;


        long AppID = MySessionManager.AppID;



        int i = 0;

        DeletePaymentPlan();

        foreach (HtmlTableRow row in this.TABLE1.Rows)
        {
            string labelstring = "lblMonth";

            string  newlbl = labelstring + i.ToString();
            Control ctrl   = null;


            if (i > 1)
            {
                if (row.Cells.Count > 0)
                {
                    ctrl = row.Cells[1].Controls[0];
                }
            }
            if (ctrl != null)
            {
                if (i > 1)
                {
                    datarow = tbl.NewPaymentPlanRow();



                    datarow.datApplicationID      = MySessionManager.AppID;
                    datarow.datMonth              = Convert.ToDateTime(((Label)row.Cells[0].Controls[0]).Text);
                    datarow.datMonthIndex         = Convert.ToInt32(i - 1);
                    datarow.datMonthlyPayment     = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text);
                    datarow.datOutstanding        = Utility.ConvertToDecimal(((TextBox)row.Cells[6].Controls[0]).Text);
                    datarow.datInterest1          = Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text);
                    datarow.datBalanceBF          = Utility.ConvertToDecimal(((TextBox)row.Cells[1].Controls[0]).Text);
                    datarow.datPrincipalComponent = Utility.ConvertToDecimal(((TextBox)row.Cells[5].Controls[0]).Text) - Utility.ConvertToDecimal(((TextBox)row.Cells[3].Controls[0]).Text);
                    tbl.Rows.Add(datarow);

                    plan.InsertPaymentPlan(Convert.ToDateTime(datarow.datMonth),
                                           Convert.ToDecimal(datarow.datBalanceBF),
                                           Convert.ToDecimal(datarow.datInterest1),
                                           Convert.ToDecimal(datarow.datMonthlyPayment),
                                           Convert.ToDecimal("0.0"),
                                           Convert.ToDecimal(datarow.datPrincipalComponent.ToString()),
                                           Convert.ToDecimal(datarow.datOutstanding.ToString()),
                                           MySessionManager.AppID,
                                           Convert.ToInt32(datarow.datMonthIndex.ToString()));
                }
            }

            i++;
        }
    }