コード例 #1
0
ファイル: AuthService.svc.cs プロジェクト: atmc9/PickMeUp
//@@@@@@@@@@@@
        public StudentVolunteerList getVolStudentDetails(string usrn)
        {
            StudentVolunteerList studentRecords = new StudentVolunteerList();

            studentRecords.studentList = new List <VStudents>();
            int count = 0;

            try
            {
                //connectionString = ConfigurationManager.ConnectionStrings
                System.Diagnostics.Debug.Write("testing username");
                SqlConnection sqlConnection1 = new SqlConnection(ConfigurationManager.ConnectionStrings["pickdb"].ConnectionString);
                SqlCommand    cmd            = new SqlCommand();
                SqlDataReader reader;


                cmd.CommandText = "SELECT * FROM student where Volunteerid ='" + usrn + "' ";
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = sqlConnection1;

                sqlConnection1.Open();

                SqlCommand getCount = new SqlCommand("Select count(studentid) from student", sqlConnection1);

                count = Convert.ToInt16(getCount.ExecuteScalar().ToString());

                VStudents[] records = new VStudents[count];
                reader = cmd.ExecuteReader();

                // Data is accessible through the DataReader object here.
                int i = 0;
                while (reader.Read())
                {
                    records[i]             = new VStudents();
                    records[i].fName       = reader.GetString(2);
                    records[i].lName       = reader.GetString(3);
                    records[i].userName    = reader.GetString(0);
                    records[i].arrivalTime = String.Format("{0:G}", reader.GetDateTime(6));;

                    studentRecords.studentList.Add(records[i]);
                    i++;
                }
                reader.Close();
                sqlConnection1.Close();
            }
            catch (Exception e)
            {
                e.GetBaseException();
            }

            return(studentRecords);
        }
コード例 #2
0
ファイル: AuthService.svc.cs プロジェクト: atmc9/PickMeUp
        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;
        }
コード例 #3
0
ファイル: AuthService.svc.cs プロジェクト: atmc9/PickMeUp
        //@@@@@@@@@@@@
        public StudentVolunteerList getVolStudentDetails(string usrn)
        {
            StudentVolunteerList studentRecords = new StudentVolunteerList();
             studentRecords.studentList = new List<VStudents>();
             int count = 0;
             try
             {
                 //connectionString = ConfigurationManager.ConnectionStrings
                 System.Diagnostics.Debug.Write("testing username");
                 SqlConnection sqlConnection1 = new SqlConnection(ConfigurationManager.ConnectionStrings["pickdb"].ConnectionString);
                 SqlCommand cmd = new SqlCommand();
                 SqlDataReader reader;

                 cmd.CommandText = "SELECT * FROM student where Volunteerid ='" + usrn + "' ";
                 cmd.CommandType = CommandType.Text;
                 cmd.Connection = sqlConnection1;

                 sqlConnection1.Open();

                 SqlCommand getCount = new SqlCommand("Select count(studentid) from student", sqlConnection1);

                 count = Convert.ToInt16(getCount.ExecuteScalar().ToString());

                 VStudents[] records = new VStudents[count];
                 reader = cmd.ExecuteReader();

                 // Data is accessible through the DataReader object here.
                 int i = 0;
                 while (reader.Read())
                 {

                     records[i] = new VStudents();
                     records[i].fName = reader.GetString(2);
                     records[i].lName = reader.GetString(3);
                     records[i].userName = reader.GetString(0);
                     records[i].arrivalTime = String.Format("{0:G}", reader.GetDateTime(6)); ;

                     studentRecords.studentList.Add(records[i]);
                     i++;
                 }
                 reader.Close();
                 sqlConnection1.Close();
             }
             catch (Exception e)
             {
                 e.GetBaseException();
             }

             return studentRecords;
        }
コード例 #4
0
ファイル: AuthService.svc.cs プロジェクト: atmc9/PickMeUp
        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);
        }