Beispiel #1
0
        private void ResetLastBackup()
        {
            int recordsAffected   = 0;
            int jurisBackupSetId  = GetBackupSetId(JurisDbName);
            int jBillsBackupSetId = GetBackupSetId(JBillsDbName);

            _jurisUtility.BeginTransaction(2);
            try
            {
                string sql;
                if (jurisBackupSetId != -1)
                {
                    sql             = string.Format(Resources.SqlUpdateBackupSet, JurisDbName, jurisBackupSetId);
                    recordsAffected = _jurisUtility.ExecuteNonQueryCommand(2, sql);
                }

                if (jBillsBackupSetId != -1)
                {
                    sql              = string.Format(Resources.SqlUpdateBackupSet, JBillsDbName, jBillsBackupSetId);
                    recordsAffected += _jurisUtility.ExecuteNonQueryCommand(2, sql);
                }

                if (recordsAffected == 2)
                {
                    _jurisUtility.CommitTransaction(2);
                }
                else
                {
                    MessageBox.Show(this, @"You must have at least one backup of this database.", @"No backups found",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _jurisUtility.RollbackTransaction(2);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(this, exception.Message, @"Error resetting last backup.", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                _jurisUtility.RollbackTransaction(2);
            }
        }