Example #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(zlzw.Model.NewsTypeListModal model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeID",   SqlDbType.Int,        4),
                new SqlParameter("@NewsTypeName", SqlDbType.NVarChar,  50),
                new SqlParameter("@IsEnable",     SqlDbType.Int,        4),
                new SqlParameter("@PublishDate4", SqlDbType.DateTime),
                new SqlParameter("@Other01",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Other02",      SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.NewsTypeID;
            parameters[1].Value = model.NewsTypeName;
            parameters[2].Value = model.IsEnable;
            parameters[3].Value = model.PublishDate4;
            parameters[4].Value = model.Other01;
            parameters[5].Value = model.Other02;

            DbHelperSQL.RunProcedure("NewsTypeList_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public zlzw.Model.NewsTypeListModal DataRowToModel(DataRow row)
 {
     zlzw.Model.NewsTypeListModal model = new zlzw.Model.NewsTypeListModal();
     if (row != null)
     {
         if (row["NewsTypeID"] != null && row["NewsTypeID"].ToString() != "")
         {
             model.NewsTypeID = int.Parse(row["NewsTypeID"].ToString());
         }
         if (row["NewsTypeName"] != null)
         {
             model.NewsTypeName = row["NewsTypeName"].ToString();
         }
         if (row["IsEnable"] != null && row["IsEnable"].ToString() != "")
         {
             model.IsEnable = int.Parse(row["IsEnable"].ToString());
         }
         if (row["PublishDate4"] != null && row["PublishDate4"].ToString() != "")
         {
             model.PublishDate4 = DateTime.Parse(row["PublishDate4"].ToString());
         }
         if (row["Other01"] != null)
         {
             model.Other01 = row["Other01"].ToString();
         }
         if (row["Other02"] != null)
         {
             model.Other02 = row["Other02"].ToString();
         }
     }
     return(model);
 }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public zlzw.Model.NewsTypeListModal GetModel(int NewsTypeID)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = NewsTypeID;

            zlzw.Model.NewsTypeListModal model = new zlzw.Model.NewsTypeListModal();
            DataSet ds = DbHelperSQL.RunProcedure("NewsTypeList_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(zlzw.Model.NewsTypeListModal model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeID",   SqlDbType.Int,        4),
                new SqlParameter("@NewsTypeName", SqlDbType.NVarChar,  50),
                new SqlParameter("@IsEnable",     SqlDbType.Int,        4),
                new SqlParameter("@PublishDate4", SqlDbType.DateTime),
                new SqlParameter("@Other01",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Other02",      SqlDbType.NVarChar, 50)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.NewsTypeName;
            parameters[2].Value     = model.IsEnable;
            parameters[3].Value     = model.PublishDate4;
            parameters[4].Value     = model.Other01;
            parameters[5].Value     = model.Other02;

            DbHelperSQL.RunProcedure("NewsTypeList_ADD", parameters, out rowsAffected);
            return((int)parameters[0].Value);
        }