/// <summary> /// 设置用户信用(该方法会在用户进行评价之后调用) /// </summary> /// <param name="goodsrateinfo">评价信息</param> /// <param name="uid">被评价人的uid</param> /// <returns></returns> public static bool SetUserCredit(Goodsrateinfo goodsRateInfo, int uid) { //获取被评价人的信用信息 GoodsusercreditinfoCollection goodsUserCreditInfoColl = GetUserCreditList(uid); //如果信用表中不存在, 则创建被评价人的信息 if (goodsUserCreditInfoColl.Count == 0) { //当初始化信息失败时则返回 if (DbProvider.GetInstance().InitGoodsUserCredit(uid) <= 0) { return(false); } //再次获取被评价人的信用信息 goodsUserCreditInfoColl = GetUserCreditList(uid); } //用于绑定要更新的用户信用 Goodsusercreditinfo cur_creditInfo = null; foreach (Goodsusercreditinfo goodsUserCreditInfo in goodsUserCreditInfoColl) { //查找符合条件的用户信用 if (goodsRateInfo.Uidtype == goodsUserCreditInfo.Ratefrom && goodsRateInfo.Ratetype == goodsUserCreditInfo.Ratetype) { cur_creditInfo = goodsUserCreditInfo; } break; } //当不为空, 表示找到了要更新的用户信用信息, 则进行下面的绑定操作 if (cur_creditInfo != null) { IDataReader iDataReader = DbProvider.GetInstance().GetGoodsRateCount(uid, goodsRateInfo.Uidtype, goodsRateInfo.Ratetype); //绑定新的查询数据 if (iDataReader.Read()) { cur_creditInfo.Ratefrom = goodsRateInfo.Uidtype; cur_creditInfo.Ratetype = goodsRateInfo.Ratetype; cur_creditInfo.Oneweek = TypeConverter.ObjectToInt(iDataReader["oneweek"]); cur_creditInfo.Onemonth = TypeConverter.ObjectToInt(iDataReader["onemonth"]); cur_creditInfo.Sixmonth = TypeConverter.ObjectToInt(iDataReader["sixmonth"]); cur_creditInfo.Sixmonthago = TypeConverter.ObjectToInt(iDataReader["sixmonthago"]); UpdateUserCredit(cur_creditInfo); } iDataReader.Close(); } return(true); }
/// <summary> /// 获得(商品)用户信用信息(DTO) /// </summary> /// <param name="__idatareader">要转换的数据</param> /// <returns>返回(商品)用户信用信息</returns> public static Goodsusercreditinfo GetGoodsUserCreditInfo(IDataReader reader) { Goodsusercreditinfo goodsUserCreditsInfo = null; if (reader.Read()) { goodsUserCreditsInfo = new Goodsusercreditinfo(); goodsUserCreditsInfo.Id = TypeConverter.ObjectToInt(reader["id"]); goodsUserCreditsInfo.Uid = TypeConverter.ObjectToInt(reader["uid"]); goodsUserCreditsInfo.Oneweek = TypeConverter.ObjectToInt(reader["oneweek"]); goodsUserCreditsInfo.Onemonth = TypeConverter.ObjectToInt(reader["onemonth"]); goodsUserCreditsInfo.Sixmonth = TypeConverter.ObjectToInt(reader["sixmonth"]); goodsUserCreditsInfo.Sixmonthago = TypeConverter.ObjectToInt(reader["sixmonthago"]); goodsUserCreditsInfo.Ratefrom = Convert.ToInt16(reader["ratefrom"].ToString()); goodsUserCreditsInfo.Ratetype = Convert.ToInt16(reader["ratetype"].ToString()); reader.Close(); } return(goodsUserCreditsInfo); }
/// <summary> /// 获得(商品)用户信用信息(DTO) /// </summary> /// <param name="dt">要转换的数据表</param> /// <returns>返回(商品)用户信用信息</returns> public static Goodsusercreditinfo[] GetGoodsUserCreditArray(DataTable dt) { if (dt == null || dt.Rows.Count == 0) { return(null); } Goodsusercreditinfo[] goodsUserCreditsInfoArray = new Goodsusercreditinfo[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { goodsUserCreditsInfoArray[i] = new Goodsusercreditinfo(); goodsUserCreditsInfoArray[i].Id = TypeConverter.ObjectToInt(dt.Rows[i]["id"].ToString()); goodsUserCreditsInfoArray[i].Uid = TypeConverter.ObjectToInt(dt.Rows[i]["uid"].ToString()); goodsUserCreditsInfoArray[i].Oneweek = TypeConverter.ObjectToInt(dt.Rows[i]["oneweek"].ToString()); goodsUserCreditsInfoArray[i].Onemonth = TypeConverter.ObjectToInt(dt.Rows[i]["onemonth"].ToString()); goodsUserCreditsInfoArray[i].Sixmonth = TypeConverter.ObjectToInt(dt.Rows[i]["sixmonth"].ToString()); goodsUserCreditsInfoArray[i].Sixmonthago = TypeConverter.ObjectToInt(dt.Rows[i]["sixmonthago"].ToString()); goodsUserCreditsInfoArray[i].Ratefrom = TypeConverter.ObjectToInt(dt.Rows[i]["ratefrom"].ToString()); goodsUserCreditsInfoArray[i].Ratetype = TypeConverter.ObjectToInt(dt.Rows[i]["ratetype"].ToString()); } dt.Dispose(); return(goodsUserCreditsInfoArray); }
/// <summary> /// 更新用户信用信息 /// </summary> /// <param name="goodsusercreditinfo">要更新的用户信用信息</param> /// <returns></returns> public static bool UpdateUserCredit(Goodsusercreditinfo goodsusercreditinfo) { return(DbProvider.GetInstance().UpdateGoodsUserCredit(goodsusercreditinfo)); }