/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_Help_Classification model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_Help_Classification set "); strSql.Append(" ClassName = @ClassName , "); strSql.Append(" ParentID = @ParentID, "); strSql.Append(" Sort = @Sort,"); strSql.Append(" State = @State,"); strSql.Append(" Count = @Count,"); strSql.Append(" CreateByID = @CreateByID,"); strSql.Append(" CreateByName = @CreateByName,"); strSql.Append(" CreateOn = @CreateOn,"); strSql.Append(" Icon = @Icon,"); strSql.Append(" Description = @Description,"); strSql.Append(" Type = @Type"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@ClassName", SqlDbType.NVarChar, 50), new SqlParameter("@ParentID", SqlDbType.Int, 4), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@Count", SqlDbType.Int, 4), new SqlParameter("@CreateByID", SqlDbType.Int, 4), new SqlParameter("@CreateByName", SqlDbType.NVarChar, 100), new SqlParameter("@CreateOn", SqlDbType.DateTime), new SqlParameter("@Icon", SqlDbType.NVarChar, 255), new SqlParameter("@Description", SqlDbType.NVarChar, 500), new SqlParameter("@Type", SqlDbType.Int, 4) }; parameters[0].Value = model.ID; parameters[1].Value = model.ClassName; parameters[2].Value = model.ParentID; parameters[3].Value = model.Sort; parameters[4].Value = model.State; parameters[5].Value = model.Count; parameters[6].Value = model.CreateByID; parameters[7].Value = model.CreateByName; parameters[8].Value = model.CreateOn; parameters[9].Value = model.Icon; parameters[10].Value = model.Description; parameters[11].Value = model.Type; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获得数据列表 /// </summary> public List <JMP.MDL.jmp_Help_Classification> DataTableToList(DataTable dt) { List <JMP.MDL.jmp_Help_Classification> modelList = new List <JMP.MDL.jmp_Help_Classification>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.MDL.jmp_Help_Classification model; for (int n = 0; n < rowsCount; n++) { model = new JMP.MDL.jmp_Help_Classification(); if (dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } model.Icon = dt.Rows[n]["Icon"].ToString(); model.Description = dt.Rows[n]["Description"].ToString(); model.ClassName = dt.Rows[n]["ClassName"].ToString(); if (dt.Rows[n]["ParentID"].ToString() != "") { model.ParentID = int.Parse(dt.Rows[n]["ParentID"].ToString()); } if (dt.Rows[n]["Sort"].ToString() != "") { model.Sort = int.Parse(dt.Rows[n]["Sort"].ToString()); } if (dt.Rows[n]["State"].ToString() != "") { model.State = int.Parse(dt.Rows[n]["State"].ToString()); } if (dt.Rows[n]["Count"].ToString() != "") { model.Count = int.Parse(dt.Rows[n]["Count"].ToString()); } if (dt.Rows[n]["CreateOn"].ToString() != "") { model.CreateOn = DateTime.Parse(dt.Rows[n]["CreateOn"].ToString()); } if (dt.Rows[n]["CreateByID"].ToString() != "") { model.CreateByID = int.Parse(dt.Rows[n]["CreateByID"].ToString()); } model.CreateByName = dt.Rows[n]["CreateByName"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_Help_Classification model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_Help_Classification("); strSql.Append("ClassName,ParentID,Sort,State,Count,CreateById,CreateByName,CreateOn,Icon,Description,Type"); strSql.Append(") values ("); strSql.Append("@ClassName,@ParentID,@Sort,@State,@Count,@CreateById,@CreateByName,@CreateOn,@Icon,@Description,@Type"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ClassName", SqlDbType.NVarChar, 50), new SqlParameter("@ParentID", SqlDbType.Int, 4), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@Count", SqlDbType.Int, 4), new SqlParameter("@CreateById", SqlDbType.Int, 4), new SqlParameter("@CreateByName", SqlDbType.NVarChar, 100), new SqlParameter("@CreateOn", SqlDbType.DateTime), new SqlParameter("@Icon", SqlDbType.NVarChar, 255), new SqlParameter("@Description", SqlDbType.NVarChar, 500), new SqlParameter("@Type", SqlDbType.Int, 4) }; parameters[0].Value = model.ClassName; parameters[1].Value = model.ParentID; parameters[2].Value = model.Sort; parameters[3].Value = model.State; parameters[4].Value = model.Count; parameters[5].Value = model.CreateByID; parameters[6].Value = model.CreateByName; parameters[7].Value = model.CreateOn; parameters[8].Value = model.Icon; parameters[9].Value = model.Description; parameters[10].Value = model.Type; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_Help_Classification GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,ClassName, ParentID , Sort,State,Count,CreateOn,CreateByID,CreateByName,Icon,Description,Type"); strSql.Append(" from jmp_Help_Classification "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; JMP.MDL.jmp_Help_Classification model = new JMP.MDL.jmp_Help_Classification(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } model.ClassName = ds.Tables[0].Rows[0]["ClassName"].ToString(); if (ds.Tables[0].Rows[0]["ParentID"].ToString() != "") { model.ParentID = int.Parse(ds.Tables[0].Rows[0]["ParentID"].ToString()); } if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if (ds.Tables[0].Rows[0]["State"].ToString() != "") { model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } if (ds.Tables[0].Rows[0]["Count"].ToString() != "") { model.Count = int.Parse(ds.Tables[0].Rows[0]["Count"].ToString()); } if (ds.Tables[0].Rows[0]["CreateByID"].ToString() != "") { model.CreateByID = int.Parse(ds.Tables[0].Rows[0]["CreateByID"].ToString()); } model.CreateByName = ds.Tables[0].Rows[0]["CreateByName"].ToString(); if (ds.Tables[0].Rows[0]["CreateOn"].ToString() != "") { model.CreateOn = DateTime.Parse(ds.Tables[0].Rows[0]["CreateOn"].ToString()); } model.Icon = ds.Tables[0].Rows[0]["Icon"].ToString(); model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); if (ds.Tables[0].Rows[0]["Type"].ToString() != "") { model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_Help_Classification model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_Help_Classification model) { return(dal.Add(model)); }