private void ClearButton_Click(object sender, EventArgs e)
        {
            //Clear all of the form's text fields

            EmployeeSalesBonusTextBox.Clear();
            EmployeeNameTextBox.Clear();
            EmployeeIdTextBox.Clear();
            EmployeeTotalSalesTextBox.Clear();
        }
 private void ClearAddEmployee(object sender, DialogClosingEventArgs eventArgs)
 {
     EmployeeNameTextBox.Clear();
     EmployeeAddressTextBox.Clear();
     EmployeeBirthDatePicker.SelectedDate = DateTime.Today;
     EmployeeSalaryTextBox.Clear();
     EmployeeDepartmentComboBox.SelectedItem = null;
     EmpoloyeeRoleComboBox.SelectedItem      = null;
     validation.Text = "";
 }
 public void addEmployee(object sender, RoutedEventArgs e)
 {
     if (ViewModel.ValidateName())
     {
         ViewModel.addEmployee();
         EmployeeNameTextBox.Clear();
         EmployeeAddressTextBox.Clear();
         EmployeeBirthDatePicker.SelectedDate = DateTime.Today;
         EmployeeSalaryTextBox.Clear();
         EmployeeDepartmentComboBox.SelectedItem = null;
         EmpoloyeeRoleComboBox.SelectedItem      = null;
         Home.ViewModel.CloseRootDialog();
     }
 }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (EmployeeIdTextBox.Text.Trim() == "" || EmployeeNameTextBox.Text.Trim() == "" || RankTextBox.Text.Trim() == "" || FacutlyComboBox.SelectedItem == null || DepartmentComboBox.SelectedItem == null || CenterComboBox.SelectedItem == null || BuildingComboBox.SelectedItem == null || LevelComboBox.SelectedItem == null)
            {
                MessageBox.Show("Sorry! Fields cannot be empty!", "Error");
                return;
            }
            Lecturer lecturer = new Lecturer
            {
                EmployeeId   = Int32.Parse(EmployeeIdTextBox.Text.Trim()),
                EmployeeName = EmployeeNameTextBox.Text.Trim(),
                Rank         = float.Parse(RankTextBox.Text.Trim())
            };

            string facultyName    = FacutlyComboBox.SelectedItem.ToString();
            string departmentName = DepartmentComboBox.SelectedItem.ToString();
            string centerName     = CenterComboBox.SelectedItem.ToString();
            string buildingName   = BuildingComboBox.SelectedItem.ToString();
            string levelName      = LevelComboBox.SelectedItem.ToString();

            LecturerDataService lecturerDataService = new LecturerDataService(new EntityFramework.TimetableManagerDbContext());

            if (!EmployeeIdTextBox.IsEnabled)
            {
                EmployeeIdTextBox.IsEnabled = true;

                lecturerDataService.UpdateLecturer(lecturer, facultyName, departmentName, centerName, buildingName, levelName).ContinueWith(result =>
                {
                    if (result != null)
                    {
                        MessageBox.Show("Lecture Updated!", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Sorry! Error occured!", "Error");
                    }
                });
            }
            else
            {
                lecturerDataService.AddLecturer(lecturer, facultyName, departmentName, centerName, buildingName, levelName).ContinueWith(result =>
                {
                    if (result != null)
                    {
                        MessageBox.Show("Lecture Added!", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Sorry! Error occured!", "Error");
                    }
                });
            }

            EmployeeIdTextBox.Clear();
            EmployeeNameTextBox.Clear();
            RankTextBox.Clear();
            FacutlyComboBox.SelectedIndex    = -1;
            DepartmentComboBox.SelectedIndex = -1;
            CenterComboBox.SelectedIndex     = -1;
            BuildingComboBox.SelectedIndex   = -1;
            LevelComboBox.SelectedIndex      = -1;

            LecturerDataList.Clear();
            _ = this.LoadLecturerData();
        }