示例#1
0
        //This Method adds a site to a Crew
        protected void RouteListView_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            int    siteId = int.Parse(e.CommandArgument.ToString());
            int    crewId;
            string message = "";

            if (!int.TryParse(CrewID.Text, out crewId))
            {
                //Verifies that a the selected a crew exists with the selected Unit
                MessageUserControl.ShowInfo("You must create a crew before assigning job sites. To make a crew select a Unit and Add at leat one (1) employee");
                RouteListView.Visible     = false;
                EmployeesListView.Visible = true;
                Route.Text = "Crew Member";
            }
            else
            {
                CrewControllers crewManager = new CrewControllers();
                MessageUserControl.TryRun(() =>
                {
                    message = crewManager.Add_Site_To_Crew(crewId, siteId);
                    //Refresh the List of Crews
                    List <CurrentCrew> currentCrews = crewManager.GetCurrentCrew(int.Parse(YardID.Text));
                    CrewRepeater.DataSource         = currentCrews;
                    CrewRepeater.DataBind();
                });

                if (!string.IsNullOrEmpty(message))
                {
                    MessageUserControl.ShowInfo("This site is already assigned to the following crews: " + message);
                }
                ;
            }
        }
示例#2
0
 //This method displays the Current Crews
 protected void RouteCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
         CrewControllers crewManager     = new CrewControllers();
         List <CurrentCrew> currentCrews = crewManager.GetCurrentCrew(int.Parse(YardID.Text));
         CrewRepeater.DataSource         = currentCrews;
         CrewRepeater.DataBind();
         Route.Text = "Crew Members";
     });
 }
示例#3
0
        //This Methode Creates(respectively Adds) a new crew (repectively crew members)
        protected void EmployeesListView_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            int employeeId = int.Parse(e.CommandArgument.ToString());
            int unitId     = int.Parse(UnitsDDL.SelectedValue);
            int crewId;

            MessageUserControl.TryRun(() =>
            {
                CrewControllers crewManager = new CrewControllers();
                //Add a new Member to a Crew
                crewId      = crewManager.Add_To_A_Crew(unitId, employeeId);
                CrewID.Text = crewId.ToString();

                //Refresh the Crew List
                List <CurrentCrew> currentCrews = crewManager.GetCurrentCrew(int.Parse(YardID.Text));
                CrewRepeater.DataSource         = currentCrews;
                CrewRepeater.DataBind();
            });
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string crewLeaderRole = ConfigurationManager.AppSettings["crewLeaderRole"];
                if (Request.IsAuthenticated)
                {
                    if (!User.IsInRole(crewLeaderRole))
                    {
                        Response.Redirect("~/Account/Login.aspx");
                    }
                }
                else
                {
                    Response.Redirect("~/Account/Login.aspx");
                }

                MessageUserControl.TryRun(() =>
                {
                    // Retrieve the YardID based on the current userId
                    // Set the Yard ID as in invisible label on the web page.
                    SecurityController securityManager = new SecurityController();
                    int?employeeId = securityManager.GetCurrentUserId(User.Identity.Name);
                    RouteController routeManager = new RouteController();
                    YardID.Text   = routeManager.GetYardId(employeeId).ToString();
                    SiteType.Text = "1";

                    //Populate the current Crews
                    CrewControllers crewManager     = new CrewControllers();
                    List <CurrentCrew> currentCrews = crewManager.GetCurrentCrew(int.Parse(YardID.Text));
                    CrewRepeater.DataSource         = currentCrews;
                    CrewRepeater.DataBind();
                });
                RouteListView.Visible = false;
            }
        }
示例#5
0
        //This Method all operations on the currents crews (Select crew, Delete Crew, Delete Crew Member, Remove sites from Crews)
        protected void CrewRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            CrewControllers crewManager = new CrewControllers();
            int             yardId      = int.Parse(YardID.Text);

            switch (e.CommandName)
            {
            case "SelectCrew":
                LoadDDLUnits();
                int crewId = int.Parse(e.CommandArgument.ToString());

                MessageUserControl.TryRun(() =>
                {
                    UnitsDDL.SelectedValue = crewManager.unitNumber(crewId).ToString();
                    Route.Text             = "Crew Members";
                    CrewID.Text            = crewId.ToString();
                });
                PopulateEmployeeAndSiteType();
                CrewID.Text = crewId.ToString();

                if (RouteListView.Visible == true)
                {
                    RouteListView.Visible = false;
                }

                break;

            case "DeleteCrew":
                MessageUserControl.TryRun(() =>
                {
                    int CrewId = int.Parse(e.CommandArgument.ToString());
                    crewManager.DeleteCrew(CrewId);

                    //refresh the current Crews
                    List <CurrentCrew> currentCrews = crewManager.GetCurrentCrew(yardId);
                    CrewRepeater.DataSource         = currentCrews;
                    CrewRepeater.DataBind();
                });
                break;

            case "DeleteMember":
                int crewMemberId = int.Parse(e.CommandArgument.ToString());
                MessageUserControl.TryRun(() =>
                {
                    crewManager.RemoveCrewMember(crewMemberId);

                    //refresh the current Crews
                    List <CurrentCrew> currentCrews = crewManager.GetCurrentCrew(yardId);
                    CrewRepeater.DataSource         = currentCrews;
                    CrewRepeater.DataBind();
                });
                break;

            case "DeleteSite":
                int crewSiteId = int.Parse(e.CommandArgument.ToString());
                MessageUserControl.TryRun(() =>
                {
                    crewManager.RemoveCrewSite(crewSiteId);

                    //refresh the current Crews
                    List <CurrentCrew> currentCrews = crewManager.GetCurrentCrew(yardId);
                    CrewRepeater.DataSource         = currentCrews;
                    CrewRepeater.DataBind();
                });
                break;
            }
        }