Example #1
0
        private void btSaveRenameRelation_Click(object sender, EventArgs e)
        {
            errorProvider.SetError(txtRenameRelation, null);
            if (txtRenameRelation.Text.Trim().Length <= 0)
            {
                errorProvider.SetError(txtRenameRelation, "You did not enter a relation name");
                return;
            }

            if (txtRenameRelation.Text.ToLower() == "select" || txtRenameRelation.Text.ToLower() == "from" || txtRenameRelation.Text.ToLower() == "where")
            {
                errorProvider.SetError(txtRenameRelation, "Relation name is not valid ( not match with keyword 'select', 'from', 'where')  ");
                return;
            }


            if (this.CurrentNameRelation == txtRenameRelation.Text.Trim().ToLower())
            {
                return;
            }


            if (this.CurrentNameRelation != txtRenameRelation.Text.Trim().ToLower())
            {
                foreach (var item in this.probDatabase.ListOfRelationNameToLower())
                {
                    if (item.Equals(txtRenameRelation.Text.ToLower()))
                    {
                        errorProvider.SetError(txtRenameRelation, "This relation name has already existed in the database ");
                        return;
                    }
                }
            }

            FProbRelationBLL relation = this.probDatabase.FproRelations.SingleOrDefault(c => c.RelationName.ToLower() == CurrentNameRelation.ToLower());

            this.probDatabase.FproRelations.Remove(relation);
            relation.DropTableByTableName();
            relation.DeleteRelationById();
            relation.RelationName = txtRenameRelation.Text.Trim();
            relation.InsertSystemRelation();
            relation.CreateTableRelation();
            relation.InsertTupleIntoTableRelation();
            this.probDatabase.FproRelations.Add(relation);
            XtraMessageBox.Show("Rename relation successful", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Example #2
0
        private void btOkDelRelation_Click(object sender, EventArgs e)
        {
            if (comboBoxDelRelation.SelectedIndex != -1)
            {
                FProbRelationBLL relation = this.probDatabase.FproRelations.SingleOrDefault(c => c.RelationName.ToLower() == comboBoxDelRelation.Properties.Items[comboBoxDelRelation.SelectedIndex].ToString());

                if (XtraMessageBox.Show("Are you sure delete this relation?", "Delete Relation" + relation.RelationName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    this.probDatabase.FproRelations.Remove(relation);
                    relation.DropTableByTableName();
                    relation.DeleteRelationById();
                    relationNameRemove = relation.RelationName;
                    XtraMessageBox.Show(" Delete successfully!", "Infomation ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }