private void studentInfoSubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            SmsData.StudentInfo newStudent = new SmsData.StudentInfo();

            newStudent.id = GenerateId();
            newStudent.name = studentNameTxtbox.Text;
            newStudent.gurdain = GuardianNameTxtbox.Text;
            newStudent.address = addressTxtbox.Text;
            newStudent.phone = phoneNoTxtbox.Text;
            newStudent.dob = dobDatepicker.SelectedDate.Value;
            newStudent.blodGroup = bloodGroupTxtbox.Text;
            newStudent.joinClass = joinClassTxtbox.Text;
            newStudent.schoolFrom = schoolFromTxtbox.Text;
            newStudent.joinDate = joinDatePicker.SelectedDate.Value;

            SmsDb.DbInteraction.RegisterNewStudent(newStudent);
        }
        private void studentInfoSubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            SmsData.StudentInfo newStudent = new SmsData.StudentInfo();

            newStudent.id         = GenerateId();
            newStudent.name       = studentNameTxtbox.Text;
            newStudent.gurdain    = GuardianNameTxtbox.Text;
            newStudent.address    = addressTxtbox.Text;
            newStudent.phone      = phoneNoTxtbox.Text;
            newStudent.dob        = dobDatepicker.SelectedDate.Value;
            newStudent.blodGroup  = bloodGroupTxtbox.Text;
            newStudent.joinClass  = joinClassTxtbox.Text;
            newStudent.schoolFrom = schoolFromTxtbox.Text;
            newStudent.joinDate   = joinDatePicker.SelectedDate.Value;



            SmsDb.DbInteraction.RegisterNewStudent(newStudent);
        }
        private static List<StudentInfo> QueryAllStudentList()
        {
            List<StudentInfo> StudentList = new List<StudentInfo>();

            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From student ;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    StudentInfo Student = new StudentInfo();

                    Student.id = msqlReader.GetString("id");
                    Student.name = msqlReader.GetString("name");
                    Student.gurdain = msqlReader.GetString("guardian");
                    Student.address = msqlReader.GetString("address");
                    Student.phone = msqlReader.GetString("phone");
                    Student.dob = msqlReader.GetDateTime("dob");
                    Student.blodGroup = msqlReader.GetString("bloodGroup");
                    Student.joinClass = msqlReader.GetString("joinClass");
                    Student.schoolFrom = msqlReader.GetString("schoolFrom");
                    Student.joinDate = msqlReader.GetDateTime("joinDate");

                    StudentList.Add(Student);
                }

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return StudentList;
        }
        public static int RegisterNewStudent(StudentInfo NewStudent)
        {
            int returnVal = 0;
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();

                //define the connection used by the command object
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "INSERT INTO student(id,name,guardian,address,phone,dob,bloodGroup,joinClass,schoolFrom,joinDate) " +
                                    "VALUES(@id,@name,@guardian,@address,@phone,@dob,@bloodGroup,@joinClass,@schoolFrom,@joinDate)";

                msqlCommand.Parameters.AddWithValue("@id", NewStudent.id);
                msqlCommand.Parameters.AddWithValue("@name", NewStudent.name);
                msqlCommand.Parameters.AddWithValue("@guardian", NewStudent.gurdain);
                msqlCommand.Parameters.AddWithValue("@address", NewStudent.address);
                msqlCommand.Parameters.AddWithValue("@phone", NewStudent.phone);
                msqlCommand.Parameters.AddWithValue("@dob", NewStudent.dob);
                msqlCommand.Parameters.AddWithValue("@bloodGroup", NewStudent.blodGroup);
                msqlCommand.Parameters.AddWithValue("@joinClass", NewStudent.joinClass);
                msqlCommand.Parameters.AddWithValue("@schoolFrom", NewStudent.schoolFrom);
                msqlCommand.Parameters.AddWithValue("@joinDate", NewStudent.joinDate);

                msqlCommand.ExecuteNonQuery();

                returnVal = 1;
            }
            catch (Exception er)
            {
                returnVal = 0;
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
            return returnVal;
        }