Ejemplo n.º 1
0
        private void Report()
        {
            double opamount = Convert.ToDouble(textBox1.Text);
            double clamount = Convert.ToDouble(textBox2.Text);


            CHTMLDocument ds  = new CHTMLDocument();
            CHTMLText     txt = new CHTMLText("     Profit And Loss Account     ");

            txt.setItalic(true);
            CHTMLHorizontalRule hr    = new CHTMLHorizontalRule();
            CHTMLInput          input = new CHTMLInput();
            //
            //
            //
            CHTMLTable table = new CHTMLTable();

            table.setBorder(1);
            table.setCaption(new CHTMLText("  Profit And Loss Account   "));

            CHTMLTableRow row = null;

            row = new CHTMLTableRow();
            CHTMLTableCell cell = null;

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText(" Expenses "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  Account Rs "));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);

            cell.addObject(new CHTMLText(" Income "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  Account Rs "));
            row.addObject(cell);
            table.addObject(row);

            row  = new CHTMLTableRow();
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText(" To Opening stock  "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.setHorizontalAlign(alignment.RIGHT);
            cell.addObject(new CHTMLText(opamount.ToString()));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText());
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText());
            row.addObject(cell);

            row.backgroundColor = "red";
            table.addObject(row);
            DataTable dt      = PandL.ProfitAndLoss2();
            DataTable dt1     = PandL.ProfitAndLoss1();
            double    crTotal = 0;
            double    drTotal = 0;
            int       crow    = dt1.Rows.Count;
            int       drow    = dt.Rows.Count;
            int       max     = Math.Max(drow, crow);
            bool      flag1   = false;
            bool      flag2   = false;

            bool equal     = (drow == crow) ? true : false;
            bool drowempty = drow == 0 ? true : false;
            bool crowempty = crow == 0 ? true : false;
            int  i         = 0;

            while (i < max)
            {
                row = new CHTMLTableRow();
                if (drow < max)
                {
                    if (i == drow)
                    {
                        flag1 = true;
                    }
                }
                if (crow < max)
                {
                    if (i == crow)
                    {
                        flag2 = true;
                    }
                }

                if (flag1 == true && equal == false)
                {
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("  "));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText("  "));
                    row.addObject(cell);
                }

                if (i < drow && drowempty == false)
                {
                    DataRow dr   = dt.Rows[i];
                    double  amnt = double.Parse(dr["Total"].ToString());


                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("To " + dr["S_DESC"].ToString()));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText(amnt.ToString()));
                    row.addObject(cell);

                    drTotal += amnt;
                }
                if (flag2 == true && equal == false)
                {
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("  "));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText(" "));
                    row.addObject(cell);
                }

                if (i < crow && crowempty == false)
                {
                    DataRow dr = dt1.Rows[i];

                    double amnt = double.Parse(dr["Total"].ToString());

                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("By " + dr["S_DESC"].ToString()));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    amnt = -amnt;

                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText(amnt.ToString()));
                    row.addObject(cell);
                    crTotal += amnt;
                }
                table.addObject(row);
                i++;
            }



            row  = new CHTMLTableRow();
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText());
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText());
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText("  By Closing stock  "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.setHorizontalAlign(alignment.RIGHT);
            cell.addObject(new CHTMLText(clamount.ToString()));
            row.addObject(cell);
            table.addObject(row);

            crTotal += clamount;
            drTotal += opamount;

            row  = new CHTMLTableRow();
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText(" To profit and loss carried down to balance sheet "));
            row.addObject(cell);


            diff = drTotal - crTotal;

            if (drTotal > crTotal)
            {
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText());
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText());
                row.addObject(cell);

                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.setHorizontalAlign(alignment.RIGHT);
                cell.addObject(new CHTMLText((diff).ToString()));
                row.addObject(cell);
                crTotal += diff;
            }
            else
            {
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.setHorizontalAlign(alignment.RIGHT);
                cell.addObject(new CHTMLText((-diff).ToString()));
                row.addObject(cell);
                drTotal += (-diff);
            }

            table.addObject(row);

            row  = new CHTMLTableRow();
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText("Total"));
            row.addObject(cell);


            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.setHorizontalAlign(alignment.RIGHT);
            cell.addObject(new CHTMLText(drTotal.ToString()));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText());
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.setHorizontalAlign(alignment.RIGHT);
            cell.addObject(new CHTMLText(crTotal.ToString()));
            row.addObject(cell);
            table.addObject(row);
            ds.addObject(table);
            string rs = ds.toHTML();

            FileStream   fs = new FileStream(@"C:\temp\a.html", FileMode.Create);
            StreamWriter st = new StreamWriter(fs);

            st.Write(rs);
            st.Close();



            webBrowser1.Navigate(new Uri(@"file://c:\temp\a.html"));
            webBrowser1.Refresh();
        }
