コード例 #1
0
ファイル: LibETextBox.cs プロジェクト: RockLowe/ConnectFour
        public bool ReadDate(out Date dateValue, TValueRequired valueRequiredDirective)
        {
            bool valueOk = true;

            dateValue = null;
            if (this.Text != "")
            {
                try
                {
                    dateValue = Date.Parse(this.Text);
                }
                catch (Exception exception)
                {
                    valueOk = false;
                    MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    this.Select();
                }
            }
            else if (valueRequiredDirective == TValueRequired.ValueRequired)
            {
                valueOk = false;
                MessageBox.Show("Must enter a value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                this.Select();
            }
            return(valueOk);
        }
コード例 #2
0
ファイル: LibETextBox.cs プロジェクト: RockLowe/ConnectFour
        public bool ReadString(out string stringValue, TValueRequired valueRequiredDirective)
        {
            bool   valueOk     = true;
            int    numOfSpaces = 0;
            string message     = "";

            if ((stringValue = this.Text) == "" && valueRequiredDirective == TValueRequired.ValueRequired)
            {
                message = "Must enter a value";
                valueOk = false;
            }
            if (valueOk)
            {
                for (int i = 0; i < stringValue.Length; i++)
                {
                    if (stringValue[i] == ' ')
                    {
                        numOfSpaces++;
                    }
                }
                if (numOfSpaces == stringValue.Length && valueRequiredDirective == TValueRequired.ValueRequired)
                {
                    message = "Must enter at least one non-space character in value";
                    valueOk = false;
                }
            }
            if (!valueOk)
            {
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                this.Select();
            }
            return(valueOk);
        }
コード例 #3
0
ファイル: LibETextBox.cs プロジェクト: JDavis22/CIS350
        public bool ReadString(out string stringValue, TValueRequired valueRequiredDirective)
        {
            bool   valueOk=true;
              int    numOfSpaces = 0;
              string message="";

              if ((stringValue = this.Text)=="" && valueRequiredDirective==TValueRequired.ValueRequired)
              {
            message = "Must enter a value";
            valueOk = false;
              }
              if (valueOk)
              {
            for(int i=0; i<stringValue.Length; i++)
              if (stringValue[i]==' ')
            numOfSpaces++;
            if (numOfSpaces==stringValue.Length && valueRequiredDirective==TValueRequired.ValueRequired)
            {
              message = "Must enter at least one non-space character in value";
              valueOk = false;
            }
              }
              if (! valueOk)
              {
            MessageBox.Show(message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Question);
            this.Select();
              }
              return valueOk;
        }
コード例 #4
0
ファイル: LibETextBox.cs プロジェクト: JDavis22/CIS350
        public bool ReadDate(out Date dateValue, TValueRequired valueRequiredDirective)
        {
            bool valueOk = true;

              dateValue = null;
              if (this.Text!="")
              {
            try
            {
              dateValue = Date.Parse(this.Text);
            }
            catch (Exception exception)
            {
              valueOk = false;
              MessageBox.Show(exception.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Question);
              this.Select();
            }
              }
              else if (valueRequiredDirective==TValueRequired.ValueRequired)
              {
            valueOk = false;
            MessageBox.Show("Must enter a value","Error",MessageBoxButtons.OK,MessageBoxIcon.Question);
            this.Select();
              }
              return valueOk;
        }