protected void Page_Load(object sender, EventArgs e) { //if the query string is not null process, else go to the homepage if (!string.IsNullOrEmpty(Request.QueryString["Id"])) { //instantiate a new instance of the engineer service engineerService = new EngineerService(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, User.Identity.GetUserId()); try { //get the intervention by its id intervention = engineerService.getInterventionById(new Guid(Request.QueryString["Id"])); //Databind the UI with details of the intervention type.Text = engineerService.getInterventionTypes().Find(i => i.Id == intervention.InterventionTypeId).Name; client.Text = engineerService.getClientById(intervention.ClientId).Name; creator.Text = engineerService.getUserById(intervention.CreatedBy).Name; if (intervention.ApprovedBy == null) { approver.Text = ""; } else { approver.Text = engineerService.getUserById(intervention.ApprovedBy.Value).Name; } state.Text = intervention.InterventionState.ToString(); hour.Text = intervention.Hours.ToString(); cost.Text = intervention.Costs.ToString(); Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE"); proposedDate.Text = intervention.DateCreate.ToShortDateString(); if (intervention.DateFinish == null) { completedDate.Text = ""; } else { completedDate.Text = intervention.DateFinish.Value.ToShortDateString(); } recentVisitDate.Text = intervention.DateRecentVisit.ToShortDateString(); lifeRemaining.Text = intervention.LifeRemaining.ToString() + "%"; Comments.Text = intervention.Comments; } catch (Exception) { Response.Redirect("~/Errors/InternalErrors.aspx", true); } } else { Response.Redirect("~/Engineer/Welcome.aspx", true); } }
protected void Page_Load(object sender, EventArgs e) { try { engineerService = new EngineerService(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, User.Identity.GetUserId()); if (!IsPostBack) { //if the query string is not null process, else go to the homepage if (!String.IsNullOrEmpty(Request.QueryString["Id"])) { //instantiate a new instance of engineer service //instantiate a new instance of engineer service intervention = engineerService.getInterventionById(new Guid(Request.QueryString["Id"])); //Data bind UI with intervention details type.Text = engineerService.getInterventionTypes().Find(i => i.Id == intervention.InterventionTypeId).Name; client.Text = engineerService.getClientById(intervention.ClientId).Name; creator.Text = engineerService.getUserById(intervention.CreatedBy).Name; State.SelectedIndex = (int)intervention.InterventionState; State.DataSource = getInterventionState(); State.DataBind(); } else { Response.Redirect("~/Engineer/Welcome.aspx", false); } } } catch (Exception) { Response.Redirect("~/Errors/InternalErrors.aspx", false); } }