/// <summary>
        /// Initializes application variables when the application
        /// is first created
        /// </summary>
        protected void Application_Start(Object sender, EventArgs e)
        {
            //
            //	Lock the application variables while editing
            //
            Application.Lock();

            //
            //	Stores the application name
            //
            Application["AZMAN_APP_NAME"] = "Expense Web";

            //
            //	Stores the Authorization Manager policy store object
            //
            Application["AZMAN_STORE"] = "AzManStore";

            //
            //	Stores the Authorization Manager application object
            //
            Application["AZMAN_APP"] = "AzManApp";

            //
            //	Stores the Authorization Manager policy store path
            //
            Application["STORE_PATH"] = "msxml://c:\\inetpub\\wwwroot\\WebExpense\\AzStore.xml";

            //
            //	Uncomment the line below to use Active Directory for the policy store
            //	You will need to configure the connection string
            //
            //Application["STORE_PATH"]="msldap://CN=AzStore,CN=Program Data,DC=microsoft,DC=com";

            //
            //	Stores the maximum number of transactions before the demo resets itself
            //
            Application["DATASTORE_MAXTRANS"] = 10;

            //
            //	Stores the ID of the last transaction to be created
            //
            Application["DATASTORE_LASTTRANS"] = 0;

            //
            //	Stores the value of the Self Approval setting
            //	True - Approvers can approve their own expenses
            //	False - Approvers cannot approve their own expenses
            //
            Application["SELF_APPROVAL"] = false;

            //
            //	Unlock the application variables
            //
            Application.UnLock();

            ExpenseCommon.Initialize();
        }
        /// <summary>
        /// Logo Image - Displays the logo of the company
        /// </summary>


        /// <summary>
        /// Message Label - Displays messages to the user
        /// </summary>


        /// <summary>
        /// Approve Link - Link to a page which lists all expense
        /// reports which need to be approved
        /// </summary>


        /// <summary>
        /// Submit Link - Link to a page which allows a user
        /// to create a new expense report to submit
        /// </summary>


        /// <summary>
        /// Administration Link - Link to a page which allows an
        /// administrator to change application settings
        /// </summary>


        /// <summary>
        /// Approve Image - Display an icon that links to a page
        /// which lists all expense reports which need to be approved
        /// </summary>


        /// <summary>
        /// Administration Image - Displays an icon that links
        /// to a page which allows an administrator to change
        /// application settings
        /// </summary>


        /// <summary>
        /// Submit Image - Displays an icon that links
        /// to a page which allows a user to create a new expense
        /// report to submit
        /// </summary>


        /// <summary>
        /// Title Label - Displays the application title
        /// </summary>
        #endregion

        /// <summary>
        /// Page Load - This is executed when the page is first requested
        /// by the user and additionally when the user clicks a button on
        /// the form
        /// </summary>
        protected void Page_Load(object sender, System.EventArgs e)
        {
            //
            //	Check for this is the first time the page is being loaded
            //	only fill in the form if this is the first time otherwise
            //	any user changes will be lost
            //
            if (!Page.IsPostBack)
            {
                ExpenseCommon.Initialize();

                //
                //	Get the client context
                //
                IAzClientContext3 AzClient = ExpenseCommon.GetAzClientContext();

                IAzBizRuleParameters BizRuleParams = AzClient.BizRuleParameters;
                BizRuleParams.AddParameter("Amount", 0);
                BizRuleParams.AddParameter("Date", "NA");
                BizRuleParams.AddParameter("SubmitterName", "NA");
                BizRuleParams.AddParameter("UserName", ExpenseCommon.GetClientSamName());

                //
                //	Use the client SAM name (\\domain\username)
                //	to display the username
                //
                string AccountName = ExpenseCommon.GetClientSamName();
                AccountName = AccountName.Substring((AccountName.IndexOf(@"\") + 1));
                MSG.Text    = string.Concat("Welcome ", AccountName, ":");


                //
                //	Get the user's task assigments from the
                //	client context
                //

                IAzTasks Tasks = AzClient.GetTasks(null);

                //
                //	Check for the user has no roles
                //
                if (Tasks.Count == 0)
                {
                    MSG.Text = string.Concat(MSG.Text, "<P>Sorry ", AccountName, " you do not have permission to use this application. <Br> Please contact your manager <Br></P>");
                }
                else
                {
                    //
                    //	Display links to the various actions the user
                    //	can perform depending on the user's role memberships and the tasks
                    //  assigned to those roles.
                    //
                    string Task;
                    foreach (IAzTask AzTask in Tasks)
                    {
                        Task = (string)AzTask.Name;

                        switch (Task)
                        {
                        case "View Pending Expenses":
                            //
                            //	User is an approver
                            //	Show link to the approval page
                            //
                            ApproveLink.Visible = true;
                            break;

                        case "Administer Settings":
                            //
                            //	User is an administrator
                            //	Show link to the administration page
                            //
                            AdminLink.Visible = true;
                            break;

                        case "Submit Expense":
                            //
                            //	User is an submitter
                            //	Show link to the expense submission page
                            //
                            SubmitLink.Visible = true;
                            break;
                        }
                    }
                }
            }
        }