Exemplo n.º 1
0
        private void UpdateCheckDefinition( )
        {
            try
            {
                //Create temporary check
                string tmpCheck = "tempCheck_" + Guid.NewGuid().ToString().Replace('-', '_');
                DbCmd.CreateCheck(_cp, Owner, TableName, tmpCheck, Content, chkNotForRep.Checked);

                //Create backup of the original
                if (chkBackup.Checked)
                {
                    DbCmd.CreateCheck(_cp, Owner, TableName, CheckName + "_bak_" + Utils.GetFormattedNow(), _originalDefinition, _originalNoRep);
                }

                //Drop original
                DbCmd.DropCheck(_cp, Owner, TableName, CheckName);

                //Rename temp to original
                DbCmd.RenameCheck(_cp, Owner, tmpCheck, CheckName);
                _originalDefinition = Content;
                //CreateCheck(false);

                SetModified(false);
                if (_afterDefinitionUpdated != null)
                {
                    _afterDefinitionUpdated(this, EventArgs.Empty);
                }
            }
            catch (Exception ex)
            {
                MessageService.ShowError("Can not update check constraint definitions!\nError Message:" + ex.Message);
            }
        }
Exemplo n.º 2
0
        public bool DropSelectedChecks(bool confirm)
        {
            if (grd.SelectedRows.Count == 0)
            {
                return(false);
            }

            if (confirm && !MessageService.AskQuestion("Are you sure you want to drop selected check constraints?"))
            {
                return(false);
            }

            using (SqlConnection conn = _cp.CreateSqlConnection(true, false))
            {
                foreach (DataGridViewRow row in grd.SelectedRows)
                {
                    if (!Utils.IsGridRowItemValid(row, 1) || !Utils.IsGridRowItemValid(row, 2) || !Utils.IsGridRowItemValid(row, 3))
                    {
                        continue;
                    }

                    DbCmd.DropCheck(conn, (string)row.Cells[1].Value, (string)row.Cells[2].Value, (string)row.Cells[3].Value);
                }
            }

            RefreshChecks();
            return(true);
        }
Exemplo n.º 3
0
        private void DropCheck( )
        {
            if (!MessageService.AskQuestion("Are you sure you want to drop this check constraint?"))
            {
                return;
            }

            DbCmd.DropCheck(_cp, Owner, TableName, CheckName);
            if (OriginForm != null)
            {
                OriginForm.Close();
            }
        }