Example #1
0
        public StudentVolunteerArrayList getStudentVolunteerDetails(string usrn)
        {
            //  StudentVolunteerList[] stdVoluList=null;
            StudentVolunteerArrayList stdVoluList = new StudentVolunteerArrayList(); ;
            stdVoluList.VolunteerList = new List<StudentVolunteerList>();
            int count = 0;
            try
            {
                Debug.Write("@@@@@@@@@@@Testing student Volunteers");
                SqlConnection sqlConnection1 = new SqlConnection(ConfigurationManager.ConnectionStrings["pickdb"].ConnectionString);
                SqlCommand cmd = new SqlCommand();
                SqlDataReader reader;

                cmd.CommandText = "SELECT * FROM Volunteer";
                cmd.CommandType = CommandType.Text;
                cmd.Connection = sqlConnection1;

                sqlConnection1.Open();

                SqlCommand getCount = new SqlCommand("Select count(*) from Volunteer", sqlConnection1);
                count = Convert.ToInt16(getCount.ExecuteScalar().ToString());
                reader = cmd.ExecuteReader();
                // Data is accessible through the DataReader object here.
                if (reader.HasRows == true)
                {

                    int i = 0;
                    while (reader.Read())
                    {
                        StudentVolunteerList VList = new StudentVolunteerList();
                        VList.studentList = new List<VStudents>();
                        VStudents Vrecord = new VStudents();
                     //   stdVoluList[i].studentList = new List<VStudents>();

                        Vrecord.userName = reader.GetString(0);
                        Vrecord.fName = reader.GetString(2);
                        Vrecord.lName = reader.GetString(3);
                       // String.Format("{0:f}", dt);
                        VList.studentList.Add(Vrecord);

                        StudentVolunteerList sList = getVolStudentDetails(Vrecord.userName);
                        VList.studentList.AddRange(sList.studentList);

                        stdVoluList.VolunteerList.Add(VList);
                        i++;
                    }
                    reader.Close();
                    sqlConnection1.Close();
                }
                else {
                    stdVoluList.VolunteerList.DefaultIfEmpty();
                }
            }
            catch (Exception e)
            {
                e.GetBaseException();
            }

            return stdVoluList;
        }
Example #2
0
        public StudentVolunteerArrayList getStudentVolunteerDetails(string usrn)
        {
            //  StudentVolunteerList[] stdVoluList=null;
            StudentVolunteerArrayList stdVoluList = new StudentVolunteerArrayList();;

            stdVoluList.VolunteerList = new List <StudentVolunteerList>();
            int count = 0;

            try
            {
                Debug.Write("@@@@@@@@@@@Testing student Volunteers");
                SqlConnection sqlConnection1 = new SqlConnection(ConfigurationManager.ConnectionStrings["pickdb"].ConnectionString);
                SqlCommand    cmd            = new SqlCommand();
                SqlDataReader reader;


                cmd.CommandText = "SELECT * FROM Volunteer";
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = sqlConnection1;

                sqlConnection1.Open();

                SqlCommand getCount = new SqlCommand("Select count(*) from Volunteer", sqlConnection1);
                count  = Convert.ToInt16(getCount.ExecuteScalar().ToString());
                reader = cmd.ExecuteReader();
                // Data is accessible through the DataReader object here.
                if (reader.HasRows == true)
                {
                    int i = 0;
                    while (reader.Read())
                    {
                        StudentVolunteerList VList = new StudentVolunteerList();
                        VList.studentList = new List <VStudents>();
                        VStudents Vrecord = new VStudents();
                        //   stdVoluList[i].studentList = new List<VStudents>();

                        Vrecord.userName = reader.GetString(0);
                        Vrecord.fName    = reader.GetString(2);
                        Vrecord.lName    = reader.GetString(3);
                        // String.Format("{0:f}", dt);
                        VList.studentList.Add(Vrecord);

                        StudentVolunteerList sList = getVolStudentDetails(Vrecord.userName);
                        VList.studentList.AddRange(sList.studentList);

                        stdVoluList.VolunteerList.Add(VList);
                        i++;
                    }
                    reader.Close();
                    sqlConnection1.Close();
                }
                else
                {
                    stdVoluList.VolunteerList.DefaultIfEmpty();
                }
            }
            catch (Exception e)
            {
                e.GetBaseException();
            }

            return(stdVoluList);
        }