Loading ...

Need help in C# POS web application

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  getting started / general asp.net   » Need help in C# POS web application

Need help in C# POS web application

Posts under the topic: Need help in C# POS web application

Posted: 7/5/2011

Lurker 360  points  Lurker
  • Joined on: 6/5/2011
  • Posts: 51

I am working on a Point of sale module for a web application. I need help ensuring my data stays in a money format ie 0.00

 

Here's my code:

Double res = Double.Parse(PriceTxtBox.Text);
            res = res * Double.Parse(QtyTxtBox.Text);
            ItemTotalTxtBox.Text = res.ToString();

            if (ItemTotalTxtBox != null)
            {
                Double rs = Double.Parse(ItemTotalTxtBox.Text);
                rs = (rs * (.075)) + Double.Parse(ItemTotalTxtBox.Text);

                Double ts = (rs *(.075));

                TotalTxtBox.Text = rs.ToString();
                TaxTxtBox.Text = ts.ToString();
            }


I can handle constraing the input on the client side.

When PriceTxtBox is 2 and QtyTxtBox is 3 I need the result to be 6.00 not 6 like I am getting now.

When ItemTotalTxtBox is 4.67 I need TotalTxtBox to be 0.35 not 0.35025 like I am getting now.

 

Thanks in advance.


Posted: 7/22/2011

Lurker 82  points  Lurker
  • Joined on: 9/15/2009
  • Posts: 9
  Answered

 


Hi mike,

Try this code it may help u

first include package : using System.Globalization;

then put the code................

 

public void show() { Double res = Double.Parse(PriceTxtBox.Text); res = res * Double.Parse(QtyTxtBox.Text); ItemTotalTxtBox.Text = formatDblToMoney(res); if (ItemTotalTxtBox != null) { Double rs = Double.Parse(ItemTotalTxtBox.Text); rs = (rs * (.075)) + Double.Parse(ItemTotalTxtBox.Text); Double ts = (rs * (.075)); TotalTxtBox.Text = formatDblToMoney(rs); TaxTxtBox.Text = formatDblToMoney(ts); } } public static string formatDblToMoney(Double d) { return String.Format(CultureInfo.CreateSpecificCulture("en-us"), "{0:N}", d); }



Page 1 of 1 (2 items)