Exemplo n.º 1
0
        private void buttonUpdateExpression_Click(object sender, EventArgs e)
        {
            if ((textBoxCondition.Text != "") && (textBoxValue.Text != ""))
            {
                if (true)//(CheckAssingment(textBoxAssignment.Text, (string)comboBoxType.SelectedItem))
                {
                    string str = (string)comboBoxField.SelectedItem;
                    int    sel = dataGridViewExpression.SelectedRows[0].Index;
                    foreach (ConditionExpressions ex in ConditionExpressionslist)
                    {
                        if (ex.FieldName.ToUpper() == str.ToUpper())
                        {
                            //for (int i = 0; i < ex.conditionlist.Count; i++)

                            //conditionstruct _conditionstruct = ex.conditionlist[sel];
                            ex.conditionlist.RemoveAt(sel);

                            conditionstruct _conditionstruct = new conditionstruct();
                            // ex.conditionlist.Insert(sel, _conditionstruct);
                            //  if (_conditionstruct.condition.ToUpper() == ((string)dataGridViewExpression.SelectedRows[0].Cells[0].Value).ToUpper())

                            _conditionstruct.condition = textBoxCondition.Text.ToUpper();
                            _conditionstruct.value     = textBoxValue.Text;
                            dataGridViewExpression.SelectedRows[0].Cells[0].Value = textBoxCondition.Text.ToUpper();
                            dataGridViewExpression.SelectedRows[0].Cells[1].Value = textBoxValue.Text;
                            ex.conditionlist.Insert(sel, _conditionstruct);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void buttonDeleteExpression_Click(object sender, EventArgs e)
        {
            string str = (string)comboBoxField.SelectedItem;

            foreach (ConditionExpressions ex in ConditionExpressionslist)
            {
                if (ex.FieldName.ToUpper() == str.ToUpper())
                {
                    for (int i = 0; i < ex.conditionlist.Count; i++)
                    {
                        conditionstruct _conditionstruct = ex.conditionlist[i];
                        if (_conditionstruct.condition.ToUpper() == ((string)dataGridViewExpression.SelectedRows[0].Cells[0].Value).ToUpper())
                        {
                            ex.conditionlist.RemoveAt(i);
                            foreach (DataGridViewRow item in this.dataGridViewArgument.SelectedRows)
                            {
                                dataGridViewExpression.Rows.RemoveAt(item.Index);
                            }
                            dataGridViewExpression.Rows[0].Selected = true;
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void buttonAddExpression_Click(object sender, EventArgs e)
        {
            if ((textBoxCondition.Text != "") && (textBoxValue.Text != ""))
            {
                if (true)//(CheckAssingment(textBoxAssignment.Text, (string)comboBoxType.SelectedItem))
                {
                    int rowId = dataGridViewExpression.Rows.Add();

                    // Grab the new row!
                    DataGridViewRow row = dataGridViewExpression.Rows[rowId];

                    // Add the data
                    row.Cells[0].Value = textBoxCondition.Text.ToUpper();
                    row.Cells[1].Value = textBoxValue.Text;
                    dataGridViewExpression.Rows[rowId].Selected = true;


                    string str   = (string)comboBoxField.SelectedItem;
                    bool   found = false;
                    foreach (ConditionExpressions ex in ConditionExpressionslist)
                    {
                        if (ex.FieldName.ToUpper() == str.ToUpper())
                        {
                            found = true;
                            conditionstruct _conditionstruct = new conditionstruct();
                            _conditionstruct.condition = textBoxCondition.Text.ToUpper();
                            _conditionstruct.value     = textBoxValue.Text;
                            ex.conditionlist.Add(_conditionstruct);
                        }
                    }
                    if (!found)
                    {
                        ConditionExpressions ex = new ConditionExpressions();
                        ex.FieldName     = str;
                        ex.FieldType     = GetFieldType(str);
                        ex.conditionlist = new List <conditionstruct>();
                        conditionstruct _conditionstruct = new conditionstruct();
                        _conditionstruct.condition = textBoxCondition.Text.ToUpper();
                        _conditionstruct.value     = textBoxValue.Text;
                        ex.conditionlist.Add(_conditionstruct);
                        ConditionExpressionslist.Add(ex);
                    }
                }
                else
                {
                    MessageBox.Show("Value " + textBoxAssignment.Text + " is not valid " + (string)comboBoxType.SelectedItem + " type");
                }
            }
        }