public void AddTutor(Tutor t) { p_tutors.Add(t); }
private void btnOk_Click(object sender, EventArgs e) { try { if (tbFIO.Text == "" || dgv.RowCount == 1) { throw new Exception("Ошибка ввода"); } Tutor[] arrT = new Tutor[dgv.RowCount - 1]; for (int i = 0; i < dgv.RowCount - 1; i++) { arrT[i] = new Tutor(dgv[0, i].Value.ToString(), double.Parse(dgv[1, i].Value.ToString())); } C_EAnswer a = new C_EAnswer(tbFIO.Text, tbG.Text, tbQ.Text, tbE.Text, tbAns.Text, arrT); a.Save(string.Format("{0}\\{1}.xml", folderBrowserDialog1.SelectedPath, tbFIO.Text)); if (Properties.Settings.Default.Tutors != null) { Properties.Settings.Default.Tutors.Clear(); } else { Properties.Settings.Default.Tutors = new System.Collections.Specialized.StringCollection(); } tbFIO.Text = tbAns.Text = ""; if (!cbG.Checked) { tbG.Text = Properties.Settings.Default.Group = ""; } else { Properties.Settings.Default.Group = tbG.Text; } if (!cbQ.Checked) { tbQ.Text = Properties.Settings.Default.Question = ""; } else { Properties.Settings.Default.Question = tbQ.Text; } if (!cbE.Checked) { tbE.Text = Properties.Settings.Default.Etalon = ""; } else { Properties.Settings.Default.Etalon = tbE.Text; } if (!cbT.Checked) { dgv.Rows.Clear(); Properties.Settings.Default.Tutors = null; } else { Properties.Settings.Default.Tutors = new System.Collections.Specialized.StringCollection(); for (int i = 0; i < dgv.RowCount - 1; i++) { Properties.Settings.Default.Tutors.Add(dgv[0, i].Value.ToString()); dgv[1, i].Value = 0; } } this.ActiveControl = tbFIO; } catch (Exception ex) { MessageBox.Show(ex.Message); } }