Example #1
0
        /**********************************************************************************/

        private void buttonApply_Click(object sender, EventArgs e)
        {
            string new_username = textBoxUsername.Text;
            string old_pass     = textBoxOldPass.Text;
            string new_pass     = textBoxNewPass.Text;

            if (new_username != m_username)  // If adding new user...
            {
                try
                {
                    m_app_manager.AddUser(new_username, new_pass);
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message, "User exists");
                    return;
                }
            }
            else  // else - edit existing user (change password)
            {
                try
                {
                    m_app_manager.ChangeUserPassword(new_username, old_pass, new_pass);
                }
                catch (UnauthorizedAccessException ex)
                {
                    MessageBox.Show("Unable to change password: invalid old password", "Access denied");
                    return;
                }
            }

            Close();
        }
Example #2
0
        /**********************************************************************************/

        public MainForm(AppManager _am)
        {
            m_app_manager = _am;
            InitializeComponent();

            m_app_manager.ComputerInfoUpdated += UpdateSysInfoLabel;

            UpdateSysInfoLabel();

            App new_app1 = new App("app_name", "producer");
            App new_app2 = new App("app_name2", "producer2");

            new_app1.InstallationDate = DateTime.Today;
            new_app2.InstallationDate = DateTime.Today;

            m_app_manager.AddApplication(new_app1);
            m_app_manager.AddApplication(new_app2);


            //m_bs_apps = new BindingSource(m_app_manager.Apps, null);
            //listBoxApps.DataSource = m_bs_apps;
            //listBoxApps.DisplayMember = "Key";
            //listBoxApps.ValueMember = "Key";

            UpdateListBoxApps();

            m_app_manager.AddUser(new User("username1", "passwd"));

            //m_bs_users = new BindingSource(m_app_manager.Users, null);
            //listBoxUsers.DataSource = m_bs_users;
            //listBoxUsers.DisplayMember = "Key";
            //listBoxUsers.ValueMember = "Key";

            UpdateListBoxUsers();

            m_app_manager.NewUserAdded += ListBoxAddUser;
            m_app_manager.NewAppAdded  += ListBoxAddApp;
        }