示例#1
0
        public moneyComponent convertToMoneyFormat(TextBox txtBox, Action function)
        {
            var error = "";
            var item  = new moneyComponent();

            if (txtBox.Text != "")
            {
                if (txtBox.Text[0] == '$')
                {
                    txtBox.Text = txtBox.Text.Remove(0, 1);
                }

                if (containLetter(txtBox.Text))
                {
                    txtBox.Text = "$0" + separator + "00";
                    error       = "Only Numbers";
                }
                else if (txtBox.Text[0] == '-')
                {
                    txtBox.Text = "$0" + separator + "00";
                    error       = "Negative Values";
                }
                else if (containFloat(txtBox.Text))
                {
                    txtBox.Text = "$" + changeFloat(txtBox.Text);
                }
                else
                {
                    txtBox.Text = "$" + txtBox.Text + separator + "00";
                }
            }
            else
            {
                txtBox.Text = "$0" + separator + "00";
            }

            function();

            AddFloat(txtBox);
            item.error            = error;
            item.TextboxComponent = txtBox;

            return(item);
        }
示例#2
0
        public moneyComponent convertToMoneyFormat(string txt)
        {
            var error = "";
            var item  = new moneyComponent();

            if (txt != "")
            {
                if (txt[0] != '$')
                {
                    if (!Char.IsNumber(txt[0]))
                    {
                        txt   = "$0" + separator + "00";
                        error = "Only Numbers";
                    }
                    else if (txt[0] == '-')
                    {
                        txt   = "$0" + separator + "00";
                        error = "Negative Values";
                    }
                    else
                    {
                        txt = "$" + txt + separator + "00";
                    }
                }
                else
                {
                    if (!Char.IsNumber(txt.Remove(0, 1)[0]))
                    {
                        txt   = "$0" + separator + "00";
                        error = "Only Numbers";
                    }
                }
            }
            else
            {
                txt = "$0" + separator + "00";
            }

            txt               = AddFloat(txt);
            item.error        = error;
            item.txtComponent = txt;

            return(item);
        }