/// <summary> /// 调用存储过程增加一个 /// </summary> /// <param name="info">实体对象</param> /// <returns>正常返回大于 0 的自增id, 0代表重复,否则返回-1</returns> public static int ZhiYeAdd(Entity.ZhiYe info) { SqlParameter[] prams = { SqlDB.MakeInParam("@Code", SqlDbType.NVarChar, 10, info.Code), SqlDB.MakeInParam("@ZhiYeName", SqlDbType.NVarChar, 150, info.ZhiYeName), SqlDB.MakeInParam("@Remark", SqlDbType.NVarChar, 100, info.Remark), SqlDB.MakeInParam("@ZhiYeLevel", SqlDbType.Int, 4, info.ZhiYeLevel), SqlDB.MakeInParam("@ParentId", SqlDbType.Int, 4, info.ParentId), SqlDB.MakeInParam("@Intro", SqlDbType.NVarChar, 0, info.Intro), SqlDB.MakeInParam("@ClickNum", SqlDbType.Int, 4, info.ClickNum), SqlDB.MakeInParam("@Url", SqlDbType.NVarChar, 200, info.Url), }; return(Basic.Utils.StrToInt(SqlDB.ExecuteScalar(CommandType.StoredProcedure, "ZhiYeAdd", prams).ToString(), -1)); }
/// <summary> /// 调用存储过程修改一个 /// </summary> /// <param name="info">实体对象</param> /// <returns>更新成功返回ture,否则返回false</returns> public static bool ZhiYeEdit(Entity.ZhiYe info) { SqlParameter[] prams = { SqlDB.MakeInParam("@Id", SqlDbType.Int, 4, info.Id), SqlDB.MakeInParam("@Code", SqlDbType.NVarChar, 10, info.Code), SqlDB.MakeInParam("@ZhiYeName", SqlDbType.NVarChar, 150, info.ZhiYeName), SqlDB.MakeInParam("@Remark", SqlDbType.NVarChar, 100, info.Remark), SqlDB.MakeInParam("@ZhiYeLevel", SqlDbType.Int, 4, info.ZhiYeLevel), SqlDB.MakeInParam("@ParentId", SqlDbType.Int, 4, info.ParentId), SqlDB.MakeInParam("@Intro", SqlDbType.NVarChar, 0, info.Intro), SqlDB.MakeInParam("@ClickNum", SqlDbType.Int, 4, info.ClickNum), SqlDB.MakeInParam("@Url", SqlDbType.NVarChar, 200, info.Url), }; int intReturnValue = 0; intReturnValue = SqlDB.ExecuteNonQuery(CommandType.StoredProcedure, "ZhiYeEdit", prams); if (intReturnValue == 1) { return(true); } return(false); }
/// <summary> /// 获取某一个实体 /// </summary> /// <param name="Id">标识</param> /// <returns>返回Entity</returns> public static Entity.ZhiYe ZhiYeEntityGet(int Id) { Entity.ZhiYe info = new Entity.ZhiYe(); DataTable dt = SqlDB.ExecuteDataset(CommandType.Text, "SELECT * FROM [ZhiYe] WHERE Id = " + Id + ";").Tables[0]; if (dt.Rows.Count > 0) { info.Id = Basic.Utils.StrToInt(dt.Rows[0]["Id"].ToString(), 0); info.Code = dt.Rows[0]["Code"].ToString(); info.ZhiYeName = dt.Rows[0]["ZhiYeName"].ToString(); info.Remark = dt.Rows[0]["Remark"].ToString(); info.ZhiYeLevel = Basic.Utils.StrToInt(dt.Rows[0]["ZhiYeLevel"].ToString(), 0); info.ParentId = Basic.Utils.StrToInt(dt.Rows[0]["ParentId"].ToString(), 0); info.Intro = dt.Rows[0]["Intro"].ToString(); info.ClickNum = Basic.Utils.StrToInt(dt.Rows[0]["ClickNum"].ToString(), 0); info.Url = dt.Rows[0]["Url"].ToString(); return(info); } else { return(null); } }