Пример #1
0
        /// <summary>
        /// 向数据表tb_CustomReply更新一条记录。带事务
        /// </summary>
        /// <param name="sp">事务对象</param>
        /// <param name="_tb_CustomReplyModel">_tb_CustomReplyModel</param>
        /// <returns>影响的行数</returns>
        public int Update(SqlTransaction sp, tb_CustomReplyEntity _tb_CustomReplyModel)
        {
            string sqlStr = "update tb_CustomReply set [UserID]=@UserID,[WeiXinCode]=@WeiXinCode,[Keyword]=@Keyword,[MatchingTypeID]=@MatchingTypeID,[ReplyTypeID]=@ReplyTypeID,[MaterialID]=@MaterialID,[AddTime]=@AddTime,[UpdateTime]=@UpdateTime where ID=@ID";

            SqlParameter[] _param =
            {
                new SqlParameter("@ID",             SqlDbType.Int),
                new SqlParameter("@UserID",         SqlDbType.VarChar),
                new SqlParameter("@WeiXinCode",     SqlDbType.VarChar),
                new SqlParameter("@Keyword",        SqlDbType.VarChar),
                new SqlParameter("@MatchingTypeID", SqlDbType.Int),
                new SqlParameter("@ReplyTypeID",    SqlDbType.Int),
                new SqlParameter("@MaterialID",     SqlDbType.Int),
                new SqlParameter("@AddTime",        SqlDbType.DateTime),
                new SqlParameter("@UpdateTime",     SqlDbType.DateTime)
            };
            _param[0].Value = _tb_CustomReplyModel.ID;
            _param[1].Value = _tb_CustomReplyModel.UserID;
            _param[2].Value = _tb_CustomReplyModel.WeiXinCode;
            _param[3].Value = _tb_CustomReplyModel.Keyword;
            _param[4].Value = _tb_CustomReplyModel.MatchingTypeID;
            _param[5].Value = _tb_CustomReplyModel.ReplyTypeID;
            _param[6].Value = _tb_CustomReplyModel.MaterialID;
            _param[7].Value = _tb_CustomReplyModel.AddTime;
            _param[8].Value = _tb_CustomReplyModel.UpdateTime;
            return(SqlHelper.ExecuteNonQuery(sp, CommandType.Text, sqlStr, _param));
        }
Пример #2
0
        public tb_MaterialExtEntity GetMaterialExtByCustomReply(string weixincode, string keyword)
        {
            tb_CustomReplyEntity Obj = new tb_CustomReplyEntity();

            SqlParameter[] _param =
            {
                new SqlParameter("@keyword",    SqlDbType.VarChar, 50),
                new SqlParameter("@weixincode", SqlDbType.VarChar, 50)
            };
            _param[0].Value = keyword;
            _param[1].Value = weixincode;
            string sqlStr = "select top 1 * from tb_CustomReply where Keyword=@keyword and WeiXinCode=@weixincode";

            using (SqlDataReader dr = SqlHelper.ExecuteReader(WebConfig.weixinRW, CommandType.Text, sqlStr, _param))
            {
                while (dr.Read())
                {
                    Obj = Populate_tb_CustomReplyEntity_FromDr(dr);
                }
            }
            if (Obj.MaterialID == 0)
            {
                return(null);
            }
            tb_MaterialDataAccessLayer dal = new tb_MaterialDataAccessLayer();

            return(dal.GetMaterialExt(Obj.MaterialID));
        }
Пример #3
0
        /// <summary>
        /// 得到  tb_customreply 数据实体
        /// </summary>
        /// <param name="dr">dr</param>
        /// <returns>tb_customreply 数据实体</returns>
        public tb_CustomReplyEntity Populate_tb_CustomReplyEntity_FromDr(IDataReader dr)
        {
            tb_CustomReplyEntity Obj = new tb_CustomReplyEntity();

            Obj.ID             = ((dr["ID"]) == DBNull.Value)?0:Convert.ToInt32(dr["ID"]);
            Obj.UserID         = dr["UserID"].ToString();
            Obj.WeiXinCode     = dr["WeiXinCode"].ToString();
            Obj.Keyword        = dr["Keyword"].ToString();
            Obj.MatchingTypeID = ((dr["MatchingTypeID"]) == DBNull.Value)?0:Convert.ToInt32(dr["MatchingTypeID"]);
            Obj.ReplyTypeID    = ((dr["ReplyTypeID"]) == DBNull.Value)?0:Convert.ToInt32(dr["ReplyTypeID"]);
            Obj.MaterialID     = ((dr["MaterialID"]) == DBNull.Value)?0:Convert.ToInt32(dr["MaterialID"]);
            Obj.AddTime        = ((dr["AddTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["AddTime"]);
            Obj.UpdateTime     = ((dr["UpdateTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["UpdateTime"]);

            return(Obj);
        }
Пример #4
0
        /// <summary>
        /// 根据ID,返回一个tb_CustomReply对象
        /// </summary>
        /// <param name="iD">iD</param>
        /// <returns>tb_CustomReply对象</returns>
        public tb_CustomReplyEntity Get_tb_CustomReplyEntity(int iD)
        {
            tb_CustomReplyEntity _obj = null;

            SqlParameter[] _param =
            {
                new SqlParameter("@ID", SqlDbType.Int)
            };
            _param[0].Value = iD;
            string sqlStr = "select * from tb_CustomReply with(nolock) where ID=@ID";

            using (SqlDataReader dr = SqlHelper.ExecuteReader(WebConfig.weixinRW, CommandType.Text, sqlStr, _param))
            {
                while (dr.Read())
                {
                    _obj = Populate_tb_CustomReplyEntity_FromDr(dr);
                }
            }
            return(_obj);
        }
Пример #5
0
        /// <summary>
        /// 得到  tb_customreply 数据实体
        /// </summary>
        /// <param name="row">row</param>
        /// <returns>tb_customreply 数据实体</returns>
        public tb_CustomReplyEntity Populate_tb_CustomReplyEntity_FromDr(DataRow row)
        {
            tb_CustomReplyEntity Obj = new tb_CustomReplyEntity();

            if (row != null)
            {
                Obj.ID             = ((row["ID"]) == DBNull.Value)?0:Convert.ToInt32(row["ID"]);
                Obj.UserID         = row["UserID"].ToString();
                Obj.WeiXinCode     = row["WeiXinCode"].ToString();
                Obj.Keyword        = row["Keyword"].ToString();
                Obj.MatchingTypeID = ((row["MatchingTypeID"]) == DBNull.Value)?0:Convert.ToInt32(row["MatchingTypeID"]);
                Obj.ReplyTypeID    = ((row["ReplyTypeID"]) == DBNull.Value)?0:Convert.ToInt32(row["ReplyTypeID"]);
                Obj.MaterialID     = ((row["MaterialID"]) == DBNull.Value)?0:Convert.ToInt32(row["MaterialID"]);
                Obj.AddTime        = ((row["AddTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["AddTime"]);
                Obj.UpdateTime     = ((row["UpdateTime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["UpdateTime"]);
            }
            else
            {
                return(null);
            }
            return(Obj);
        }
Пример #6
0
 public void Update(tb_CustomReplyEntity tb_CustomReplyEntity)
 {
     tb_CustomReplydal.Update(tb_CustomReplyEntity);
 }
Пример #7
0
 public int Insert(tb_CustomReplyEntity tb_CustomReplyEntity)
 {
     return(tb_CustomReplydal.Insert(tb_CustomReplyEntity));
 }