Ejemplo n.º 2
0
        private void Report3()
        {
            CHTMLDocument ds  = new CHTMLDocument();
            CHTMLText     txt = new CHTMLText("Trial Balance");

            txt.setItalic(true);
            CHTMLHorizontalRule hr    = new CHTMLHorizontalRule();
            CHTMLInput          input = new CHTMLInput();
            //
            //
            //
            CHTMLTable table = new CHTMLTable();

            table.setBorder(1);
            table.setCaption(new CHTMLText("TRIAL BALANCE"));

            CHTMLTableRow row = null;

            row = new CHTMLTableRow();

            CHTMLTableCell cell = null;

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  Account "));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  DR "));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  CR "));
            row.addObject(cell);


            row.backgroundColor = "red";
            table.addObject(row);
            DataTable dt      = TrialBalance.TrialTable();
            double    crTotal = 0;
            double    drTotal = 0;

            foreach (DataRow dr in dt.Rows)
            {
                row  = new CHTMLTableRow();
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText(dr["S_DESC"].ToString()));
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.RIGHT);

                double amnt = double.Parse(dr["Total"].ToString());
                if (amnt >= 0)
                {
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText(amnt.ToString()));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("   "));
                    row.addObject(cell);
                    drTotal += amnt;
                }
                else if (amnt < 0)
                {
                    amnt = -amnt;
                    cell.addObject(new CHTMLText("   "));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText(amnt.ToString()));
                    row.addObject(cell);
                    crTotal += amnt;
                }

                table.addObject(row);
            }
            row  = new CHTMLTableRow();
            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("Total"));
            row.addObject(cell);


            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText(drTotal.ToString()));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText(crTotal.ToString()));
            row.addObject(cell);
            table.addObject(row);
            ds.addObject(table);
            string rs = ds.toHTML();

            FileStream   fs = new FileStream(@"C:\temp\a.html", FileMode.Create);
            StreamWriter st = new StreamWriter(fs);

            st.Write(rs);
            st.Close();



            webBrowser1.Navigate(new Uri(@"file://c:\temp\a.html"));
            webBrowser1.Refresh();
        }
