private void LoadStudent(Student s) { cbName.Text = s.Name; cbCourse.Text = s.Course; cbYear.Text = s.Year.ToString(); cbTerm.Text = s.Term; txtGrade.Text = s.GradeValue.ToString(); }
private void btnSave_Click(object sender, EventArgs e) { var student = new Student(cbName.Text, cbCourse.Text, Convert.ToInt16(cbYear.Text), cbTerm.Text, Convert.ToDouble(txtGrade.Text)); if (editIndex == -1) ParentFrm.AddStudent(student); else ParentFrm.EditStudent(student, editIndex); Close(); }
public void LoadFromTxt(string path = @"StudGradesDB.txt") { var textDB = File.ReadAllText(path).Trim().Split('\n'); foreach (var line in textDB) { var ls = line.Replace("\r", string.Empty).Split('|'); var s = new Student { Name = ls[0], Course = ls[1], Year = Convert.ToInt16(ls[2]), Term = ls[3], GradeValue = Convert.ToDouble(ls[4]) }; AddStudent(s); } }
public void EditStudent(Student s, int i) { students[i] = s; RefreshStudentList(); SaveToText(); }
public void AddStudent(Student s) { students.Add(s); RefreshStudentList(); SaveToText(); }