Ejemplo n.º 1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            m_series.Expression = basicEquation1.SeriesExpression;
            var a = this.basicEquation1.SeriesName;

            if (a != "")
            {
                m_series.Name = a;
                string tn = basicEquation1.TimeInterval.ToString().ToLower() + "_" + TimeSeriesDatabase.SafeTableName(a);
                tn = tn.Replace("irregular", "instant");
                m_series.Table.TableName = tn;
            }
            a = basicEquation1.Units.Trim();
            if (a != "")
            {
                m_series.Units = a;
            }

            string errorMessage = "";

            m_series.TimeInterval = basicEquation1.TimeInterval;
            if (m_series.TimeSeriesDatabase.Parser.VariableResolver is Parser.HydrometVariableResolver ||
                m_series.IsValidExpression(basicEquation1.SeriesExpression, out errorMessage))
            {
            }
            else
            {
                var result = MessageBox.Show("Your equation may have an error. Click OK to proceed.\n" + errorMessage, "Use this Equation?", MessageBoxButtons.OKCancel);
                if (result == DialogResult.Cancel)
                {
                    DialogResult = DialogResult.None;
                }
            }
        }
Ejemplo n.º 2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            m_series.Expression = basicEquation1.SeriesExpression;
            var a = this.basicEquation1.SiteID;

            if (a != "")
            {
                if (string.IsNullOrEmpty(basicEquation1.Parameter))
                {
                    m_series.Name = a;
                    a            += "_c" + DateTime.Now.ToString("yyyyMMMddHHmmssfff").ToLower();
                }
                else
                {
                    a            += "_" + basicEquation1.Parameter;
                    m_series.Name = a;
                }

                string tn = basicEquation1.TimeInterval.ToString().ToLower() + "_" + TimeSeriesDatabase.SafeTableName(a);
                tn = tn.Replace("irregular", "instant");
                m_series.Table.TableName = tn;

                TimeSeriesName x = new TimeSeriesName(a, basicEquation1.TimeInterval);
                m_series.Parameter = x.pcode;
                m_series.SiteID    = x.siteid;
            }

            string errorMessage = "";

            m_series.TimeInterval = basicEquation1.TimeInterval;

            var xcs = m_db.GetCalculationSeries(m_series.SiteID, m_series.Parameter, m_series.TimeInterval);

            if (xcs != null)
            {
                errorMessage = "This calculation already exists.";
                MessageBox.Show("Error: " + errorMessage);
                DialogResult = DialogResult.None;
            }
            else
            if (
                m_series.TimeSeriesDatabase.Parser.VariableResolver is Parser.HydrometVariableResolver ||
                m_series.IsValidExpression(basicEquation1.SeriesExpression, out errorMessage)
                )
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                var result = MessageBox.Show("Your equation may have an error. Click OK to proceed.\n" + errorMessage, "Use this Equation?", MessageBoxButtons.OKCancel);
                if (result == DialogResult.Cancel)
                {
                    DialogResult = DialogResult.None;
                }
            }
        }