Beispiel #1
0
        private void Execute_UpdatePass(object obj)
        {
            var p = (RePass)obj;

            if (!p.validate())
            {
                System.Windows.Forms.MessageBox.Show("Empty", "Warning",
                                                     MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var curAcc   = accountRepository.GetByID(UID);
            var password = curAcc.Password;

            if (password != p.curpass)
            {
                System.Windows.Forms.MessageBox.Show("Wrong Password", "Warning",
                                                     MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (p.newpass != p.repass)
                {
                    System.Windows.Forms.MessageBox.Show("New-Password and Re-Password don't match", "Warning",
                                                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    curAcc.Password = p.newpass;
                    accountRepository.Update(curAcc);
                    accountRepository.Save();
                    System.Windows.Forms.MessageBox.Show("Successfully updated", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    RePass.clear();
                    var ProfilePage = App.Current.Windows.OfType <Profile>().FirstOrDefault();
                    if (ProfilePage != null)
                    {
                        ProfilePage.Close();
                    }
                }
            }
        }
Beispiel #2
0
        public ProfileViewModel()
        {
            accountRepository = new BaseRepository <account>();
            staffRepository   = new BaseRepository <staff>();
            _rePass           = new RePass();
            session           = Session.GetCurrentSingleton();
            UID        = (int)session.AccountID;
            _roleName  = session.Role.ToString();
            _myProfile = staffRepository.GetByID(UID);
            _name      = _myProfile.Name;

            /*
             * Not much point in this case, but for the record, you can have
             * different data depending on if you're in design or runtime like this:
             */


            // This will register our method with the Messenger class for incoming
            // messages of type RefreshPeople.
            //Messenger.Default.Register<RefreshPeople>(this, (msg) => Execute_RefreshPeople(msg.PeopleToFetch));
            //Messenger.Default.Register<Parameter>(this, res => Function(res.param));
        }