Example #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            db = new DBPOS();
            users = db.GetUserAccounts();
            current = 0;

            if (String.IsNullOrEmpty(txtBxUserName.Text) && String.IsNullOrEmpty(txtBxPassword.Text))
            {
                lblLoginErrorMsg.Text = "Please ensure all fields are entered";
                txtBxUserName.ResetText();
                txtBxPassword.ResetText();
            }
            else if (users.Exists(u => u.Username.Equals(txtBxUserName.Text)))
            {
                current = users.FindIndex(u => u.Username.Equals(txtBxUserName.Text));
                if (users[current].Username.Equals(txtBxUserName.Text) && users[current].Password.Equals(txtBxPassword.Text))
                {
                    lblLoginErrorMsg.Text = "";
                    txtBxUserName.ResetText();
                    txtBxPassword.ResetText();
                    MessageBox.Show(string.Format("Welcome {0}! Your AccountType is {1}.", users[current].Username, users[current].AccountType));
                    UserControlPanel cp = new UserControlPanel();
                    cp.CurrentUser = users[current];
                    cp.ShowDialog();
                }
            }

            else
            {
                txtBxUserName.ResetText();
                txtBxPassword.ResetText();
                lblLoginErrorMsg.Text = "Either the username or password was incorrect.";
            }
        }
        public void ChangeAccountSettings_Load(object sender, EventArgs e)
        {
            txtBxPasswordNew.PasswordChar = '\u2022';
            txtBxCVC.MaxLength = 3;
            txtBxCreditCardNo.MaxLength = 16;
            txtBxMobileNoNew.MaxLength = 8;
            txtBxSixDigitPIN.MaxLength = 6;
            txtBxCreditCardNo.MaxLength = 16;
            if (user.AccountType == "Administrator" || user.AccountType == "Vendor")
            {
                dbp = new DBPOS();
                users = dbp.GetUserAccounts();
                panelPg2.Visible = true;
                CustPanel.Visible = false;
                PassEmailPanel.Visible = true;
                panelPg3.Visible = false;
                PassEmailPanel.Location = new Point(37, 31);
                txtBxPasswordNew.Text = users[0].Password;
                txtBxEmailNew.Text = users[0].Email;
            }
            else {
                dbp = new DBPOS();
                users = dbp.GetUserInfo(user.AccountID);
                txtBxFirstNameNew.Text = users[0].FirstName;
                txtBxLastNameNew.Text = users[0].LastName;
                txtBxMobileNoNew.Text = users[0].MobileNo.ToString();
                txtBxPasswordNew.Text = users[0].Password;
                txtBxEmailNew.Text = users[0].Email;

                panelPg2.Visible = true;
                panelPg3.Visible = false;
            }
            }