Exemplo n.º 1
0
 /// <summary>
 /// 调用存储过程增加一个
 /// </summary>
 /// <param name="info">实体对象</param>
 /// <returns>正常返回大于 0 的自增id, 0代表重复,否则返回-1</returns>
 public static int ShengKongXianArticleAdd(Entity.ShengKongXianArticle info)
 {
     SqlParameter[] prams =
     {
         SqlDB.MakeInParam("@Title",           SqlDbType.NVarChar, 200, info.Title),
         SqlDB.MakeInParam("@Metatitle",       SqlDbType.NVarChar, 500, info.Metatitle),
         SqlDB.MakeInParam("@Metakeywords",    SqlDbType.NVarChar, 500, info.Metakeywords),
         SqlDB.MakeInParam("@Metadescription", SqlDbType.NVarChar, 500, info.Metadescription),
         SqlDB.MakeInParam("@ProvinceId",      SqlDbType.Int,        4, info.ProvinceId),
         SqlDB.MakeInParam("@DataYear",        SqlDbType.Int,        4, info.DataYear),
         SqlDB.MakeInParam("@Content",         SqlDbType.NVarChar,   0, info.Content),
     };
     return(Basic.Utils.StrToInt(SqlDB.ExecuteScalar(CommandType.StoredProcedure, "ShengKongXianArticleAdd", prams).ToString(), -1));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取某一个实体
        /// </summary>
        /// <param name="Id">标识</param>
        /// <returns>返回Entity</returns>
        public static Entity.ShengKongXianArticle ShengKongXianArticleEntityGet(int Id)
        {
            Entity.ShengKongXianArticle info = new Entity.ShengKongXianArticle();
            DataTable dt = SqlDB.ExecuteDataset(CommandType.Text, "SELECT * FROM [ShengKongXianArticle] 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.Metatitle       = dt.Rows[0]["Metatitle"].ToString();
                info.Metakeywords    = dt.Rows[0]["Metakeywords"].ToString();
                info.Metadescription = dt.Rows[0]["Metadescription"].ToString();
                info.ProvinceId      = Basic.Utils.StrToInt(dt.Rows[0]["ProvinceId"].ToString(), 0);
                info.DataYear        = Basic.Utils.StrToInt(dt.Rows[0]["DataYear"].ToString(), 0);
                info.Content         = dt.Rows[0]["Content"].ToString();
            }
            return(info);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 调用存储过程修改一个
        /// </summary>
        /// <param name="info">实体对象</param>
        /// <returns>更新成功返回ture,否则返回false</returns>
        public static bool ShengKongXianArticleEdit(Entity.ShengKongXianArticle info)
        {
            SqlParameter[] prams =
            {
                SqlDB.MakeInParam("@Id",              SqlDbType.Int,        4, info.Id),
                SqlDB.MakeInParam("@Title",           SqlDbType.NVarChar, 200, info.Title),
                SqlDB.MakeInParam("@Metatitle",       SqlDbType.NVarChar, 500, info.Metatitle),
                SqlDB.MakeInParam("@Metakeywords",    SqlDbType.NVarChar, 500, info.Metakeywords),
                SqlDB.MakeInParam("@Metadescription", SqlDbType.NVarChar, 500, info.Metadescription),
                SqlDB.MakeInParam("@ProvinceId",      SqlDbType.Int,        4, info.ProvinceId),
                SqlDB.MakeInParam("@DataYear",        SqlDbType.Int,        4, info.DataYear),
                SqlDB.MakeInParam("@Content",         SqlDbType.NVarChar,   0, info.Content),
            };
            int intReturnValue = 0;

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