Click here to Skip to main content
15,896,111 members
Articles / Programming Languages / C#

AccountPlus

Rate me:
Please Sign up or sign in to vote.
4.47/5 (63 votes)
10 Sep 2009LGPL320 min read 242.9K   61.8K   209  
A Complete Account Management System
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;
using AccountPlus.DataAccess;
using System.Windows.Forms;
using System.Collections;


namespace AccountPlus.BusinessLogic
{
    public class Arch
    {
        private DBHelper _dbHelper = new DBHelper();

        public DataTable GetDataTableFrom2DArray(string[] columnName, string[,] reportData)
        {
            DataTable table = new DataTable();            
            int cols = columnName.Length ;
            DataColumn[] dataColumn = new DataColumn[cols];
                        
            for (int c=0; c<cols; c++)
            {
                dataColumn[c] = new DataColumn(columnName[c], typeof(string));
                table.Columns.Add(dataColumn[c]);
            }
                      
            string[,] reportArray = reportData;

            for (int i = 0; i < reportArray.GetUpperBound(0) + 1; i++)
            {
                DataRow row = table.NewRow();

                for (int columns = 0; columns < dataColumn.Length; columns++)
                {
                    row[dataColumn[columns]] = reportArray[i,columns];
                }               

                table.Rows.Add(row);
            }
            return table;
        }

        public string ReadeTxtFile()
        {
            string filePath = System.Environment.CurrentDirectory + "\\AboutAccountPlus.txt";
            string aboutData = string.Empty;

            if (File.Exists(filePath))
            {
                StreamReader reader= new StreamReader(filePath);
                try
                {                   
                    while (reader.Peek() != -1)
                    {
                        aboutData = aboutData + reader.ReadLine().Trim() + "\n";
                    }

                    reader.Close();
                    reader.Dispose();
                }
                catch(Exception err)
                {
                    reader.Close();
                    reader.Dispose();                    
                }                
            }
            else
            {
                return "Sorry could not get the information about AccountPlus.";
            }
            return aboutData;
        }

        public string DecodeMonthYear(string month, string year)
        {
            year = year.Substring(2);
            string monthYear = string.Empty;

            switch (month)
            {
                case "Jan":
                    monthYear = "01" + year;
                    break;
                case "Feb":
                    monthYear = "02" + year;
                    break;
                case "Mar":
                    monthYear = "03" + year;
                    break;
                case "Apr":
                    monthYear = "04" + year;
                    break;
                case "May":
                    monthYear = "05" + year;
                    break;
                case "Jun":
                    monthYear = "06" + year;
                    break;
                case "Jul":
                    monthYear = "07" + year;
                    break;
                case "Aug":
                    monthYear = "08" + year;
                    break;
                case "Sep":
                    monthYear = "09" + year;
                    break;
                case "Oct":
                    monthYear = "10" + year;
                    break;
                case "Nov":
                    monthYear = "11" + year;
                    break;
                case "Dec":
                    monthYear = "12" + year;
                    break;
            }

            return monthYear;
        }

        public string GetPreviousMonth(string month)
        {
            string previousMonth = string.Empty;

            switch (month)
            {
                case "Jan":
                    previousMonth = "Dec";
                    break;
                case "Feb":
                    previousMonth = "Jan";
                    break;
                case "Mar":
                    previousMonth = "Feb";
                    break;
                case "Apr":
                    previousMonth = "Mar";
                    break;
                case "May":
                    previousMonth = "Apr";
                    break;
                case "Jun":
                    previousMonth = "May";
                    break;
                case "Jul":
                    previousMonth = "Jun";
                    break;
                case "Aug":
                    previousMonth = "Jul";
                    break;
                case "Sep":
                    previousMonth = "Aug";
                    break;
                case "Oct":
                    previousMonth = "Sep";
                    break;
                case "Nov":
                    previousMonth = "Oct";
                    break;
                case "Dec":
                    previousMonth = "Nov";
                    break;
            }

            return previousMonth;
        }

        public string GetNextMonth(string month)
        {
            string nextMonth = string.Empty;

            switch (month)
            {
                case "Jan":
                    nextMonth = "Feb";
                    break;
                case "Feb":
                    nextMonth = "Mar";
                    break;
                case "Mar":
                    nextMonth = "Apr";
                    break;
                case "Apr":
                    nextMonth = "May";
                    break;
                case "May":
                    nextMonth = "Jun";
                    break;
                case "Jun":
                    nextMonth = "Jul";
                    break;
                case "Jul":
                    nextMonth = "Aug";
                    break;
                case "Aug":
                    nextMonth = "Sep";
                    break;
                case "Sep":
                    nextMonth = "Oct";
                    break;
                case "Oct":
                    nextMonth = "Nov";
                    break;
                case "Nov":
                    nextMonth = "Dec";
                    break;
                case "Dec":
                    nextMonth = "Jan";
                    break;
            }

            return nextMonth;
        }

        public string GetPrevMonthsYear(string month, string year)
        {
            int prevMonthsYear = 0;
            if (month.Equals("Jan"))
                prevMonthsYear = Convert.ToInt16(year) - 1;
            else
                prevMonthsYear = Convert.ToInt16(year);

            return prevMonthsYear.ToString();
        }

        public string GetNextMonthsYear(string month, string year)
        {
            int nextMonthsYear = 0;
            if (month.Equals("Dec"))
                nextMonthsYear = Convert.ToInt16(year) + 1;
            else
                nextMonthsYear = Convert.ToInt16(year);

            return nextMonthsYear.ToString();
        }

        public enum ComboBoxItem
        {
            Role,
            Item
        }

        public void FillDataInCombo(ComboBox cmbItems, ComboBoxItem item)
        {
            cmbItems.Items.Clear();
            DataTable dt = new DataTable();
            cmbItems.Items.Insert(0, new DictionaryEntry("-1", "[ SELECT ]"));

            string Query = string.Empty;
            Query = item == ComboBoxItem.Item ? "SELECT Item_Id, Item_Name from Item_Details where IsActive=1" : "SELECT RoleId, Role from RoleDetails";
            dt = _dbHelper.ExecuteDataTable(Query);

            for (int i = 0; i < dt.Rows.Count; i++)            
                cmbItems.Items.Add(new DictionaryEntry(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString()));

            cmbItems.ValueMember = "Key";
            cmbItems.DisplayMember = "Value";
            cmbItems.SelectedIndex = 0;
        }

        public void FillDataInCombo(ComboBox cmbItems, string selectQuery, int index)
        {            
            DataTable dt = new DataTable();
            cmbItems.Items.Clear();
            dt = _dbHelper.ExecuteDataTable(selectQuery);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbItems.Items.Add(dt.Rows[i][index].ToString());
            }
        }

        public int GetMonth(string month)
        {
            int iMonth=0;
            switch (month)
            {
                case "Jan":
                    iMonth = 1;
                    break;
                case "Feb":
                    iMonth = 2;
                    break;
                case "Mar":
                    iMonth = 3;
                    break;
                case "Apr":
                    iMonth = 4;
                    break;
                case "May":
                    iMonth = 5;
                    break;
                case "Jun":
                    iMonth = 6;
                    break;
                case "Jul":
                    iMonth = 7;
                    break;
                case "Aug":
                    iMonth = 8;
                    break;
                case "Sep":
                    iMonth = 9;
                    break;
                case "Oct":
                    iMonth = 10;
                    break;
                case "Nov":
                    iMonth = 11;
                    break;
                case "Dec":
                    iMonth = 12;
                    break;
            }

            return iMonth;
        }
    }
}

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)


Written By
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

Comments and Discussions