/// <summary> /// 得到回复规则的【图文】信息 /// </summary> /// <param name="rid">规则主键Id</param> /// <returns></returns> public IList<MxWeiXinPF.Model.wx_requestRuleContent> GetTuWenContent(int rid) { IList<MxWeiXinPF.Model.wx_requestRuleContent> rcList = new List<Model.wx_requestRuleContent>(); StringBuilder strSql = new StringBuilder(); strSql.Append("select top 10 rContent,rContent2 ,picUrl,detailUrl from wx_requestRuleContent "); strSql.Append(" where rid=@rid order by seq asc"); SqlParameter[] parameters = { new SqlParameter("@rid", SqlDbType.Int,4) }; parameters[0].Value = rid; SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters); MxWeiXinPF.Model.wx_requestRuleContent model = new MxWeiXinPF.Model.wx_requestRuleContent(); while (sr.Read()) { model = new MxWeiXinPF.Model.wx_requestRuleContent(); model.rContent = sr["rContent"].ToString(); model.rContent2 = sr["rContent2"].ToString(); model.picUrl = sr["picUrl"].ToString(); model.detailUrl = sr["detailUrl"].ToString(); rcList.Add(model); } sr.Close(); return rcList; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MxWeiXinPF.Model.wx_requestRuleContent model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_requestRuleContent("); strSql.Append("uId,rId,rContent,rContent2,detailUrl,picUrl,mediaUrl,meidaHDUrl,remark,seq,createDate,extInt,extInt2,extStr,extStr2,extstr3)"); strSql.Append(" values ("); strSql.Append("@uId,@rId,@rContent,@rContent2,@detailUrl,@picUrl,@mediaUrl,@meidaHDUrl,@remark,@seq,@createDate,@extInt,@extInt2,@extStr,@extStr2,@extstr3)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@uId", SqlDbType.Int, 4), new SqlParameter("@rId", SqlDbType.Int, 4), new SqlParameter("@rContent", SqlDbType.Text), new SqlParameter("@rContent2", SqlDbType.VarChar, 2000), new SqlParameter("@detailUrl", SqlDbType.VarChar, 1000), new SqlParameter("@picUrl", SqlDbType.VarChar, 1000), new SqlParameter("@mediaUrl", SqlDbType.VarChar, 1500), new SqlParameter("@meidaHDUrl", SqlDbType.VarChar, 1500), new SqlParameter("@remark", SqlDbType.VarChar, 2000), new SqlParameter("@seq", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@extInt", SqlDbType.Int, 4), new SqlParameter("@extInt2", SqlDbType.Int, 4), new SqlParameter("@extStr", SqlDbType.VarChar, 800), new SqlParameter("@extStr2", SqlDbType.VarChar, 1000), new SqlParameter("@extstr3", SqlDbType.VarChar, 1500) }; parameters[0].Value = model.uId; parameters[1].Value = model.rId; parameters[2].Value = model.rContent; parameters[3].Value = model.rContent2; parameters[4].Value = model.detailUrl; parameters[5].Value = model.picUrl; parameters[6].Value = model.mediaUrl; parameters[7].Value = model.meidaHDUrl; parameters[8].Value = model.remark; parameters[9].Value = model.seq; parameters[10].Value = model.createDate; parameters[11].Value = model.extInt; parameters[12].Value = model.extInt2; parameters[13].Value = model.extStr; parameters[14].Value = model.extStr2; parameters[15].Value = model.extstr3; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到回复规则的语音信息 /// </summary> /// <param name="rid">规则主键Id</param> /// <returns></returns> public MxWeiXinPF.Model.wx_requestRuleContent GetMusicContent(int rid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 rContent,rContent2 ,mediaUrl from wx_requestRuleContent "); strSql.Append(" where rid=@rid"); SqlParameter[] parameters = { new SqlParameter("@rid", SqlDbType.Int,4) }; parameters[0].Value = rid; SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(),parameters); MxWeiXinPF.Model.wx_requestRuleContent model = new MxWeiXinPF.Model.wx_requestRuleContent(); while (sr.Read()) { model.rContent = sr["rContent"].ToString(); model.rContent2 = sr["rContent2"].ToString(); model.mediaUrl = sr["mediaUrl"].ToString(); } sr.Close(); return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_requestRuleContent GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 id,uId,rId,rContent,rContent2,detailUrl,picUrl,mediaUrl,meidaHDUrl,remark,seq,createDate,extInt,extInt2,extStr,extStr2,extstr3 from wx_requestRuleContent "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; MxWeiXinPF.Model.wx_requestRuleContent model=new MxWeiXinPF.Model.wx_requestRuleContent(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_requestRuleContent DataRowToModel(DataRow row) { MxWeiXinPF.Model.wx_requestRuleContent model=new MxWeiXinPF.Model.wx_requestRuleContent(); if (row != null) { if(row["id"]!=null && row["id"].ToString()!="") { model.id=int.Parse(row["id"].ToString()); } if(row["uId"]!=null && row["uId"].ToString()!="") { model.uId=int.Parse(row["uId"].ToString()); } if(row["rId"]!=null && row["rId"].ToString()!="") { model.rId=int.Parse(row["rId"].ToString()); } if(row["rContent"]!=null) { model.rContent=row["rContent"].ToString(); } if(row["rContent2"]!=null) { model.rContent2=row["rContent2"].ToString(); } if(row["detailUrl"]!=null) { model.detailUrl=row["detailUrl"].ToString(); } if(row["picUrl"]!=null) { model.picUrl=row["picUrl"].ToString(); } if(row["mediaUrl"]!=null) { model.mediaUrl=row["mediaUrl"].ToString(); } if(row["meidaHDUrl"]!=null) { model.meidaHDUrl=row["meidaHDUrl"].ToString(); } if(row["remark"]!=null) { model.remark=row["remark"].ToString(); } if(row["seq"]!=null && row["seq"].ToString()!="") { model.seq=int.Parse(row["seq"].ToString()); } if(row["createDate"]!=null && row["createDate"].ToString()!="") { model.createDate=DateTime.Parse(row["createDate"].ToString()); } if(row["extInt"]!=null && row["extInt"].ToString()!="") { model.extInt=int.Parse(row["extInt"].ToString()); } if(row["extInt2"]!=null && row["extInt2"].ToString()!="") { model.extInt2=int.Parse(row["extInt2"].ToString()); } if(row["extStr"]!=null) { model.extStr=row["extStr"].ToString(); } if(row["extStr2"]!=null) { model.extStr2=row["extStr2"].ToString(); } if(row["extstr3"]!=null) { model.extstr3=row["extstr3"].ToString(); } } return model; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MxWeiXinPF.Model.wx_requestRuleContent model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update wx_requestRuleContent set "); strSql.Append("uId=@uId,"); strSql.Append("rId=@rId,"); strSql.Append("rContent=@rContent,"); strSql.Append("rContent2=@rContent2,"); strSql.Append("detailUrl=@detailUrl,"); strSql.Append("picUrl=@picUrl,"); strSql.Append("mediaUrl=@mediaUrl,"); strSql.Append("meidaHDUrl=@meidaHDUrl,"); strSql.Append("remark=@remark,"); strSql.Append("seq=@seq,"); strSql.Append("createDate=@createDate,"); strSql.Append("extInt=@extInt,"); strSql.Append("extInt2=@extInt2,"); strSql.Append("extStr=@extStr,"); strSql.Append("extStr2=@extStr2,"); strSql.Append("extstr3=@extstr3"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@uId", SqlDbType.Int,4), new SqlParameter("@rId", SqlDbType.Int,4), new SqlParameter("@rContent", SqlDbType.Text), new SqlParameter("@rContent2", SqlDbType.VarChar,2000), new SqlParameter("@detailUrl", SqlDbType.VarChar,1000), new SqlParameter("@picUrl", SqlDbType.VarChar,1000), new SqlParameter("@mediaUrl", SqlDbType.VarChar,1500), new SqlParameter("@meidaHDUrl", SqlDbType.VarChar,1500), new SqlParameter("@remark", SqlDbType.VarChar,2000), new SqlParameter("@seq", SqlDbType.Int,4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@extInt", SqlDbType.Int,4), new SqlParameter("@extInt2", SqlDbType.Int,4), new SqlParameter("@extStr", SqlDbType.VarChar,800), new SqlParameter("@extStr2", SqlDbType.VarChar,1000), new SqlParameter("@extstr3", SqlDbType.VarChar,1500), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.uId; parameters[1].Value = model.rId; parameters[2].Value = model.rContent; parameters[3].Value = model.rContent2; parameters[4].Value = model.detailUrl; parameters[5].Value = model.picUrl; parameters[6].Value = model.mediaUrl; parameters[7].Value = model.meidaHDUrl; parameters[8].Value = model.remark; parameters[9].Value = model.seq; parameters[10].Value = model.createDate; parameters[11].Value = model.extInt; parameters[12].Value = model.extInt2; parameters[13].Value = model.extStr; parameters[14].Value = model.extStr2; parameters[15].Value = model.extstr3; parameters[16].Value = model.id; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } }