예제 #1
0
        private void simpleButtonAdd_Click(object sender, EventArgs e)
        {
            if (!CheckData())
            {
                return;
            }
            if (tabLesson != null)
            {
                DataRow[] matchs = tabLesson.Select("Name='" + name + "'");
                if (matchs.Length > 0)
                {
                    MessageBox.Show("课程名称已经存在", "信息提示", MessageBoxButtons.OK);
                    return;
                }
            }
            LessonBean b = new LessonBean();

            b.Name        = name;
            b.Price       = price;
            b.TimeLength  = timeLength;
            b.Description = description;


            LessonDAO d = new LessonDAO();

            d.AddLesson(b);
        }
예제 #2
0
        private void simpleButtonDelete_Click(object sender, EventArgs e)
        {
            if (id == -1)
            {
                MessageBox.Show("未选择课程", "信息提示", MessageBoxButtons.OK);
                return;
            }

            LessonBean b = new LessonBean();

            b.Id = id;
            LessonDAO d = new LessonDAO();

            d.DeleteLesson(b);

            LoadData();
        }
예제 #3
0
        public int DeleteLesson(LessonBean b)
        {
            int count = 0;

            try
            {
                SqlParameter[] sp =
                {
                    para = new SqlParameter("@Id", b.Id),
                };
                count = sh.RunSql("PR_Lesson_Delete", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(count);
        }
예제 #4
0
        private SqlParameter para; //参数

        public int AddLesson(LessonBean b)
        {
            int count = 0;

            try
            {
                SqlParameter[] sp =
                {
                    para = new SqlParameter("@Name",        b.Name),
                    para = new SqlParameter("@Price",       b.Price),
                    para = new SqlParameter("@TimeLength",  b.TimeLength),
                    para = new SqlParameter("@Description", b.Description),
                };
                count = sh.RunSql("PR_Lesson_Add", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(count);
        }