Пример #1
0
        private void trailBal()
        {
            try
            {
                tbl_AccGroup  grp  = new tbl_AccGroup();
                tbl_AccLedger ledg = new tbl_AccLedger();

                acc_list               = new Acc_list();
                acc_list.group         = grp.ToString();
                acc_list.ledger        = ledg.ToString();
                acc_list.only_opening  = false;
                acc_list.start_date    = null;
                acc_list.end_date      = null;
                acc_list.affects_gross = -1;
                acc_list.start(0);

                decimal dr = acc_list.dr_total;
                decimal cr = acc_list.cr_total;

                print_account_chart(acc_list, -1, this);

                ReportDataSource datasource = new ReportDataSource("DataSet1", dmList);

                this.reportViewer1.LocalReport.DataSources.Clear();
                this.reportViewer1.LocalReport.DataSources.Add(datasource);

                dmList = new List <DummyList>();
                dm     = new DummyList();

                dm.date = DateTime.Now.Date.ToString("dd-MM-yyyy");

                dm.TotaldrAmt = toCurr.toCurrenc("D", dr);
                dm.TotalcrAmt = toCurr.toCurrenc("D", dr);

                dmList.Add(dm);

                ReportDataSource datasource1 = new ReportDataSource("DataSet2", dmList);
                this.reportViewer1.LocalReport.DataSources.Add(datasource1);
            }
            catch (Exception x)
            {
            }
        }
