Ejemplo n.º 1
0
        public Course getCourseByTitle(string title)
        {
            MySqlCommand command = connection().CreateCommand();

            command.CommandText = "select * FROM course WHERE title = '" + title + "' ";

            MySqlDataReader dr     = command.ExecuteReader();
            Course          course = null;
            CourseData      data   = new CourseData();

            while (dr.Read())
            {
                data.setTitle(title);
                data.setDescription(dr["description"].ToString());
                data.setSuitable(dr["suitable"].ToString());
                data.setPrice(dr["price"].ToString());
                data.setNotice(dr["notice"].ToString());
                data.setOther(dr["other"].ToString());
            }

            course = courseMapper.CourseDataTransformToCourse(data);

            connection().Close();
            return(course);
        }
Ejemplo n.º 2
0
        public CourseData CourseTransformToCourseData(Course course)
        {
            CourseData data = new CourseData();

            data.setTitle(course.getTitle());
            data.setDescription(course.getDescription());
            data.setSuitable(course.getSuitable());
            data.setPrice(course.getPrice());
            data.setNotice(course.getNotice());
            data.setOther(course.getOther());
            return(data);
        }
Ejemplo n.º 3
0
        public Course getCourseByTitle(string title)
        {
            DataRow[]  selectedCourse = DataHelper.courseTable.Select("課程名稱 ='" + title + "'");
            Course     course         = null;
            CourseData data           = new CourseData();

            foreach (DataRow row in selectedCourse)
            {
                data.setTitle(row["課程名稱"].ToString());
                data.setDescription(row["課程說明"].ToString());
                data.setSuitable(row["適合對象"].ToString());
                data.setPrice(row["定價"].ToString());
                data.setNotice(row["注意事項"].ToString());
                data.setOther(row["備註"].ToString());
            }

            course = courseMapper.CourseDataTransformToCourse(data);

            return(course);
        }
Ejemplo n.º 4
0
        public Course getCourseByTitle(string title)
        {
            DataTable dt = readAllCourse();

            DataRow[]  selectedCourse = dt.Select("Title ='" + title + "'");
            Course     course         = null;
            CourseData data           = new CourseData();

            foreach (DataRow row in selectedCourse)
            {
                data.setTitle(row["Title"].ToString());
                data.setDescription(row["Description"].ToString());
                data.setSuitable(row["Suitable"].ToString());
                data.setPrice(row["Price"].ToString());
                data.setNotice(row["Notice"].ToString());
                data.setOther(row["Other"].ToString());
            }

            course = courseMapper.CourseDataTransformToCourse(data);

            return(course);
        }