/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_sTicket GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,wid,actionName,succTip,brief,beginDate,endDate,aContent,usedRemark,telphone,wUrl,seq,remark,createDate,endNotice,endContent,bannerPic,beginPic,endPic,pwd from wx_sTicket "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; WeiXinPF.Model.wx_sTicket model = new WeiXinPF.Model.wx_sTicket(); 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 int Add(WeiXinPF.Model.wx_sTicket model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_sTicket("); strSql.Append("wid,actionName,succTip,brief,beginDate,endDate,aContent,usedRemark,telphone,wUrl,seq,remark,createDate,endNotice,endContent,bannerPic,beginPic,endPic,pwd)"); strSql.Append(" values ("); strSql.Append("@wid,@actionName,@succTip,@brief,@beginDate,@endDate,@aContent,@usedRemark,@telphone,@wUrl,@seq,@remark,@createDate,@endNotice,@endContent,@bannerPic,@beginPic,@endPic,@pwd)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@actionName", SqlDbType.VarChar, 100), new SqlParameter("@succTip", SqlDbType.VarChar, 500), new SqlParameter("@brief", SqlDbType.VarChar, 500), new SqlParameter("@beginDate", SqlDbType.DateTime), new SqlParameter("@endDate", SqlDbType.DateTime), new SqlParameter("@aContent", SqlDbType.VarChar, 2000), new SqlParameter("@usedRemark", SqlDbType.VarChar, 500), new SqlParameter("@telphone", SqlDbType.VarChar, 30), new SqlParameter("@wUrl", SqlDbType.VarChar, 1000), new SqlParameter("@seq", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 4000), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@endNotice", SqlDbType.VarChar, 100), new SqlParameter("@endContent", SqlDbType.VarChar, 500), new SqlParameter("@bannerPic", SqlDbType.VarChar, 800), new SqlParameter("@beginPic", SqlDbType.VarChar, 800), new SqlParameter("@endPic", SqlDbType.VarChar, 800), new SqlParameter("@pwd", SqlDbType.VarChar, 20) }; parameters[0].Value = model.wid; parameters[1].Value = model.actionName; parameters[2].Value = model.succTip; parameters[3].Value = model.brief; parameters[4].Value = model.beginDate; parameters[5].Value = model.endDate; parameters[6].Value = model.aContent; parameters[7].Value = model.usedRemark; parameters[8].Value = model.telphone; parameters[9].Value = model.wUrl; parameters[10].Value = model.seq; parameters[11].Value = model.remark; parameters[12].Value = model.createDate; parameters[13].Value = model.endNotice; parameters[14].Value = model.endContent; parameters[15].Value = model.bannerPic; parameters[16].Value = model.beginPic; parameters[17].Value = model.endPic; parameters[18].Value = model.pwd; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_sTicket DataRowToModel(DataRow row) { WeiXinPF.Model.wx_sTicket model = new WeiXinPF.Model.wx_sTicket(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["actionName"] != null) { model.actionName = row["actionName"].ToString(); } if (row["succTip"] != null) { model.succTip = row["succTip"].ToString(); } if (row["brief"] != null) { model.brief = row["brief"].ToString(); } if (row["beginDate"] != null && row["beginDate"].ToString() != "") { model.beginDate = DateTime.Parse(row["beginDate"].ToString()); } if (row["endDate"] != null && row["endDate"].ToString() != "") { model.endDate = DateTime.Parse(row["endDate"].ToString()); } if (row["aContent"] != null) { model.aContent = row["aContent"].ToString(); } if (row["usedRemark"] != null) { model.usedRemark = row["usedRemark"].ToString(); } if (row["telphone"] != null) { model.telphone = row["telphone"].ToString(); } if (row["wUrl"] != null) { model.wUrl = row["wUrl"].ToString(); } if (row["seq"] != null && row["seq"].ToString() != "") { model.seq = int.Parse(row["seq"].ToString()); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["endNotice"] != null) { model.endNotice = row["endNotice"].ToString(); } if (row["endContent"] != null) { model.endContent = row["endContent"].ToString(); } if (row["bannerPic"] != null) { model.bannerPic = row["bannerPic"].ToString(); } if (row["beginPic"] != null) { model.beginPic = row["beginPic"].ToString(); } if (row["endPic"] != null) { model.endPic = row["endPic"].ToString(); } if (row["pwd"] != null) { model.pwd = row["pwd"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WeiXinPF.Model.wx_sTicket model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_sTicket set "); strSql.Append("wid=@wid,"); strSql.Append("actionName=@actionName,"); strSql.Append("succTip=@succTip,"); strSql.Append("brief=@brief,"); strSql.Append("beginDate=@beginDate,"); strSql.Append("endDate=@endDate,"); strSql.Append("aContent=@aContent,"); strSql.Append("usedRemark=@usedRemark,"); strSql.Append("telphone=@telphone,"); strSql.Append("wUrl=@wUrl,"); strSql.Append("seq=@seq,"); strSql.Append("remark=@remark,"); strSql.Append("createDate=@createDate,"); strSql.Append("endNotice=@endNotice,"); strSql.Append("endContent=@endContent,"); strSql.Append("bannerPic=@bannerPic,"); strSql.Append("beginPic=@beginPic,"); strSql.Append("endPic=@endPic,"); strSql.Append("pwd=@pwd"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@actionName", SqlDbType.VarChar, 100), new SqlParameter("@succTip", SqlDbType.VarChar, 500), new SqlParameter("@brief", SqlDbType.VarChar, 500), new SqlParameter("@beginDate", SqlDbType.DateTime), new SqlParameter("@endDate", SqlDbType.DateTime), new SqlParameter("@aContent", SqlDbType.VarChar, 2000), new SqlParameter("@usedRemark", SqlDbType.VarChar, 500), new SqlParameter("@telphone", SqlDbType.VarChar, 30), new SqlParameter("@wUrl", SqlDbType.VarChar, 1000), new SqlParameter("@seq", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 4000), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@endNotice", SqlDbType.VarChar, 100), new SqlParameter("@endContent", SqlDbType.VarChar, 500), new SqlParameter("@bannerPic", SqlDbType.VarChar, 800), new SqlParameter("@beginPic", SqlDbType.VarChar, 800), new SqlParameter("@endPic", SqlDbType.VarChar, 800), new SqlParameter("@pwd", SqlDbType.VarChar, 20), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.actionName; parameters[2].Value = model.succTip; parameters[3].Value = model.brief; parameters[4].Value = model.beginDate; parameters[5].Value = model.endDate; parameters[6].Value = model.aContent; parameters[7].Value = model.usedRemark; parameters[8].Value = model.telphone; parameters[9].Value = model.wUrl; parameters[10].Value = model.seq; parameters[11].Value = model.remark; parameters[12].Value = model.createDate; parameters[13].Value = model.endNotice; parameters[14].Value = model.endContent; parameters[15].Value = model.bannerPic; parameters[16].Value = model.beginPic; parameters[17].Value = model.endPic; parameters[18].Value = model.pwd; parameters[19].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }