protected void DenyRequest(object sender, EventArgs e)
 {
     try
     {
         if (this.IsCommentsValid)
         {
             TravelAndTrainingRequestFinder requestFinder = new TravelAndTrainingRequestFinder(this.User);
             TravelAndTrainingRequest request = requestFinder.GetRequestById(REQUEST_ID);
             request.Deny(this.txtComments.Text);
             this.litStatus.Text = "The request has been denied. You may now close your browser or go Home to view more requests.";
         }
         else
         {
             this.litError.Text = string.Format("Comments cannot be more than {0} characters.", COMMENTS_LENGTH);
         }
     }
     catch (System.Security.SecurityException ex)
     {
         this.litError.Text = ex.Message;
     }
     catch (InvalidOperationException oex)
     {
         this.litError.Text = oex.Message;
     }
     finally
     {
         this.ucSummary.LoadRequestSummary(REQUEST_ID);
     }
 }
        private TravelAndTrainingRequest PackRequest()
        {
            TravelAndTrainingRequest request = null;
            if (this.RequestId == 0)
                request = new TravelAndTrainingRequest(this.User);
            else
            {
                TravelAndTrainingRequestFinder requestFinder = new TravelAndTrainingRequestFinder(this.User);
                request = requestFinder.GetRequestById(this.RequestId);
            }

            request.EventName = this.txtEvent.Text;
            if (this.txtEventStartDate.Text.Length > 0)
            {
                try
                {
                    request.EventStart = DateTime.Parse(this.txtEventStartDate.Text);
                }
                catch (FormatException)
                {
                    request.EventStart = BizObjectValidator.DEFAULT_DATETIME;
                    this.packingErrors.Add("Event start date is not valid.");
                }
            }
            else
                request.EventStart = BizObjectValidator.DEFAULT_DATETIME;
            if (this.txtEventEndDate.Text.Length > 0)
            {
                try
                {
                    request.EventEnd = DateTime.Parse(this.txtEventEndDate.Text);
                }
                catch (FormatException)
                {
                    request.EventEnd = BizObjectValidator.DEFAULT_DATETIME;
                    this.packingErrors.Add("Event end date is not valid.");
                }
            }
            else
                request.EventEnd = BizObjectValidator.DEFAULT_DATETIME;
            request.EventCity = this.txtEventCity.Text;
            request.EventState = this.ddlEventStates.SelectedValue;
            request.BusinessPurpose = this.txtEventPurpose.Text;
            request.ProjectName = this.txtEventProjects.Text;

            if (this.ckbTraining.Checked)
                request.HasTraining = true;
            else
                request.HasTraining = false;
            request.Training.TrainingName = this.txtTrainName.Text;
            if (this.txtTrainStart.Text.Length > 0)
            {
                try
                {
                    request.Training.StartingDate = DateTime.Parse(this.txtTrainStart.Text);
                }
                catch (FormatException)
                {
                    request.Training.StartingDate = BizObjectValidator.DEFAULT_DATETIME;
                    this.packingErrors.Add("Start date is not valid.");
                }
            }
            else
                request.Training.StartingDate = BizObjectValidator.DEFAULT_DATETIME;
            if (this.txtTrainEnd.Text.Length > 0)
            {
                try
                {
                    request.Training.EndingDate = DateTime.Parse(this.txtTrainEnd.Text);
                }
                catch (FormatException)
                {
                    request.Training.EndingDate = BizObjectValidator.DEFAULT_DATETIME;
                    this.packingErrors.Add("End date is not valid.");
                }
            }
            else
                request.Training.EndingDate = BizObjectValidator.DEFAULT_DATETIME;
            if (this.txtTrainCost.Text.Length > 0)
            {
                try
                {
                    request.Training.TotalCost = System.Convert.ToDecimal(this.txtTrainCost.Text);
                }
                catch (FormatException)
                {
                    request.Training.TotalCost = BizObjectValidator.DEFAULT_COST;
                    this.packingErrors.Add("Training estimated cost is not valid.");
                }
            }
            else
                request.Training.TotalCost = BizObjectValidator.DEFAULT_COST;

            if (this.ckbTravel.Checked)
                request.HasTravel = true;
            else
                request.HasTravel = false;
            request.Travel.DestinationCity = this.txtTravelCity.Text;
            request.Travel.DestinationState = this.ddlTravelStates.SelectedValue;
            if (this.ckbTravelAir.Checked)
                request.Travel.HasFlightArrangements = true;
            else
                request.Travel.HasFlightArrangements = false;

            request.Travel.FlightArrangements.DestinationMethod = this.ddlAirDestinationMode.SelectedValue;
            request.Travel.FlightArrangements.ReturnMethod = this.ddlAirReturnMode.SelectedValue;

            if (this.txtAirCost.Text.Length > 0)
            {
                try
                {
                    request.Travel.FlightArrangements.TotalCost =
                        System.Convert.ToDecimal(this.txtAirCost.Text);
                }
                catch (FormatException)
                {
                    request.Travel.FlightArrangements.TotalCost = BizObjectValidator.DEFAULT_COST;
                    this.packingErrors.Add("Flight estimated cost is not valid.");
                }
            }
            else
                request.Travel.FlightArrangements.TotalCost = BizObjectValidator.DEFAULT_COST;

            if (this.ckbTravelGround.Checked)
                request.Travel.HasGroundArrangements = true;
            else
                request.Travel.HasGroundArrangements = false;

            request.Travel.GroundArrangements.Modes.Clear();
            foreach (ListItem groundMode in this.ckblstGroundModes.Items)
                if(groundMode.Selected)
                    request.Travel.GroundArrangements.Modes.Add(groundMode.Value);

            if (this.txtGroundCost.Text.Length > 0)
            {
                try
                {
                    request.Travel.GroundArrangements.TotalCost =
                        System.Convert.ToDecimal(this.txtGroundCost.Text);
                }
                catch (FormatException)
                {
                    request.Travel.GroundArrangements.TotalCost = BizObjectValidator.DEFAULT_COST;
                    this.packingErrors.Add("Ground estimated cost is not valid.");
                }
            }
            else
                request.Travel.GroundArrangements.TotalCost = BizObjectValidator.DEFAULT_COST;

            if (this.ckbTravelLodging.Checked)
                request.Travel.HasLodgingArrangements = true;
            else
                request.Travel.HasLodgingArrangements = false;

            if (this.txtLodgingNights.Text.Length > 0)
            {
                try
                {
                    request.Travel.LodgingArrangements.NumberOfNights =
                        System.Convert.ToInt32(this.txtLodgingNights.Text);
                }
                catch (FormatException)
                {
                    request.Travel.LodgingArrangements.NumberOfNights = 0;
                    this.packingErrors.Add("Lodging # of nights is not valid.");
                }
            }
            else
                request.Travel.LodgingArrangements.NumberOfNights = 0;
            if (this.txtLodgingCost.Text.Length > 0)
            {
                try
                {
                    request.Travel.LodgingArrangements.TotalCost =
                        System.Convert.ToDecimal(this.txtLodgingCost.Text);
                }
                catch (FormatException)
                {
                    request.Travel.LodgingArrangements.TotalCost = BizObjectValidator.DEFAULT_COST;
                    this.packingErrors.Add("Lodging estimated cost is not valid.");
                }
            }
            else
                request.Travel.LodgingArrangements.TotalCost = BizObjectValidator.DEFAULT_COST;
            request.MiscealleanousCostsComments = this.txtMiscComments.Text;
            if (this.txtMiscCost.Text.Length > 0)
            {
                try
                {
                    request.MisceallaneousCosts = System.Convert.ToDecimal(this.txtMiscCost.Text);
                }
                catch (FormatException)
                {
                    request.MisceallaneousCosts = BizObjectValidator.DEFAULT_COST;
                    this.packingErrors.Add("Additional estimated costs is not valid.");
                }
            }
            else
                request.MisceallaneousCosts = BizObjectValidator.DEFAULT_COST;
            return request;
        }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.RequestId = System.Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]);
                if (this.RequestId != 0)
                {
                    TravelAndTrainingRequestFinder requestFinder = new TravelAndTrainingRequestFinder(this.User);
                    TravelAndTrainingRequest request = requestFinder.GetRequestById(this.RequestId);

                    // adamsb 2/27/09 Check status for routing
                    if (request != null)
                    {
                        if (request.CanBeReviewed)
                        {
                            RequestOfficer securityOfficer = new RequestOfficer(this.User);
                            if (securityOfficer.CanApprove())
                                Response.Redirect(string.Format("~/Approvers/RequestApproval.aspx?id={0}",
                                    request.Id), false);
                            else
                            {
                                // if not a final approver,
                                // load the request, set the active step to the confirmation page
                                // and load the summary
                                this.UnpackRequest(request);
                                requestIsLoaded = true;
                                this.wzCreateRequest.ActiveStepIndex = 2;
                                this.LoadSummary(request);
                            }
                        }
                        else if (request.CanBeSaved)
                        {
                            // if not a final approver,
                            // load the request, set the active step to the confirmation page
                            // and load the summary
                            this.UnpackRequest(request);
                            requestIsLoaded = true;
                            this.wzCreateRequest.ActiveStepIndex = 2;
                            this.LoadSummary(request);
                        }
                        else
                            Response.Redirect("~/Main.aspx", false);
                    }
                    //if (request != null && request.CanBeSaved)
                    //{
                    //    this.UnpackRequest(request);
                    //    // if its pending review by someone, then load the summary page
                    //    if (request.PendingReviewBy.Length > 0)
                    //    {
                    //        requestIsLoaded = true;
                    //        this.wzCreateRequest.ActiveStepIndex = 2;
                    //        this.LoadSummary(request);
                    //    }
                    //}
                    //else
                    //    Response.Redirect("~/Main.aspx", false);
                }
            }
        }
 protected void Route(object sender, EventArgs e)
 {
     try
     {
         TravelAndTrainingRequestFinder requestFinder = new TravelAndTrainingRequestFinder(this.User);
         TravelAndTrainingRequest request = requestFinder.GetRequestById(REQUEST_ID);
         request.RouteTo(new System.Net.Mail.MailAddress(this.ddlApprovers.SelectedValue));
         this.litStatus.Text = "The request has been routed. You may now close your browser or go Home to view more requests.";
     }
     catch (System.Security.SecurityException ex)
     {
         this.litError.Text = ex.Message;
     }
     catch (InvalidOperationException oex)
     {
         this.litError.Text = oex.Message;
     }
     finally
     {
         this.ucSummary.LoadRequestSummary(REQUEST_ID);
     }
 }