Пример #1
0
        public void create(Course course)
        {
            CourseData data = courseMapper.CourseTransformToCourseData(course);

            string[] _course =
            {
                data.getTitle(),
                data.getDescription(),
                data.getSuitable(),
                data.getPrice(),
                data.getNotice(),
                data.getOther()
            };

            MySqlCommand command = connection().CreateCommand();

            command.CommandText = "Insert into course(title,description,suitable,price,notice,other) " + "values('"
                                  + data.getTitle() + "','"
                                  + data.getDescription() + "','"
                                  + data.getSuitable() + "','"
                                  + data.getPrice() + "'" + ",'"
                                  + data.getNotice() + "','"
                                  + data.getOther() + "')";
            command.ExecuteNonQuery();
            connection().Close();
        }
Пример #2
0
        public Course CourseDataTransformToCourse(CourseData courseData)
        {
            Course course = new Course();

            course.setTitle(courseData.getTitle());
            course.setDescription(courseData.getDescription());
            course.setSuitable(courseData.getSuitable());
            course.setPrice(courseData.getPrice());
            course.setNotice(courseData.getNotice());
            course.setOther(courseData.getOther());
            return(course);
        }
Пример #3
0
        public void create(Course course)
        {
            CourseData data = courseMapper.CourseTransformToCourseData(course);

            string[] _course =
            {
                data.getTitle(),
                data.getDescription(),
                data.getSuitable(),
                data.getPrice(),
                data.getNotice(),
                data.getOther()
            };
            DataHelper.courseTable.Rows.Add(_course);
            DataSet ds = new DataSet("course");

            ds.Tables.Add(DataHelper.courseTable.Copy());
            ds.WriteXml(@path);
        }
Пример #4
0
        public void update(string oldTitle, Course course)
        {
            CourseData data = courseMapper.CourseTransformToCourseData(course);

            DataRow[] _course = DataHelper.courseTable.Select("課程名稱 ='" + oldTitle + "'");

            foreach (DataRow row in _course)
            {
                row["課程名稱"] = data.getTitle();
                row["課程說明"] = data.getDescription();
                row["適合對象"] = data.getSuitable();
                row["定價"]   = data.getPrice();
                row["注意事項"] = data.getNotice();
                row["備註"]   = data.getOther();
            }

            DataSet ds = new DataSet("course");

            ds.Tables.Add(DataHelper.courseTable.Copy());
            ds.WriteXml(@path);
        }
Пример #5
0
        public void update(string oldTitle, Course course)
        {
            CourseData data = courseMapper.CourseTransformToCourseData(course);
            DataTable  dt   = readAllCourse();

            DataRow[] _course = dt.Select("Title ='" + oldTitle + "'");

            foreach (DataRow row in _course)
            {
                row["Title"]       = data.getTitle();
                row["Description"] = data.getDescription();
                row["Suitable"]    = data.getSuitable();
                row["Price"]       = data.getPrice();
                row["Notice"]      = data.getNotice();
                row["Other"]       = data.getOther();
            }

            DataSet ds = new DataSet("course");

            ds.Tables.Add(dt.Copy());
            ds.WriteXml(@path);
        }