Ejemplo n.º 3
0
        private void Report()
        {
            double closingstock = Convert.ToDouble(clstocktxt.Text);
            double pft          = Convert.ToDouble(pltxt.Text);
            double crTotal      = 0;
            double drTotal      = 0;
            bool   flag1        = false;
            bool   flag2        = false;
            bool   equal        = false;

            CHTMLDocument ds  = new CHTMLDocument();
            CHTMLText     txt = new CHTMLText(" BalanceSheet  ");

            txt.setItalic(true);
            CHTMLHorizontalRule hr    = new CHTMLHorizontalRule();
            CHTMLInput          input = new CHTMLInput();
            //
            //
            //
            CHTMLTable table = new CHTMLTable();

            table.setBorder(1);
            table.setCaption(new CHTMLText(" BalanceSheet "));

            CHTMLTableRow row = null;

            row = new CHTMLTableRow();
            CHTMLTableCell cell = null;

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("Liabilities "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  Account Rs "));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);

            cell.addObject(new CHTMLText(" Assets "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  Account Rs "));
            row.addObject(cell);
            table.addObject(row);
            row = null;

            if (pft > 0)
            {
                row  = new CHTMLTableRow();
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText(" Profit "));
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.setHorizontalAlign(alignment.RIGHT);
                cell.addObject(new CHTMLText((pft).ToString()));
                row.addObject(cell);

                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText("  "));
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText("  "));
                row.addObject(cell);
                table.addObject(row);
                row      = null;
                crTotal += (pft);
            }
            else if (pft < 0)
            {
                row = new CHTMLTableRow();

                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText("  "));
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText("  "));
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.addObject(new CHTMLText("Loss "));
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.RIGHT);
                cell.setHorizontalAlign(alignment.RIGHT);
                cell.addObject(new CHTMLText((-pft).ToString()));
                row.addObject(cell);

                table.addObject(row);
                row      = null;
                drTotal += -pft;
            }


            // row.backgroundColor = "red";
            //table.addObject(row);
            DataTable dt  = Balancesheet.ShowBalance2();
            DataTable dt1 = Balancesheet.ShowBalance1();

            int drow = dt.Rows.Count;
            int crow = dt1.Rows.Count;
            int max  = Math.Max(drow, crow);

            equal = (drow == crow) ? true : false;
            int i = 0;

            while (i < max)
            {
                row = new CHTMLTableRow();

                if (crow < max)
                {
                    if (i == crow)
                    {
                        flag1 = true;;
                    }
                }
                if (drow < max)
                {
                    if (i == drow)
                    {
                        flag2 = true;
                    }
                }



                if (flag1 == true && equal == false)
                {
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("  "));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText("  "));
                    row.addObject(cell);
                }

                if (i < crow)
                {
                    DataRow dr = dt1.Rows[i];

                    double amnt = double.Parse(dr["Total"].ToString());


                    if (amnt < 0)
                    {
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText(dr["S_DESC"].ToString()));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.setHorizontalAlign(alignment.RIGHT);
                        cell.addObject(new CHTMLText((-amnt).ToString()));
                        row.addObject(cell);

                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText("  "));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText("  "));
                        row.addObject(cell);

                        crTotal += -amnt;
                    }
                    else
                    {
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText("   "));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText("  "));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText(dr["S_DESC"].ToString()));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.setHorizontalAlign(alignment.RIGHT);
                        cell.addObject(new CHTMLText((amnt).ToString()));
                        row.addObject(cell);
                        table.addObject(row);
                        row = new CHTMLTableRow();

                        drTotal += (amnt);
                    }
                }
                if (flag2 == true && equal == false)
                {
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("  "));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText(" "));
                    row.addObject(cell);
                }


                if (i < drow)
                {
                    DataRow dr   = dt.Rows[i];
                    double  amnt = double.Parse(dr["Total"].ToString());



                    if (amnt > 0)
                    {
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText("  "));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText("  "));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText(dr["S_DESC"].ToString()));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.setHorizontalAlign(alignment.RIGHT);
                        cell.addObject(new CHTMLText((amnt).ToString()));
                        row.addObject(cell);

                        drTotal += (amnt);
                    }
                    else if (amnt < 0)
                    {
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.addObject(new CHTMLText(dr["S_DESC"].ToString()));
                        row.addObject(cell);
                        cell = new CHTMLTableCell(alignment.RIGHT);
                        cell.setHorizontalAlign(alignment.RIGHT);
                        cell.addObject(new CHTMLText((amnt).ToString()));
                        row.addObject(cell);

                        crTotal += (amnt);
                    }
                }
                table.addObject(row);
                row = null;
                i++;
            }


            row  = new CHTMLTableRow();
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText("  "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText("  "));
            row.addObject(cell);
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText("Closing stock"));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.setHorizontalAlign(alignment.RIGHT);
            cell.addObject(new CHTMLText(closingstock.ToString()));
            row.addObject(cell);
            table.addObject(row);
            drTotal += closingstock;



            row  = new CHTMLTableRow();
            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText("Total"));
            row.addObject(cell);


            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.setHorizontalAlign(alignment.RIGHT);
            cell.addObject(new CHTMLText(drTotal.ToString()));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.addObject(new CHTMLText());
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.RIGHT);
            cell.setHorizontalAlign(alignment.RIGHT);
            cell.addObject(new CHTMLText(crTotal.ToString()));
            row.addObject(cell);
            table.addObject(row);

            ds.addObject(table);
            string rs = ds.toHTML();

            FileStream   fs = new FileStream(@"C:\temp\a.html", FileMode.Create);
            StreamWriter st = new StreamWriter(fs);

            st.Write(rs);
            st.Close();



            webBrowser1.Navigate(new Uri(@"file://c:\temp\a.html"));
            webBrowser1.Refresh();
        }
