如何将字段舍入到最接近的千位 [英] how to round off a field to nearest thousand

查看:75
本文介绍了如何将字段舍入到最接近的千位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在表中有2个字段,即成本价,售价。

我的项目是这样工作的: -



成本价格* 2 =售价。



因此,如果我以成本价格输入21928,那么在它成倍增加之后2,它来自43856



i希望这个售价能够达到44000.我的意思是我想要舍入到最接近的千位,以便最后3位数始终为零。



我写了代码。

Hi
I have 2 fields in a table namely cost price, selling price.
My project is working like this:-

Cost price * 2= selling price.

so if i enter 21928 as cost price, then after it gets multiplied by 2 it comes as 43856

i want this selling price to make 44000. I mean i want to make rounded off to nearest thousand so that last 3 digits comes zero always.

I have written the code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Configuration;
using System.Data;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Reporting;
using CrystalDecisions.Web;

/// 
/// Summary description for JewelleryHelper
/// 
 public class JewelleryHelper
{
    /// 
    /// Get encoded selling price
    /// 
    /// Selling price
    /// Encoded selling price
    public static string GetEncodedSellingPrice(string price)
    {
        char[] arrPrice = Math.Round(double.Parse(price) * 2).ToString().ToCharArray();
       string finalSellingPrice = string.Empty;
        //Populating price in encoded format
        foreach (char letter in arrPrice)
        {
            finalSellingPrice += GetEncodedLetter(letter);
        }



任何人都可以告诉我。







谢谢

Sudeshna


Can anyone please tell me.

Please

Thanks
Sudeshna

推荐答案

尝试 Math.Round(Decimal.Parse (价格)/ 1000d,0)* 1000;


这篇关于如何将字段舍入到最接近的千位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