/// <summary> /// Returneaza lista de probleme /// </summary> /// <param name="save">Adevarat daca se salveaza problema</param> /// <returns></returns> private CustomListViewItem<Problema> GetProblemaListView(bool save) { int id; if (save) { if (Res.Instance.SelectedProblema == null) return null; id = Res.Instance.SelectedProblema.Id; } else id = Res.Instance.GetNextAvailableProblemaId(); if (comboBoxTipProblema.Text.Equals("<nespecificat>") || comboBoxTipProblema.Text.Length == 0) { errorProvider.SetError(comboBoxTipProblema, Messages.TYPE_UNSPECIFIED); return null; } errorProvider.SetError(comboBoxTipProblema, ""); if (txtTitluProblema.Text.Length == 0) { errorProvider.SetError(txtTitluProblema, Messages.TITLE_UNSPECIFIED); return null; } errorProvider.SetError(txtTitluProblema, ""); ValidateTextBoxText(txtCuvinteCheieProblema, false); int difficulty; int.TryParse(comboBoxDificultateProblema.Text, out difficulty); if (difficulty < 1 || difficulty > 3) { errorProvider.SetError(comboBoxDificultateProblema, Messages.INCORRECT_VALUE); return null; } errorProvider.SetError(comboBoxDificultateProblema, ""); Problema newProblema = new Problema(id, comboBoxTipProblema.Text, txtTitluProblema.Text, txtCerintaProblema.Text, difficulty, txtCuvinteCheieProblema.Text, Config.ProblemePath); return new CustomListViewItem<Problema>(newProblema.Titlu, newProblema); }
/// <summary> /// Sterge toate referintele referitoare la problema specificata /// </summary> public void RemoveProblema(Problema problema) { if (problema == null) return; ContinutHandler.Instance.ProblemeContinut.Add(new ContinutUpdate<Problema> (SelectedProblema, ContinutUpdateType.DELETE)); IdsProbleme.Remove(problema.Id); ListaProbleme.Remove(problema); }