Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(NCPEP.Model.T_NewsType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_NewsType set ");
            strSql.Append("NewsTypeName=@NewsTypeName,");
            strSql.Append("Editor=@Editor,");
            strSql.Append("CreateDate=@CreateDate");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeName", SqlDbType.NVarChar,  50),
                new SqlParameter("@Editor",       SqlDbType.NVarChar,  50),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.NewsTypeName;
            parameters[1].Value = model.Editor;
            parameters[2].Value = model.CreateDate;
            parameters[3].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(NCPEP.Model.T_NewsType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_NewsType(");
            strSql.Append("NewsTypeName,Editor,CreateDate)");
            strSql.Append(" values (");
            strSql.Append("@NewsTypeName,@Editor,@CreateDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsTypeName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Editor",       SqlDbType.NVarChar, 50),
                new SqlParameter("@CreateDate",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.NewsTypeName;
            parameters[1].Value = model.Editor;
            parameters[2].Value = model.CreateDate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public NCPEP.Model.T_NewsType DataRowToModel(DataRow row)
 {
     NCPEP.Model.T_NewsType model = new NCPEP.Model.T_NewsType();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["NewsTypeName"] != null)
         {
             model.NewsTypeName = row["NewsTypeName"].ToString();
         }
         if (row["Editor"] != null)
         {
             model.Editor = row["Editor"].ToString();
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NCPEP.Model.T_NewsType GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,NewsTypeName,Editor,CreateDate from T_NewsType ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            NCPEP.Model.T_NewsType model = new NCPEP.Model.T_NewsType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(NCPEP.Model.T_NewsType model)
 {
     return(dal.Update(model));
 }
Esempio n. 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(NCPEP.Model.T_NewsType model)
 {
     return(dal.Add(model));
 }