Esempio n. 1
0
        private void tbDates_TextChanged(object sender, EventArgs e)
        {
            if (updating || _axis == null)
            {
                return;
            }

            TextBox s = (TextBox)sender;

            if (string.IsNullOrWhiteSpace(s.Text))
            {
                _errorProvider.SetError(s, "Field cannot be blank");
                _errorProvider.Tag = s;
            }
            else if (_errorProvider.Tag == s)
            {
                _errorProvider.Clear();
            }

            try
            {
                //if user enters a date then put
                DateTime dt = DateTime.Parse(s.Text);

                updating = true;
                s.Text   = "'" + dt.ToString("yyyy-MM-dd") + "'";
                updating = false;
            }
            catch (Exception)
            {
            }

            if (s == tbStartDate)
            {
                _axis.StartDate = s.Text;
            }
            else
            {
                _axis.EndDate = s.Text;
            }

            try
            {
                SyntaxChecker.ParityCheckCharacterPairs(new[] { '(', '\'' }, new[] { ')', '\'' }, s.Text);
                s.ForeColor = Color.Black;

                _axis.SaveToDatabase();
                AxisSaved();
            }
            catch (SyntaxErrorException)
            {
                s.ForeColor = Color.Red;
            }
        }