Ejemplo n.º 4
0
        private void Report2(DataTable dt)
        {
            CHTMLDocument ds  = new CHTMLDocument();
            CHTMLText     txt = new CHTMLText("Ledger");

            txt.setItalic(true);
            CHTMLHorizontalRule hr    = new CHTMLHorizontalRule();
            CHTMLInput          input = new CHTMLInput();
            //
            //
            //
            CHTMLTable table = new CHTMLTable();

            table.setBorder(1);
            table.setCaption(new CHTMLText("Ledger Of " + _acc_string));

            CHTMLTableRow row = null;

            row = new CHTMLTableRow();

            CHTMLTableCell cell = null;

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  Date "));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText(" Account Name "));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  DR "));
            row.addObject(cell);

            cell = new CHTMLTableCell(alignment.HEADING);
            cell.addObject(new CHTMLText("  CR "));
            row.addObject(cell);


            row.backgroundColor = "red";
            table.addObject(row);

            foreach (DataRow dr in dt.Rows)
            {
                row  = new CHTMLTableRow();
                cell = new CHTMLTableCell(alignment.HEADING);
                cell.addObject(new CHTMLText(dr["J_DATE"].ToString()));
                row.addObject(cell);
                cell = new CHTMLTableCell(alignment.HEADING);
                if (dr["J_DRCR"].ToString() == "CR")
                {
                    cell.addObject(new CHTMLText("TO " + dr["S_DESC"].ToString()));
                }
                else
                {
                    cell.addObject(new CHTMLText("BY " + dr["S_DESC"].ToString()));
                }
                row.addObject(cell);
                if (dr["J_DRCR"].ToString() == "CR")
                {
                    cell = new CHTMLTableCell(alignment.HEADING);
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText(dr["J_AMOUNT"].ToString()));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.addObject(new CHTMLText("   "));
                    row.addObject(cell);
                }
                else
                {
                    cell = new CHTMLTableCell(alignment.HEADING);
                    cell.addObject(new CHTMLText("   "));
                    row.addObject(cell);
                    cell = new CHTMLTableCell(alignment.RIGHT);
                    cell.setHorizontalAlign(alignment.RIGHT);
                    cell.addObject(new CHTMLText(dr["J_AMOUNT"].ToString()));
                    row.addObject(cell);
                }


                table.addObject(row);
            }

            ds.addObject(table);
            string rs = ds.toHTML();

            FileStream   fs = new FileStream(@"C:\temp\a.html", FileMode.Create);
            StreamWriter st = new StreamWriter(fs);

            st.Write(rs);
            st.Close();



            webBrowser1.Navigate(new Uri(@"file://c:\temp\a.html"));
            webBrowser1.Refresh();
        }