private void addPrj_Click(object sender, EventArgs e) { int newProjectId; //Removes whitespace before and after project name newProject.Name = nameInput.Text.Trim(' '); //Attempt to add new project string result = ProjectRepository.Add(newProject, out newProjectId); //If no errors, succesfully added and information updated for use in caller if (result == FakeProjectRepository.NO_ERROR) { newProject.Id = newProjectId; this.DialogResult = DialogResult.OK; this.isCreated = true; this.Close(); } //If errors, display message based on error else if (result == FakeProjectRepository.DUPLPICATE_PROJECT_NAME_ERROR) { MessageBox.Show(FakeProjectRepository.DUPLPICATE_PROJECT_NAME_ERROR, "Attention"); } else if (result == FakeProjectRepository.EMPTY_PROJECT_NAME_ERROR) { MessageBox.Show(FakeProjectRepository.EMPTY_PROJECT_NAME_ERROR, "Attention"); } }
private void buttonAdd_Click(object sender, EventArgs e) { FakeProjectRepository projectRepository = new FakeProjectRepository(); Project project = new Project(); project.Name = textBoxProjectName.Text.Trim(); int assignedProjectId; string result = projectRepository.Add(project, out assignedProjectId); if (result == FakeProjectRepository.NO_ERROR) { MessageBox.Show("Project added successfully."); } else { MessageBox.Show("Project not created. " + result, "Attention."); } this.Close(); }