コード例 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (comboBoxConstraints.SelectedIndex > -1)
            {
                Codenesium.DatabaseContracts.Constraint constraint = (Codenesium.DatabaseContracts.Constraint)comboBoxConstraints.SelectedItem;
                if (this.comboBoxColumns.SelectedIndex > -1)
                {
                    Column column = (Column)this.comboBoxColumns.SelectedItem;

                    if (constraint.Columns.Any(x => x.Name == column.Name))
                    {
                        return; // the column is already in the list
                    }

                    ConstraintColumn newColumn = new ConstraintColumn()
                    {
                        Name             = column.Name,
                        Order            = listBoxConstraintColumns.Items.Count + 1,
                        Descending       = false,
                        IsIncludedColumn = false
                    };
                    constraint.Columns.Add(newColumn);
                }
                this.selectConstraint(constraint);
                listBoxConstraintColumns.SelectedIndex = -1;
            }
        }
コード例 #2
0
 private void comboBoxConstraintType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxConstraints.SelectedIndex > -1)
     {
         Codenesium.DatabaseContracts.Constraint constraint = (Codenesium.DatabaseContracts.Constraint)comboBoxConstraints.SelectedItem;
         constraint.ConstraintType = comboBoxConstraintType.Text;
     }
 }
コード例 #3
0
 private void checkBoxIsPrimaryKey_CheckedChanged(object sender, EventArgs e)
 {
     if (comboBoxConstraints.SelectedIndex > -1)
     {
         Codenesium.DatabaseContracts.Constraint constraint = (Codenesium.DatabaseContracts.Constraint)comboBoxConstraints.SelectedItem;
         constraint.IsPrimaryKey = checkBoxIsPrimaryKey.Checked;
     }
 }
コード例 #4
0
        private void checkBoxIncludedColumn_CheckedChanged(object sender, EventArgs e)
        {
            if (listBoxConstraintColumns.SelectedIndex > -1)
            {
                Codenesium.DatabaseContracts.Constraint constraint = (Codenesium.DatabaseContracts.Constraint)comboBoxConstraints.SelectedItem;

                ConstraintColumn column = (ConstraintColumn)listBoxConstraintColumns.SelectedItem;

                column.IsIncludedColumn = checkBoxIncludedColumn.Checked;
            }
        }
コード例 #5
0
        private void checkBoxIsIdentity_CheckedChanged(object sender, EventArgs e)
        {
            if (comboBoxConstraints.SelectedIndex > -1 && listBoxConstraintColumns.SelectedIndex > -1)
            {
                Codenesium.DatabaseContracts.Constraint constraint = (Codenesium.DatabaseContracts.Constraint)comboBoxConstraints.SelectedItem;

                var column = constraint.Columns.First(x => x.Name.ToUpper() == ((ConstraintColumn)(listBoxConstraintColumns.SelectedValue)).Name.ToUpper());

                column.IsIdentity = checkBoxIsIdentity.Checked;
            }
        }
コード例 #6
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listBoxConstraintColumns.SelectedIndex > -1)
            {
                Codenesium.DatabaseContracts.Constraint constraint = (Codenesium.DatabaseContracts.Constraint)comboBoxConstraints.SelectedItem;

                ConstraintColumn column = (ConstraintColumn)listBoxConstraintColumns.SelectedItem;

                constraint.Columns.Remove(column);

                selectConstraint(constraint);
            }
        }
コード例 #7
0
        private void selectConstraint(Codenesium.DatabaseContracts.Constraint constraint)
        {
            this.listBoxConstraintColumns.DataSource    = null;
            this.listBoxConstraintColumns.DataSource    = constraint.Columns;
            this.listBoxConstraintColumns.DisplayMember = "Name";

            this.checkBoxIsUnique.Checked            = constraint.IsUnique;
            this.checkBoxIsPrimaryKey.Checked        = constraint.IsPrimaryKey;
            this.comboBoxConstraintType.SelectedItem = constraint.ConstraintType;
            if (listBoxConstraintColumns.Items.Count > 0)
            {
                listBoxConstraintColumns.SelectedIndex = 0;
            }
            else
            {
                listBoxConstraintColumns.SelectedIndex = -1;
            }
        }