Exemplo n.º 1
0
        public void ShowProjects(Project[] projects)
        {
            if (projects == null)
            {
                throw new ArgumentNullException("projects");
            }

            projectsListView.BeginUpdate();

            projectsListView.Items.Clear();
            foreach (var project in projects)
            {
                ListViewItem lvi = new ListViewItem();

                lvi.Text = project.Name;
                lvi.Tag = project;

                projectsListView.Items.Add(lvi);
            }

            projectsListView.EndUpdate();

            projectsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            projectsListView.Columns[0].Width -= 4;

            return;
        }
Exemplo n.º 2
0
        private void AddProject()
        {
            Project project = new Project();
            ProjectDetailsForm form = new ProjectDetailsForm();
            form.ProjectDetailsUserControl.ShowProject(project);

            Again:
            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Check name.
                if (string.IsNullOrWhiteSpace(form.ProjectDetailsUserControl.ProjectName))
                {
                    MessageBox.Show
                    (
                        Resources.String_TheProjectNameCannotBeBlank,
                        Resources.String_Error,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        FormMessageBoxOptions
                    );
                    goto Again;
                }

                form.ProjectDetailsUserControl.RetrieveProject(project);

                // Add.
                project.Add();

                // Flush.
                Database.Flush();

                // Show projects.
                ShowProjects();

                // Select new project.
                projectsListUserControl.ProjectsListView.SelectedItems.Clear();
                foreach (ListViewItem item in projectsListUserControl.ProjectsListView.Items)
                {
                    Project p = (Project)item.Tag;
                    if (p.ID == project.ID)
                    {
                        item.Selected = true;
                        break;
                    }
                }

                UpdateControlsEnabledProperty();

                // Show edit project form.
                EditProject();

                projectsListUserControl.Focus();
            }

            return;
        }
Exemplo n.º 3
0
        public void ShowProject(Project project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            nameTextBox.Text = project.Name;
            displayOrderNumericUpDown.Value = Math.Min(project.DisplayOrder, displayOrderNumericUpDown.Maximum);
            descriptionTextBox.Text = project.Description;

            return;
        }
Exemplo n.º 4
0
        public void RetrieveProject(Project project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            project.Name = nameTextBox.Text;
            project.DisplayOrder = (int)displayOrderNumericUpDown.Value;
            project.Description = descriptionTextBox.Text;

            return;
        }
Exemplo n.º 5
0
        public ProjectForm(Project project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            Project = project;

            InitializeComponent();

            milestonesListUserControl.MilestonesListView.SelectedIndexChanged += MilestonesListView_SelectedIndexChanged;
            milestonesListUserControl.MilestonesListView.DoubleClick += MilestonesListView_DoubleClick;

            ticketsListUserControl.TicketsListView.SelectedIndexChanged += TicketsListView_SelectedIndexChanged;
            ticketsListUserControl.TicketsListView.DoubleClick += TicketsListView_DoubleClick;

            ShowProjectDetails();
            ShowMilestones();
            ShowTickets();
        }
Exemplo n.º 6
0
        public static Project GetProject(int id)
        {
            ProjectsTableAdapter tableAdapter = Database.ProjectsTableAdapter;

            PeygirDatabaseDataSet.ProjectsDataTable rows = tableAdapter.GetDataByID(id);

            if (rows.Count == 1)
            {
                // Found.
                Project project = new Project(rows[0]);
                return project;
            }

            // Not found.
            return null;
        }
Exemplo n.º 7
0
        public static Project[] GetProjects()
        {
            ProjectsTableAdapter tableAdapter = Database.ProjectsTableAdapter;

            PeygirDatabaseDataSet.ProjectsDataTable rows = tableAdapter.GetData();

            // Create list.
            List<Project> projects = new List<Project>();
            foreach (var row in rows)
            {
                // Add.
                Project project = new Project(row);
                projects.Add(project);
            }

            return projects.ToArray();
        }