Beispiel #1
0
        private void UnitCompleteButton_Click(object sender, EventArgs e)
        {
            newUnit.Id = newUnit.Faction + newUnit.Name;
            UnitController unitControl = new UnitController();

            unitControl.AddUnit(newUnit);
            UnitMenu newScreen = new UnitMenu();

            newScreen.Show();
            Close();
        }
Beispiel #2
0
    /// <summary>
    /// This button on click method is for adding a new unit to the selected site in the database.
    /// <summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>

    protected void AddUnitButton_Click(object sender, EventArgs e)
    {
        int            siteId     = int.Parse(SelectedSiteID.Text);
        int            userId     = (int)Session["adminID"];
        string         unitNumber = AddUnitTextBox.Text.Trim();
        UnitController sysmgr     = new UnitController();

        MessageUserControl.TryRun(() =>
        {
            sysmgr.AddUnit(unitNumber, userId, siteId);
            UnitsListView.DataBind();
            AddUnitTextBox.Text = "";
        }, "Success", "Successfully added the new unit: \"" + unitNumber + "\"");
    }
Beispiel #3
0
    /*
     * CREATED:     A. Valberg		MAR 3 2018
     * MODIFIED:    H. Conant		MAR 5 2018
     *  - Updated method signature
     *  - Updated method body code
     * MODIFIED:    H. Conant		MAR 27 2018
     *  - Updated method body code
     * MODIFIED:    H. L'Heureux	APR 03 2018
     *  - Updated method body code
     *
     * AddUnitButton_Click()
     * This method allows the user to add a specified unit in the database.
     *
     * PARAMETERS:
     * object sender - object on the page that is being targeted
     * EventArgs e - event that has triggered the method
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * MessageUserControl.ShowInfoMessage()
     * UnitController.AddUnit()
     * MessageUserControl.ShowSuccessMessage()
     * MessageUserControl.ShowErrorMessage()
     * ClearPage()
     */
    protected void AddUnitButton_Click(object sender, EventArgs e)
    {
        string pattern = @"^[A-z 0-9 .-]{1,60}$";

        Regex reg = new Regex(pattern);

        Match unitNameFormat = reg.Match(AddUnitNameTB.Text);

        if (string.IsNullOrWhiteSpace(AddUnitNameTB.Text) || AddUnitNameTB.Text.Length > 60 || !unitNameFormat.Success)
        {
            MessageUserControl.ShowInfoMessage("Please enter a unit name up to 60 characters. Unit names can only contain letters, numbers, and the following symbols: . -");
        }
        else
        {
            int tempCareSiteID;
            int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteID);
            if (tempCareSiteID == 0)
            {
                MessageUserControl.ShowInfoMessage("Please select a care site.");
            }
            else
            {
                UnitDTO tempUnit = new UnitDTO();
                tempUnit.caresiteid = tempCareSiteID;
                tempUnit.unitname   = AddUnitNameTB.Text.Trim();
                try
                {
                    unitController.AddUnit(tempUnit);
                    MessageUserControl.ShowSuccessMessage("Unit " + AddUnitNameTB.Text + " has been added to the " + CareSiteDDL.SelectedItem.Text + " care site.");
                    ClearPage();
                }
                catch (Exception ex)
                {
                    MessageUserControl.ShowErrorMessage("Adding unit failed. Please try again. If error persists, please contact your administrator.", ex);
                }
            }
        }
    }
Beispiel #4
0
 /*
  * CREATED:     C. Stanhope		MAR 2 2018
  * MODIFIED:    A. Valberg		MAR 3 2018
  *  - Added method body code
  * MODIFIED:    H. Conant		MAR 5 2018
  *  - Updated method signature
  *  - Updated method body code
  *
  * DeactivateUnitButton_Click()
  * This method allows the user to deactivate a specified unit in the database.
  *
  * PARAMETERS:
  * object sender - object on the page that is being targeted
  * EventArgs e - event that has triggered the method
  *
  * RETURNS:
  * void - Nothing is returned
  *
  * METHOD CALLS:
  * .IsNullOrWhiteSpace()
  * .TryParse()
  * UnitDTO()
  * .DeactivateUnit()
  * ClearPage();
  */
 protected void AddUnitButton_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(AddUnitNameTB.Text))
     {
         UserMessage.Text = "Please enter a unit name";
     }
     else
     {
         int tempCareSiteID;
         int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteID); //HiddenCareSiteID.Value
         UnitDTO tempUnit = new UnitDTO();
         tempUnit.caresiteid = tempCareSiteID;
         tempUnit.unitname   = AddUnitNameTB.Text;
         try
         {
             unitController.AddUnit(tempUnit);
             ClearPage();
         } catch (Exception ex)
         {
             ErrorMessage.Text = "Add unit failed. Please contact the system administrator.";
         }
     }
 }
        public void SetStartGameState(NWGameStateInfo _state)
        {
            if (_state == null)
            {
                Console.LogError(ConsoleFilter.GameController, "Start GameStateInfo is null");
                return;
            }

            if (Util.ArrayIsNullOrEmpty(_state.Teams))
            {
                Console.LogError(ConsoleFilter.GameController, "Start GameStateInfo  Teams is null");
                return;
            }
            foreach (NWTeamInfo team in _state.Teams)
            {
                if (teams.ContainsKey(team.Id))
                {
                    Console.LogErrorFormat(ConsoleFilter.GameController, "Dublicate Team {0}", team.Id);
                    continue;
                }
                teams.Add(team.Id, team);
            }


            if (!Util.ArrayIsNullOrEmpty(_state.Units))
            {
                foreach (NWUnit unit in _state.Units)
                {
                    UnitController.AddUnit(unit);
                }
            }

            if (!Util.ArrayIsNullOrEmpty(_state.Builds))
            {
                foreach (NWBuild build in _state.Builds)
                {
                    if (build == null)
                    {
                        Console.LogError(ConsoleFilter.MainController, "ServerBuild  is null");
                        continue;
                    }
                    BuildController.AddBuild(build);
                }
            }

            if (!Util.ArrayIsNullOrEmpty(_state.Turrets))
            {
                foreach (NWTurret turret in _state.Turrets)
                {
                    if (turret == null)
                    {
                        Console.LogError(ConsoleFilter.MainController, "ServerTurret is null");
                    }
                    BuildController.AddTurret(turret);
                }
            }

            if (gameControllers.SwichScreenController != null)
            {
                gameControllers.SwichScreenController.LoadScreenDone();
            }

            commandQueue.Enqueue(() =>
            {
                if (teams.ContainsKey(MainPlayerController.TeamId))
                {
                    UI.SetMainPlayerTeamInfo(teams[MainPlayerController.TeamId]);
                }
            });
        }