コード例 #1
0
        public Client GetClientByID(int id)
        {
            Client record = new Client();

            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("SELECT [portal_id],[portal_nm],[notes] ,[title] ,[keyword],[description],[introduction],[promotion],[data],[completion],[contact_email] FROM[dbo].[u_portal] WHERE [portal_id] = @id; ");
                String       sql  = sb.ToString();
                SqlParameter parm = new SqlParameter("@id", id);

                using (SqlDataReader reader = SQLhelper.ExecuteReader(sqlBuilder.ConnectionString, System.Data.CommandType.Text, sql, parm))
                {
                    while (reader.Read())
                    {
                        return(SetClientProperties(reader));
                    }
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.ToString());
            }

            return(record);
        }
コード例 #2
0
        public ClientContext() : base("CredibleDB")
        {
            List <Client> list = new List <Client>();


            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("SELECT [portal_id],[portal_nm],[notes] ,[title] ,[keyword]  ,[description],[introduction],[promotion],[data],[completion],[contact_email] FROM[dbo].[u_portal];");
                String sql = sb.ToString();

                using (SqlDataReader reader = SQLhelper.ExecuteReader(sqlBuilder.ConnectionString, System.Data.CommandType.Text, sql))
                {
                    while (reader.Read())
                    {
                        list.Add(SetClientProperties(reader));
                    }
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.ToString());
            }


            Clients = list;
        }
コード例 #3
0
        public UserContext() : base("CredibleDB")
        {
            List <User> list = new List <User>();


            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("select u.user_id, u.first_nm, u.last_nm from [dbo].[u_user] u order by  u.last_nm, u.first_nm; ");
                String sql = sb.ToString();

                using (SqlDataReader reader = SQLhelper.ExecuteReader(sqlBuilder.ConnectionString, System.Data.CommandType.Text, sql))
                {
                    while (reader.Read())
                    {
                        list.Add(SetUserProperties(reader));
                    }
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e);
            }

            Users = list;
        }
コード例 #4
0
        public CourseContext() : base("CredibleDB")
        {
            List <Course> list = new List <Course>();


            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("SELECT [portal_id],[course_subject],[course_topic],[course_display_nm],[course_default_standard],[credit_acceptance],[credit_type_nm],[course_portal_id],[course_portal_nm] FROM [dbo].[u_course_portal]; ");
                String sql = sb.ToString();

                using (SqlDataReader reader = SQLhelper.ExecuteReader(sqlBuilder.ConnectionString, System.Data.CommandType.Text, sql))
                {
                    while (reader.Read())
                    {
                        list.Add(SetCourseProperties(reader));
                    }
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.ToString());
            }

            Courses = list;
        }
コード例 #5
0
        public RegistrationContext() : base("CredibleDB")
        {
            List <RegistratedUser> list = new List <RegistratedUser>();


            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("select r.registration_id, r.user_id, r.course_portal_id, r.registration_dttm, u.first_nm, u.last_nm  ");
                sb.Append("from u_registration r inner JOIN u_user u on r.user_id = u.user_id order by r.registration_dttm;");

                String sql = sb.ToString();

                using (SqlDataReader reader = SQLhelper.ExecuteReader(sqlBuilder.ConnectionString, System.Data.CommandType.Text, sql))
                {
                    while (reader.Read())
                    {
                        list.Add(SetRegistrationProperties(reader));
                    }
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e);

                throw e;
            }

            RegistratedUsers = list;
        }