Пример #2
0
        private void BalanceSheetData()
        {
            tbl_AccGroup  grp  = new tbl_AccGroup();
            tbl_AccLedger ledg = new tbl_AccLedger();

            acc = new MicroAccountsEntities1();

            var acc_group_id = (from c in acc.tbl_AccGroup
                                where c.groupName == "Incomes"
                                select c.id).FirstOrDefault();


            assets = new Acc_list();

            //Income
            income = new Acc_list();

            income.group        = grp.ToString();
            income.ledger       = ledg.ToString();
            income.only_opening = only_opening;
            // income.start_date = txtStartDate.Text;
            //income.end_date = txtEndDate.Text;
            income.affects_gross = -1;

            income.start(Convert.ToInt32(acc_group_id));

            //Expenses

            acc          = new MicroAccountsEntities1();
            acc_group_id = (from c in acc.tbl_AccGroup
                            where c.groupName == "Expenses"
                            select c.id).FirstOrDefault();

            assets  = new Acc_list();
            expense = new Acc_list();

            expense.group        = grp.ToString();
            expense.ledger       = ledg.ToString();
            expense.only_opening = only_opening;
            // expense.start_date = txtStartDate.Text;
            // expense.end_date = txtEndDate.Text;
            expense.affects_gross = -1;
            expense.start(Convert.ToInt32(acc_group_id));

            if (income.cl_total_dc == "C")
            {
                income_total = income.cl_total;
            }
            else
            {
                income_total = Convert.ToDecimal(income.cl_total);
            }
            if (expense.cl_total_dc == "D")
            {
                expense_total = expense.cl_total;
            }
            else
            {
                expense_total = Convert.ToDecimal(expense.cl_total);
            }

            pandl = income_total - expense_total;

            op_diff = new string[] { };
            op_diff = opening_diff();
            if (Convert.ToDecimal(op_diff[1]) == 0)
            {
                is_diff = false;
            }
            else
            {
                is_diff = true;
            }

            //------------------------------------------------------------------------


            ListViewGroup Assets = new ListViewGroup("Assets", HorizontalAlignment.Left);

            acc          = new MicroAccountsEntities1();
            acc_group_id = (from c in acc.tbl_AccGroup
                            where c.groupName == "Assets"
                            select c.id).FirstOrDefault();

            assets = new Acc_list();

            assets.group        = grp.ToString();
            assets.ledger       = ledg.ToString();
            assets.only_opening = only_opening;
            //assets.start_date = txtStartDate.Text;
            // assets.end_date = txtEndDate.Text;
            assets.affects_gross = -1;
            assets.start(Convert.ToInt32(acc_group_id));

            Account_st_short(assets, -1, "D", this, 1);

            //  dataGridView2.DataSource = dmList;

            labels = new Label[dmList.Count + 1];

            int k = 35;

            // create array elements in a loop
            for (int i = 0; i < dmList.Count; i++)
            {
                Font FNT = new Font("Century Gothic", 10.0f, FontStyle.Bold);

                labels[i] = new Label();

                labels[i].Top  = k * (i + 1);
                labels[i].Left = 546;
                labels[i].Font = FNT;
                labels[i].Size = new Size(200, 19);

                if (dmList[i].ledger == "1")
                {
                    labels[i].Text      = "    " + dmList[i].group.ToString();
                    labels[i].ForeColor = Color.Blue;
                }
                else
                {
                    labels[i].ForeColor = Color.Black;
                    labels[i].Text      = dmList[i].group.ToString();
                }

                assetsLabelTop = k * (i + 1);
            }

            this.Controls.AddRange(labels);

            labels = new Label[dmList.Count + 1];
            k      = 36;
            for (int i = 0; i < dmList.Count; i++)
            {
                Font FNT = new Font("Century Gothic", 10.0f, FontStyle.Bold);

                labels[i] = new Label();

                labels[i].Top  = k * (i + 1);
                labels[i].Left = 800;
                labels[i].Font = FNT;
                labels[i].Size = new Size(200, 19);

                labels[i].ForeColor = Color.Black;
                labels[i].Text      = dmList[i].amt.ToString();
            }

            this.Controls.AddRange(labels);


            dmList = new List <DummyList>();

            ListViewGroup LiabilitiesandOwnersEquity = new ListViewGroup("Liabilities and Owners Equity", HorizontalAlignment.Left);

            acc          = new MicroAccountsEntities1();
            acc_group_id = (from c in acc.tbl_AccGroup
                            where c.groupName == "Liabilities and Owners Equity"
                            select c.id).FirstOrDefault();

            liabilities = new Acc_list();

            liabilities.group        = grp.ToString();
            liabilities.ledger       = ledg.ToString();
            liabilities.only_opening = only_opening;
            //liabilities.start_date = txtStartDate.Text;
            //liabilities.end_date = txtEndDate.Text;
            liabilities.affects_gross = -1;
            liabilities.start(Convert.ToInt32(acc_group_id));

            Account_st_short(liabilities, -1, "C", this, 2);

            k      = 35;
            labels = new Label[dmList.Count + 1];
            // create array elements in a loop
            for (int i = 0; i < dmList.Count; i++)
            {
                Font FNT = new Font("Century Gothic", 10.0f, FontStyle.Bold);

                labels[i] = new Label();

                labels[i].Top  = k * (i + 1);
                labels[i].Left = 43;
                labels[i].Font = FNT;

                if (dmList[i].ledger == "1")
                {
                    labels[i].Text      = "    " + dmList[i].group.ToString();
                    labels[i].ForeColor = Color.Blue;
                    labels[i].Size      = new Size(200, 19);
                }
                else
                {
                    labels[i].ForeColor = Color.Black;
                    labels[i].Text      = dmList[i].group.ToString();
                    labels[i].Size      = new Size(200, 19);
                }

                libLabelTop = k * (i + 1);
            }
            this.Controls.AddRange(labels);

            k      = 36;
            labels = new Label[dmList.Count + 1];
            for (int i = 0; i < dmList.Count; i++)
            {
                FNT = new Font("Century Gothic", 10.0f, FontStyle.Bold);

                labels[i] = new Label();

                labels[i].Top  = k * (i + 1);
                labels[i].Left = 293;
                labels[i].Font = FNT;
                labels[i].Size = new Size(200, 19);

                labels[i].ForeColor = Color.Black;
                labels[i].Text      = dmList[i].amt.ToString();
            }
            this.Controls.AddRange(labels);

            if (liabilities.cl_total_dc == "C")
            {
                liabilities_total = liabilities.cl_total;
            }
            else
            {
                liabilities_total = Convert.ToDecimal(liabilities.cl_total * -1);
            }

            if (assets.cl_total_dc == "D")
            {
                assets_total = assets.cl_total;
            }
            else
            {
                assets_total = Convert.ToDecimal(assets.cl_total * -1);
            }

            /**** Final balancesheet total ****/

            final_liabilities_total = liabilities_total;
            final_assets_total      = assets_total;

            /* If net profit add to liabilities, if net loss add to assets */

            if (pandl >= 0)
            {
                final_liabilities_total = final_liabilities_total + pandl;
            }
            else
            {
                positive_pandl     = pandl * -1;
                final_assets_total = final_assets_total + positive_pandl;
            }

            /**
             * If difference in opening balance is Dr then subtract from
             * assets else subtract from liabilities
             */

            if (is_diff)
            {
                if (op_diff[0] == "D")
                {
                    final_assets_total = Convert.ToDecimal(final_assets_total + Convert.ToDecimal(op_diff[1]));
                }

                else
                {
                    final_liabilities_total = Convert.ToDecimal(final_liabilities_total + Convert.ToDecimal(op_diff[1]));
                }
            }


            panel4.Visible = true;
            panel4.Top     = assetsLabelTop + 35;


            /* Difference in opening balance */

            /* Total */

            dmList = new List <DummyList>();

            DummyList dm = new DummyList();

            if (assets_total >= 0)
            {
                Label lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "Total Assets";
                lb.Top  = assetsLabelTop + 50;
                lb.Left = 549;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = toCurr.toCurrenc("D", assets_total);
                lb.Top  = assetsLabelTop + 50;
                lb.Left = 800;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);
            }
            else
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text      = "Total Assets";
                lb.Top       = assetsLabelTop + 50;
                lb.Left      = 549;
                lb.Font      = FNT;
                lb.Size      = new Size(200, 19);
                lb.ForeColor = Color.Red;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "(Expecting positive Dr Balance)";
                lb.Top  = assetsLabelTop + 65;
                lb.Left = 549;
                Font FNTs = new Font("Century Gothic", 8.0f, FontStyle.Bold);
                lb.Font      = FNTs;
                lb.Size      = new Size(250, 19);
                lb.ForeColor = Color.Red;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text      = toCurr.toCurrenc("D", assets_total);
                lb.Top       = assetsLabelTop + 50;
                lb.Left      = 800;
                lb.Font      = FNT;
                lb.ForeColor = Color.Red;

                lb.Size = new Size(200, 19);
            }
            dmList.Add(dm);
            dm = new DummyList();

            html.Append("<tr style='font-weight:bold'>");

            if (pandl >= 0)
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "";
                lb.Top  = assetsLabelTop + 100;
                lb.Left = 549;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "";
                lb.Top  = assetsLabelTop + 100;
                lb.Left = 800;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);
            }
            else
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "Profit & Loss Account (Net Loss)";
                lb.Top  = assetsLabelTop + 100;
                lb.Left = 549;
                lb.Font = FNT;
                lb.Size = new Size(250, 19);

                positive_pandl = pandl * -1;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = toCurr.toCurrenc("D", positive_pandl);
                lb.Top  = assetsLabelTop + 100;
                lb.Left = 800;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);
            }



            if (is_diff)
            {
                /* If diff in opening balance is Dr */
                if (op_diff[0] == "D")
                {
                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = "Diff in O/P Balance";
                    lb.Top  = assetsLabelTop + 130;
                    lb.Left = 549;
                    lb.Font = FNT;
                    lb.Size = new Size(200, 19);

                    positive_pandl = pandl * -1;

                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = toCurr.toCurrenc("D", Convert.ToDecimal(op_diff[1]));
                    lb.Top  = assetsLabelTop + 130;
                    lb.Left = 800;
                    lb.Font = FNT;
                    lb.Size = new Size(200, 19);
                }
                else
                {
                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = "";
                    lb.Top  = assetsLabelTop + 130;
                    lb.Left = 549;
                    lb.Font = FNT;
                    lb.Size = new Size(200, 19);

                    positive_pandl = pandl * -1;

                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = "";
                    lb.Top  = assetsLabelTop + 130;
                    lb.Left = 800;
                    lb.Font = FNT;
                    lb.Size = new Size(200, 19);
                }
            }

            if (final_liabilities_total == final_assets_total)
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "Total";
                lb.Top  = assetsLabelTop + 150;
                lb.Left = 549;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);

                positive_pandl = pandl * -1;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = toCurr.toCurrenc("D", Convert.ToDecimal(final_assets_total));
                lb.Top  = assetsLabelTop + 150;
                lb.Left = 800;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);
            }
            else
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text        = "Total";
                lb.Top         = assetsLabelTop + 150;
                lb.Left        = 549;
                lb.Font        = FNT;
                lb.ForeColor   = Color.Red;
                positive_pandl = pandl * -1;
                lb.Size        = new Size(200, 19);

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text      = toCurr.toCurrenc("D", Convert.ToDecimal(final_assets_total));
                lb.Top       = assetsLabelTop + 150;
                lb.Left      = 800;
                lb.Font      = FNT;
                lb.ForeColor = Color.Red;
                lb.Size      = new Size(200, 19);
            }


            //Liablities bottom total

            panel6.Visible = true;
            panel6.Top     = libLabelTop + 35;

            if (liabilities_total >= 0)
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "Total Liability and Owners Equity";
                lb.Size = new Size(200, 19);
                lb.Top  = libLabelTop + 50;
                lb.Left = 42;
                lb.Font = FNT;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = (toCurr.toCurrenc("C", liabilities_total));
                lb.Top  = libLabelTop + 55;
                lb.Left = 293;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);
            }
            else
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text      = "Total Liability and Owners Equity";
                lb.Top       = libLabelTop + 50;
                lb.Left      = 42;
                lb.Font      = FNT;
                lb.Size      = new Size(200, 19);
                lb.ForeColor = Color.Red;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text      = (toCurr.toCurrenc("C", liabilities_total));
                lb.Top       = libLabelTop + 55;
                lb.Left      = 293;
                lb.Font      = FNT;
                lb.Size      = new Size(200, 19);
                lb.ForeColor = Color.Red;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "(Expecting positive Cr Balance)";
                lb.Top  = libLabelTop + 70;
                lb.Left = 42;
                Font FNTss = new Font("Century Gothic", 8.0f, FontStyle.Bold);
                lb.Font      = FNTss;
                lb.Size      = new Size(250, 19);
                lb.ForeColor = Color.Red;
            }

            if (pandl >= 0)
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "Profit & Loss Account (Net Loss)";
                lb.Top  = libLabelTop + 100;
                lb.Left = 42;
                lb.Font = FNT;
                lb.Size = new Size(250, 19);

                positive_pandl = pandl * -1;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = toCurr.toCurrenc("C", pandl);
                lb.Top  = libLabelTop + 100;
                lb.Left = 293;
                lb.Font = FNT;
                lb.Size = new Size(250, 19);
            }
            else
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = " ";
                lb.Top  = libLabelTop + 100;
                lb.Left = 42;
                lb.Font = FNT;
                lb.Size = new Size(250, 19);

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "  ";
                lb.Top  = libLabelTop + 100;
                lb.Left = 293;
                lb.Font = FNT;
                lb.Size = new Size(250, 19);
            }

            if (is_diff)
            {
                html.Append("<tr style='font-weight:bold;color:red'>");
                /* If diff in opening balance is Cr */
                if (op_diff[0] == "C")
                {
                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text      = "Diff in O/P Balance";
                    lb.Top       = libLabelTop + 130;
                    lb.Left      = 42;
                    lb.Font      = FNT;
                    lb.Size      = new Size(250, 19);
                    lb.ForeColor = Color.Red;

                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text      = toCurr.toCurrenc("C", Convert.ToDecimal(op_diff[1]));
                    lb.Top       = libLabelTop + 130;
                    lb.Left      = 293;
                    lb.Font      = FNT;
                    lb.Size      = new Size(250, 19);
                    lb.ForeColor = Color.Red;
                }
                else
                {
                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = " ";
                    lb.Top  = libLabelTop + 130;
                    lb.Left = 42;
                    lb.Font = FNT;
                    lb.Size = new Size(250, 19);

                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = "  ";
                    lb.Top  = libLabelTop + 130;
                    lb.Left = 293;
                    lb.Font = FNT;
                    lb.Size = new Size(250, 19);
                }
            }



            if (final_liabilities_total == final_assets_total)
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = "Total";
                lb.Top  = libLabelTop + 150;
                lb.Left = 42;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);

                positive_pandl = pandl * -1;

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text = toCurr.toCurrenc("c", Convert.ToDecimal(final_assets_total));
                lb.Top  = libLabelTop + 150;
                lb.Left = 293;
                lb.Font = FNT;
                lb.Size = new Size(200, 19);
            }
            else
            {
                lb = new Label();
                this.Controls.Add(lb);
                lb.Text        = "Total";
                lb.Top         = libLabelTop + 150;
                lb.Left        = 42;
                lb.Font        = FNT;
                lb.ForeColor   = Color.Red;
                positive_pandl = pandl * -1;
                lb.Size        = new Size(200, 19);

                lb = new Label();
                this.Controls.Add(lb);
                lb.Text      = toCurr.toCurrenc("c", Convert.ToDecimal(final_assets_total));
                lb.Top       = libLabelTop + 150;
                lb.Left      = 293;
                lb.Font      = FNT;
                lb.ForeColor = Color.Red;
                lb.Size      = new Size(200, 19);
            }
        }
