private void textBoxINN_TextChanged(object sender, EventArgs e) { Int64 newIndex = controller.checkInn(textBoxINN.Text); if (newIndex == -1 && textBoxINN.Text.Length <= 1) { textBoxINN.Text = string.Empty; } else { textBoxINN.Text = newIndex == -1 ? textBoxINN.Text.Substring(0, textBoxINN.Text.Length - 1) : newIndex.ToString(); } textBoxINN.SelectionStart = textBoxINN.Text.Length; saveButton.Enabled = controller.checkSaveForAll(textBoxName.Text, richTextBoxFactadress.Text, textBoxIndex.Text, textBoxINN.Text); saveButton.BackColor = controller.checkSaveForAll(textBoxName.Text, richTextBoxFactadress.Text, textBoxIndex.Text, textBoxINN.Text) ? Color.DarkOrange : Color.Red; textBoxINN.BackColor = controller.checkSaveForInn(textBoxINN.Text) ? Color.White : Color.Red; }
private void textBoxINN_KeyPress(object sender, KeyPressEventArgs e) { char l = e.KeyChar; if (l != '\b' && l != ',' && (l < '0' || l > '9')) { e.Handled = true; } else { if (l != '\b' && textBoxINN.Text.Length > 11) { MessageBox.Show("Длина ИНН должа быть равна 12!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxINN.Text.Substring(0, 12); e.Handled = true; } } textBoxINN.SelectionStart = textBoxINN.Text.Length; saveButton.Enabled = controller.checkSaveForAll(textBoxName.Text, richTextBoxFactadress.Text, textBoxIndex.Text, textBoxINN.Text, maskedTextBoxPhone.Text); saveButton.BackColor = controller.checkSaveForAll(textBoxName.Text, richTextBoxFactadress.Text, textBoxIndex.Text, textBoxINN.Text, maskedTextBoxPhone.Text) ? Color.DarkOrange : Color.LightBlue; textBoxINN.BackColor = controller.checkSaveForInn(textBoxINN.Text) ? Color.White : Color.LightBlue; }