Ejemplo n.º 1
0
        private void cboSelectAction_SelectionChangeCommitted(object sender, EventArgs e)
        {
            switch (cboSelectAction.SelectedIndex)
            {
            case 0:     // add new
                if (_loginForm.UserAccountId < 1)
                {
                    throw new Exception("Login is required!");
                }
                else
                {
                    _pwTracker.InsertNewRecord(GetPasswordValues());
                    break;
                }

            case 1:     // edit
                _pwTracker.EditEntry(GetPasswordValues());
                break;

            case 2:     // delete
                var id = (int)dv.Rows[dv.CurrentCell.RowIndex].Cells["Id"].Value;
                _pwTracker.DeleteEntry(id);
                break;
            }
            ClearSelection();
        }
Ejemplo n.º 2
0
        public int CreateNewUserAccount(LoginUser userData)
        {
            //check if user is in the database
            var accRec = GetAccountUser(userData);

            AccountUserId = _userAccount.InsertNewRecord(accRec);
            _password     = userData.Password;
            return(AccountUserId);
        }
Ejemplo n.º 3
0
 public void AddNewPassword(int userId, DataGridView dataGrid, PasswordTracker pw)
 {
     if (string.IsNullOrEmpty(pw.Name) ||
         string.IsNullOrEmpty(pw.Username) ||
         string.IsNullOrEmpty(pw.Password))
     {
         throw new Exception("Required field(s) not filled out!");
     }
     _pwTracker.InsertNewRecord(pw);
     MessageBox.Show(@"Record successfully added!", @"Record Added");
     //_entry.ResetEntryForm();
     LoadDataGrid(dataGrid, false);
 }
Ejemplo n.º 4
0
        public void SetEmailAccount(string emailAddress, IModelAdapter <EmailAccount> emailAccount)
        {
            var email = emailAccount.GetRecordById(emailAccount.Id);

            if (email == null)
            {
                email = new EmailAccount()
                {
                    Email  = emailAddress,
                    UserId = emailAccount.Id
                };
                emailAccount.InsertNewRecord(email);
            }
            else
            {
                emailAccount.EditEntry(email);
            }
        }
Ejemplo n.º 5
0
        private void LoginUserFromForm()
        {
            try
            {
                switch (choice)
                {
                case "Add":
                    SaveEmailAccount();
                    UserAccountId = userAccount.InsertNewRecord(CredentialsInitializer());
                    if (UserAccountId == 0)
                    {
                        throw new Exception("Error creating user!");
                    }
                    break;

                case "Edit":
                    SaveEmailAccount();
                    UserAccountId = userAccount.EditEntry(CredentialsInitializer()).UserId;
                    if (UserAccountId == 0)
                    {
                        throw new Exception("Error editing user!");
                    }
                    break;

                default:
                    var user = userAccount.GetRecordByCredentials(txtUsername.Text, txtPassword.Text);
                    if (user == null)
                    {
                        throw new Exception("Invalid login!");
                    }
                    UserAccountId = user.UserId;
                    break;
                }
                Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, @"Invalid Entry Detected", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }