Beispiel #1
0
        protected void AssignDriver()
        {
            string category = (FleetCategory.SelectedIndex < 0) ? "" : FleetCategory.SelectedItem.Text.Trim();

            int driverId = 0;

            //Retrieve the selected DriverID
            foreach (GridViewRow row in EmployeeGridView.Rows)
            {
                if ((row.FindControl("SelectedDriver") as RadioButton).Checked == true)
                {
                    driverId = int.Parse((row.FindControl("EmployeeID") as Label).Text);
                }
            }

            //Checks that a driver is selecetd. then proceed
            if (driverId == 0)
            {
                InfoUserControl.ShowInfo("Please select a driver");
            }
            else
            {
                CrewController crewManager = new CrewController();
                InfoUserControl.TryRun(() =>
                {
                    crewManager.CreateCrew(int.Parse(SelectUnitDDL.SelectedValue), driverId, category);
                    List <CurrentCrews> crews = crewManager.GetCurrentCrews(int.Parse(YardID.Text));
                    crews.Sort((x, y) => y.CrewID.CompareTo(x.CrewID));
                    CrewID.Text = crews.Count <= 0 ? "" : (crews[0].CrewID).ToString();
                    CloseCrewPane();
                });

                PopulateUnitReport();
            }
        }
Beispiel #2
0
        /// <summary>
        /// This event fires when when the user presses on the Create a Crew button
        ///     It retrives the driver ID
        ///     It calls the method that creates a New Crew
        ///     It populates/refreshes all current crews
        /// </summary>
        /// <param name="sender">The sender is a button control</param>
        /// <param name="e"></param>
        protected void CreateCrew_Click(object sender, EventArgs e)
        {
            int    driverId = 0;
            string category = (FleetCategory.SelectedItem.Text).Trim();

            //Retrieve the selected DriverID
            foreach (GridViewRow row in EmployeeGridView.Rows)
            {
                if ((row.FindControl("SelectedDriver") as RadioButton).Checked == true)
                {
                    driverId = int.Parse((row.FindControl("EmployeeID") as Label).Text);
                }
            }

            //Checks that a driver is selecetd. then proceed
            if (driverId == 0)
            {
                InfoUserControl.ShowInfo("Please select a driver");
            }
            else
            {
                DriverID.Text = driverId.ToString();
                CrewController crewManager = new CrewController();
                InfoUserControl.TryRun(() =>
                {
                    crewManager.CreateCrew(int.Parse(SelectUnitDDL.SelectedValue), driverId, category);
                    Refresh.Text = "Member";
                    EmployeeGridView.PageIndex = 0;
                    Cancel.Visible             = true;
                    CreateCrew.Visible         = false;
                    PopulateUnitReport();
                    RefreshCrewMember();
                    RefreshCurrentCrews();
                    InfoUserControl.ShowInfo("Add Crew Members");
                    List <CurrentCrews> crews = crewManager.GetCurrentCrews(int.Parse(YardID.Text));
                    crews.Sort((x, y) => y.CrewID.CompareTo(x.CrewID));
                    CrewID.Text = crews.Count <= 0 ? "" : (crews[0].CrewID).ToString();
                });
            }
        }