Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!File.Exists(adminaddress + textBox3.Text))
            {
                MessageBox.Show("Invalid Username/Password");
            }

            else
            {
                FileStream      fs = new FileStream(adminaddress + textBox3.Text, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                BinaryFormatter b  = new BinaryFormatter();
                tc = (TeacherData)b.Deserialize(fs);
                fs.Close();
                if (textBox1.Text == tc.Password)
                {
                    process();

                    WelcomeO wc = new WelcomeO();
                    this.Hide();
                    wc.Show();
                    textBox1.Text = "";
                    textBox1.Text = "";
                }
                else
                {
                    MessageBox.Show("Invalid Username/Password");
                }
            }
        }
Beispiel #2
0
        private void ViewRecordsTeacher_Load(object sender, EventArgs e)
        {
            string[] id = { "kindergarten", "grade1", "grade2", "grade3", "grade4", "grade5", "grade6", "headteacher" };

            for (int i = 7; i >= 0; i--)
            {
                //MessageBox.Show(id[i]);
                if (File.Exists("c:/Confidential/GESMIS/Teacher/" + id[i]))
                {
                    FileStream      fs = new FileStream("c:/Confidential/GESMIS/Teacher/" + id[i], FileMode.Open, FileAccess.Read);
                    BinaryFormatter b  = new BinaryFormatter();
                    st = (TeacherData)b.Deserialize(fs);
                    fs.Close();

                    string[] row0 = { st.Username, st.Name, st.Teachingfield, st.Gender, st.Address, st.Contact };
                    dataGridView1.Rows.Add(row0);
                }
            }
        }
Beispiel #3
0
 private void button9_Click(object sender, EventArgs e)
 {
     if (!File.Exists(adminaddress + Teacher_Username.Text))
     {
         MessageBox.Show("Sorry Invalid Id...!!!");
         button8.PerformClick();
     }
     else
     {
         try
         {
             FileStream      fs = new FileStream(adminaddress + Teacher_Username.Text, FileMode.OpenOrCreate, FileAccess.ReadWrite);
             BinaryFormatter b  = new BinaryFormatter();
             tc = (TeacherData)b.Deserialize(fs);
             fs.Close();
             Teacher_Username.Text = tc.Username;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Beispiel #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            tc          = new TeacherData();
            tc.Username = TeacherUsername.Text;
            tc.Password = TeacherPassword.Text;



            if (!Directory.Exists(adminaddress))
            {
                Directory.CreateDirectory(adminaddress);
            }
            try
            {
                if (File.Exists(adminaddress + tc.Username))
                {
                    MessageBox.Show("This Id  Is Already Exist...Sorry");
                }
                else if (TeacherUsername.Text == "")
                {
                    MessageBox.Show("Teacher Id Can Not Be Empty..!!!");
                }
                else
                {
                    FileStream      fs = new FileStream(adminaddress + tc.Username, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                    BinaryFormatter b  = new BinaryFormatter();
                    b.Serialize(fs, tc);
                    fs.Close();
                    MessageBox.Show("Teacher Has Been Added Successfully... Thank You...!!!");
                    button2.PerformClick();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public WelcomeO()
        {
            InitializeComponent();

            us = new UserData();
            tc = new TeacherData();
            try
            {
                FileStream      fs = new FileStream(useraddress + "USER", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                BinaryFormatter b  = new BinaryFormatter();
                us = (UserData)b.Deserialize(fs);
                fs.Close();
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.Message);
            }



            try
            {
                FileStream      fs1 = new FileStream(adminaddress + us.username, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                BinaryFormatter b1  = new BinaryFormatter();
                tc = (TeacherData)b1.Deserialize(fs1);
                fs1.Close();
            }

            catch (Exception exe)
            {
                MessageBox.Show(exe.Message);
            }


            switch (us.username)
            {
            case "grade6":
                groupBox1.Text           = "Account: Grade 6";
                label3.Text              = "View Records\n   (Grade 6)";
                TeacherProfilePic1.Image = tc.pic;
                label5.Text              = tc.Name;
                break;

            case "grade5":
                groupBox1.Text           = "Account: Grade 5";
                label3.Text              = "View Records\n   (Grade 5)";
                TeacherProfilePic1.Image = tc.pic;
                label5.Text              = tc.Name;
                break;

            case "grade4":
                groupBox1.Text           = "Account: Grade 4";
                label3.Text              = "View Records\n   (Grade 4)";
                TeacherProfilePic1.Image = tc.pic;
                label5.Text              = tc.Name;
                break;

            case "grade3":
                groupBox1.Text           = "Account: Grade 3";
                label3.Text              = "View Records\n   (Grade 3)";
                TeacherProfilePic1.Image = tc.pic;
                label5.Text              = tc.Name;
                break;

            case "grade2":
                groupBox1.Text           = "Account: Grade 2";
                label3.Text              = "View Records\n   (Grade 2)";
                TeacherProfilePic1.Image = tc.pic;
                label5.Text              = tc.Name;
                break;

            case "grade1":
                groupBox1.Text           = "Account: Grade 1";
                label3.Text              = "View Records\n   (Grade 1)";
                TeacherProfilePic1.Image = tc.pic;
                label5.Text              = tc.Name;
                break;

            case "kindergarten":
                groupBox1.Text           = "Account: Kindergarten";
                label3.Text              = "View Records\n(Kindergarten)";
                TeacherProfilePic1.Image = tc.pic;
                label5.Text              = tc.Name;
                break;
            }
        }