示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJS.Model.Channel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Channel(");
            strSql.Append("EditId,EditDate,ChannelName,IsDeleted,CreateId,CreateDate");
            strSql.Append(") values (");
            strSql.Append("@EditId,@EditDate,@ChannelName,@IsDeleted,@CreateId,@CreateDate");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EditId",      model.EditId),
                new SqlParameter("@EditDate",    model.EditDate),
                new SqlParameter("@ChannelName", model.ChannelName),
                new SqlParameter("@IsDeleted",   model.IsDeleted),
                new SqlParameter("@CreateId",    model.CreateId),
                new SqlParameter("@CreateDate",  model.CreateDate)
            };


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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJS.Model.Channel GetModel(int ChannelId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ChannelId, EditId, EditDate, ChannelName, IsDeleted, CreateId, CreateDate  ");
            strSql.Append("  from Channel ");
            strSql.Append(" where ChannelId=@ChannelId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ChannelId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ChannelId;


            BWJS.Model.Channel model = new BWJS.Model.Channel();
            DataSet            ds    = BWJSHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJS.Model.Channel DataRowToModel(DataRow row)
        {
            BWJS.Model.Channel model = new BWJS.Model.Channel();

            if (row != null)
            {
                if (row["ChannelId"].ToString() != "")
                {
                    model.ChannelId = int.Parse(row["ChannelId"].ToString());
                }
                if (row["EditId"].ToString() != "")
                {
                    model.EditId = int.Parse(row["EditId"].ToString());
                }
                if (row["EditDate"].ToString() != "")
                {
                    model.EditDate = DateTime.Parse(row["EditDate"].ToString());
                }
                model.ChannelName = row["ChannelName"].ToString();
                if (row["IsDeleted"].ToString() != "")
                {
                    model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
                }
                if (row["CreateId"].ToString() != "")
                {
                    model.CreateId = int.Parse(row["CreateId"].ToString());
                }
                if (row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJS.Model.Channel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Channel set ");

            strSql.Append(" EditId = @EditId , ");
            strSql.Append(" EditDate = @EditDate , ");
            strSql.Append(" ChannelName = @ChannelName , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" CreateId = @CreateId , ");
            strSql.Append(" CreateDate = @CreateDate  ");
            strSql.Append(" where ChannelId=@ChannelId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ChannelId",   model.ChannelId),
                new SqlParameter("@EditId",      model.EditId),
                new SqlParameter("@EditDate",    model.EditDate),
                new SqlParameter("@ChannelName", model.ChannelName),
                new SqlParameter("@IsDeleted",   model.IsDeleted),
                new SqlParameter("@CreateId",    model.CreateId),
                new SqlParameter("@CreateDate",  model.CreateDate)
            };

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BWJS.Model.Channel model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(BWJS.Model.Channel model)
 {
     return(dal.Add(model));
 }