Monday, February 20, 2012

Money format

hello everyone...,

i have problem in money format...

i have moneytable is containning:

userid money

A 20000,0000

B 40000,0000

userid type varchar(50)

money type money

i have store procedure like this:

ALTER PROCEDURE [dbo].[paid]
(
@.userid AS varchar(50),

@.cost AS money,
@.message as int="1" output
)
AS

begin transaction
declare @.money as money

select @.money = money
from moneytable
where userid=@.userid

if (@.money > @.cost)
begin
set @.money = @.money - @.cost
UPDATE moneytable
SET money = @.money
WHERE userid=@.userid
set @.message ='1'
end
else
begin
set @.message = '2'
end

COMMIT TRANSACTION

when i execute this procedure. i insert value to

userid A

cost 100,0000

it can not decrease, because cost 100,0000 is same with 1000000, why is like that?

i want cost 100,0000 is same with 100.

how can i do that?

thx...

use the dot. character in ploce of comma, "," is used for sepration not for decreasing the amount of number.

e.g:

100.0000=100

100,0000=1000000

thanks

|||

thx hkhaled...,

how can i make it todot. format?

because the system automatic to make all money incomma, format

in my city, i use money format like this example:

Rp 7.000,00 =7000

Rp 100,00 =100

how can i do it?

is there need to change type in database?

thx...

|||

this is usually inhereted from your system Control Panel if you want to have it changed go to your Computer Control Panel and then under theRegional and Language Options, Format tab,Customize this Format, click oncurrency tab and change theDecimal Symbol and Digits Grouping Symbol to the choice of your own.

thanks

|||

thx hkhaled..

it can not too..

my friend said to change money type in visual studio 2005 system. is it true?

how to change it?

thx..

|||

Maybe this example will help you:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

protected void Button1_Click(object sender, EventArgs e)
{
decimal dec = decimal.Parse(TextBox1.Text);
System.Globalization.NumberFormatInfo inf = new System.Globalization.NumberFormatInfo();
inf.CurrencyDecimalSeparator = ".";
Response.Write(dec.ToString(inf));
}

|||

thx kipo..

but i am not use code behind.

i am only execute data in store procedure..

when i execute, it display page told me to insert value like that:

userid default

cost default

message default

so i insert the value like that:

userid A

cost 100,0000

message default

after i click ok, it should decrease that cost with money in the table.

my moneytable display like that:

userid money

A 20000,0000

B 40000,0000

but it not decrease . because the system read 100,0000 is same with 1000000.

if i insert 1,0000 , it can decrease. and the money from userid A in table became 10000,0000.

i am confusion... the system can read data in table like 10000,0000=10000 .but can not read in store procedure..

it seem in store procedure read ike 100,0000=1000000.

how should i do? is there i need change code in store procedure?

thx...

No comments:

Post a Comment