Exemplo n.º 1
0
        private void buttonModify_Click(object sender, EventArgs e)
        {
            // Better make sure it isn't the empty string or all blanks
            string newProjectName = textBoxProjectName.Text.Trim();

            if (newProjectName == "")
            {
                MessageBox.Show("Project name cannot be empty or blank", "Attention");
                return;
            }
            FakeProjectRepository projectRepository = new FakeProjectRepository();

            if (projectRepository.IsDupliclateName(newProjectName))
            {
                MessageBox.Show("Project name already exists.", "Attention");
                return;
            }
            Project project = new Project {
                Id = _SelectedProjectId, Name = newProjectName
            };
            string result = projectRepository.Modify(_SelectedProjectId, project);

            if (result != FakeProjectRepository.NO_ERROR)
            {
                MessageBox.Show("Error modifying project. Error: " + result);
            }
            else
            {
                MessageBox.Show("Project modification successful.", "Information");
                this.Close();
            }
        }
Exemplo n.º 2
0
        private void mdfy_Click(object sender, EventArgs e)
        {
            Project updatedProject = new Project();
            string  newName        = textBox1.Text;

            // remove extra whitespace
            newName.Trim();
            updatedProject.Id   = projectToModify.Id;
            updatedProject.Name = newName;
            //Check if current project
            if (currentProject != projectToModify)
            {
                //Modify
                string result = ProjectRepository.Modify(projectToModify.Id, updatedProject);
                //If no errors, modify succesful
                if (result == FakeProjectRepository.NO_ERROR)
                {
                    this.DialogResult = DialogResult.OK;
                    this.isModified   = true;
                    this.Close();
                }
                //If there is an error, display in message box and close modify form
                else
                {
                    MessageBox.Show(result, "Attention");
                    this.Close();
                }
            }
            //If the project is the same as the current, give error in message box
            else
            {
                MessageBox.Show(FakeProjectRepository.MODIFIED_PROJECT_ID_ERROR, "Attention");
                this.Close();
            }
        }