Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Applications » Downloads
 
Add your own
alternative version
Go to top

AccountPlus

, 10 Sep 2009
A Complete Account Management System
accountplus.zip
AccountPlus
AccountPlus
AccountPlus.JPG
Database
AccountPlus.mdb
Documents
AccountPlus.doc
Thumbs.db
Setup
setup.msi
Thumbs.db
Source_Code.zip
accountplussource.zip
AccountPlusSource
AccountPlus.BusinessLogic
AccountPlus.BusinessLogic.csproj.user
Properties
AccountPlus.Configurations
Properties
AccountPlus.DataAccess
Properties
AccountPlus.Formatting
Properties
AccountPlus.Messaging
Properties
AccountPlus.Setup
AccountPlus.Setup.CustomActions
Properties
Settings.settings
AccountPlus.Setup.vdproj
AccountPlus.UserInterface
AccountPlus.UserInterface.csproj.user
AccPlus.csproj.user
Help
AccountPlus.pdf
log4net.dll
Properties
Settings.settings
propertiesORoptions.ico
Assemblies
log4net.dll
database.zip
Database
MS Access
AccountPlus.mdb
MySQL
SQL Server
Backup
AccountPlus.bak
Script
setup.zip
Setup
Setup.msi
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using AccountPlus.DataAccess;

namespace AccountPlus.BusinessLogic
{
    public class ItemWiseAnalytics
    {
        private Arch arch = new Arch();
        private DBHelper _dbHelper = new DBHelper();
        private CommonArch commonReportArch = new CommonArch();
        private ItemAnalyticArch itemAnalyticArch = new ItemAnalyticArch();
        private ReportArchitecture reportArch = new ReportArchitecture();

        public DataTable ItemWiseTrendReport(string month, string year)
        {
            DataTable data = new DataTable();

            //Checks that Data exist for present month or not?
            string presentMMYYYY = arch.DecodeMonthYear(month, year);
            bool dataExistForPresntMonth = commonReportArch.DataExistForMonth(month, year);

            //Checks that Data exist for prev month or not?            
            string previousMonth = arch.GetPreviousMonth(month);
            string previousMonthYear = arch.GetPrevMonthsYear(month, year);
            string prevMMYYYY = arch.DecodeMonthYear(previousMonth, previousMonthYear);
            bool dataExistForPrevMonth = commonReportArch.DataExistForMonth(previousMonth, previousMonthYear);

            //Checks that Data exist for next month or not?
            string nextMonth = arch.GetNextMonth(month);
            string nextMonthYear = arch.GetNextMonthsYear(month, year);
            string nextMMYYYY = arch.DecodeMonthYear(nextMonth, nextMonthYear);
            bool dataExistForNextMonth = commonReportArch.DataExistForMonth(nextMonth, nextMonthYear);

            string[,] reportData = null;

            string[] columnName = null;

            if (dataExistForPresntMonth && dataExistForPrevMonth && dataExistForNextMonth)
            {
                columnName = new string[] { "Item", previousMonth + " (Prev.)", "Trend1", month + " (Pres.)", "Trend2", nextMonth + " (Nxt.)" };
                reportData = new string[itemAnalyticArch.GetAllItems().Length, 6];
                reportData = GetReportData1(prevMMYYYY, presentMMYYYY, nextMMYYYY);
                data = arch.GetDataTableFrom2DArray(columnName, reportData);
            }
            else if (dataExistForPresntMonth && dataExistForPrevMonth && !dataExistForNextMonth)
            {
                columnName = new string[] { "Item", previousMonth + " (Prev.)", "Trend", month + " (Pres.)" };
                reportData = new string[itemAnalyticArch.GetAllItems().Length, 4];
                reportData = GetReportData2(prevMMYYYY, presentMMYYYY);
                data = arch.GetDataTableFrom2DArray(columnName, reportData);

            }
            else if (dataExistForPresntMonth && !dataExistForPrevMonth && !dataExistForNextMonth)
            {
                columnName = new string[] { "Item", month + " (Pres.)" };
                data = itemAnalyticArch.MonthlyReportData(month, year);
            }
            else if (dataExistForPresntMonth && !dataExistForPrevMonth && dataExistForNextMonth)
            {
                columnName = new string[] { "Item", month + " (Pres.)", "Trend", nextMonth + " (Nxt.)" };
                reportData = new string[reportArch.GetAllUsers().Length, 4];
                reportData = GetReportData2(presentMMYYYY, nextMMYYYY);
                data = arch.GetDataTableFrom2DArray(columnName, reportData);
            }

            return data;
        }

