Beispiel #1
0
        private void btnEnroll_Click(object sender, EventArgs e)
        {
            bool goodToProceed = entryVal.validateUserEntry(txtUsername.Text,
                                                            txtPassword.Text,
                                                            txtHint.Text,
                                                            cboRelation.Text,
                                                            txtPhone.Text,
                                                            txtEMail.Text,
                                                            txtFirstName.Text,
                                                            txtLastName.Text,
                                                            rdoAdmin.Checked,
                                                            rdoBasic.Checked);

            try
            {
                if (goodToProceed)
                {
                    string userLevel = String.Empty;
                    if (rdoAdmin.Checked == true)
                    {
                        userLevel = sysMessages.msgAdminLabel;
                    }
                    if (rdoBasic.Checked == true)
                    {
                        userLevel = sysMessages.msgBasicLabel;
                    }

                    enrollUser.NewUser(
                        txtUsername.Text,
                        passwordOps.EncodePassword(txtPassword.Text),
                        txtHint.Text,
                        cboRelation.Text,
                        txtPhone.Text,
                        txtEMail.Text,
                        txtFirstName.Text,
                        txtLastName.Text,
                        userLevel);
                }
                else
                {
                    result = MessageBox.Show(sysMessages.msgIncompleteEntry,
                                             sysMessages.msgAttention,
                                             MessageBoxButtons.OK,
                                             MessageBoxIcon.Exclamation);

                    if (result == DialogResult.OK)
                    {
                        txtUsername.Focus();
                    }
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString(),
                                sysMessages.dbError,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            finally
            {
                if (goodToProceed)
                {
                    clearEntries();
                    this.Close();
                }
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            int userId    = logIn.getUserId(txtUsername.Text, passwordOps.EncodePassword(txtPassword.Text));
            int girlCount = girlInfo.countGirlPerUser(userId);

            if (userId <= 0 && txtUsername.Text != sysMessages.msgUsername)
            {
                MessageBox.Show(sysMessages.msgUserPWNotFound,
                                sysMessages.msgUserNotFound,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                txtUsername.Text = defUserName;
                txtPassword.Text = String.Empty;
                txtUsername.Focus();
                if (chkShowPassword.Checked)
                {
                    chkShowPassword.Checked = false;
                }
            }

            if (btnLogin.Text == sysMessages.btnLogin)
            {
                logIn.logOn(txtUsername.Text, passwordOps.EncodePassword(txtPassword.Text));
                try
                {
                    if (girlCount == 1)
                    {
                        SingleGirl(logIn.userInfo.userId, girlCount);
                        GirlDisplay();
                    }
                    else if (girlCount > 1)
                    {
                        tsLeft.Text = sysMessages.msgSelectGirl;
                        girlComboControl(userId, girlCount);
                    }
                    else
                    {
                        tsLeft.Text = sysMessages.msgEnterGirl;
                    }
                }
                finally
                {
                    btnLogin.Text = sysMessages.btnLogoff;
                    linkControls();
                    loginComplete(logIn.userInfo.userId, logIn.userInfo.userLevel);
                    enableTab();
                }
            }
            else
            if (btnLogin.Text == sysMessages.btnLogoff)
            {
                girlComboControl(-1, -1);
                userControls();
                logIn.LogOff();
                enableTab(); //disables tab controls
                girlInfo.clearGirl();
                troopInfoControls();
                linkControls();
                lblHint.Visible = false;
                btnLogin.Text   = sysMessages.btnLogin;
                tsLeft.Text     = defLeft;
                if (chkShowPassword.Checked)
                {
                    chkShowPassword.Checked = false;
                }
                if (logIn.userInfo.userLevel == sysMessages.msgBasicLabel)
                {
                    tabMain.TabPages.Add(tabMaintenance);
                }
            }
        }