public InputePhoneClient() { InitializeComponent(); if (MainStaticClass.get_currency() == "руб.") { this.txtB_phone_number.MaxLength = 12; } this.txtB_phone_number.KeyPress += new KeyPressEventHandler(txtB_phone_number_KeyPress); this.Load += new EventHandler(InputePhoneClient_Load); this.txtB_phone_number.SelectionStart = 1; this.KeyPreview = true; }
private void non_cash_KeyUp(object sender, KeyEventArgs e) { try { if (this.non_cash_sum.Text.Length == 0) { if (numberDecimalSeparator() == ".") { if (MainStaticClass.get_currency() == "руб.") { this.non_cash_sum.Text = "0"; } else { this.non_cash_sum.Text = "0.00"; } } else { if (MainStaticClass.get_currency() == "руб.") { this.non_cash_sum.Text = "0"; } else { this.non_cash_sum.Text = "0,00"; } } } calculate(); if (MainStaticClass.get_currency() == "руб.") { } else { if (curpos_non_cash < 0) { non_cash_sum.SelectionStart = 0; curpos_non_cash = 0; } else { non_cash_sum.SelectionStart = curpos_non_cash; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } int start = non_cash_sum.SelectionStart; string _sum_ = non_cash_sum.Text; non_cash_sum.Text = ""; non_cash_sum.Text = _sum_; non_cash_sum.SelectionStart = start; non_cash_sum.Update(); if (MainStaticClass.get_currency() == "руб.") { } else { non_cash_sum.SelectionStart = curpos_non_cash; } }
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(); }
private void cash_sum_KeyUp(object sender, KeyEventArgs e) { try { if (this.cash_sum.Text.Length == 0) { if (numberDecimalSeparator() == ".") { if (MainStaticClass.get_currency() == "руб.")//зарпет на ввод запятой и точек можно только цифры или бекспейс { this.cash_sum.Text = "0"; } else { this.cash_sum.Text = "0.00"; } } else { if (MainStaticClass.get_currency() == "руб.")//зарпет на ввод запятой и точек можно только цифры или бекспейс { this.cash_sum.Text = "0"; } else { this.cash_sum.Text = "0,00"; } } } calculate(); if (MainStaticClass.get_currency() == "руб.") { } else { if (curpos < 0) { cash_sum.SelectionStart = 0; curpos = 0; //MessageBox.Show("0"); } else { cash_sum.SelectionStart = curpos; //MessageBox.Show("1"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } int start = cash_sum.SelectionStart; string _sum_ = cash_sum.Text; cash_sum.Text = ""; cash_sum.Text = _sum_; cash_sum.SelectionStart = start; cash_sum.Update(); if (MainStaticClass.get_currency() == "руб.") { } else { cash_sum.SelectionStart = curpos; } }