public List <ITutor> selectfromApptutor()
        {
            List <ITutor> tutorlist = new List <ITutor>();

            com.CommandText = "SELECT * FROM ApplicantTutor";
            SqlDataReader reader;

            try
            {
                con.Open();
                com.Connection = con;
                reader         = com.ExecuteReader();
                while (reader.Read())
                {
                    ITutor t = new Tutor();
                    t.id           = Convert.ToInt16(reader["requestnum"]);
                    t.name         = reader["name"].ToString();
                    t.age          = Convert.ToInt16(reader["age"]);
                    t.exp          = Convert.ToInt16(reader["exp"]);
                    t.g            = Convert.ToChar(reader["gender"]);
                    t.fee          = Convert.ToInt16(reader["fee"]);
                    t.alma         = reader["almamater"].ToString();
                    t.eid          = reader["eid"].ToString();
                    t.mob          = reader["mob"].ToString();
                    t.type         = reader["type"].ToString();
                    t.tlat         = Convert.ToDouble(reader["lat"]);
                    t.tlong        = Convert.ToDouble(reader["lon"]);
                    t.pass         = reader["pass"].ToString();
                    t.teachingstr1 = reader["teachingstr1"].ToString();
                    t.teachingstr2 = reader["teachingstr2"].ToString();
                    t.teachingstr3 = reader["teachingstr3"].ToString();
                    tutorlist.Add(t);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Some exception occured:{0}", ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(tutorlist);
        }
        public ITutor selafromApptutor(int reqnum)
        {
            ITutor t = new Tutor();

            com.CommandText = "SELECT * FROM ApplicantTutor WHERE requestnum=" + reqnum;
            SqlDataReader reader;

            try
            {
                con.Open();
                com.Connection = con;
                reader         = com.ExecuteReader();
                while (reader.Read())
                {
                    t.name  = reader["name"].ToString();
                    t.age   = Convert.ToInt16(reader["age"]);
                    t.exp   = Convert.ToInt16(reader["exp"]);
                    t.g     = Convert.ToChar(reader["gender"]);
                    t.fee   = Convert.ToInt16(reader["fee"]);
                    t.alma  = reader["almamater"].ToString();
                    t.eid   = reader["eid"].ToString();
                    t.mob   = reader["mob"].ToString();
                    t.type  = reader["type"].ToString();
                    t.tlat  = Convert.ToDouble(reader["lat"]);
                    t.tlong = Convert.ToDouble(reader["lon"]);
                    t.pass  = reader["pass"].ToString();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Some exception occured:{0}", ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(t);
        }
Example #3
0
        public List <ITutor> selectTutor(string type, string sub, string std, string loc, string lm)
        {
            List <ITutor> tutorlist = new List <ITutor>();

            SqlDataReader reader;

            try
            {
                con.Open();
                com.Connection  = con;
                com.CommandType = CommandType.StoredProcedure;
                com.CommandText = "spfindtutor";
                if (type == "Any")
                {
                    com.Parameters.Add(new SqlParameter("@type", DBNull.Value));
                }
                else
                {
                    com.Parameters.Add(new SqlParameter("@type", type));
                }
                if (std == "Any")
                {
                    com.Parameters.Add(new SqlParameter("@std", DBNull.Value));
                }
                else
                {
                    com.Parameters.Add(new SqlParameter("@std", std));
                }
                if (sub == "Any")
                {
                    com.Parameters.Add(new SqlParameter("@sub", DBNull.Value));
                }
                else
                {
                    com.Parameters.Add(new SqlParameter("@sub", sub));
                }
                if (loc == "Any")
                {
                    com.Parameters.Add(new SqlParameter("@loc", DBNull.Value));
                }
                else
                {
                    com.Parameters.Add(new SqlParameter("@loc", loc));
                }
                if (lm == "Any")
                {
                    com.Parameters.Add(new SqlParameter("@lm", DBNull.Value));
                }
                else
                {
                    com.Parameters.Add(new SqlParameter("@lm", lm));
                }
                reader = com.ExecuteReader();


                while (reader.Read())
                {
                    ITutor t = new Tutor();
                    t.id     = Convert.ToInt16(reader["tid"]);
                    t.name   = reader["name"].ToString();
                    t.age    = Convert.ToInt16(reader["age"]);
                    t.exp    = Convert.ToInt16(reader["experience"]);
                    t.g      = Convert.ToChar(reader["gender"]);
                    t.fee    = Convert.ToInt16(reader["fee"]);
                    t.alma   = reader["almamater"].ToString();
                    t.loc    = reader["locname"].ToString();
                    t.std    = reader["stdname"].ToString();
                    t.sub    = reader["subname"].ToString();
                    t.type   = reader["typename"].ToString();
                    t.rating = Convert.ToDouble(reader["rating"]);
                    t.lm     = reader["lmname"].ToString();
                    t.tlat   = Convert.ToDouble(reader["tlat"]);
                    t.tlong  = Convert.ToDouble(reader["tlong"]);
                    t.lmlat  = Convert.ToDouble(reader["lat"]);
                    t.lmlong = Convert.ToDouble(reader["long"]);
                    tutorlist.Add(t);
                }

                if (reader == null)
                {
                    tutorlist = new List <ITutor>();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Some exception occured:{0}", ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(tutorlist);
        }