示例#1
0
        void LoadTheStudentFile()
        {
            MessageBox.Show("Welcome to IHCC", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
            try
            {
                if (File.Exists("studentList.ser"))
                {
                    FileStream      inFile = new FileStream("studentList.ser", FileMode.Open, FileAccess.Read);
                    BinaryFormatter bf     = new BinaryFormatter();


                    while (inFile.Position < inFile.Length)
                    {
                        CurrentStudent inventory = (CurrentStudent)bf.Deserialize(inFile);
                        stuList.Add(inventory);
                    }

                    inFile.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        void SerializeOrders()
        {
            if (rad_commuter.Checked)
            {
                CurrentStudent inventory = new CurrentStudent(txt_studentName.Text, int.Parse(txt_studentID.Text));
                stuList.Add(inventory);
            }
            else
            {
                char dorm;

                if (rad_oak.Checked)
                {
                    dorm = 'O';
                }
                else if (rad_Trustee.Checked)
                {
                    dorm = 'T';
                }
                else if (rad_Wapello.Checked)
                {
                    dorm = 'W';
                }

                else if (rad_Appanoose.Checked)
                {
                    dorm = 'A';
                }
                else
                {
                    dorm = 'M';
                }

                char meals;

                if (rad_basic.Checked)

                {
                    meals = 'B';
                }
                else if (rad_medium.Checked)
                {
                    meals = 'M';
                }
                else
                {
                    meals = 'H';
                }

                //instantiate your dorm student after youve collected all the parts needed to make a whole object

                DormStudent inventory = new DormStudent(txt_studentName.Text, int.Parse(txt_studentID.Text), dorm, meals);
                stuList.Add(inventory);
            }
        }
示例#3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //authList[listStudents.SelectedIndex].AuthBooks.Clear();            //either remove the books from the selected author, OR
            StudentAssignments[listStudents.SelectedIndex].AssignGrades = new List <CurrentStudent>();   //allocate a new book list for that author

            foreach (DataGridViewRow dr in dgvStudents.Rows)
            {
                if (dr.Cells[0].Value != null)  //to avoid processing past the last datagridview row
                {
                    string         t = dr.Cells[0].Value.ToString();
                    int            n = Convert.ToInt32(dr.Cells[1].Value);
                    double         p = Convert.ToDouble(dr.Cells[2].Value);
                    CurrentStudent b = new CurrentStudent(t, n);

                    StudentAssignments[listStudents.SelectedIndex].AssignGrades.Add(b);
                }
            }
        }