Exemple #1
0
        private void b_button_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.StreamReader str = new
                                             System.IO.StreamReader(openFileDialog1.FileName);
                str.Close();
            }

            FileWritingAndReading f = new FileWritingAndReading();

            List <Student> students = new List <Student>();

            string courseName = openFileDialog1.FileName; //Can't do this at startup... User must be able to upload a specific file.

            //Use a menuStrip, and add a "Load" button. Be able to select a file. However... find a way to preserve each student's data
            string[] info = new string[] { "Last Name", "First Name", "Student Number", "Parent e-mail" };

            int[] indices = f.findIndices(courseName, info);

            string[][] data = f.readSomeData(courseName);

            for (int i = 1; i < data.Length; i++)
            {
                Student stu = new Student(new string[] { data[i][indices[0]], data[i][indices[1]], data[i][indices[2]], data[i][indices[3]] });
                students.Add(stu);
            }


            c = new Classes(courseName, students);
        }
Exemple #2
0
        private void b_button_Click(object sender, EventArgs e)
        {
            string data3 = "";
            bool   boo1  = false;

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.StreamReader str = new
                                             System.IO.StreamReader(openFileDialog1.FileName);
                str.Close();
            }


            FileWritingAndReading f = new FileWritingAndReading(); //this needs to be declared before it's used you stupid!

            string[] allData = f.readAllData(openFileDialog1.FileName);

            CourseCode CC = new CourseCode(data3);

            if (CC.ShowDialog() == DialogResult.OK)
            {
                data3 = CC.t_course.Text;
                foreach (string s in allData)
                {
                    if (s.Contains(data3))
                    {
                        boo1 = true;
                    }
                }

                if (boo1 == true)
                {
                    string[] courseData = new string[allData.Length];
                    int      counters   = 0;

                    foreach (string s in allData)
                    {
                        if (s.Contains(data3))
                        {
                            courseData[counters] = s;

                            counters += 1;
                        }
                    }

                    f.writeAllDataToFile(CC.t_course.Text, courseData);



                    List <Student> students = new List <Student>();

                    string courseName = CC.t_course.Text; //Can't do this at startup... User must be able to upload a specific file.
                                                          //Use a menuStrip, and add a "Load" button. Be able to select a file. However... find a way to preserve each student's data
                    string[] info = new string[] { "Last Name", "First Name", "Student Number", "Parent e-mail" };

                    int[] indices = f.findIndices(courseName, info);

                    string[][] data = f.readSomeData(courseName);

                    for (int i = 1; i < data.Length; i++)
                    {
                        Student stu = new Student(new string[] { data[i][indices[0]], data[i][indices[1]], data[i][indices[2]], data[i][indices[3]] });
                        students.Add(stu);
                    }


                    c = new Classes(courseName, students);
                }
                else
                {
                    MessageBox.Show("Your course code was invalid, please restart the program and try again");
                }
            }
            else
            {
                MessageBox.Show("Your course code was invalid, please restart the program and try again");
            }
        }