public bool AddBasic(Model_S_KnowledgePoint model, Model_S_KnowledgePointBasic modelBasic) { Dictionary <string, SqlParameter[]> dictionary = new Dictionary <string, SqlParameter[]>(); StringBuilder builder = new StringBuilder(); builder = new StringBuilder(); builder.Append("insert into S_KnowledgePointBasic("); builder.Append("S_KnowledgePointBasic_Id,GradeTerm,Subject,KPNameBasic,CreateUser,CreateTime,UpdateUser,UpdateTime)"); builder.Append(" values ("); builder.Append("@S_KnowledgePointBasic_Id,@GradeTerm,@Subject,@KPNameBasic,@CreateUser,@CreateTime,@UpdateUser,@UpdateTime)"); SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@S_KnowledgePointBasic_Id", SqlDbType.Char, 0x24), new SqlParameter("@GradeTerm", SqlDbType.Char, 0x24), new SqlParameter("@Subject", SqlDbType.Char, 0x24), new SqlParameter("@KPNameBasic", SqlDbType.VarChar, 200), new SqlParameter("@CreateUser", SqlDbType.Char, 0x24), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateUser", SqlDbType.Char, 0x24), new SqlParameter("@UpdateTime", SqlDbType.DateTime) }; parameterArray[0].Value = modelBasic.S_KnowledgePointBasic_Id; parameterArray[1].Value = modelBasic.GradeTerm; parameterArray[2].Value = modelBasic.Subject; parameterArray[3].Value = modelBasic.KPNameBasic; parameterArray[4].Value = modelBasic.CreateUser; parameterArray[5].Value = modelBasic.CreateTime; parameterArray[6].Value = modelBasic.UpdateUser; parameterArray[7].Value = modelBasic.UpdateTime; dictionary.Add(builder.ToString(), parameterArray); builder = new StringBuilder(); builder.Append("insert into S_KnowledgePoint("); builder.Append("S_KnowledgePoint_Id,GradeTerm,Subject,Resource_Version,Book_Type,KPLevel,Parent_Id,S_KnowledgePointBasic_Id,KPName,KPCode,Cognitive_Level,IsLast,CreateUser,CreateTime,UpdateUser,UpdateTime)"); builder.Append(" values ("); builder.Append("@S_KnowledgePoint_Id,@GradeTerm,@Subject,@Resource_Version,@Book_Type,@KPLevel,@Parent_Id,@S_KnowledgePointBasic_Id,@KPName,@KPCode,@Cognitive_Level,@IsLast,@CreateUser,@CreateTime,@UpdateUser,@UpdateTime)"); SqlParameter[] parameterArray2 = new SqlParameter[] { new SqlParameter("@S_KnowledgePoint_Id", SqlDbType.Char, 0x24), new SqlParameter("@GradeTerm", SqlDbType.Char, 0x24), new SqlParameter("@Subject", SqlDbType.Char, 0x24), new SqlParameter("@Resource_Version", SqlDbType.Char, 0x24), new SqlParameter("@Book_Type", SqlDbType.Char, 0x24), new SqlParameter("@KPLevel", SqlDbType.Char, 0x24), new SqlParameter("@Parent_Id", SqlDbType.Char, 0x24), new SqlParameter("@S_KnowledgePointBasic_Id", SqlDbType.Char, 0x24), new SqlParameter("@KPName", SqlDbType.VarChar, 200), new SqlParameter("@KPCode", SqlDbType.VarChar, 200), new SqlParameter("@Cognitive_Level", SqlDbType.Char, 0x24), new SqlParameter("@IsLast", SqlDbType.Char, 1), new SqlParameter("@CreateUser", SqlDbType.Char, 0x24), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateUser", SqlDbType.Char, 0x24), new SqlParameter("@UpdateTime", SqlDbType.DateTime) }; parameterArray2[0].Value = model.S_KnowledgePoint_Id; parameterArray2[1].Value = model.GradeTerm; parameterArray2[2].Value = model.Subject; parameterArray2[3].Value = model.Resource_Version; parameterArray2[4].Value = model.Book_Type; parameterArray2[5].Value = model.KPLevel; parameterArray2[6].Value = model.Parent_Id; parameterArray2[7].Value = model.S_KnowledgePointBasic_Id; parameterArray2[8].Value = model.KPName; parameterArray2[9].Value = model.KPCode; parameterArray2[10].Value = model.Cognitive_Level; parameterArray2[11].Value = model.IsLast; parameterArray2[12].Value = model.CreateUser; parameterArray2[13].Value = model.CreateTime; parameterArray2[14].Value = model.UpdateUser; parameterArray2[15].Value = model.UpdateTime; dictionary.Add(builder.ToString(), parameterArray2); return(DbHelperSQL.ExecuteSqlTran(dictionary) > 0); }
public bool UpdateBasic(Model_S_KnowledgePoint model, Model_S_KnowledgePointBasic modelBasic) { Dictionary <string, SqlParameter[]> dictionary = new Dictionary <string, SqlParameter[]>(); StringBuilder builder = new StringBuilder(); builder = new StringBuilder(); builder.Append("insert into S_KnowledgePointBasic("); builder.Append("S_KnowledgePointBasic_Id,GradeTerm,Subject,KPNameBasic,CreateUser,CreateTime,UpdateUser,UpdateTime)"); builder.Append(" values ("); builder.Append("@S_KnowledgePointBasic_Id,@GradeTerm,@Subject,@KPNameBasic,@CreateUser,@CreateTime,@UpdateUser,@UpdateTime)"); SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@S_KnowledgePointBasic_Id", SqlDbType.Char, 0x24), new SqlParameter("@GradeTerm", SqlDbType.Char, 0x24), new SqlParameter("@Subject", SqlDbType.Char, 0x24), new SqlParameter("@KPNameBasic", SqlDbType.VarChar, 200), new SqlParameter("@CreateUser", SqlDbType.Char, 0x24), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateUser", SqlDbType.Char, 0x24), new SqlParameter("@UpdateTime", SqlDbType.DateTime) }; parameterArray[0].Value = modelBasic.S_KnowledgePointBasic_Id; parameterArray[1].Value = modelBasic.GradeTerm; parameterArray[2].Value = modelBasic.Subject; parameterArray[3].Value = modelBasic.KPNameBasic; parameterArray[4].Value = modelBasic.CreateUser; parameterArray[5].Value = modelBasic.CreateTime; parameterArray[6].Value = modelBasic.UpdateUser; parameterArray[7].Value = modelBasic.UpdateTime; dictionary.Add(builder.ToString(), parameterArray); builder = new StringBuilder(); builder = new StringBuilder(); builder.Append("update S_KnowledgePoint set "); builder.Append("KPLevel=@KPLevel,"); builder.Append("S_KnowledgePointBasic_Id=@S_KnowledgePointBasic_Id,"); builder.Append("KPName=@KPName,"); builder.Append("KPCode=@KPCode,"); builder.Append("Cognitive_Level=@Cognitive_Level,"); builder.Append("IsLast=@IsLast,"); builder.Append("UpdateUser=@UpdateUser,"); builder.Append("UpdateTime=@UpdateTime"); builder.Append(" where S_KnowledgePoint_Id=@S_KnowledgePoint_Id "); SqlParameter[] parameterArray2 = new SqlParameter[] { new SqlParameter("@KPLevel", SqlDbType.Char, 0x24), new SqlParameter("@S_KnowledgePointBasic_Id", SqlDbType.Char, 0x24), new SqlParameter("@KPName", SqlDbType.VarChar, 200), new SqlParameter("@KPCode", SqlDbType.VarChar, 200), new SqlParameter("@Cognitive_Level", SqlDbType.Char, 0x24), new SqlParameter("@IsLast", SqlDbType.Char, 1), new SqlParameter("@UpdateUser", SqlDbType.Char, 0x24), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@S_KnowledgePoint_Id", SqlDbType.Char, 0x24) }; parameterArray2[0].Value = model.KPLevel; parameterArray2[1].Value = model.S_KnowledgePointBasic_Id; parameterArray2[2].Value = model.KPName; parameterArray2[3].Value = model.KPCode; parameterArray2[4].Value = model.Cognitive_Level; parameterArray2[5].Value = model.IsLast; parameterArray2[6].Value = model.UpdateUser; parameterArray2[7].Value = model.UpdateTime; parameterArray2[8].Value = model.S_KnowledgePoint_Id; dictionary.Add(builder.ToString(), parameterArray2); return(DbHelperSQL.ExecuteSqlTran(dictionary) > 0); }
public List <Model_S_KnowledgePointBasic> DataTableToList(DataTable dt) { List <Model_S_KnowledgePointBasic> list = new List <Model_S_KnowledgePointBasic>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Model_S_KnowledgePointBasic item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
public bool Add(Model_S_KnowledgePointBasic model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into S_KnowledgePointBasic("); builder.Append("S_KnowledgePointBasic_Id,GradeTerm,Subject,KPNameBasic,CreateUser,CreateTime,UpdateUser,UpdateTime)"); builder.Append(" values ("); builder.Append("@S_KnowledgePointBasic_Id,@GradeTerm,@Subject,@KPNameBasic,@CreateUser,@CreateTime,@UpdateUser,@UpdateTime)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@S_KnowledgePointBasic_Id", SqlDbType.Char, 0x24), new SqlParameter("@GradeTerm", SqlDbType.Char, 0x24), new SqlParameter("@Subject", SqlDbType.Char, 0x24), new SqlParameter("@KPNameBasic", SqlDbType.VarChar, 200), new SqlParameter("@CreateUser", SqlDbType.Char, 0x24), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateUser", SqlDbType.Char, 0x24), new SqlParameter("@UpdateTime", SqlDbType.DateTime) }; cmdParms[0].Value = model.S_KnowledgePointBasic_Id; cmdParms[1].Value = model.GradeTerm; cmdParms[2].Value = model.Subject; cmdParms[3].Value = model.KPNameBasic; cmdParms[4].Value = model.CreateUser; cmdParms[5].Value = model.CreateTime; cmdParms[6].Value = model.UpdateUser; cmdParms[7].Value = model.UpdateTime; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public Model_S_KnowledgePointBasic DataRowToModel(DataRow row) { Model_S_KnowledgePointBasic basic = new Model_S_KnowledgePointBasic(); if (row != null) { if (row["S_KnowledgePointBasic_Id"] != null) { basic.S_KnowledgePointBasic_Id = row["S_KnowledgePointBasic_Id"].ToString(); } if (row["GradeTerm"] != null) { basic.GradeTerm = row["GradeTerm"].ToString(); } if (row["Subject"] != null) { basic.Subject = row["Subject"].ToString(); } if (row["KPNameBasic"] != null) { basic.KPNameBasic = row["KPNameBasic"].ToString(); } if (row["CreateUser"] != null) { basic.CreateUser = row["CreateUser"].ToString(); } if ((row["CreateTime"] != null) && (row["CreateTime"].ToString() != "")) { basic.CreateTime = new DateTime?(DateTime.Parse(row["CreateTime"].ToString())); } if (row["UpdateUser"] != null) { basic.UpdateUser = row["UpdateUser"].ToString(); } if ((row["UpdateTime"] != null) && (row["UpdateTime"].ToString() != "")) { basic.UpdateTime = new DateTime?(DateTime.Parse(row["UpdateTime"].ToString())); } } return(basic); }
public bool Update(Model_S_KnowledgePointBasic model) { StringBuilder builder = new StringBuilder(); builder.Append("update S_KnowledgePointBasic set "); builder.Append("GradeTerm=@GradeTerm,"); builder.Append("Subject=@Subject,"); builder.Append("KPNameBasic=@KPNameBasic,"); builder.Append("CreateUser=@CreateUser,"); builder.Append("CreateTime=@CreateTime,"); builder.Append("UpdateUser=@UpdateUser,"); builder.Append("UpdateTime=@UpdateTime"); builder.Append(" where S_KnowledgePointBasic_Id=@S_KnowledgePointBasic_Id "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@GradeTerm", SqlDbType.Char, 0x24), new SqlParameter("@Subject", SqlDbType.Char, 0x24), new SqlParameter("@KPNameBasic", SqlDbType.VarChar, 200), new SqlParameter("@CreateUser", SqlDbType.Char, 0x24), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateUser", SqlDbType.Char, 0x24), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@S_KnowledgePointBasic_Id", SqlDbType.Char, 0x24) }; cmdParms[0].Value = model.GradeTerm; cmdParms[1].Value = model.Subject; cmdParms[2].Value = model.KPNameBasic; cmdParms[3].Value = model.CreateUser; cmdParms[4].Value = model.CreateTime; cmdParms[5].Value = model.UpdateUser; cmdParms[6].Value = model.UpdateTime; cmdParms[7].Value = model.S_KnowledgePointBasic_Id; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public bool Add(Model_S_KnowledgePointBasic model) { return(this.dal.Add(model)); }
public bool Update(Model_S_KnowledgePointBasic model) { return(this.dal.Update(model)); }
public bool AddBasic(Model_S_KnowledgePoint model, Model_S_KnowledgePointBasic modelBasic) { return(this.dal.AddBasic(model, modelBasic)); }
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>"); } }