Beispiel #1
0
        private void createProjectToolStripMenuItem_Click(object sender, EventArgs e)
        { // CREATE
            string       newProjectOut;
            DialogResult newProjectResult;

            FakeProjectRepository projects = new FakeProjectRepository();
            Project newProject             = new Project();

            bool validresult = false;

            using (FormCreateProject CreateProjectForm = new FormCreateProject())
            {
                do
                {
                    CreateProjectForm.ShowDialog();
                    newProjectResult = CreateProjectForm.DialogResult;

                    if (newProjectResult == DialogResult.OK)
                    {
                        if (CreateProjectForm.NewProjectsName != "")
                        {
                            newProject.Name = CreateProjectForm.NewProjectsName;
                            newProjectOut   = projects.Add(newProject, out int Id);

                            if (newProjectOut != "")
                            {
                                MessageBox.Show(newProjectOut); // shows error string from FakeProjectRepo.
                            }
                            else
                            {
                                validresult = true;
                            }
                        }
                    }
                    else if (newProjectResult == DialogResult.Cancel)
                    {
                        validresult = true;
                    }
                } while (!validresult);
            }
        }
Beispiel #2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            Project createProject = new Project();
            bool    duplicate     = FakeProjectRepository.isDuplicateName(newProjectName);

            createProject.Name = newProjectName;
            if (projectNameText.Text.Trim() == string.Empty)
            {
                MessageBox.Show(FakeProjectRepository.EMPTY_PROJECTNAME_ERROR);
                return;
            }

            if (duplicate == false)
            {
                string newProject = FakeProjectRepository.Add(createProject, FakeProjectRepository.Projects.Count() + 1);
                MessageBox.Show("Project Added Successfully.");
            }
            else
            {
                MessageBox.Show(FakeProjectRepository.DUPLPICATEPROJECTNAME_ERROR);
            }
            // add way to add new project to show project form
            this.Close();
        }