/// <summary> /// 得到一个对象实体 /// </summary> public MerchantVsImgModel GetModel(decimal MerchantId, string ImgId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select MerchantId, ImgId, vsType "); strSql.Append(" from MerchantVsImg "); strSql.Append(" where MerchantId=@MerchantId and ImgId=@ImgId "); SqlParameter[] parameters = { new SqlParameter("@MerchantId", SqlDbType.Decimal, 9), new SqlParameter("@ImgId", SqlDbType.VarChar, 50) }; parameters[0].Value = MerchantId; parameters[1].Value = ImgId; MerchantVsImgModel model = new MerchantVsImgModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["MerchantId"].ToString() != "") { model.MerchantId = decimal.Parse(ds.Tables[0].Rows[0]["MerchantId"].ToString()); } model.ImgId = ds.Tables[0].Rows[0]["ImgId"].ToString(); model.vsType = ds.Tables[0].Rows[0]["vsType"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(MerchantVsImgModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into MerchantVsImg("); strSql.Append("MerchantId,ImgId,vsType"); strSql.Append(") values ("); strSql.Append("@MerchantId,@ImgId,@vsType"); strSql.Append(") "); strSql.Append(Common.SqlStrHelper.BindImgSqlStr(model.ImgId)); SqlParameter[] parameters = { new SqlParameter("@MerchantId", SqlDbType.Decimal, 9), new SqlParameter("@ImgId", SqlDbType.VarChar, 50), new SqlParameter("@vsType", SqlDbType.VarChar, 10) }; parameters[0].Value = model.MerchantId; parameters[1].Value = model.ImgId; parameters[2].Value = model.vsType; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MerchantVsImgModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update MerchantVsImg set "); strSql.Append(" MerchantId = @MerchantId , "); strSql.Append(" ImgId = @ImgId , "); strSql.Append(" vsType = @vsType "); strSql.Append(" where MerchantId=@MerchantId and ImgId=@ImgId "); SqlParameter[] parameters = { new SqlParameter("@MerchantId", SqlDbType.Decimal, 9), new SqlParameter("@ImgId", SqlDbType.VarChar, 50), new SqlParameter("@vsType", SqlDbType.VarChar, 10) }; parameters[0].Value = model.MerchantId; parameters[1].Value = model.ImgId; parameters[2].Value = model.vsType; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }