Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //instantiate a new instance of engineer service
                engineerService = new EngineerService(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, User.Identity.GetUserId());
                if (!IsPostBack)
                {
                    //call engineer service to get a list of interventions created  and approvedby this engineer and then bind them to UIs
                    List <Intervention> interventions = engineerService.getInterventionListByUserId(getDetail().Id).ToList();



                    foreach (var intervention in interventions)
                    {
                        intervention.InterventionType = engineerService.getInterventionTypes().Find(it => it.Id == intervention.InterventionTypeId);
                    }

                    ListofIntervention.DataSource = interventions;
                    ListofIntervention.DataBind();
                }
            }
            catch (Exception)
            {
                Response.Redirect("~/Errors/InternalErrors.aspx", true);
            }
        }
        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);
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Instantiate a new instance of engineer service
            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"]))
                {
                    interventionId = new Guid(Request.QueryString["Id"]);
                    try
                    {
                        //get intervention from engineer service by using the query string
                        Intervention intervention = engineerService.getInterventionById(interventionId);

                        //Data bind the UI with intervention quality information

                        txtInterventionType.Text  = engineerService.getInterventionTypes().Find(i => i.Id == intervention.InterventionTypeId).Name;
                        ClientName.Text           = engineerService.getClientById(intervention.ClientId).Name;
                        InterventionComments.Text = intervention.Comments;

                        LifeRemaining.Text = intervention.LifeRemaining.ToString();
                        Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
                        InterventionVisitDate.Text          = intervention.DateRecentVisit.ToShortDateString();
                    }
                    catch (Exception)
                    {
                        Response.Redirect("~/Errors/InternalErrors.aspx", true);
                    }
                }
                else
                {
                    Response.Redirect("~/Engineer/Welcome.aspx", false);
                }
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Call engineer service to return all the intervention types
 /// </summary>
 /// <returns>A list of Intervention Type</returns>
 public List <InterventionType> GetInterventionTypes()
 {
     return(engineerService.getInterventionTypes());
 }