Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            err.Clear();
            bool valid = true;

            if (string.IsNullOrWhiteSpace(txtSource.Text))
            {
                err.SetError(txtSource, "不可空白");
                valid = false;
            }

            if (string.IsNullOrWhiteSpace(cboTarget.Text))
            {
                err.SetError(cboTarget, "不可空白");
                valid = false;
            }

            if (cboSourceType.Text == SourceType.Variable.ToString())
            {
                bool contains = false;
                foreach (IVariable v in _service.Variables)
                {
                    if (v.Name == txtSource.Text)
                    {
                        contains = true;
                        break;
                    }
                }
                if (!contains)
                {
                    err.SetError(txtSource, "InternalVariable 中不包含此變數");
                    valid = false;
                }
            }

            if (!valid)
            {
                return;
            }

            if (Completed == null)
            {
                this.Close();
                return;
            }

            Condition condition = new Condition();

            condition.InputConverter   = ConverterType.Parse(cboInputConverter.Text);
            condition.Required         = chkRequired.Checked;
            condition.Source           = txtSource.Text;
            condition.Target           = cboTarget.Text;
            condition.Comparer         = cboComparer.Text;
            condition.EmptyReplacement = string.Empty;

            SourceType stype = SourceType.Request;

            if (!Enum.TryParse <SourceType>(cboSourceType.Text, true, out stype))
            {
                stype = SourceType.Request;
            }

            condition.SourceType = stype;

            Completed.Invoke(this, new ConditionEventArgs(condition));
            this.Close();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            err.Clear();
            bool valid = true;

            if (string.IsNullOrWhiteSpace(txtSource.Text))
            {
                err.SetError(txtSource, "不可空白");
                valid = false;
            }

            if (string.IsNullOrWhiteSpace(cboTarget.Text))
            {
                err.SetError(cboTarget, "不可空白");
                valid = false;
            }

            if (cboSourceType.Text == SourceType.Variable.ToString())
            {
                bool contains = false;
                foreach (IVariable v in _service.Variables)
                {
                    if (v.Name == txtSource.Text)
                    {
                        contains = true;
                        break;
                    }
                }

                if (!contains)
                {
                    foreach (Preprocess p in _service.Preprocesses)
                    {
                        if (p.Type == PreprocessType.Variable && p.Name == txtSource.Text)
                        {
                            contains = true;
                            break;
                        }
                    }
                }

                if (!contains)
                {
                    err.SetError(txtSource, "InternalVariable 中不包含此變數");
                    valid = false;
                }
            }

            if (!valid)
            {
                return;
            }

            if (Completed == null)
            {
                this.Close();
                return;
            }

            Field field = new Field();

            field.Alias           = txtAlias.Text;
            field.AutoNumber      = chkAutoNumber.Checked;
            field.InputConverter  = ConverterType.Parse(cboInputConverter.Text);
            field.OutputConverter = ConverterType.Parse(cboOutputConverter.Text);
            field.Mandatory       = chkMandatory.Checked;
            field.Quote           = chkQuote.Checked;
            field.Required        = chkRequired.Checked;
            field.Source          = txtSource.Text;
            field.Target          = cboTarget.Text;

            IOType itype = IOType.Element;

            if (!Enum.TryParse <IOType>(cboInputType.Text, true, out itype))
            {
                itype = IOType.Element;
            }

            field.InputType = itype;

            IOType otype = IOType.Element;

            if (!Enum.TryParse <IOType>(cboOutputType.Text, true, out otype))
            {
                otype = IOType.Element;
            }

            field.OutputType = otype;

            SourceType stype = SourceType.Request;

            if (!Enum.TryParse <SourceType>(cboSourceType.Text, true, out stype))
            {
                stype = SourceType.Request;
            }

            field.SourceType = stype;

            Completed.Invoke(this, new FieldEventArgs(field));
            this.Close();
        }