public static int recalculateMemberBalancePoints1(string strMemberID, string strUpdateType, int intPoints, string strLoyaltyTranID) { int intExistingPoints = 0; int intBalancePoints = 0; SqlParameter[] paramR = new SqlParameter[1]; paramR[0] = new SqlParameter("@MemberID", SqlDbType.NVarChar); paramR[0].Value = strMemberID; string sqlQryR = "select BalancePoints from Members where MemberID = @MemberID"; SqlDataReader drR = DataAccessor.ExecuteQueryDataReader(sqlQryR, paramR); while (drR.Read()) { intExistingPoints = GeneralFunctions._parseStringToInt(drR["BalancePoints"].ToString()); } drR.Close(); SqlParameter[] paramU = new SqlParameter[2]; paramU[0] = new SqlParameter("@MemberID", SqlDbType.NVarChar); paramU[0].Value = strMemberID; paramU[1] = new SqlParameter("@BalancePoints", SqlDbType.Int); paramU[1].Value = intBalancePoints; DataAccessor.ExecuteQuery("Update Members set BalancePoints=@BalancePoints where MemberID=@MemberID", paramU); return(intBalancePoints); }
public static int recalculateMemberBalancePoints(string strMemberID) { int intRedeemedPoints = 0; int intEarnedPoints = 0; int intBalancePoints = 0; SqlParameter[] paramR = new SqlParameter[1]; paramR[0] = new SqlParameter("@MemberID", SqlDbType.NVarChar); paramR[0].Value = strMemberID; string sqlQryR = "select isnull(sum(Points),0) as RedeemedPoints from LoyaltyTransactions "; sqlQryR += "where Status = 'Confirmed' and Activity = 'Redeemed' and MemberID = @MemberID"; SqlDataReader drR = DataAccessor.ExecuteQueryDataReader(sqlQryR, paramR); while (drR.Read()) { intRedeemedPoints = GeneralFunctions._parseStringToInt(drR["RedeemedPoints"].ToString()); } drR.Close(); SqlParameter[] paramE = new SqlParameter[1]; paramE[0] = new SqlParameter("@MemberID", SqlDbType.NVarChar); paramE[0].Value = strMemberID; string sqlQryE = "select isnull(sum(Points),0) as EarnedPoints from LoyaltyTransactions "; sqlQryE += "where Status = 'Confirmed' and Activity = 'Earned' and MemberID = @MemberID"; SqlDataReader drE = DataAccessor.ExecuteQueryDataReader(sqlQryE, paramE); while (drE.Read()) { intEarnedPoints = GeneralFunctions._parseStringToInt(drE["EarnedPoints"].ToString()); } drE.Close(); intBalancePoints = intEarnedPoints - intRedeemedPoints; SqlParameter[] paramU = new SqlParameter[2]; paramU[0] = new SqlParameter("@MemberID", SqlDbType.NVarChar); paramU[0].Value = strMemberID; paramU[1] = new SqlParameter("@BalancePoints", SqlDbType.Int); paramU[1].Value = intBalancePoints; DataAccessor.ExecuteQuery("Update Members set BalancePoints=@BalancePoints where MemberID=@MemberID", paramU); return(intBalancePoints); }