Пример #3
0
        private void TrailBalance_Load(object sender, EventArgs e)
        {
            try
            {
                tbl_AccGroup  grp  = new tbl_AccGroup();
                tbl_AccLedger ledg = new tbl_AccLedger();

                acc_list               = new Acc_list();
                acc_list.group         = grp.ToString();
                acc_list.ledger        = ledg.ToString();
                acc_list.only_opening  = false;
                acc_list.start_date    = null;
                acc_list.end_date      = null;
                acc_list.affects_gross = -1;
                acc_list.start(0);

                decimal dr = acc_list.dr_total;
                decimal cr = acc_list.cr_total;

                print_account_chart(acc_list, -1, this);

                panel2.Top = top + 10;


                if (dr == cr)
                {
                    Label lb2 = new Label();
                    this.Controls.Add(lb2);
                    lb2.Text = "Total";
                    //lb.Top = assetsLabelTop + 50;
                    lb2.Top       = top + 25;
                    lb2.Left      = 42;
                    lb2.Font      = FNT;
                    lb2.ForeColor = Color.Green;
                    lb2.Size      = new Size(150, 19);

                    Label lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = toCurr.toCurrenc("D", dr);
                    //lb.Top = assetsLabelTop + 50;
                    lb.Top       = top + 25;
                    lb.Left      = 483;
                    lb.Font      = FNT;
                    lb.ForeColor = Color.Green;
                    lb.Size      = new Size(150, 19);

                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = toCurr.toCurrenc("C", cr);
                    //lb.Top = assetsLabelTop + 50;
                    lb.Top       = top + 25;
                    lb.Left      = 651;
                    lb.Font      = FNT;
                    lb.ForeColor = Color.Green;
                    lb.Size      = new Size(150, 19);
                }
                else
                {
                    Label lb1 = new Label();
                    this.Controls.Add(lb1);
                    lb1.Text = "Total";
                    //lb.Top = assetsLabelTop + 50;
                    lb1.Top       = top + 25;
                    lb1.Left      = 42;
                    lb1.Font      = FNT;
                    lb1.ForeColor = Color.Red;
                    lb1.Size      = new Size(150, 19);

                    Label lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = toCurr.toCurrenc("D", dr);
                    //lb.Top = assetsLabelTop + 50;
                    lb.Top       = top + 25;
                    lb.Left      = 483;
                    lb.Font      = FNT;
                    lb.ForeColor = Color.Red;
                    lb.Size      = new Size(150, 19);

                    lb = new Label();
                    this.Controls.Add(lb);
                    lb.Text = toCurr.toCurrenc("C", cr);
                    //lb.Top = assetsLabelTop + 50;
                    lb.Top       = top + 25;
                    lb.Left      = 651;
                    lb.Font      = FNT;
                    lb.ForeColor = Color.Red;
                    lb.Size      = new Size(150, 19);
                }
            }
            catch (Exception x)
            {
            }
        }