/// <summary> /// 更新一条数据 /// </summary> public bool Update(WeiXinPF.Model.wx_ucard_score model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_ucard_score set "); strSql.Append("wid=@wid,"); strSql.Append("userdContent=@userdContent,"); strSql.Append("scoreRegular=@scoreRegular,"); strSql.Append("qiandaoScore=@qiandaoScore,"); strSql.Append("qiandao6Score=@qiandao6Score,"); strSql.Append("consumeMoney=@consumeMoney,"); strSql.Append("consumeMoneyScore=@consumeMoneyScore,"); strSql.Append("sId=@sId"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@userdContent", SqlDbType.VarChar, 1500), new SqlParameter("@scoreRegular", SqlDbType.VarChar, 1500), new SqlParameter("@qiandaoScore", SqlDbType.Int, 4), new SqlParameter("@qiandao6Score", SqlDbType.Int, 4), new SqlParameter("@consumeMoney", SqlDbType.Int, 4), new SqlParameter("@consumeMoneyScore", SqlDbType.Int, 4), new SqlParameter("@sId", SqlDbType.Int, 4), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.userdContent; parameters[2].Value = model.scoreRegular; parameters[3].Value = model.qiandaoScore; parameters[4].Value = model.qiandao6Score; parameters[5].Value = model.consumeMoney; parameters[6].Value = model.consumeMoneyScore; parameters[7].Value = model.sId; parameters[8].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_ucard_score DataRowToModel(DataRow row) { WeiXinPF.Model.wx_ucard_score model = new WeiXinPF.Model.wx_ucard_score(); 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["userdContent"] != null) { model.userdContent = row["userdContent"].ToString(); } if (row["scoreRegular"] != null) { model.scoreRegular = row["scoreRegular"].ToString(); } if (row["qiandaoScore"] != null && row["qiandaoScore"].ToString() != "") { model.qiandaoScore = int.Parse(row["qiandaoScore"].ToString()); } if (row["qiandao6Score"] != null && row["qiandao6Score"].ToString() != "") { model.qiandao6Score = int.Parse(row["qiandao6Score"].ToString()); } if (row["consumeMoney"] != null && row["consumeMoney"].ToString() != "") { model.consumeMoney = int.Parse(row["consumeMoney"].ToString()); } if (row["consumeMoneyScore"] != null && row["consumeMoneyScore"].ToString() != "") { model.consumeMoneyScore = int.Parse(row["consumeMoneyScore"].ToString()); } if (row["sId"] != null && row["sId"].ToString() != "") { model.sId = int.Parse(row["sId"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WeiXinPF.Model.wx_ucard_score model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_ucard_score("); strSql.Append("wid,userdContent,scoreRegular,qiandaoScore,qiandao6Score,consumeMoney,consumeMoneyScore,sId)"); strSql.Append(" values ("); strSql.Append("@wid,@userdContent,@scoreRegular,@qiandaoScore,@qiandao6Score,@consumeMoney,@consumeMoneyScore,@sId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@userdContent", SqlDbType.VarChar, 1500), new SqlParameter("@scoreRegular", SqlDbType.VarChar, 1500), new SqlParameter("@qiandaoScore", SqlDbType.Int, 4), new SqlParameter("@qiandao6Score", SqlDbType.Int, 4), new SqlParameter("@consumeMoney", SqlDbType.Int, 4), new SqlParameter("@consumeMoneyScore", SqlDbType.Int, 4), new SqlParameter("@sId", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.userdContent; parameters[2].Value = model.scoreRegular; parameters[3].Value = model.qiandaoScore; parameters[4].Value = model.qiandao6Score; parameters[5].Value = model.consumeMoney; parameters[6].Value = model.consumeMoneyScore; parameters[7].Value = model.sId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 店铺的积分规则 /// </summary> public WeiXinPF.Model.wx_ucard_score GetStoreModel(int sId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,wid,userdContent,scoreRegular,qiandaoScore,qiandao6Score,consumeMoney,consumeMoneyScore,sId from wx_ucard_score "); strSql.Append(" where sId=@sId"); SqlParameter[] parameters = { new SqlParameter("@sId", SqlDbType.Int, 4) }; parameters[0].Value = sId; WeiXinPF.Model.wx_ucard_score model = new WeiXinPF.Model.wx_ucard_score(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }