protected void btnFinalize_Click(object sender, EventArgs e)
 {
     try
     {
        InvestmentDSTableAdapters.GetInvScheduleTableAdapter InvSch= new InvestmentDSTableAdapters.GetInvScheduleTableAdapter();
        InvSch.UpdateInvScheduleStatus(4, MySessionManager.InvAccID);
     }
     catch (Exception ex) { }
 }
 protected void btnFinalize_Click(object sender, EventArgs e)
 {
     try
     {
         InvestmentDSTableAdapters.GetInvScheduleTableAdapter InvSch = new InvestmentDSTableAdapters.GetInvScheduleTableAdapter();
         InvSch.UpdateInvScheduleStatus(4, MySessionManager.InvAccID);
     }
     catch (Exception ex) { }
 }
    private void CalculateIntPayment(int terms, int freq, Decimal amt, decimal per, DateTime firstpaymentdate)
    {
        decimal totalAmt = 0;

        try
        {
            this.TABLE1.Rows.Clear();

            this.TABLE1.Rows.Add(new HtmlTableRow());
            HtmlTableRow row;



            DateTime firstdt = firstpaymentdate;

            string[,] data = amountcalculation(freq, terms, amt, per, firstdt);

            Label lblMonth1 = new Label();
            lblMonth1.Style["font-weight"] = "bold";
            lblMonth1.Text = firstdt.ToString("dd") + " " + firstdt.ToString("MMM") + " " + firstdt.ToString("yy");

            Label lbl;
            TextBox txt1;
            TextBox txt2;
            TextBox txt3;


            row = new HtmlTableRow();

            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());


            Label lbl1 = new Label();
            Label lbl2 = new Label();
            Label lbl3 = new Label();


            lbl1.Text = "Payment Date";
            lbl2.Text = "Days";
            lbl3.Text = "Interest";


            lbl1.Font.Bold = true;
            lbl2.Font.Bold = true;
            lbl3.Font.Bold = true;

            row.Cells[0].Controls.Add(lbl1);
            row.Cells[1].Controls.Add(lbl2);
            row.Cells[2].Controls.Add(lbl3);


            row.Cells[0].Align = "center";
            row.Cells[1].Align = "center";
            row.Cells[2].Align = "center";


            this.TABLE1.Rows.Add(row);



            for (int i = 0; i < data.GetLength(0); i++)
            {
                row = new HtmlTableRow();

                row.Cells.Add(new HtmlTableCell());
                row.Cells.Add(new HtmlTableCell());
                row.Cells.Add(new HtmlTableCell());

                txt1 = new TextBox();
                txt2 = new TextBox();
                txt3 = new TextBox();

                lbl = new Label();
                lbl.ID = "lblPaymentDates" + i.ToString();

                lbl.Text = Convert.ToDateTime(data[i, 0]).ToString("dd MMM yyyy");
                lbl.Style["font-weight"] = "bold";
                row.Cells[0].Controls.Add(lbl);

                txt1.ID = "txtDays" + i.ToString();
                txt1.CssClass = "BF" + i.ToString();
                txt1.Style["font-weight"] = "bold";
                txt1.Style["border"] = "none";
                txt1.Style.Add("text-align", "center");
                txt1.Style.Add("width", "100%");

                txt1.Text = data[i, 1].ToString();

                txt2.ID = "txtInterest" + i.ToString();
                txt2.CssClass = "_IR" + i.ToString();
                txt2.Style["font-weight"] = "bold";
                txt2.Style["border"] = "none";
                txt2.Style.Add("text-align", "right");
                txt2.Style.Add("width", "100%");
                txt2.Text = data[i, 2].ToString();
                totalAmt = totalAmt + Convert.ToDecimal(data[i, 2]);
                row.Cells[1].Controls.Add(txt1);
                row.Cells[2].Controls.Add(txt2);

                this.TABLE1.Rows.Add(row);

            }
            row = new HtmlTableRow();

            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());

            TextBox txtA = new TextBox();
            TextBox txtB = new TextBox();

            txtA.Text = "Total";
            txtA.ID = "txttotal";
            txtA.CssClass = "BF";
            txtA.Style["font-weight"] = "bold";
            txtA.Style["border"] = "none";
            txtA.Style.Add("text-align", "center");
            txtA.Style.Add("width", "100%");


            txtB.Text = totalAmt.ToString("C").Replace("$", "");

            txtB.ID = "txtTotalAmt";
            txtB.CssClass = "BF";
            txtB.Style["font-weight"] = "bold";
            txtB.Style["border"] = "none";
            txtB.Style.Add("text-align", "right");
            txtB.Style.Add("width", "100%");

            row.Cells[1].Controls.Add(txtA);
            row.Cells[2].Controls.Add(txtB);

            this.TABLE1.Rows.Add(row);

            if (editFlag == true)
            {
                //Record the values in the db
                InvestmentDSTableAdapters.GetInvScheduleTableAdapter InvSch = new InvestmentDSTableAdapters.GetInvScheduleTableAdapter();
                InvestmentDS.GetInvScheduleDataTable tblInvSch = InvSch.GetInvSchedule(MySessionManager.InvAppID);
                if (tblInvSch.Rows.Count > 0)
                {
                    InvSch.DeleteInvAccID(MySessionManager.InvAppID);
                }

                for (int i = 0; i < data.GetLength(0); i++)
                {
                    InvSch.InsertPaymentSch(MySessionManager.InvAppID,
                                            Convert.ToDateTime(data[i, 0]),
                                            Convert.ToInt32(data[i, 1]),
                                            Convert.ToDecimal(data[i, 2]),
                                            0,
                                            1
                                            );
                }

            }
        }
        catch (Exception ex) { }
    }
