Exemplo n.º 1
0
 /// <summary>
 /// 调用存储过程增加一个
 /// </summary>
 /// <param name="info">实体对象</param>
 /// <returns>正常返回大于 0 的自增id, 0代表重复,否则返回-1</returns>
 public static int KMAdd(Entity.KM info)
 {
     SqlParameter[] prams =
     {
         SqlDB.MakeInParam("@Title",    SqlDbType.NVarChar, 1000, info.Title),
         SqlDB.MakeInParam("@ParentId", SqlDbType.Int,         4, info.ParentId),
         SqlDB.MakeInParam("@Url",      SqlDbType.NVarChar, 1000, info.Url),
         SqlDB.MakeInParam("@Content1", SqlDbType.NVarChar,    0, info.Content1),
         SqlDB.MakeInParam("@LinkId",   SqlDbType.Int,         4, info.LinkId),
         SqlDB.MakeInParam("@ClassTy",  SqlDbType.Int,         4, info.ClassTy),
         SqlDB.MakeInParam("@Content2", SqlDbType.NVarChar,    0, info.Content2),
         SqlDB.MakeInParam("@Content3", SqlDbType.NVarChar,    0, info.Content3),
     };
     return(Basic.Utils.StrToInt(SqlDB.ExecuteScalar(CommandType.StoredProcedure, "KMAdd", prams).ToString(), -1));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取某一个实体
        /// </summary>
        /// <param name="Id">标识</param>
        /// <returns>返回Entity</returns>
        public static Entity.KM KMEntityGet(int Id)
        {
            Entity.KM info = new Entity.KM();
            DataTable dt   = SqlDB.ExecuteDataset(CommandType.Text, "SELECT * FROM [KM] WHERE Id = " + Id + ";").Tables[0];

            if (dt.Rows.Count > 0)
            {
                info.Id       = Basic.Utils.StrToInt(dt.Rows[0]["Id"].ToString(), 0);
                info.Title    = dt.Rows[0]["Title"].ToString();
                info.ParentId = Basic.Utils.StrToInt(dt.Rows[0]["ParentId"].ToString(), 0);
                info.Url      = dt.Rows[0]["Url"].ToString();
                info.Content1 = dt.Rows[0]["Content1"].ToString();
                info.LinkId   = Basic.Utils.StrToInt(dt.Rows[0]["LinkId"].ToString(), 0);
                info.ClassTy  = Basic.Utils.StrToInt(dt.Rows[0]["ClassTy"].ToString(), 0);
                info.Content2 = dt.Rows[0]["Content2"].ToString();
                info.Content3 = dt.Rows[0]["Content3"].ToString();
                return(info);
            }
            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 调用存储过程修改一个
        /// </summary>
        /// <param name="info">实体对象</param>
        /// <returns>更新成功返回ture,否则返回false</returns>
        public static bool KMEdit(Entity.KM info)
        {
            SqlParameter[] prams =
            {
                SqlDB.MakeInParam("@Id",       SqlDbType.Int,         4, info.Id),
                SqlDB.MakeInParam("@Title",    SqlDbType.NVarChar, 1000, info.Title),
                SqlDB.MakeInParam("@ParentId", SqlDbType.Int,         4, info.ParentId),
                SqlDB.MakeInParam("@Url",      SqlDbType.NVarChar, 1000, info.Url),
                SqlDB.MakeInParam("@Content1", SqlDbType.NVarChar,    0, info.Content1),
                SqlDB.MakeInParam("@LinkId",   SqlDbType.Int,         4, info.LinkId),
                SqlDB.MakeInParam("@ClassTy",  SqlDbType.Int,         4, info.ClassTy),
                SqlDB.MakeInParam("@Content2", SqlDbType.NVarChar,    0, info.Content2),
                SqlDB.MakeInParam("@Content3", SqlDbType.NVarChar,    0, info.Content3),
            };
            int intReturnValue = 0;

            intReturnValue = SqlDB.ExecuteNonQuery(CommandType.StoredProcedure, "KMEdit", prams);
            if (intReturnValue == 1)
            {
                return(true);
            }
            return(false);
        }