Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need this SQL rewritten in C#

Posted on 2011-09-30
3
Medium Priority
?
194 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
Comment
Question by:MikeMCSD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Expert Comment

by:xav056
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

by:
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;
}

Open in new window

0
 
LVL 16

Author Closing Comment

by:MikeMCSD
ID: 36893495
Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

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

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

Join & Ask a Question