Example #1
0
        private bool Validation()
        {
            if (txtKeyName.Text.Trim() == "")
            {
                MessageBox.Show("Empty Key Name", "Validation failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtChar.Focus();
                return(false);
            }

            if (txtChar.Text.Trim() == "")
            {
                MessageBox.Show("Empty Character", "Validation failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtChar.Focus();
                return(false);
            }
            if (!chkSK.Checked && !chkExec.Checked)
            {
                MessageBox.Show("Specify an action to be performed", "Validation failed",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (!chkSK.Checked)
                {
                    chkSK.Focus();
                }
                else if (!chkExec.Checked)
                {
                    chkExec.Focus();
                }
                return(false);
            }
            if (chkSK.Checked && txtSK.Text.Trim() == "")
            {
                MessageBox.Show("Empty Send Keys", "Validation failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSK.Focus();
                return(false);
            }
            if (chkExec.Checked && txtExec.Text.Trim() == "")
            {
                MessageBox.Show("Empty Application path", "Validation failed",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtExec.Focus();
                return(false);
            }
            KeyCommand tmpObject = GetSaveObject();

            //if (!CheckDuplication(tmpObject))
            //{
            //    MessageBox.Show("Hotkey Registered Already", "Validation failed",
            //           MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    chkCTRL.Focus();
            //    return false;
            //}



            if (!CheckExistence(tmpObject.ToString(), false, _editMode)) // Hot key exists in deleted records
            {
                if (!tmpObject.CanRegister())
                {
                    MessageBox.Show("Error Registering Hotkey", "Validation failed",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    chkCTRL.Focus();
                    return(false);
                }
            }

            if (CheckExistence(txtKeyName.Text, true, _editMode))
            {
                MessageBox.Show("A Key name already exists.", "Validation failed",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                chkCTRL.Focus();
                return(false);
            }

            return(true);
        }