예제 #1
0
        protected void DetailsView7_ItemInserting(object sender, DetailsViewInsertEventArgs e)         //answer表插入判断
        {
            StudentManager stu = new StudentManager();
            ProblemManager p   = new ProblemManager();

            if (e.Values["student"] == null || e.Values["problem"] == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!answer表中Student,prob字段不能为空');", true);
                e.Cancel = true;
                return;
            }
            if (stu.GetStudent(e.Values["student"].ToString()) == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!answer表中外键student字段不存在');", true);
                e.Cancel = true;
                return;
            }
            if (p.GetProblemById(int.Parse(e.Values["problem"].ToString())) == null)
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "msg1", "alert('插入失败!answer表中外键problem字段不存在');", true);
                e.Cancel = true;
                return;
            }
        }