コード例 #1
0
        private void Get_Report_Button_Click(object sender, RoutedEventArgs e)
        {
            string[] report     = ServerConnector.GetReport();
            string   reportPath = Environment.CurrentDirectory;

            using (StreamWriter reportFile = new StreamWriter(reportPath + @"\Report.txt"))
            {
                foreach (string line in report)
                {
                    reportFile.WriteLine(line);
                }
            }
            Process.Start(reportPath + @"\Report.txt");
        }
コード例 #2
0
        private void Delete_Project_Button_Click(object sender, RoutedEventArgs e)
        {
            string           messageBoxText = "Do you want to remove the project: " + ((ComboBoxItem)projectsComboBox.SelectedItem).Content + "?";
            string           caption        = "Remove project";
            MessageBoxButton button         = MessageBoxButton.YesNo;
            MessageBoxImage  icon           = MessageBoxImage.Question;
            MessageBoxResult result         = MessageBox.Show(this, messageBoxText, caption, button, icon);

            if (result == MessageBoxResult.Yes)
            {
                int projectId = (int)((ComboBoxItem)projectsComboBox.SelectedItem).Tag;
                ServerConnector.RemoveProject(projectId);
                refreshProjectsComboBox();
            }
        }
コード例 #3
0
        private void Add_Project_Button_Click(object sender, RoutedEventArgs e)
        {
            AddProjectWindow addProject = new AddProjectWindow();

            if (addProject.ShowDialog() == true)
            {
                if (ServerConnector.PlaceProject(addProject.ProjectName))
                {
                    refreshProjectsComboBox();
                }
                else
                {
                    string           messageBoxText = "The entered project name has alredy exist! Please, enter another project name.";
                    string           caption        = "Wrong project name";
                    MessageBoxButton button         = MessageBoxButton.OK;
                    MessageBoxImage  icon           = MessageBoxImage.Warning;
                    MessageBox.Show(this, messageBoxText, caption, button, icon);
                }
            }
        }
コード例 #4
0
        private void Add_Employee_Button_Click(object sender, RoutedEventArgs e)
        {
            AddEmployeeWindow addEmployee = new AddEmployeeWindow();

            if (addEmployee.ShowDialog() == true)
            {
                if (ServerConnector.PlaceEmployee(addEmployee.FirstName, addEmployee.LastName))
                {
                    refreshEmployeesComboBox();
                }
                else
                {
                    string           messageBoxText = "The entered employee first and last name have alredy exist! Please, enter another employee name.";
                    string           caption        = "Wrong employee name";
                    MessageBoxButton button         = MessageBoxButton.OK;
                    MessageBoxImage  icon           = MessageBoxImage.Warning;
                    MessageBox.Show(this, messageBoxText, caption, button, icon);
                }
            }
        }
コード例 #5
0
 private void refreshProjectsComboBox()
 {
     ProjectContract[] projects = ServerConnector.GetAllProjects();
     projectsComboBox.Items.Clear();
     if (projects != null && projects.Count() > 0)
     {
         foreach (ProjectContract project in projects)
         {
             projectsComboBox.Items.Add(new ComboBoxItem {
                 Content = project.Name, Tag = project.ProjectId
             });
         }
     }
     else
     {
         projectsComboBox.Items.Add(new ComboBoxItem {
             Content = " - Add a project -> ", Tag = 0
         });
     }
     projectsComboBox.Items.Refresh();
     projectsComboBox.SelectedIndex = 0;
 }
コード例 #6
0
        // Fill the ComboBoxes
        private void refreshEmployeesComboBox()
        {
            EmployeeContract[] employees = ServerConnector.GetAllEmployees();
            employeesComboBox.Items.Clear();
            if (employees != null && employees.Count() > 0)
            {
                foreach (EmployeeContract employee in employees)
                {
                    employeesComboBox.Items.Add(new ComboBoxItem {
                        Content = employee.FirstName + " " + employee.LastName, Tag = employee.EmployeeId
                    });
                }
            }
            else
            {
                employeesComboBox.Items.Add(new ComboBoxItem {
                    Content = " - Add an employee -> ", Tag = 0
                });
            }

            employeesComboBox.Items.Refresh();
            employeesComboBox.SelectedIndex = 0;
        }