MikeMCSD
asked on
Need this SQL rewritten in C#
I have this SQL :
UPDATE Nop_ProductVariant
SET Price =
CASE WHEN Price-floor(Price) >= 0.70 THEN floor(Price) + 0.95 ELSE
CASE WHEN Price-floor(Price) >= 0.50 THEN floor(Price) + 0.69 ELSE
CASE WHEN Price-floor(Price) >= 0.30 THEN floor(Price) + 0.49 ELSE
CASE WHEN Price-floor(Price) >= 0.01 THEN floor(Price) + 0.29 ELSE
CASE WHEN Price-floor(Price) = 0.00 THEN floor(Price) + 0.00
END END END END END
It rounds the digits after the decimal point.
So if Price is "29.14", it would be "29.29", . . . "18.78" would be "18.99", etc.
I now need this written in C#. How can I do this? thanks
UPDATE Nop_ProductVariant
SET Price =
CASE WHEN Price-floor(Price) >= 0.70 THEN floor(Price) + 0.95 ELSE
CASE WHEN Price-floor(Price) >= 0.50 THEN floor(Price) + 0.69 ELSE
CASE WHEN Price-floor(Price) >= 0.30 THEN floor(Price) + 0.49 ELSE
CASE WHEN Price-floor(Price) >= 0.01 THEN floor(Price) + 0.29 ELSE
CASE WHEN Price-floor(Price) = 0.00 THEN floor(Price) + 0.00
END END END END END
It rounds the digits after the decimal point.
So if Price is "29.14", it would be "29.29", . . . "18.78" would be "18.99", etc.
I now need this written in C#. How can I do this? thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
if (price - System.Math.Floor(price) >= 0.7) {
price = System.Math.Floor(price) + 0.95;
} else if (price - System.Math.Floor(price) >= 0.5) {
price = System.Math.Floor(price) + 0.69;
} else if (price - System.Math.Floor(price) >= 0.3) {
price = System.Math.Floor(price) + 0.49;
} else if (price - System.Math.Floor(price) >= 0.01) {
price = System.Math.Floor(price) + 0.29;
} else if (price - System.Math.Floor(price) == 0.0) {
price = System.Math.Floor(price) + 0.0;
}