示例#1
0
        /// <summary>
        /// BACK
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            var frm = new FrmHome();

            frm.Show();

            this.Hide();
        }
示例#2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUserName.Text))
            {
                MessageBoxHelper.ShowError("Please enter the username ...");
                return;
            }

            if (string.IsNullOrEmpty(txtPassword.Text))
            {
                MessageBoxHelper.ShowError("Please enter the password ...");
                return;
            }

            btnLogin.Enabled = false;
            var serializer  = new JsonSerializer();
            var errorLogger = new ErrorLogger();
            var loginClient = new AdmissionLoginClient(serializer, errorLogger);
            var user        = loginClient.LogIn(txtUserName.Text, txtPassword.Text);

            if (user.status == "success")
            {
                MisCache.UserToken           = user.user_token;
                MisCache.UserEmail           = user.user_email;
                MisCache.IsImportClasses     = true;
                MisCache.IsImportExamResults = true;

                SIMSDllResolution.AddSIMSDllResolution();
                if (!LoginHelper.SIMSlogin(AppSetting.Server,
                                           AppSetting.Database,
                                           AppSetting.User,
                                           AppSetting.Password))
                {
                    MessageBoxHelper.ShowError("Could not access to SIMS. Please check the SIMS user / password.");
                    Application.Exit();
                    return;
                }
                var frmHome = new FrmHome();
                frmHome.Show();
                this.Hide();
            }
            else
            {
                MisCache.UserToken = null;
                MisCache.UserEmail = null;
                MessageBoxHelper.ShowError(user.message ?? "Invalid user name or password.");
                btnLogin.Enabled = true;
            }
        }