private void MainForm_Load(object sender, EventArgs e) { CenterToScreen(); string username = Properties.Settings.Default.Username; string project = Properties.Settings.Default.Preference; FakePreferenceRepository pref = new FakePreferenceRepository(); string preference = pref.GetPreference(username, project); string title = pref.GetPreference(username, preference); this.Text = "Main - " + project; }
private void ModifyProjectModifyButton_Click(object sender, EventArgs e) { string newName = ModifyProjectTextBox.Text; string oldName = Properties.Settings.Default.Preference; string UserName = Properties.Settings.Default.Username; FakePreferenceRepository preferenceRepository = new FakePreferenceRepository(); string pref = preferenceRepository.GetPreference(UserName, oldName); FakeProjectRepository projectRepository = new FakeProjectRepository(); //string newName = ModifyProjectTextBox.Text; string result = projectRepository.Modify(idToBeModified, new Project { Name = newName }); if (result != FakePreferenceRepository.NO_ERROR) { MessageBox.Show("Error modifying project. " + result); } else { MessageBox.Show("Successfully modified project"); } this.Close(); }
private void buttonSelectProject_Click(object sender, EventArgs e) { if (listBox1.SelectedItem == null) { MessageBox.Show("Must select a project to continue"); } else { if (whoCalledTheMethod == "Modify") { string selectedItem = listBox1.SelectedItem.ToString(); string result = selectedItem.Substring(4, selectedItem.Length - 4); string Username = Properties.Settings.Default.Username; FakePreferenceRepository preference = new FakePreferenceRepository(); string pref = preference.GetPreference(Username, result); if (result == Properties.Settings.Default.Preference) { MessageBox.Show("Cannot modify your current session project."); this.Hide(); this.Close(); } else { char idInCharacterForm = selectedItem[0]; int selectedId = idInCharacterForm - '0'; this.Hide(); ModifyProject modifyProject = new ModifyProject(selectedId); modifyProject.Show(); this.Close(); } } else if (whoCalledTheMethod == "Main" || whoCalledTheMethod == "Login") { string selectedItem = listBox1.SelectedItem.ToString(); string result = selectedItem.Substring(4, selectedItem.Length - 4); Properties.Settings.Default.Preference = result; string preference = Properties.Settings.Default.Preference; char idInCharacterForm = selectedItem[0]; string UserName = Properties.Settings.Default.Username; FakePreferenceRepository preferenceRepository = new FakePreferenceRepository(); preferenceRepository.SetPreference(UserName, result, Char.ToString(selectedItem[0])); FakePreferenceRepository pref = new FakePreferenceRepository(); pref.GetPreference(UserName, result); this.Hide(); MainForm main = new MainForm(); main.Show(); this.Close(); } else if (whoCalledTheMethod == "Remove") { string selectedItem = listBox1.SelectedItem.ToString(); string result = selectedItem.Substring(4, selectedItem.Length - 4); if (result == Properties.Settings.Default.Preference) { MessageBox.Show("Cannot remove your current session project."); this.Hide(); this.Close(); } else { char idInCharacterForm = selectedItem[0]; int selectedId = idInCharacterForm - '0'; this.Hide(); RemoveProject removeProject = new RemoveProject(selectedId); removeProject.Show(); this.Close(); } } } }