Esempio n. 1
0
    void CheckEmployeeState(EmployeeStates state)
    {
        switch (state)
        {
        case EmployeeStates.Work:
            Work();
            if (Time.time >= employeeStateStartTime + 20f)
            {
                ChangeEmployeeState(EmployeeStates.Idle);
            }

            if (currentNeedState != NeedsStates.Fine)
            {
                ChangeEmployeeState(EmployeeStates.FulfillNeed);
            }
            break;

        case EmployeeStates.Idle:
            Idle();
            if (currentNeedState != NeedsStates.Fine)
            {
                ChangeEmployeeState(EmployeeStates.FulfillNeed);
            }
            break;

        case EmployeeStates.FulfillNeed:
            FulfillNeed();
            if (currentNeedState == NeedsStates.Fine)
            {
                ChangeEmployeeState(EmployeeStates.Work);
            }
            break;
        }
    }
Esempio n. 2
0
 /// <summary>
 ///     Employee's work logic.
 /// </summary>
 public void DoWork()
 {
     while (!IsEndOfDay)
     {
         if (HasSomethingToDo())
         {
             _employeeState = EmployeeStates.Working;
             Work();
         }
         else
         {
             _employeeState = EmployeeStates.Resting;
             Rest();
         }
     }
     _employeeState = EmployeeStates.WentHome;
     GoHome();
 }
Esempio n. 3
0
 public void ChangeEmployeeState(EmployeeStates newEmployeeState)
 {
     employeeStateStartTime = Time.time;
     Debug.Log("State Start Time = " + employeeStateStartTime);
     currentEmployeeState = newEmployeeState;
 }
Esempio n. 4
0
 private void cancelButton_Click(object sender, EventArgs e)
 {
     this.InternalState = EmployeeStates.Main;
 }
Esempio n. 5
0
 private void createEmployeeButton_Click(object sender, EventArgs e)
 {
     this.InternalState = EmployeeStates.AddEmployee;
 }
Esempio n. 6
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (this.addressTextBox.Text == string.Empty || this.firstNameTextBox.Text == string.Empty ||
                this.lastNameTextBox.Text == string.Empty || this.phoneTextBox.Text == string.Empty ||
                this.ssnTextBox.Text == string.Empty || this.passwordTextBox.Text == string.Empty)
            {
                MessageBox.Show(@"Please enter a value for every field.");
                return;
            }

            if (this.phoneTextBox.Text.Length != 10)
            {
                ErrorHandler.DisplayErrorBox("Phone Number Invalid", "Please enter a valid 10 digit phone number.");
                return;
            }

            try
            {
                long.Parse(this.phoneTextBox.Text);
            }
            catch (Exception)
            {
                ErrorHandler.DisplayErrorBox("Phone Number Invalid", "Please enter a valid 10 digit phone number.");
                return;
            }

            if (this.ssnTextBox.Text.Length != 9)
            {
                ErrorHandler.DisplayErrorBox("SSN Invalid", "Please enter a valid 9 digit SSN.");
                return;
            }

            try
            {
                uint.Parse(this.ssnTextBox.Text);
            }
            catch (Exception)
            {
                ErrorHandler.DisplayErrorBox("SSN Invalid", "Please enter a valid 9 digit SSN.");
                return;
            }

            try
            {
                Employee anEmployee = new Employee
                {
                    FirstName       = this.firstNameTextBox.Text,
                    LastName        = this.lastNameTextBox.Text,
                    PhoneNumber     = this.phoneTextBox.Text,
                    SSN             = this.ssnTextBox.Text,
                    IsAdmin         = this.adminCheckBox.Checked,
                    EmployeeAddress = { Id = this.addressTextBox.Text }
                };


                this.theController.AddEmployee(anEmployee, this.passwordTextBox.Text);

                this.loadEmployees();
                this.InternalState = EmployeeStates.Main;
            }
            catch (Exception exception)
            {
                ErrorHandler.DisplayErrorMessageToUserAndLog("Error",
                                                             "Failed to add employee to database. Please try again.", exception);
            }
        }
Esempio n. 7
0
 private void createEmployeeButton_Click(object sender, EventArgs e)
 {
     this.InternalState = EmployeeStates.AddEmployee;
 }
Esempio n. 8
0
 private void cancelButton_Click(object sender, EventArgs e)
 {
     this.InternalState = EmployeeStates.Main;
 }
Esempio n. 9
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (this.addressTextBox.Text == string.Empty || this.firstNameTextBox.Text == string.Empty ||
                this.lastNameTextBox.Text == string.Empty || this.phoneTextBox.Text == string.Empty ||
                this.ssnTextBox.Text == string.Empty || this.passwordTextBox.Text == string.Empty)
            {
                MessageBox.Show(@"Please enter a value for every field.");
                return;
            }

            if (this.phoneTextBox.Text.Length != 10)
            {
                ErrorHandler.DisplayErrorBox("Phone Number Invalid", "Please enter a valid 10 digit phone number.");
                return;
            }

            try
            {
                long.Parse(this.phoneTextBox.Text);
            }
            catch (Exception)
            {
                ErrorHandler.DisplayErrorBox("Phone Number Invalid", "Please enter a valid 10 digit phone number.");
                return;
            }

            if (this.ssnTextBox.Text.Length != 9)
            {
                ErrorHandler.DisplayErrorBox("SSN Invalid", "Please enter a valid 9 digit SSN.");
                return;
            }

            try
            {
                uint.Parse(this.ssnTextBox.Text);
            }
            catch (Exception)
            {
                ErrorHandler.DisplayErrorBox("SSN Invalid", "Please enter a valid 9 digit SSN.");
                return;
            }

            try
            {
                Employee anEmployee = new Employee
                {
                    FirstName = this.firstNameTextBox.Text,
                    LastName = this.lastNameTextBox.Text,
                    PhoneNumber = this.phoneTextBox.Text,
                    SSN = this.ssnTextBox.Text,
                    IsAdmin = this.adminCheckBox.Checked,
                    EmployeeAddress = {Id = this.addressTextBox.Text}
                };


                this.theController.AddEmployee(anEmployee, this.passwordTextBox.Text);

                this.loadEmployees();
                this.InternalState = EmployeeStates.Main;
            }
            catch (Exception exception)
            {
                ErrorHandler.DisplayErrorMessageToUserAndLog("Error",
                    "Failed to add employee to database. Please try again.", exception);
            }
        }
Esempio n. 10
0
 /// <summary>
 ///     Employee's work logic.
 /// </summary>
 public void DoWork()
 {
     while (!IsEndOfDay)
     {
         if (HasSomethingToDo())
         {
             _employeeState = EmployeeStates.Working;
             Work();
         }
         else
         {
             _employeeState = EmployeeStates.Resting;
             Rest();
         }
     }
     _employeeState = EmployeeStates.WentHome;
     GoHome();
 }