protected void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(kpId)) { #region 添加 //验证KPCode是否已存在 string strWhereCount = " KPCode='" + txtKPCode.Text.Trim() + "' and GradeTerm='" + GradeTerm + "' and Subject='" + Subject + "' and Syllabus='" + Syllabus + "' and Test_Category='" + Exam_Type + "' and Data_Type='3'"; if (bll.GetRecordCount(strWhereCount) > 0) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('编码已存在。', { time: 2000, icon: 4})</script>"); return; } model.S_KnowledgePoint_Id = Guid.NewGuid().ToString(); model.Data_Type = "3"; model.GradeTerm = GradeTerm; model.Subject = Subject; model.Syllabus = Syllabus; model.Test_Category = Exam_Type; model.Parent_Id = parentId; model.KPName = txtKPName.Text.Trim(); model.KPCode = txtKPCode.Text.Trim(); model.KPLevel = ddlKPLevel.SelectedValue; model.Importance = hidImportance.Value; model.CreateTime = DateTime.Now; model.CreateUser = loginUser.SysUser_ID; if (bll.Add(model)) { if (parentId == "0") { ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index)});</script>"); return; } } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增失败!',{ time: 2000,icon:2});</script>"); return; } Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "新增同步知识点"); #endregion } else { #region 修改 model = bll.GetModel(kpId); model.Data_Type = "3"; model.KPName = txtKPName.Text.Trim(); model.KPCode = txtKPCode.Text.Trim(); model.KPLevel = ddlKPLevel.SelectedValue; model.UpdateTime = DateTime.Now; model.UpdateUser = loginUser.SysUser_ID; if (bll.Update(model)) { if (parentId == "0") { ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index);});</script>"); } } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('修改失败!',{ time: 2000,icon:2});</script>"); return; } Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "修改同步知识点"); #endregion } } catch (Exception) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(function(){layer.msg('操作失败!',{ time: 2000,icon:2});});</script>"); } }
protected void btnSave_Click(object sender, EventArgs e) { try { bool flag = false; Model_S_KnowledgePoint model = new Model_S_KnowledgePoint(); if (string.IsNullOrEmpty(kpId)) { #region 添加 #region 验证KPCode是否已存在 string strWhereCount = " KPCode='" + txtKPCode.Text.Trim() + "' and GradeTerm='" + GradeTerm + "' and Subject='" + Subject + "' and Resource_Version='" + Resource_Version + "' and Book_Type='" + Book_Type + "'"; if (bll.GetRecordCount(strWhereCount) > 0) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('编码已存在。', { time: 2000, icon: 4})</script>"); return; } #endregion if (rbtIsLast0.Checked || (rbtIsLast1.Checked && !string.IsNullOrEmpty(hidKPNameBasic_Id.Value))) { #region 是最后一级 或 是最后一级且基本知识点已存在 #region 知识点数据表 model.S_KnowledgePoint_Id = Guid.NewGuid().ToString(); model.GradeTerm = GradeTerm; model.Subject = Subject; model.Resource_Version = Resource_Version; model.Book_Type = Book_Type; model.Parent_Id = parentId; model.IsLast = "0"; model.S_KnowledgePointBasic_Id = ""; model.KPName = txtKPName.Text.Trim(); if (rbtIsLast1.Checked)//是最后一级 { model.IsLast = "1"; model.S_KnowledgePointBasic_Id = hidKPNameBasic_Id.Value; model.KPName = ""; } model.KPCode = txtKPCode.Text.Trim(); model.KPLevel = ddlKPLevel.SelectedValue; model.Cognitive_Level = ddlCognitive_Level.SelectedValue; model.CreateTime = DateTime.Now; model.CreateUser = loginUser.SysUser_ID; flag = bll.Add(model); #endregion #endregion } else { #region 是最后一级 且 基本知识点不存在 #region 基本知识点表 Model_S_KnowledgePointBasic modelBasic = new Model_S_KnowledgePointBasic(); string S_KnowledgePointBasic_Id = Guid.NewGuid().ToString(); modelBasic.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id; modelBasic.GradeTerm = GradeTerm; modelBasic.Subject = Subject; modelBasic.KPNameBasic = hidKPNameBasic.Value.Trim(); modelBasic.CreateTime = DateTime.Now; modelBasic.CreateUser = loginUser.SysUser_ID; #endregion #region 知识点数据表 model.S_KnowledgePoint_Id = Guid.NewGuid().ToString(); model.GradeTerm = GradeTerm; model.Subject = Subject; model.Resource_Version = Resource_Version; model.Book_Type = Book_Type; model.Parent_Id = parentId; model.IsLast = "1"; model.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id; model.KPName = ""; model.KPCode = txtKPCode.Text.Trim(); model.KPLevel = ddlKPLevel.SelectedValue; model.Cognitive_Level = ddlCognitive_Level.SelectedValue; model.CreateTime = DateTime.Now; model.CreateUser = loginUser.SysUser_ID; #endregion flag = bll.AddBasic(model, modelBasic); #endregion } if (flag) { if (parentId == "0") { ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index)});</script>"); return; } } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('新增失败!',{ time: 2000,icon:2});</script>"); return; } Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "新增同步知识点"); #endregion } else { #region 修改 if (rbtIsLast0.Checked || (rbtIsLast1.Checked && !string.IsNullOrEmpty(hidKPNameBasic_Id.Value))) { #region 是最后一级 或 是最后一级且基本知识点已存在 #region 知识点数据表 model = bll.GetModel(kpId); model.IsLast = "0"; model.S_KnowledgePointBasic_Id = ""; model.KPName = txtKPName.Text.Trim(); if (rbtIsLast1.Checked)//是最后一级 { model.IsLast = "1"; model.S_KnowledgePointBasic_Id = hidKPNameBasic_Id.Value; model.KPName = ""; } model.KPCode = txtKPCode.Text.Trim(); model.KPLevel = ddlKPLevel.SelectedValue; model.Cognitive_Level = ddlCognitive_Level.SelectedValue; model.UpdateTime = DateTime.Now; model.UpdateUser = loginUser.SysUser_ID; flag = bll.Update(model); #endregion #endregion } else { #region 是最后一级 且 基本知识点不存在 model = bll.GetModel(kpId); #region 基本知识点表 Model_S_KnowledgePointBasic modelBasic = new Model_S_KnowledgePointBasic(); string S_KnowledgePointBasic_Id = Guid.NewGuid().ToString(); modelBasic.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id; modelBasic.GradeTerm = model.GradeTerm; modelBasic.Subject = model.Subject; modelBasic.KPNameBasic = hidKPNameBasic.Value.Trim(); modelBasic.CreateTime = DateTime.Now; modelBasic.CreateUser = loginUser.SysUser_ID; #endregion #region 知识点数据表 model.IsLast = "1"; model.S_KnowledgePointBasic_Id = S_KnowledgePointBasic_Id; model.KPName = ""; model.KPCode = txtKPCode.Text.Trim(); model.KPLevel = ddlKPLevel.SelectedValue; model.Cognitive_Level = ddlCognitive_Level.SelectedValue; model.UpdateTime = DateTime.Now; model.UpdateUser = loginUser.SysUser_ID; #endregion flag = bll.UpdateBasic(model, modelBasic); #endregion } if (flag) { if (parentId == "0") { ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadSubData2('0');parent.layer.close(index);});</script>"); } } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('修改失败!',{ time: 2000,icon:2});</script>"); return; } Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "修改同步知识点"); #endregion } } catch (Exception) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(function(){layer.msg('操作失败!',{ time: 2000,icon:2});});</script>"); } }