private void CreateIssueButton_Click(object sender, EventArgs e) { int newissueId = 1; foreach (Issue issueId in issueRepository.GetAll(_SelectedProjectId)) { if (issueId.Id > newissueId) { newissueId = issueId.Id; } } newissueId++; Issue issue = new Issue(); issue.Id = newissueId; issue.Title = textBoxtitle.Text.Trim(); issue.DiscoveryDate = DateTime.Parse(dateTimediscovery.Text); issue.Discoverer = comboBoxdiscoverer.Text; issue.InitialDescription = textBoxdescription.Text; issue.Component = textBoxcomponent.Text; issue.IssueStatusId = issueStatusRepository.GetIdByStatus(comboBoxstatus.Text); FakePreferenceRepository preferenceRepository = new FakePreferenceRepository(); _SelectedProjectId = Convert.ToInt32(preferenceRepository.GetPreference(_CurrentAppUser.UserName, FakePreferenceRepository.PREFERENCE_PROJECT_ID)); issue.ProjectId = _SelectedProjectId; string result = issueRepository.Add(issue); if (result == FakeIssueRepository.NO_ERROR) { MessageBox.Show("Issue added successfully."); } else { MessageBox.Show("Issue not created. " + result, "Attention."); } this.Close(); }
private string selectAProject() { string selectedProject = ""; FormSelectProject form = new FormSelectProject(); form.ShowDialog(); if (form.DialogResult == DialogResult.OK) { FakePreferenceRepository preferenceRepository = new FakePreferenceRepository(); preferenceRepository.SetPreference(_CurrentAppUser.UserName, FakePreferenceRepository.PREFERENCE_PROJECT_NAME, form._SelectedProjectName); int selectedProjectId = form._SelectedProjectId; preferenceRepository.SetPreference(_CurrentAppUser.UserName, FakePreferenceRepository.PREFERENCE_PROJECT_ID, selectedProjectId.ToString()); this.Text = "Main - " + form._SelectedProjectName; selectedProject = form._SelectedProjectName; } form.Dispose(); return(selectedProject); }
private void ModifyProject_Load(object sender, EventArgs e) { this.CenterToScreen(); FormSelectProject form = new FormSelectProject(); form.ShowDialog(); if (form.DialogResult != DialogResult.OK) { MessageBox.Show("No project selected.", "Attention"); Close(); } _SelectedProjectId = form._SelectedProjectId; FakePreferenceRepository preferenceRepository = new FakePreferenceRepository(); string preferredProjectId = preferenceRepository.GetPreference(_CurrentAppUser.UserName, FakePreferenceRepository.PREFERENCE_PROJECT_ID); if (_SelectedProjectId.ToString() == preferredProjectId) { MessageBox.Show("Cannot modify your current session project.", "Attention"); Close(); } textBoxProjectName.Text = form._SelectedProjectName; }