Ejemplo n.º 4
0
    private void CalculateIntPayment(int terms, int freq, Decimal amt, decimal per, DateTime firstpaymentdate)
    {
        decimal totalAmt = 0;

        try
        {
            this.TABLE1.Rows.Clear();

            this.TABLE1.Rows.Add(new HtmlTableRow());
            HtmlTableRow row;



            DateTime firstdt = firstpaymentdate;

            string[,] data = amountcalculation(freq, terms, amt, per, firstdt);

            Label lblMonth1 = new Label();
            lblMonth1.Style["font-weight"] = "bold";
            lblMonth1.Text = firstdt.ToString("dd") + " " + firstdt.ToString("MMM") + " " + firstdt.ToString("yy");

            Label   lbl;
            TextBox txt1;
            TextBox txt2;
            TextBox txt3;


            row = new HtmlTableRow();

            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());


            Label lbl1 = new Label();
            Label lbl2 = new Label();
            Label lbl3 = new Label();


            lbl1.Text = "Payment Date";
            lbl2.Text = "Days";
            lbl3.Text = "Interest";


            lbl1.Font.Bold = true;
            lbl2.Font.Bold = true;
            lbl3.Font.Bold = true;

            row.Cells[0].Controls.Add(lbl1);
            row.Cells[1].Controls.Add(lbl2);
            row.Cells[2].Controls.Add(lbl3);


            row.Cells[0].Align = "center";
            row.Cells[1].Align = "center";
            row.Cells[2].Align = "center";


            this.TABLE1.Rows.Add(row);



            for (int i = 0; i < data.GetLength(0); i++)
            {
                row = new HtmlTableRow();

                row.Cells.Add(new HtmlTableCell());
                row.Cells.Add(new HtmlTableCell());
                row.Cells.Add(new HtmlTableCell());

                txt1 = new TextBox();
                txt2 = new TextBox();
                txt3 = new TextBox();

                lbl    = new Label();
                lbl.ID = "lblPaymentDates" + i.ToString();

                lbl.Text = Convert.ToDateTime(data[i, 0]).ToString("dd MMM yyyy");
                lbl.Style["font-weight"] = "bold";
                row.Cells[0].Controls.Add(lbl);

                txt1.ID                   = "txtDays" + i.ToString();
                txt1.CssClass             = "BF" + i.ToString();
                txt1.Style["font-weight"] = "bold";
                txt1.Style["border"]      = "none";
                txt1.Style.Add("text-align", "center");
                txt1.Style.Add("width", "100%");

                txt1.Text = data[i, 1].ToString();

                txt2.ID                   = "txtInterest" + i.ToString();
                txt2.CssClass             = "_IR" + i.ToString();
                txt2.Style["font-weight"] = "bold";
                txt2.Style["border"]      = "none";
                txt2.Style.Add("text-align", "right");
                txt2.Style.Add("width", "100%");
                txt2.Text = data[i, 2].ToString();
                totalAmt  = totalAmt + Convert.ToDecimal(data[i, 2]);
                row.Cells[1].Controls.Add(txt1);
                row.Cells[2].Controls.Add(txt2);

                this.TABLE1.Rows.Add(row);
            }
            row = new HtmlTableRow();

            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());
            row.Cells.Add(new HtmlTableCell());

            TextBox txtA = new TextBox();
            TextBox txtB = new TextBox();

            txtA.Text                 = "Total";
            txtA.ID                   = "txttotal";
            txtA.CssClass             = "BF";
            txtA.Style["font-weight"] = "bold";
            txtA.Style["border"]      = "none";
            txtA.Style.Add("text-align", "center");
            txtA.Style.Add("width", "100%");


            txtB.Text = totalAmt.ToString("C").Replace("$", "");

            txtB.ID                   = "txtTotalAmt";
            txtB.CssClass             = "BF";
            txtB.Style["font-weight"] = "bold";
            txtB.Style["border"]      = "none";
            txtB.Style.Add("text-align", "right");
            txtB.Style.Add("width", "100%");

            row.Cells[1].Controls.Add(txtA);
            row.Cells[2].Controls.Add(txtB);

            this.TABLE1.Rows.Add(row);

            if (editFlag == true)
            {
                //Record the values in the db
                InvestmentDSTableAdapters.GetInvScheduleTableAdapter InvSch = new InvestmentDSTableAdapters.GetInvScheduleTableAdapter();
                InvestmentDS.GetInvScheduleDataTable tblInvSch = InvSch.GetInvSchedule(MySessionManager.InvAppID);
                if (tblInvSch.Rows.Count > 0)
                {
                    InvSch.DeleteInvAccID(MySessionManager.InvAppID);
                }

                for (int i = 0; i < data.GetLength(0); i++)
                {
                    InvSch.InsertPaymentSch(MySessionManager.InvAppID,
                                            Convert.ToDateTime(data[i, 0]),
                                            Convert.ToInt32(data[i, 1]),
                                            Convert.ToDecimal(data[i, 2]),
                                            0,
                                            1
                                            );
                }
            }
        }
        catch (Exception ex) { }
    }