示例#1
0
文件: Pay.cs 项目: waitmail/Cash8
        public Pay()
        {
            InitializeComponent();
            this.cash_sum.SelectionStart     = 0;
            this.non_cash_sum.SelectionStart = 0;
            this.pay_bonus.SelectionStart    = 0;

            this.KeyPreview                 = true;
            this.Load                      += new EventHandler(Pay_Load);
            this.cash_sum.KeyPress         += new KeyPressEventHandler(cash_sum_KeyPress);
            this.cash_sum.KeyUp            += new KeyEventHandler(cash_sum_KeyUp);
            this.non_cash_sum.KeyPress     += new KeyPressEventHandler(non_cash_KeyPress);
            this.non_cash_sum.KeyUp        += new KeyEventHandler(non_cash_KeyUp);
            this.pay_bonus.KeyPress        += new KeyPressEventHandler(pay_bonus_KeyPress);
            this.pay_bonus.KeyUp           += new KeyEventHandler(pay_bonus_KeyUp);
            this.non_cash_sum_kop.KeyPress += new KeyPressEventHandler(non_cash_sum_kop_KeyPress);
            this.button_pay.Enabled         = false;
            listView_sertificates           = new ListView();
            if (MainStaticClass.NumberDecimalSeparator() == ".")
            {
                this.pay_bonus_many.Text = "0.00";
            }
            else
            {
                this.pay_bonus_many.Text = "0,00";
            }
        }
示例#2
0
文件: Pay.cs 项目: waitmail/Cash8
        private void cash_sum_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((Char.IsDigit(e.KeyChar)))
            {
                if (firs_input)
                {
                    firs_input              = false;
                    cash_sum.Text           = e.KeyChar + cash_sum.Text.Substring(1, cash_sum.Text.Length - 1);
                    e.Handled               = true;
                    cash_sum.SelectionStart = 1;
                    curpos = 1;
                }
            }
            if (MainStaticClass.get_currency() == "руб.")//зарпет на ввод запятой и точек можно только цифры или бекспейс
            {
                if (!(Char.IsDigit(e.KeyChar)) && (e.KeyChar != (char)Keys.Back))
                {
                    e.Handled = true;
                }
            }
            if (!(Char.IsDigit(e.KeyChar)))
            {
                if ((e.KeyChar == '.') || (e.KeyChar == ','))
                {
                    cash_sum.SelectionStart = cash_sum.Text.IndexOf(MainStaticClass.NumberDecimalSeparator()) + 1;
                    curpos = cash_sum.SelectionStart; e.Handled = true;
                }

                if (e.KeyChar != (char)Keys.Back)
                {
                    e.Handled = true;
                }
            }

            if (e.Handled == false)
            {
                if (e.KeyChar != (char)Keys.Back)
                {
                    curpos = cash_sum.SelectionStart;
                    curpos++;
                }
                else
                {
                    if (cash_sum.SelectionStart != 0)
                    {
                        if (cash_sum.Text.Substring(cash_sum.SelectionStart - 1, 1) == ".")
                        {
                            e.Handled = true;
                            cash_sum.SelectionStart -= 1;
                            curpos = cash_sum.SelectionStart;
                        }
                        else if ((cash_sum.SelectionStart == 2) && (!e.Handled))
                        {
                            curpos = 1;
                        }
                        else
                        {
                            curpos = cash_sum.SelectionStart - 1;
                        }
                    }
                }
            }

            this.cash_sum.Update();
        }