예제 #1
0
        private void textBoxIndex_TextChanged(object sender, EventArgs e)
        {
            int newIndex = controller.checkIndex(textBoxIndex.Text);

            if (newIndex == -1 && textBoxIndex.Text.Length <= 1)
            {
                textBoxIndex.Text = string.Empty;
            }
            else
            {
                textBoxIndex.Text = newIndex == -1 ? textBoxIndex.Text.Substring(0, textBoxIndex.Text.Length - 1) : newIndex.ToString();
            }
            textBoxIndex.SelectionStart = textBoxIndex.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;
            textBoxIndex.BackColor      = controller.checkSaveForIndex(textBoxIndex.Text) ? Color.White : Color.Red;
        }
예제 #2
0
        private void textBoxIndex_KeyPress(object sender, KeyPressEventArgs e)
        {
            char l = e.KeyChar;

            if (l != '\b' && l != ',' && (l < '0' || l > '9'))
            {
                e.Handled = true;
            }
            else
            {
                if (l != '\b' && textBoxIndex.Text.Length > 5)
                {
                    MessageBox.Show("Длина индекса должа быть равна 6!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBoxIndex.Text.Substring(0, 6);
                    e.Handled = true;
                }
            }
            textBoxIndex.SelectionStart = textBoxIndex.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;
            textBoxIndex.BackColor      = controller.checkSaveForIndex(textBoxIndex.Text) ? Color.White : Color.LightBlue;
        }