Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (validation())
            {
                var user = Session.Entities.GetUser(txtUserName.Text, passwordIsHash ? Session.Entities.GetSetting().PasswordHash : txtPassword.Text.ComputeSha256Hash(txtUserName.Text));
                if (user != null)
                {
                    if (!string.IsNullOrEmpty(user.LanguageCode))
                    {
                        Session.Entities.GetSetting().LanguageCode = user.LanguageCode;
                    }
                    SettingSave();
                    frmMain frmMain = new frmMain();
                    Session.User = user;

                    if (Session.User.Accounts.Count == 0)
                    {
                        frmAccount frm = new frmAccount();
                        frm.ShowDialog();
                        Session.DefaultAccount = Session.User.Accounts.FirstOrDefault();
                        if (Session.DefaultAccount != null)
                        {
                            Hide();
                            frmMain.Show();
                        }
                        else
                        {
                            MessageBox.Show(Translate.GetMessage("account-not-found"), Translate.GetMessage("error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (Session.User.Accounts.Count == 1)
                    {
                        Hide();
                        Session.DefaultAccount = user.Accounts.FirstOrDefault();
                        frmMain.Show();
                    }
                    else if (Session.User.Accounts.Any(c => c.DefaultAccount))
                    {
                        Hide();
                        Session.DefaultAccount = user.Accounts.FirstOrDefault(c => c.DefaultAccount);
                        frmMain.Show();
                    }
                    else
                    {
                        frmAccountChoose frmAccountChoose = new frmAccountChoose();
                        frmAccountChoose.ShowDialog();
                        if (Session.DefaultAccount != null)
                        {
                            frmMain.Show();
                            Hide();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(Translate.GetMessage("username-or-password-incorrect"), Translate.GetMessage("error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 2
0
        private void changeAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmAccountChoose frm = new frmAccountChoose();

            frm.ShowDialog();
            cbPeriod_Fill();
            refreshList();
        }