Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# Need this SQL rewritten in C#

Posted on 2011-09-30
Medium Priority
197 Views
Last Modified: 2012-05-12
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

0
Question by:MikeMCSD
• 2
3 Comments

LVL 9

Expert Comment

ID: 36892956
double price = 0;
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;
}
0

LVL 9

Accepted Solution

xav056 earned 2000 total points
ID: 36892961
actually no need to declare price (take this out double price=0)
this should be it
``````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;
}
``````
0

LVL 16

Author Closing Comment

ID: 36893495
Thank you
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
###### Suggested Courses
Course of the Month13 days, 23 hours left to enroll

#### 580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.