        private string[,] GetReportData1(string previousMonthYear, string presentMonthYear, string nextMonthYear)
        {
            int numberOfItems = itemAnalyticArch.GetAllItems().Length;
            string[,] reportData = new string[numberOfItems+1, 6];
            string[] expForItem = itemAnalyticArch.GetAllItems();
            string[] prevMontExpense = itemAnalyticArch.GetExpenseForItems(previousMonthYear);
            string[] trndPreviousPresent = new string[prevMontExpense.Length];
            string[] presentMontExpense = itemAnalyticArch.GetExpenseForItems(presentMonthYear);
            string[] trendPresentVsNextMonth = new string[presentMontExpense.Length];
            string[] nextMontExpense = itemAnalyticArch.GetExpenseForItems(nextMonthYear);

            double sumPrevMonthExp = GetTotalExpense(prevMontExpense);
            double sumPresentMonthExp = GetTotalExpense(presentMontExpense);
            double sumNextMonthExp = GetTotalExpense(nextMontExpense);

            for (int row = 0; row <= numberOfItems ; row++)
            {
                if (row == numberOfItems)
                {
                    reportData[row, 0] = "T O T A L :";
                    reportData[row, 1] = sumPrevMonthExp.ToString();
                    reportData[row, 2] = GetTrendSymbol(sumPrevMonthExp.ToString(), sumPresentMonthExp.ToString());
                    reportData[row, 3] = sumPresentMonthExp.ToString();
                    reportData[row, 4] = GetTrendSymbol(sumPresentMonthExp.ToString(), sumNextMonthExp.ToString());
                    reportData[row, 5] = sumNextMonthExp.ToString();
                }
                else
                {
                    reportData[row, 0] = expForItem[row];
                    reportData[row, 1] = prevMontExpense[row];
                    reportData[row, 2] = GetTrendSymbol(prevMontExpense[row], presentMontExpense[row]);
                    reportData[row, 3] = presentMontExpense[row];
                    reportData[row, 4] = GetTrendSymbol(presentMontExpense[row], nextMontExpense[row]);
                    reportData[row, 5] = nextMontExpense[row];
                }                
            }

            return reportData;
        }

        private double GetTotalExpense(string[] expenses)
        {
            double totalExpense = 0.0;
            for (int i = 0; i < expenses.Length; i++)
            {
                totalExpense = totalExpense + Convert.ToDouble(expenses[i]);
            }

            return totalExpense;
        }

        private string GetTrendSymbol(string month1, string month2)
        {
            double firstMonth = Convert.ToDouble(month1);
            double secMonth = Convert.ToDouble(month2);

            if (firstMonth > secMonth)
                return " > ";
            else if (firstMonth < secMonth)
                return " < ";
            else
                return " = ";
        }

        private string[,] GetReportData2(string previousMonthYear, string presentMonthYear)
        {
            int numberOfItems = itemAnalyticArch.GetAllItems().Length;
            string[,] reportData = new string[numberOfItems + 1, 4];
            string[] expBy = itemAnalyticArch.GetAllItems();
            string[] prevMontExpense = itemAnalyticArch.GetExpenseForItems(previousMonthYear);
            string[] trndPreviousPresent = new string[prevMontExpense.Length];
            string[] presentMontExpense = itemAnalyticArch.GetExpenseForItems(presentMonthYear);

            double sumPrevMonthExp = GetTotalExpense(prevMontExpense);
            double sumPresentMonthExp = GetTotalExpense(presentMontExpense);            

            for (int row = 0; row <= itemAnalyticArch.GetAllItems().Length; row++)
            {
                if (row == numberOfItems)
                {
                    reportData[row, 0] = "T O T A L :";
                    reportData[row, 1] = sumPrevMonthExp.ToString();
                    reportData[row, 2] = GetTrendSymbol(sumPrevMonthExp.ToString(), sumPresentMonthExp.ToString());
                    reportData[row, 3] = sumPresentMonthExp.ToString();                   
                }
                else
                {
                    reportData[row, 0] = expBy[row];
                    reportData[row, 1] = prevMontExpense[row];
                    reportData[row, 2] = GetTrendSymbol(prevMontExpense[row], presentMontExpense[row]);
                    reportData[row, 3] = presentMontExpense[row];
                }
            }
            return reportData;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

Share

About the Author

Ashish Tripathi
Founder Aspirea Technologies Pvt Ltd
India India
• 8 years of experience in IT Industry as a Developer.
• Experience of End-To-End Software Development and Implementation (Entire SDLC i.e Software Development Life Cycle)
• Real time Exposure to Banking, Finance and Energy industry.
• Expertise in distributed application architecture as well as web based applications using Microsoft.NET platform.
• Expertise in database design, SQL programming and SQL performance tuning.
• Expertise in Web Services and WCF Services.
• Experience of Rich Internet Application using Adobe Flex.
• Experience in migration of legacy application to latest technology, migration of VB application to .NET.
• Knowledge of OOPS and Design Concepts.
• Expertise in Agile/ Scrum software development processes.
 
Specialties
• Languages\ Technologies-
.NET Framework 1.1/2.0/3.0/3.5, C#.NET, VB.NET, ASP.NET, VB6, AJAX, ASP.NET, Adobe Flex 3.0, Web Services, Windows Communication Foundation (WCF), LINQ, SQL Server, Oracle, MySql, MS Access, HTML, XML, JavaScript, C# Script, CSS and XSLT.
 
• Methodology/ Concepts-
OOPS, Data Structures, Design Concepts and Agile/ Scrum Software Development
Follow on   Twitter

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 10 Sep 2009
Article Copyright 2008 by Ashish Tripathi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid