Пример #1
0
        private void Modify_Click(object sender, EventArgs e)
        {
            Project updatedProject = new Project();
            string  newName        = textBox1.Text;

            newName.Trim();
            updatedProject.ID   = projectModify.ID;
            updatedProject.Name = newName;

            if (currentProject != projectModify)
            {
                string result = ProjectRepository.Modify(projectModify.ID, updatedProject);

                if (result == FakeProjectRepository.ERROR)
                {
                    this.DialogResult = DialogResult.OK;
                    this.isModified   = true;
                    this.Close();
                }

                else
                {
                    MessageBox.Show(result, "Attention");
                    this.Close();
                }
            }

            else
            {
                MessageBox.Show(FakeProjectRepository.MODIFIEDPROJECTID_ERROR, "Attention");
                this.Close();
            }
        }
Пример #2
0
        private void modifyProjectToolStripMenuItem_Click(object sender, EventArgs e)
        { // MODIFY
            Project ProjectToModify = null;
            bool    validresult     = false;
            string  modifyProjectOut;
            FakeProjectRepository projects = new FakeProjectRepository();

            using (FormSelectProject SelectProjectForm = new FormSelectProject())
            {
                do
                {
                    SelectProjectForm.ShowDialog();
                    if (SelectProjectForm.DialogResult == DialogResult.OK)
                    {
                        if (SelectProjectForm.SelectedProject == currentProject)
                        {
                            MessageBox.Show("Cannot modify your current session project.", "Attention");
                        }
                        else
                        {
                            ProjectToModify = SelectProjectForm.SelectedProject;
                            validresult     = true;
                        }
                    }
                    else if (SelectProjectForm.DialogResult == DialogResult.Cancel)
                    {
                        validresult = true;
                    }
                } while (!validresult);
            }

            if (ProjectToModify != null)
            {
                using (FormModifyProject ModifyProjectForm = new FormModifyProject())
                {
                    validresult = false;
                    do
                    {
                        ModifyProjectForm.ProjectsNewName = ProjectToModify.Name;
                        if (ModifyProjectForm.ShowDialog() == DialogResult.OK)
                        {
                            Project ModifiedProject = new Project
                            {
                                Name = ModifyProjectForm.ProjectsNewName,
                                Id   = ProjectToModify.Id
                            };
                            modifyProjectOut = projects.Modify(ProjectToModify.Id, ModifiedProject);

                            if (modifyProjectOut != "")
                            {
                                MessageBox.Show(modifyProjectOut);
                            }
                            else
                            {
                                validresult = true;
                            }
                        }
                        else if (ModifyProjectForm.DialogResult == DialogResult.Cancel)
                        {
                            validresult = true;
                        }
                    } while (!validresult);
                }
            }
        }