<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4404882008975950183</id><updated>2011-11-27T16:46:35.089-08:00</updated><category term='C#'/><category term='Applications'/><category term='Windows'/><category term='Website'/><category term='Programming'/><category term='ASP.NET'/><category term='.NET'/><title type='text'>OGL Systems</title><subtitle type='html'>Ogolla's Code Snippets
By Ogolla Himself</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ogolla.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4404882008975950183/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ogolla.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>onyango ogolla fredrick</name><uri>http://www.blogger.com/profile/01998041930097309710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_6K2749qb6Q8/SQfvT9aOnPI/AAAAAAAAAAg/3guV7MVq9uI/S220/Mbichi+00004.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4404882008975950183.post-3662778258138546162</id><published>2008-10-28T20:51:00.000-07:00</published><updated>2008-11-02T21:18:17.875-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Applications'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Website'/><title type='text'>My C# Template - For Web and Windows Applications</title><content type='html'>&lt;div style="text-align: left; color: rgb(255, 0, 0);"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;// I DESIGNED THIS TEMPLATE WHILE IN THIRD YEAR,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;// IN READINESS FOR MY FOURTH YEAR PROJECT.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;// FEATURES INCLUDE CRYPTOGRAPHY, DB ACCESS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System.Collections.Generic;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System.Text;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System.IO;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System.Net.Sockets;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System.Data;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System.Windows.Forms;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using System.Security.Cryptography;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using Fleet_Management_System;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using DataworldResearchServicesKenya;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using Fleet_Management_System.App_Interface;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using Fleet_Management_System.App_Data;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using Fleet_Management_System.Properties;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//using sqlMobile = System.Data.SqlServerCe;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using Access = System.Data.OleDb;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using OG_RA = DataworldResearchServicesKenya.cRijndaelAlgorithm;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using OG_DB = DataworldResearchServicesKenya.cDatabase;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using OG_CN = DataworldResearchServicesKenya.cConnect;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;using OG_PRG = DataworldResearchServicesKenya.Program;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;namespace DataworldResearchServicesKenya&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// NOTE: THIS IS MY MAIN AREA OF RESEARCH, FOR THE FINAL YEAR PROJECT.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// Illustrates the use of cRijndaelAlgorithm class to encrypt and decrypt data.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// decrypt data. As long as encryption and decryption routines use the same&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// parameters to generate the keys, the keys are guaranteed to be the same.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// This Class has been sealed against modifications via inheritance.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;   /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    public sealed class cRijndaelAlgorithm&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Passphrase can be any string.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Used to derive a pseudo-random password,&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// which is used to generate the encryption key.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// In this final year project,&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// I assume that this passphrase is an ASCII string.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        public string passPhrase = "KenyaPolice";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// saltValue can be any string.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Used along with passphrase to generate password.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// In this final year project,&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// I assume that this saltValue is an ASCII string.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        public string saltValue = "UtumishiKwaWote";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// hashAlgorithm can be "MD5" or "SHA1".&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// SHA1 hashes are a bit slower, but more secure than MD5 hashes.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// the hashAlgorithm is used to generate the password.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// In this final year project,&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// I implemented cryptography using SHA1 hashes.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        public string hashAlgorithm = "SHA1";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Initialization vector (or IV/initVector) must be 16 bytes&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// This value is required to encrypt the first block of plaintext data.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// For RijndaelManaged class IV must be exactly 16 ASCII characters long.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        public string initVector = "@1B2c3D4e5F6g7H8";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// passwordIterations can be any number.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// It is the number of iterations used to generate password.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// In this final year project,&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// I randomly generate an integer,&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// between two and five, for each new session.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        public int passwordIterations = 2;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Size of encryption key in bits.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// keySize can be 128, 192 or 256.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Longer keys are more secure than shorter keys.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// NOTE: [NIST only documented for 128 bit keys]&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        public int keySize = 256;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Class constructor&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick - Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        public cRijndaelAlgorithm()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                //create random passPhrase for the session&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                this.passPhrase = (this.sEncrypt(this.passPhrase));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                //create random saltValue for the session&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                this.saltValue = (this.sEncrypt(this.saltValue));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;summary&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Encrypts specified plaintext using Rijndael symmetric key algorithm&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// and returns a base64-encoded result.&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        ///&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        /// &lt;/span&gt;&lt;/div&gt;&lt;param name="plainText"&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// Plaintext value to be encrypted.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        ///&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;&lt;/returns&gt;&lt;br /&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;       /// Encrypted value formatted as a base64-encoded string.&lt;/returns&gt;&lt;br /&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;       /// &lt;/returns&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        public string sEncrypt(string plainText)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            string r = null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Converted string [initVector] defining encryption key&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// characteristics into byte arrays.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Assumes that strings only contain ASCII codes.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// If strings include Unicode characters, use;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Unicode, UTF7, UTF8, UTF32, BigEndianUnicode or Default).&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] initVectorBytes = Encoding.ASCII.GetBytes(this.initVector);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Converted string [initVector] defining encryption key&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// characteristics into byte arrays.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Assumes that strings only contain ASCII codes.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// If strings include Unicode characters, use;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Unicode, UTF7, UTF8, UTF32, BigEndianUnicode or Default).&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] saltValueBytes = Encoding.ASCII.GetBytes(this.saltValue);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Convert our plaintext into a byte array.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Let us assume that plaintext contains UTF8-encoded characters.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // First, we must create a password, from which the key will be derived.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // This password will be generated from the specified passphrase and&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // salt value. The password will be created using the specified hash&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // algorithm. Password creation can be done in several iterations.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                PasswordDeriveBytes password = new PasswordDeriveBytes(&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                this.passPhrase,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                saltValueBytes,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                this.hashAlgorithm,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                this.passwordIterations);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Use the password to generate pseudo-random bytes for the encryption&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // key. Specify the size of the key in bytes (instead of bits).&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] keyBytes = password.GetBytes(this.keySize / 8);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Create uninitialized Rijndael encryption object.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                RijndaelManaged symmetricKey = new RijndaelManaged();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // It is reasonable to set encryption mode to Cipher Block Chaining&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // (CBC). Use default options for other symmetric key parameters.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                symmetricKey.Mode = CipherMode.CBC;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Generate encryptor from the existing key bytes and initialization&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // vector. Key size will be defined based on the number of the key&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // bytes.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                ICryptoTransform encryptor = symmetricKey.CreateEncryptor(&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                 keyBytes,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                 initVectorBytes);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Define memory stream which will be used to hold encrypted data.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                MemoryStream memoryStream = new MemoryStream();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Define cryptographic stream (always use Write mode for encryption).&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                CryptoStream cryptoStream = new CryptoStream(memoryStream,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                             encryptor,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                             CryptoStreamMode.Write);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Start encrypting.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Finish encrypting.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                cryptoStream.FlushFinalBlock();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Convert our encrypted data from a memory stream into a byte array.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] cipherTextBytes = memoryStream.ToArray();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Close both streams.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                memoryStream.Close();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                cryptoStream.Close();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Convert encrypted data into a base64-encoded string.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                string cipherText = Convert.ToBase64String(cipherTextBytes);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Return encrypted string.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                r = cipherText;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            return r;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Decrypts specified ciphertext using Rijndael symmetric key algorithm.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;param name="cipherText"&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// Base64-formatted ciphertext value.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;&lt;/returns&gt;&lt;br /&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;       /// Decrypted string value.&lt;/returns&gt;&lt;br /&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;       /// &lt;/returns&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;remarks style="color: rgb(255, 0, 0);"&gt;&lt;/remarks&gt;&lt;br /&gt;&lt;remarks style="color: rgb(255, 0, 0);"&gt;       /// Most of the logic in this function is similar to the Encrypt&lt;/remarks&gt;&lt;br /&gt;&lt;remarks style="color: rgb(255, 0, 0);"&gt;       /// logic. In order for decryption to work, all parameters of this function&lt;/remarks&gt;&lt;br /&gt;&lt;remarks style="color: rgb(255, 0, 0);"&gt;       /// - except cipherText value - must match the corresponding parameters of&lt;/remarks&gt;&lt;br /&gt;&lt;remarks style="color: rgb(255, 0, 0);"&gt;       /// the Encrypt function which was called to generate the&lt;/remarks&gt;&lt;br /&gt;&lt;remarks style="color: rgb(255, 0, 0);"&gt;       /// ciphertext.&lt;/remarks&gt;&lt;br /&gt;&lt;remarks style="color: rgb(255, 0, 0);"&gt;       /// &lt;/remarks&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        public string sDecrypt(string cipherText)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            string r = null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Converted string [initVector] defining encryption key&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// characteristics into byte arrays.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Assumes that strings only contain ASCII codes.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// If strings include Unicode characters, use;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Unicode, UTF7, UTF8, UTF32, BigEndianUnicode or Default).&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] initVectorBytes = Encoding.ASCII.GetBytes(this.initVector);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Converted string [saltValue] defining encryption key&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// characteristics into byte arrays.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Assumes that strings only contain ASCII codes.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// If strings include Unicode characters, use;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Unicode, UTF7, UTF8, UTF32, BigEndianUnicode or Default).&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;               /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] saltValueBytes = Encoding.ASCII.GetBytes(this.saltValue);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Convert our ciphertext into a byte array.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] cipherTextBytes = Convert.FromBase64String(cipherText);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // First, we must create a password, from which the key will be&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // derived. This password will be generated from the specified&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // passphrase and salt value. The password will be created using&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // the specified hash algorithm. Password creation can be done in&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // several iterations.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                PasswordDeriveBytes password = new PasswordDeriveBytes(&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                this.passPhrase,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                saltValueBytes,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                this.hashAlgorithm,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                this.passwordIterations);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Use the password to generate pseudo-random bytes for the encryption&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // key. Specify the size of the key in bytes (instead of bits).&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] keyBytes = password.GetBytes(this.keySize / 8);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Create uninitialized Rijndael encryption object.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                RijndaelManaged symmetricKey = new RijndaelManaged();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // It is reasonable to set encryption mode to Cipher Block Chaining&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // (CBC). Use default options for other symmetric key parameters.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                symmetricKey.Mode = CipherMode.CBC;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Generate decryptor from the existing key bytes and initialization&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // vector. Key size will be defined based on the number of the key&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // bytes.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                ICryptoTransform decryptor = symmetricKey.CreateDecryptor(&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                 keyBytes,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                                 initVectorBytes);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Define memory stream which will be used to hold encrypted data.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                MemoryStream memoryStream = new MemoryStream(cipherTextBytes);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Define cryptographic stream (always use Read mode for encryption).&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                CryptoStream cryptoStream = new CryptoStream(memoryStream,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                              decryptor,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                              CryptoStreamMode.Read);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Since at this point I don't know what the size of decrypted data&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // will be, I allocate the buffer long enough to hold ciphertext;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // plaintext is never longer than ciphertext.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                byte[] plainTextBytes = new byte[cipherTextBytes.Length];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Start decrypting.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                int decryptedByteCount = cryptoStream.Read(plainTextBytes,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                           0,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                           plainTextBytes.Length);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Close both streams.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                memoryStream.Close();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                cryptoStream.Close();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Convert decrypted data into a string.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Assumes that the original plaintext string was UTF8-encoded.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                string plainText = Encoding.UTF8.GetString(plainTextBytes,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                           0,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                                                           decryptedByteCount);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                // Return decrypted string.  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                r = plainText;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            return r;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    }//end of cRijndaelAlgorithm&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// This class is used for all reads/writes to the database.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    public class cConnect&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        //ALL VARIABLE MEMBERS ARE PRIVATE FOR ABSTRACTION IN IMPLEMENTATION PURPOSES&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        //private sqlMobile.SqlCeConnection mDB = new sqlMobile.SqlCeConnection(Program.mConnectionString);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        private Access.OleDbConnection mDB = new Access.OleDbConnection(global::Fleet_Management_System.Properties.Settings.Default.Database);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Class Constructor&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        public cConnect()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// initializes the connection [opens the database].&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Only works for my database settings&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// [Note that you can't give a database path]&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        private void sDefaults()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                if (global::Fleet_Management_System.Properties.Settings.Default.Database.Length &gt; 5)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    this.mDB = new Access.OleDbConnection(global::Fleet_Management_System.Properties.Settings.Default.Database);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    //this.mDB = new sqlMobile.SqlCeConnection(Program.mConnectionString);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    this.mDB.Open();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// This method is used for reading purposes only.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// NB: Only for reading NOT writing.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// The database will have a shared lock.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        ///&lt;/span&gt;&lt;br /&gt;&lt;param name="vSQL"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// SQL statement 2B executed.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;&lt;/returns&gt;&lt;br /&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;       /// returns a data reader containing the execution&lt;/returns&gt;&lt;br /&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;       /// results of the sql select statement&lt;/returns&gt;&lt;br /&gt;&lt;returns style="color: rgb(255, 0, 0);"&gt;       /// &lt;/returns&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        public Access.OleDbDataReader sRead(string vSQL)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            Access.OleDbDataReader r = null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            //sqlMobile.SqlCeDataReader r = null;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                if (this.mDB.State != ConnectionState.Open)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    this.sDefaults();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //sqlMobile.SqlCeCommand vCMD = new sqlMobile.SqlCeCommand(vSQL, this.mDB);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                Access.OleDbCommand vCMD = new Access.OleDbCommand(vSQL, this.mDB);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                r = vCMD.ExecuteReader(CommandBehavior.CloseConnection);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            return r;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// This method is used to update/insert/delete&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// records using the appropriate SQL Statements.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// The database will have an exclusive lock.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        ///&lt;/span&gt;&lt;br /&gt;&lt;param name="vSQL"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// SQL Statement 2B executed&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        public void sExecute(string vSQL)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            DataSet vDS = new DataSet();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vDS.EnforceConstraints = true;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                if (this.mDB.State != ConnectionState.Open)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    this.sDefaults();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //sqlMobile.SqlCeDataAdapter vDA = new sqlMobile.SqlCeDataAdapter(vSQL, Program.mConnectionString);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                Access.OleDbDataAdapter vDA = new Access.OleDbDataAdapter(vSQL, global::Fleet_Management_System.Properties.Settings.Default.Database);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vDA.AcceptChangesDuringFill = true;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vDA.Fill(vDS);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vDS.RejectChanges();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vDS.Dispose();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    }//end of cConnect&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// Create, Backup and Restore the physical database&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// It inherits the database connection class&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// This Class has been sealed against modifications via inheritance.&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;   /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    public sealed class cDatabase : cConnect&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// class constructor&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        public cDatabase()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                System.IO.FileInfo vFL=new FileInfo("App_Data\\Price List.mdb");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                if (vFL.Exists)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    //sqlMobile.SqlCeEngine vEng = new System.Data.SqlServerCe.SqlCeEngine(Program.mConnectionString);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    //vEng.CreateDatabase();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                    //this.sSetEntities();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// create all the entities&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        private void sSetEntities()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                sProducts();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                sPrices();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                sDefaults();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// create table Products;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        private void sProducts()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                string vSQL;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //CREATE NEW TABLE - Products&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "CREATE TABLE Products(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //vSQL += " [vIndex] IDENTITY (1,1),";//Left parameter is for initial value; Right parameter is for incremental value&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " [Product ID] integer NOT NULL,";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " [Description] string(50) NOT NULL,";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " PRIMARY KEY ([Product ID])";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += ");";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// create table Prices;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        private void sPrices()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                string vSQL;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //CREATE NEW TABLE - Prices&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "CREATE TABLE Prices(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //vSQL += " [vIndex] IDENTITY (1,1),";//Left parameter is for initial value; Right parameter is for incremental value&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " [Product ID] integer NOT NULL,";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " [Amount] currency NOT NULL,";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " FOREIGN KEY ([Product ID]) REFERENCES Products";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " ON UPDATE CASCADE";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " ON DELETE CASCADE";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //vSQL += " ON DELETE SET NULL";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += ");";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                //base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        /// &lt;/span&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// create default records;&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       ///&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Designed by: Ogolla Onyango Fredrick -&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// Final year project - CS 282 - 0515/02&lt;/summary&gt;&lt;br /&gt;&lt;summary style="color: rgb(255, 0, 0);"&gt;       /// &lt;/summary&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        private void sDefaults()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                string vSQL;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Products([Product ID], [Description]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 1, 'KASUKU 1');";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Products([Product ID], [Description]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 2, 'KASUKU 2');";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Products([Product ID], [Description]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 3, 'KASUKU 3');";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Products([Product ID], [Description]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 4, 'KASUKU 4');";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Products([Product ID], [Description]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 5, 'KASUKU 5');";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Prices([Product ID], [Amount]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 1, 10);";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Prices([Product ID], [Amount]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 2, 20);";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Prices([Product ID], [Amount]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 3, 30);";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Prices([Product ID], [Amount]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 4, 40);";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL = "INSERT INTO Prices([Product ID], [Amount]) VALUES(";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                vSQL += " 5, 50);";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                base.sExecute(vSQL);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            catch (Exception)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                throw; /* bubble the error to the active document,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;                        * where the error is caught and resolved */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4404882008975950183-3662778258138546162?l=ogolla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ogolla.blogspot.com/feeds/3662778258138546162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4404882008975950183&amp;postID=3662778258138546162' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4404882008975950183/posts/default/3662778258138546162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4404882008975950183/posts/default/3662778258138546162'/><link rel='alternate' type='text/html' href='http://ogolla.blogspot.com/2008/10/my-c-template-for-web-and-windows.html' title='My C# Template - For Web and Windows Applications'/><author><name>onyango ogolla fredrick</name><uri>http://www.blogger.com/profile/01998041930097309710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://3.bp.blogspot.com/_6K2749qb6Q8/SQfvT9aOnPI/AAAAAAAAAAg/3guV7MVq9uI/S220/Mbichi+00004.jpg'/></author><thr:total>1</thr:total></entry></feed>
