Esempio n. 1
0
        //assignment表插入判断
        protected void DetailsView4_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            CourseManager course = new CourseManager();
            if (e.Values["course"] == null || e.Values["major"] == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!assignment表中course,major字段不能为空');", true);
                e.Cancel = true;
                return;
            }

            if (course.GetCourseByNum(e.Values["num"].ToString()) == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!assignment表中外键num不存在');", true);
                e.Cancel = true;
                return;
            }
        }
Esempio n. 2
0
        //course 插入判断
        protected void DetailsView3_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            CourseManager course = new CourseManager();
            TeacherManager t = new TeacherManager();
            if (e.Values["num"] == null || e.Values["teacher"] == null || e.Values["name"] == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!course表中num,teacher,name字段都不能为空');", true);
                e.Cancel = true;
                return;
            }
            if (course.GetCourseByNum(e.Values["num"].ToString()) != null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!course表中num已存在');", true);
                e.Cancel = true;
                return;
            }

            if (t.GetTeacher(e.Values["teacher"].ToString())==null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!course表中外键teacher不存在');", true);
                e.Cancel = true;
                return;
            }
        }