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

AccountPlus

, 10 Sep 2009 LGPL3
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.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AccountPlus.Messaging;
using AccountPlus.BusinessLogic;
using AccountPlus.Formatting;


namespace AccountPlus.UI
{
    public partial class Login : AccountPlusBase
    {
        UserAuthentication _userAuthentication = new UserAuthentication();
        public Login()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = txtUserID.Text.Trim();
                string password = txtPassword.Text.Trim();
                errorProvider1.Clear();
                lblMessage.Text = string.Empty;

                if (userName == string.Empty && password == string.Empty)
                {
                    lblMessage.Text = MessageManager.GetMessage("1", false);
                    errorProvider1.SetError(txtUserID, MessageManager.GetMessage("1", false));
                    return;
                }

                if (userName == string.Empty)
                {
                    lblMessage.Text = MessageManager.GetMessage("1", false);
                    errorProvider1.SetError(txtUserID, MessageManager.GetMessage("1", false));

                    return;
                }

                if (password == string.Empty)
                {
                    lblMessage.Text = MessageManager.GetMessage("1", false);
                    errorProvider1.SetError(txtPassword, MessageManager.GetMessage("1", false));

                    return;
                }

                int userId = 0;
                Common.UserRole role = new Common.UserRole();

                bool validUser = _userAuthentication.IsValidUser(userName, password, out userId, out role);
                Logger.WriteTrace("Login", "Username : " + userName + Environment.NewLine + "Success : " + validUser.ToString());

                if (!validUser)
                    MessageManager.DisplayCustomMessage("Invalid user Id or password.");
                else
                {
                    if (chkRememberMe.Checked)
                        SavePreference(true);
                    else
                        SavePreference(false);
                    
                    SessionParameters.UserID = userId;
                    SessionParameters.UserName = userName;
                    SessionParameters.UserRole = role;                    
                    (new Users()).UpdateLastLoginDate(SessionParameters.UserID);

                    this.Hide();
                    Home objHome = new Home();
                    objHome.Show();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }            
        }

        private void SavePreference(bool rememberMe)
        {
            if (rememberMe)
            {
                Preferences.SavePreference(Preferences.Preference.Username, txtUserID.Text.Trim());
                Preferences.SavePreference(Preferences.Preference.Password, txtPassword.Text.Trim());
                Preferences.SavePreference(Preferences.Preference.RememberMe, "true");
            }
            else
            {
                Preferences.SavePreference(Preferences.Preference.Username, string.Empty);
                Preferences.SavePreference(Preferences.Preference.Password, string.Empty);
                Preferences.SavePreference(Preferences.Preference.RememberMe, "false");
            }

            Preferences.SavePreference(Preferences.Preference.LastLoginDate, DateTime.Now.ToString());
            Preferences.SavePreference(Preferences.Preference.LastUser, txtUserID.Text.Trim());
            Preferences.Save();
        }

    

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {                 
        }

        

        private void Form1_Load(object sender, EventArgs e)
        {
            base.SetBGColor(this);
            LoadPreferences();
            lblProductName.Text = ApplicationDetails.AssemblyProduct;
            lblVersion.Text = ApplicationDetails.AssemblyVersion;
        }

        private void LoadPreferences()
        {
            if(DataFormat.GetBoolean(Preferences.GetPreference(Preferences.Preference.RememberMe)))
            {
                txtUserID.Text = Preferences.GetPreference(Preferences.Preference.Username).Trim();
                txtPassword.Text = Preferences.GetPreference(Preferences.Preference.Password).Trim();
            }

            lblComputerName.Text = "Computer name : " + Environment.MachineName;
            lblLastLogonBy.Text = "Last logon by : " + Preferences.GetPreference(Preferences.Preference.LastUser);
            lblLastLogOnDate.Text = "Last logon date : " + Preferences.GetPreference(Preferences.Preference.LastLoginDate);
        }

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

        private void btnInfo_Click(object sender, EventArgs e)
        {
            string buttonText = ((Button)(sender)).Text.Trim();
            switch (buttonText)
            {
                case "&Info >>":
                    this.Width = 425;
                    this.Height = 328;
                    btnLogin.Location = new Point(198, 268);
                    btnCancel.Location = new Point(261, 268);
                    btnInfo.Location = new Point(348, 268);
                    btnInfo.Text = "&Info <<";
                    grpLogonInfo.Location = new Point(20, 191);
                    break;
                case "&Info <<":
                    this.Width = 425;
                    this.Height = 255;
                    btnLogin.Location = new Point(198, 192);
                    btnCancel.Location = new Point(261, 192);
                    btnInfo.Location = new Point(348, 192);
                    btnInfo.Text = "&Info >>";
                    grpLogonInfo.Location = new Point(20, 220);

                    break;
            }
        }
    }
}

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 | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 10 Sep 2009
Article Copyright 2008 by Ashish Tripathi
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid