private void btnUpdateProfile_Click(object sender, EventArgs e)
        {
            if (txtFullname.Text == "")
            {
                MessageBox.Show("Please enter your fullname!");
                txtFullname.Focus();
                return;
            }

            if (acc.isAuthenticated(acc.Email, txtCfmPass.Text))
            {
                UserAccount updateAcc = new UserAccount();
                updateAcc.Email     = acc.Email;
                updateAcc.Fullname  = txtFullname.Text;
                updateAcc.Address   = txtAddress.Text;
                updateAcc.Phone     = txtPhone.Text;
                updateAcc.Birthdate = txtBirthdate.Value.ToShortDateString();

                if (updateAcc.editProfile())
                {
                    acc = updateAcc;
                    MessageBox.Show("Updated successfully!", "Edit Profile",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    fillFields();
                    txtCfmPass.Clear();
                }
                else
                {
                    MessageBox.Show("Failed!", "Edit Profile",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Invalid passphrase! Update failed!", "Edit Profile",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtCfmPass.Focus();
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            UserAccount acc = new UserAccount();

            if (acc.isAuthenticated(txtEmail.Text, txtPass.Text))
            {
                if (btnLogin.Text == "Login")
                {
                    frmMain main = new frmMain(acc.getAccountByEmail(txtEmail.Text), this);
                    main.Show();
                }

                else if (btnLogin.Text == "Export")
                {
                    exportKeyInfoDialog1.Title    = "Export keys info";
                    exportKeyInfoDialog1.FileName = txtEmail.Text.Substring(0,
                                                                            txtEmail.Text.IndexOf('@')) + ".xml";
                    DialogResult dlgRes = exportKeyInfoDialog1.ShowDialog();
                    saveTo = exportKeyInfoDialog1.FileName;
                    if (dlgRes == DialogResult.OK)
                    {
                        if (passControl("OK", txtEmail.Text, txtPass.Text, saveTo))
                        {
                            MessageBox.Show("Exported successfully!",
                                            "Export keys info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Invalid email or passphrase!",
                                "Login", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }