private void DiscardButton_Click(object sender, RoutedEventArgs e)
 {
     // revert to original employee information
     NameTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     EmployeeIdTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     ContactInfoTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
 }
 private void refreshTextBoxes()
 {
     EmployeeIdTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     NameTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     ContactInfoTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     JoinedOnTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     ActiveCheckBox.GetBindingExpression(ToggleButton.IsCheckedProperty)?.UpdateTarget();
 }
        private void ClearButton_Click(object sender, EventArgs e)
        {
            //Clear all of the form's text fields

            EmployeeSalesBonusTextBox.Clear();
            EmployeeNameTextBox.Clear();
            EmployeeIdTextBox.Clear();
            EmployeeTotalSalesTextBox.Clear();
        }
Beispiel #4
0
 private void RefreshTextBoxes()
 {
     EmployeeIdTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     NameTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
     LastPaymentDateTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
 }
        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();
        }