/// <summary>
        /// метод, который запускается при открытии окна
        /// открывается список проектов менеджера
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                ProjectActions  projectActions  = new ProjectActions();
                DatabaseActions databaseActions = new DatabaseActions();

                List <string> listName = await databaseActions.ShowUserProjects(user);

                List <Project> listProjects = await projectActions.ShowProjects();

                BackButton.Background = new ImageBrush(new BitmapImage(new Uri(path)));
                BackButton.Foreground = new ImageBrush(new BitmapImage(new Uri(path)));

                try
                {
                    for (int i = 0; i < listProjects.Count; i++)
                    {
                        for (int j = 0; j < listName.Count; j++)
                        {
                            if (listName[j] == listProjects[i].Name)
                            {
                                listBox.Items.Add(listProjects[i]);
                            }
                        }
                    }
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("You havent projects and risks");
                }

                flag = false;
            }
        }
        /// <summary>
        /// метод запускается при открытии окна
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Activated(object sender, EventArgs e)
        {
            if (flag)
            {
                BackButton.Background = new ImageBrush(new BitmapImage(new Uri(path)));
                BackButton.Foreground = new ImageBrush(new BitmapImage(new Uri(path)));

                ProjectActions projectActions = new ProjectActions();
                List <Project> listProjects   = await projectActions.ShowUsersProjects(user.Login);

                for (int i = 0; i < listProjects.Count; i++)
                {
                    listBoxProjects.Items.Add(listProjects[i]);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// метод, который при нажатии кнопки Create Project создаёт новый проект с заданными пользователем параметрами
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ProjectActions projectActions = new ProjectActions();

                if (TypeCombobox.Text == "Choose Type of the Project")
                {
                    MessageBox.Show("You have to choose the type of a project!");
                }
                else if (Name.Text == null)
                {
                    MessageBox.Show("You have to enter the name of the project!");
                }
                else if (listOwners.SelectedItem == null)
                {
                    MessageBox.Show("You have to choose project's owner!");
                }
                else
                {
                    await projectActions.AddProject(Name.Text, TypeCombobox.Text, ((User)(listOwners.SelectedItem)).Login);

                    AdministratorGraphic graphic = new AdministratorGraphic(new Project(Name.Text, ((User)(listOwners.SelectedItem)).Login, TypeCombobox.Text));
                    Close();
                    graphic.Show();
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }