Ejemplo n.º 1
0
        private void SaveRecord()
        {
            try
            {
                _Storage.OpenConnection();
                _Storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted);

                #region  Managers
                KeyValuePair <string, bool>[] managers = _Application.GetManagers();
                foreach (CheckBox sqlLogin in flpManagers.Controls)
                {
                    if (sqlLogin.Checked)
                    {
                        if (!FindLogin(managers, sqlLogin.Text))
                        {
                            _Application.GrantAccessAsManager(sqlLogin.Text);
                        }
                    }
                    else
                    {
                        if (FindLogin(managers, sqlLogin.Text))
                        {
                            _Application.RevokeAccessAsManager(sqlLogin.Text);
                        }
                    }
                }
                #endregion

                #region Users
                KeyValuePair <string, bool>[] users = _Application.GetUsers();
                foreach (CheckBox sqlLogin in flpUsers.Controls)
                {
                    if (sqlLogin.Checked)
                    {
                        if (!FindLogin(users, sqlLogin.Text))
                        {
                            _Application.GrantAccessAsUser(sqlLogin.Text);
                        }
                    }
                    else
                    {
                        if (FindLogin(users, sqlLogin.Text))
                        {
                            _Application.RevokeAccessAsUser(sqlLogin.Text);
                        }
                    }
                }
                #endregion

                #region Readers
                KeyValuePair <string, bool>[] readers = _Application.GetReaders();
                foreach (CheckBox sqlLogin in flpReaders.Controls)
                {
                    if (sqlLogin.Checked)
                    {
                        if (!FindLogin(readers, sqlLogin.Text))
                        {
                            _Application.GrantAccessAsReader(sqlLogin.Text);
                        }
                    }
                    else
                    {
                        if (FindLogin(readers, sqlLogin.Text))
                        {
                            _Application.RevokeAccessAsReader(sqlLogin.Text);
                        }
                    }
                }
                #endregion

                _Storage.CommitTransaction();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                _Storage.CloseConnection();
            }
            _Dirty = true;
        }