private void AddSolutionButton_Click(object sender, System.EventArgs e) { if (problemPickBox.Text == "") { MessageBox.Show("Choose a problem!"); return; } if (languagePickBox.Text == "") { MessageBox.Show("Choose a language!"); return; } int id = sourceForm.Sdao.GetNextSolutionId(); int pid = Problem.Parse(problemPickBox.Text).Id; string lang = languagePickBox.Text; string content = contentBox.Text.Replace("\r\n", "\n"); sourceForm.Sdao.AddSolution(new Solution(id, pid, lang, content)); DialogResult dr = MessageBox.Show("Addition successful!"); sourceForm.AddStatus(string.Format("Successfully added solution #{0}.", id)); if (dr == DialogResult.OK) { this.Close(); } }
private void AddProblemButton_Click(object sender, EventArgs e) { int id = sourceForm.Pdao.GetNextProblemId(); string name; float ptl, pml; try { name = this.pnameBox.Text; ptl = float.Parse(this.ptlBox.Text); pml = float.Parse(this.pmlBox.Text); sourceForm.Pdao.AddProblem(new Problem(id, name, ptl, pml)); } catch (Exception exc) { MessageBox.Show(exc.Message); return; } DialogResult dr = MessageBox.Show("Addition successful!"); sourceForm.AddStatus(String.Format("Successfully added problem {0}.", name)); sourceForm.InitializeSolution_ProPicker(); if (dr == DialogResult.OK) { this.Close(); } }