/// <summary> /// Message Label - Displays any messages for the user /// </summary> /// <summary> /// Transaction List - Displays the transactions /// filtered by the ModeSelect drop down listbox /// </summary> /// <summary> /// Mode Select Drop Down ListBox - Filters which /// expense transactions are displayed in the transaction list /// </summary> /// <summary> /// Mode Label - Displays the filter on the transaction list /// </summary> /// <summary> /// Logo Link - Displays the company logo and links /// back to the main page of the application /// </summary> /// <summary> /// Title Label - Displays the page title /// </summary> /// <summary> /// Return Link - Displays a link back to the main /// page of the application /// </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) { // // To prevent users from by-passing the portal page (index.aspx) // and going directly to this page, use URL Authorization // See <url> for details. // // // 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) { // // Check if the user has permission to list expenses // // // // Get the client context from the session variables // IAzClientContext3 AzClient = ExpenseCommon.GetAzClientContext(); // // Set BizRule Parameters // IAzBizRuleParameters BizRuleParams = AzClient.BizRuleParameters; BizRuleParams.AddParameter("Amount", 0); BizRuleParams.AddParameter("Date", DateTime.Now.ToShortDateString()); BizRuleParams.AddParameter("SubmitterName", ""); BizRuleParams.AddParameter("UserName", ExpenseCommon.GetClientSamName()); // // Run the access check on the submit operation // Passing the audit text, scope, operations and business rule parameters // uint result = AzClient.AccessCheck2("List Expense Reports", "", ExpenseCommon.AzopList); // // Check for success of the access check // bool bAuthorized = false; if (result == ExpenseCommon.NoError) { bAuthorized = true; } else if (result == ExpenseCommon.AccessDenied) { string errorMessage = AzClient.GetBusinessRuleString(); if (errorMessage != "") { MSG.Text = "<font color=\"FF0000\">Access Denied." + errorMessage + "</font>"; } else { MSG.Text = "<font color=\"FF0000\">Access Denied. You do not have sufficient permissions to perform this operation.</font>"; } bAuthorized = false; } else { // // Check for other error // if (result != ExpenseCommon.NoError) { Win32Exception ex = new Win32Exception(); MSG.Text = "<font color=\"FF0000\">There was an error performing the AccessCheck: " + ex.Message + "</font>"; } } if (bAuthorized) { // // List the expense reports // ListTransactions(); } else { // // Access Check failed so display an error message to the user // MSG.Text = "Error Access Denied: " + AzClient.GetBusinessRuleString(); return; } } }