Exemplo n.º 1
0
        private static void Visitor()
        {
            //setup a collection of employees
            Employees employees = new Employees();

            employees.AddEmployee(new Developer());
            employees.AddEmployee(new Clerk());

            //Visit employees
            employees.Accept(new IncomeVisitor());
            employees.Accept(new VacationVisitor());
        }
 public void SaveEmployeeExecute()
 {
     try
     {
         MessageBoxResult result = MessageBox.Show("Are you sure you want to save the employee?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             bool canCreate = employees.CanCreate(employee);
             if (canCreate == true)
             {
                 bool isCreated = employees.AddEmployee(employee);
                 if (isCreated == true)
                 {
                     MessageBox.Show("Employee is created.", "Notification", MessageBoxButton.OK);
                     IsVisibleAddingEmployee = Visibility.Hidden;
                 }
                 else
                 {
                     MessageBox.Show("Employee cannot be created.", "Notification", MessageBoxButton.OK);
                 }
             }
             else
             {
                 MessageBox.Show("Employee cannot be created, because there is no competent manager for this floor.", "Notification", MessageBoxButton.OK);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 public void SaveExecute()
 {
     try
     {
         employees.AddEmployee(employee);
         addEmployeeView.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void btnEnumerators_Click(object sender, RoutedEventArgs e)
        {
            Employee firstEmployee = new Employee(1, "furkan", 100);

            screenList.Items.Add(firstEmployee.ToString());

            Employees EmpList = new Employees();
            Employee  e1      = new Employee(1, "Employee#1", 1250.75);
            Employee  e2      = new Employee(2, "Employee#2", 1275.85);

            EmpList.AddEmployee(e1);
            EmpList.AddEmployee(e2);

            foreach (Employee emp in EmpList)
            {
                screenList.Items.Add(emp.ToString());
            }

            IEnumerator EmpEnumerator = EmpList.GetEnumerator();

            EmpEnumerator.Reset();
            while (EmpEnumerator.MoveNext())
            {
                screenList.Items.Add((Employee)EmpEnumerator.Current);
            }

            // Display powers of 2 up to the exponent of 8:
            foreach (int i in Power(2, 8))
            {
                screenList.Items.Add(i);
            }

            Debug.WriteLine(" ");

            Debug.WriteLine(" ");

            ShowGalaxies();
        }
Exemplo n.º 5
0
 /// <summary>
 /// This method invokes a methods for adding employee and checks if sector of employee exists. If not exist, invokes a method for adding sector.
 /// </summary>
 public void SaveExecute()
 {
     if (String.IsNullOrEmpty(Employee.NameAndSurname) || String.IsNullOrEmpty(Employee.NumberOfIdentityCard) || String.IsNullOrEmpty(Employee.JMBG) || Gender == null ||
         String.IsNullOrEmpty(Employee.PhoneNumber) || String.IsNullOrEmpty(Sector) || Location == null)
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save the employee?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 if (sectors.IsSectorExists(Sector) == false)
                 {
                     sectors.AddSector(sector);
                 }
                 //invoking method to find sector and setting that sector to employee sector
                 Employee.Sector     = sectors.FindSector(sector);
                 Employee.LocationId = Convert.ToInt32(Location.LocationId);
                 Employee.Gender     = Convert.ToInt32(Gender.GenderId);
                 if (Manager != null)
                 {
                     Employee.Manager = Convert.ToInt32(Manager.EmployeeId);
                 }
                 bool isCreated = employees.AddEmployee(Employee);
                 if (isCreated)
                 {
                     MessageBox.Show("Employee is created.", "Notification", MessageBoxButton.OK);
                     addEmployeeView.Close();
                 }
                 else
                 {
                     MessageBox.Show("Employee cannot be created.", "Notification", MessageBoxButton.OK);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
 public void SaveExecute()
 {
     if (String.IsNullOrEmpty(Employee.NameAndSurname) || String.IsNullOrEmpty(Employee.DateOfBirth.ToString()) || String.IsNullOrEmpty(Employee.Email) || String.IsNullOrEmpty(Employee.Username) ||
         String.IsNullOrEmpty(Employee.Password) || String.IsNullOrEmpty(Employee.HotelFloor.ToString()) || String.IsNullOrEmpty(Employee.Engagement) || String.IsNullOrEmpty(Employee.Citizenship) ||
         String.IsNullOrEmpty(Employee.Gender) || Employee.DateOfBirth == DateTime.MinValue)
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save the employee?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 bool canCreate = employees.CanCreate(employee);
                 if (canCreate == true)
                 {
                     bool isCreated = employees.AddEmployee(Employee);
                     if (isCreated)
                     {
                         MessageBox.Show("Employee is created.", "Notification", MessageBoxButton.OK);
                         employeeView.Close();
                     }
                     else
                     {
                         MessageBox.Show("Employee cannot be created.", "Notification", MessageBoxButton.OK);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Employee cannot be created, because there is no competent manager for this floor.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
        private void btn_addInstructor_Click(object sender, RoutedEventArgs e)
        {
            if (cmb_gender.SelectedIndex == -1)
            {
                return;
            }


            try
            {
                var newEmp = new Employee()
                {
                    Name       = txt_employeeName.Text,
                    Address    = txt_address.Text,
                    Phone      = txt_phone.Text,
                    Gender     = cmb_gender.SelectedIndex,
                    Qualifier  = txt_qualifier.Text,
                    Age        = Convert.ToInt32(num_age.Value),
                    NationalId = txt_nationalId.Text,
                };

                if (EditedEmployee == null)
                {
                    Employees.AddEmployee(newEmp);
                }
                else
                {
                    newEmp.Id = EditedEmployee.Id;
                    Employees.EditEmployee(newEmp);
                }

                Globals.RefreshReferenceInformation();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// This method invokes a methods for adding employee and checks if sector of employee exists. If not exist, invokes a method for adding sector.
 /// </summary>
 public void SaveExecute()
 {
     try
     {
         if (sectors.IsSectorExists(Sector) == false)
         {
             sectors.AddSector(sector);
         }
         //invoking method to find sector and setting that sector to employee sector
         Employee.Sector     = sectors.FindSector(sector);
         Employee.LocationID = Convert.ToInt32(Location.LocationID);
         Employee.Gender     = Convert.ToInt32(Gender.GenderID);
         if (Manager != null)
         {
             Employee.Manager = Convert.ToInt32(Manager.EmployeeID);
         }
         employees.AddEmployee(employee);
         addEmployeeView.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }