internal TemplateManager(PogsDatabase database)
        {
            if (database == null)
                throw new ArgumentNullException("database");

            _database = database;

            InitializeComponent();

            entryFieldTypeViewBindingSource.DataSource = EntryFieldTypeView.All;
            templateViewBindingSource.DataSource = _templateViews;
            LoadExistingTemplates();
        }
Exemple #2
0
        private void SetCurrentDatabase(PogsDatabase pogsDatabase)
        {
            if (pogsDatabase != null)
            {
                using (var ls = new LockScreen(pogsDatabase))
                {
                    if (ls.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }
            }

            if (this.CurrentDatabase != null)
            {
                this.CurrentDatabase.ConnectionUnexpectedlyClosed -= new EventHandler(CurrentDatabase_ConnectionUnexpectedlyClosed);
                this.CurrentDatabase.ClientsAdded -= new EventHandler<ClientRecordEventArgs>(CurrentDatabase_ClientsAdded);
                this.CurrentDatabase.ClientsRemoved -= new EventHandler<ClientRecordEventArgs>(CurrentDatabase_ClientsRemoved);
                this.CurrentDatabase.Dispose();
            }

            this.CurrentDatabase = pogsDatabase;

            if (this.CurrentDatabase == null)
            {
                this.Text = "Pogs";
                _clients = null;
                clientListBindingSource.DataSource = typeof(ClientRecord);
                addClientButton.Enabled = false;
                newClientToolStripMenuItem.Enabled = false;
                changePINToolStripMenuItem.Enabled = false;
            }
            else
            {
                this.Text = String.Format("Pogs - [{0} on {1}]", pogsDatabase.DatabaseName, pogsDatabase.ServerName);

                this.CurrentDatabase.Refresh(this.CurrentDatabase.DefaultSecurity);
                this.CurrentDatabase.RefreshClientList();

                //set up the initial client list
                _clients = new SortableBindingList<ClientRecord>();
                foreach (var client in this.CurrentDatabase.Clients)
                    _clients.Add(client);

                clientListBindingSource.DataSource = _clients;

                //listen for future changes
                this.CurrentDatabase.ConnectionUnexpectedlyClosed += new EventHandler(CurrentDatabase_ConnectionUnexpectedlyClosed);
                this.CurrentDatabase.ClientsAdded += new EventHandler<ClientRecordEventArgs>(CurrentDatabase_ClientsAdded);
                this.CurrentDatabase.ClientsRemoved += new EventHandler<ClientRecordEventArgs>(CurrentDatabase_ClientsRemoved);

                //set up the UI
                addClientButton.Enabled = this.CurrentDatabase.CurrentUser.IsAdmin;
                newClientToolStripMenuItem.Enabled = true;
                changePINToolStripMenuItem.Enabled = true;
            }
        }
Exemple #3
0
 internal LockScreen(PogsDatabase database)
     : this()
 {
     _database = database;
     unlockInstructions.Text = String.Format(unlockInstructions.Text, database.DatabaseName, database.ServerName);
 }