public List <Models.StudentWithDepartmentName> GetStudentWithDepartmentName()
        {
            Qurey   = "SELECT * FROM studentWithDepartmentName";
            Command = new SqlCommand(Qurey, Connection);
            List <StudentWithDepartmentName> studentsWithDepartment = new List <StudentWithDepartmentName>();

            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                StudentWithDepartmentName student = new Models.StudentWithDepartmentName();
                student.StudentId = Convert.ToInt32(Reader["id"]);
                student.Name      = Reader["name"].ToString();
                student.RegNo     = Reader["registrationNo"].ToString();
                student.Email     = Reader["email"].ToString();
                student.Contact   = Reader["contactNo"].ToString();
                student.Address   = Reader["address"].ToString();
                DateTime dateTime = Convert.ToDateTime(Reader["date"]);
                student.Date           = dateTime.ToShortDateString();
                student.DepartmentId   = Convert.ToInt32(Reader["departmentId"]);
                student.DepartmentName = Reader["departmentName"].ToString();
                student.DepartmentCode = Reader["code"].ToString();

                studentsWithDepartment.Add(student);
            }
            Reader.Close();
            Connection.Close();

            return(studentsWithDepartment);
        }
        public Models.StudentWithDepartmentName GetStudentByEmail(string email)
        {
            Qurey   = "SELECT * FROM studentWithDepartmentName WHERE email = @email";
            Command = new SqlCommand(Qurey, Connection);
            Command.Parameters.AddWithValue("@email", email);
            Models.StudentWithDepartmentName student = null;

            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                student         = new Models.StudentWithDepartmentName();
                student.Name    = Reader["name"].ToString();
                student.RegNo   = Reader["registrationNo"].ToString();
                student.Email   = Reader["email"].ToString();
                student.Contact = Reader["contactNo"].ToString();
                student.Address = Reader["address"].ToString();
                DateTime dateTime = Convert.ToDateTime(Reader["date"]);
                student.Date           = dateTime.ToShortDateString();
                student.DepartmentName = Reader["departmentName"].ToString();
            }
            Reader.Close();
            Connection.Close();

            return(student);
        }