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.Text;
using System.Windows.Forms;
using System.Xml;
using AccountPlus.Formatting;

namespace AccountPlus.BusinessLogic
{

    /// <summary>
    /// Contains Function or routine to read and write the user preferences xml i.e. Preferences.xml.
    /// </summary>
    public class Preferences
    {
        private static DataSecurity security = new DataSecurity();
        private static XMLHelper xmlHelper = new XMLHelper();
        private const string PASSWORD_KEY = "password";
        private const string USERNAME_KEY = "username";
        private const string REMEMBER_ME_KEY = "rememberme";
        private const string SCANNING_RESOLUTION_KEY = "scanningResolution";
        private const string FILE_SAVE_RESOLUTION_KEY = "filesaveresolution";
        private const string DUPLEX_SCANNING_ENABLED_KEY = "duplexenabled";
        private const string DOCUMENT_FEEDER_ENABLED_KEY = "feederenabled";
        private const string LAST_LOGGED_IN_USER_KEY = "lastuser";
        private const string LAST_LOGIN_DATE_KEY = "lastlogindate";
        private const string IMAGE_SIZE_KEY = "imagesize";
        private const string XFER_COUNT_KEY = "xfercount";


        /// <summary>
        /// List of preferences
        /// </summary>
        public enum Preference
        {
            RememberMe,
            Username,
            Password,
            LastUser,
            LastLoginDate
        }
        #region "Public Methods"

        /// <summary>
        /// Saves the preference value passed.
        /// </summary>
        /// <param name="preference">Preference fro which value needs to be saved.</param>
        /// <param name="value">Value</param>
        public static void SavePreference(Preference preference, string value)
        {
            switch (preference)
            {
                case Preference.Username:
                    xmlHelper.SetValue(USERNAME_KEY, security.Encrypt(value));
                    break;
                case Preference.Password:
                    xmlHelper.SetValue(PASSWORD_KEY, security.Encrypt(value));
                    break;
                case Preference.LastUser:
                    xmlHelper.SetValue(LAST_LOGGED_IN_USER_KEY, security.Encrypt(value));
                    break;
                case Preference.LastLoginDate:
                    xmlHelper.SetValue(LAST_LOGIN_DATE_KEY, value);
                    break;
                case Preference.RememberMe:
                    xmlHelper.SetValue(REMEMBER_ME_KEY, value);
                    break;
            }
        }

        /// <summary>
        /// Clear credentials stored into Preferences.xml file
        /// </summary>
        public static void ClearCredentials()
        {
            xmlHelper.SetValue(REMEMBER_ME_KEY, "false");
            xmlHelper.SetValue(USERNAME_KEY, string.Empty);
            xmlHelper.SetValue(PASSWORD_KEY, string.Empty);
            xmlHelper.Save();
        }
        /// <summary>
        /// Save changes made to Preference.xml
        /// </summary>
        public static void Save()
        {
            xmlHelper.Save();
        }
        /// <summary>
        /// Reads the Preference.xml file and returns the value stored.
        /// </summary>
        /// <param name="preference">Preference for which stored value is needed.</param>
        /// <returns>Preference value stored</returns>
        public static string GetPreference(Preference preference)
        {
            string value = string.Empty;
            switch (preference)
            {
                case Preference.Username:
                    value = xmlHelper.GetValue(USERNAME_KEY);
                    if (!string.IsNullOrEmpty(value))
                        value = security.Decrypt(value);
                    else
                        value = string.Empty;
                    break;
                case Preference.Password:
                    value = xmlHelper.GetValue(PASSWORD_KEY);
                    if (!string.IsNullOrEmpty(value))
                        value = security.Decrypt(value);
                    else
                        value = string.Empty;
                    break;
                case Preference.RememberMe:
                    value = xmlHelper.GetValue(REMEMBER_ME_KEY);
                    break;
                case Preference.LastUser:
                    value = xmlHelper.GetValue(LAST_LOGGED_IN_USER_KEY);
                    if (!string.IsNullOrEmpty(value))
                        value = security.Decrypt(value);
                    else
                        value = string.Empty;
                    break;
                case Preference.LastLoginDate:
                    value = xmlHelper.GetValue(LAST_LOGIN_DATE_KEY);
                    break;
            }

            return value;
        }

        #endregion

        #region "Public Properties"
        /// <summary>
        /// Gets PictureBoxSizeMode for the picture box in which scanned image is shown.
        /// </summary>    
        public static PictureBoxSizeMode ImageSize
        {
            get
            {
                PictureBoxSizeMode imageSizeMode = PictureBoxSizeMode.StretchImage;
                string value = xmlHelper.GetValue(IMAGE_SIZE_KEY);

                if (!string.IsNullOrEmpty(value))
                {
                    switch (value)
                    {
                        case "AutoSize":
                            imageSizeMode = PictureBoxSizeMode.AutoSize;
                            break;
                        case "CenterImage":
                            imageSizeMode = PictureBoxSizeMode.CenterImage;
                            break;
                        case "Normal":
                            imageSizeMode = PictureBoxSizeMode.Normal;
                            break;
                        case "StretchImage":
                            imageSizeMode = PictureBoxSizeMode.StretchImage;
                            break;
                        case "Zoom":
                            imageSizeMode = PictureBoxSizeMode.Zoom;
                            break;
                        default:
                            imageSizeMode = PictureBoxSizeMode.StretchImage;
                            break;
                    }
                }

                return imageSizeMode;
            }
        }
     
        #endregion

    }
}

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
Web01 | 2.8.150327.1 | Last Updated 10 Sep 2009
Article Copyright 2008 by Ashish Tripathi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid