Click here to Skip to main content
15,885,546 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 239.9K   61.8K   209  
A Complete Account Management System
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AccountPlus.BusinessLogic;
using AccountPlus.Messaging;
using AccountPlus.Formatting;




namespace AccountPlus.UI
{
    public partial class NewItem : AccountPlusBase
    {
        Items _itemManagement = new Items();
        public NewItem()
        {
            InitializeComponent();
            LoadData(string.Empty, string.Empty);
        }

        private void LoadData(string itemName, string  itemDesc)
        {
            //StringBuilder sqlCommand = new StringBuilder("SELECT Item_Id, Item_Name, Item_Desc, IsActive From Item_Details ");
            
            //if (itemName != string.Empty)
            //    sqlCommand.Append(" WHERE Item_Name LIKE '" + itemName + "'");

            //if (itemName != string.Empty && itemDesc != string.Empty)            
            //    sqlCommand.Append(" AND Item_Name LIKE '" + itemDesc + "'");
            //else if (itemName == string.Empty && itemDesc != string.Empty)
            //    sqlCommand.Append(" WHERE Item_Name LIKE '" + itemDesc + "'");



            GRID_VIEW_ITEM_DETAILS.DataSource = _itemManagement.GetItems(itemName, itemDesc);
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            AddUpdateItem();                        
        }

        private void AddUpdateItem()
        {
            errorProvider1.Clear();
            lblMessage.Clear();

            string itemName = txtItemName.Text.Trim();
            string itemDesc = txtaDesc.Text.Trim();
            string message = string.Empty;
            


            if (itemName == string.Empty)
            {
                message = MessageManager.GetMessage("33");
                errorProvider1.SetError(txtItemName, message);
                lblMessage.SetMessage(message);
                return;
            }

            if (itemDesc == string.Empty)
            {
                message = MessageManager.GetMessage("34");
                errorProvider1.SetError(txtaDesc, message);
                lblMessage.SetMessage(message);
                return;
            }

            if (_itemId != 0)
            {
                if (_itemManagement.UpdateItem(_itemId, itemDesc, SessionParameters.UserID.ToString(), System.DateTime.Now.ToShortDateString()))
                {
                    lblMessage.SetMessage(MessageManager.GetMessage("35"));
                    Clear();
                }
                else
                    lblMessage.SetMessage(MessageManager.GetMessage("36"));
            }
            else
            {
                if (!_itemManagement.ItemExist(itemName))
                {
                    if (_itemManagement.AddNewItem(itemName, itemDesc, SessionParameters.UserID, System.DateTime.Now.ToShortDateString()))
                    {
                        lblMessage.SetMessage(MessageManager.GetMessage("38", itemName));
                        Clear();
                    }
                    else
                        lblMessage.SetMessage(MessageManager.GetMessage("36"));
                }
                else
                    lblMessage.SetMessage(MessageManager.GetMessage("37", itemName));
            }


            LoadData(string.Empty, string.Empty);            
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            Clear();
        }

        private void Clear()
        {
            LoadData(string.Empty, string.Empty);
            errorProvider1.Clear();
            txtItemName.Clear();
            txtaDesc.Clear();
            btnUpdate.Enabled = false;
            txtItemName.ReadOnly = false;
            btnAdd.Enabled = true;
            btnSearch.Enabled = true;
            _itemId = 0;
        }

        private int _itemId = 0;
        private void GRID_VIEW_ITEM_DETAILS_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            errorProvider1.Clear();
            lblMessage.Clear();
            _itemId = DataFormat.GetInteger(GRID_VIEW_ITEM_DETAILS.Rows[e.RowIndex].Cells[0].Value);
            txtItemName.Text = DataFormat.GetString(GRID_VIEW_ITEM_DETAILS.Rows[e.RowIndex].Cells["Item_Name"].Value);
            txtaDesc.Text = DataFormat.GetString(GRID_VIEW_ITEM_DETAILS.Rows[e.RowIndex].Cells["Item_Desc"].Value);

            btnAdd.Enabled = false;
            btnUpdate.Enabled = true;
            btnSearch.Enabled = false;
            txtItemName.ReadOnly = true;
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            LoadData(txtItemName.Text.Trim(), txtaDesc.Text.Trim());
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            AddUpdateItem();
        }

        private void NewItem_Load(object sender, EventArgs e)
        {
            base.SetBGColor(this);
        }
    }
}

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