예제 #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValid())
                {
                    string password = ClassSecurity.HashString(txtPassword.Text);

                    BusinessLogic.UserManager userManager = new BusinessLogic.UserManager();
                    bool status = userManager.LoginUser(txtUsername.Text, password);

                    if (status == false)
                    {
                        lblMessage.Text = "Username or Password is not correct, please try again.";
                    }
                    else
                    {
                        this.Hide();
                        frmHome frm = new TIMS.frmHome();
                        frm.Tag = txtUsername.Text;
                        frm.Show();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #2
0
        private void btnUpdateUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValidUser())
                {
                    BusinessLogic.UserManager userManager = new BusinessLogic.UserManager();
                    BusinessEntity.UserEntity newUser     = new BusinessEntity.UserEntity();

                    newUser.ID       = int.Parse(listViewUser.SelectedItems[0].SubItems[0].Text);
                    newUser.Username = txtUsername.Text;
                    newUser.Password = ClassSecurity.HashString(txtPassword.Text).ToString();

                    userManager.Update(newUser);

                    MessageBox.Show("User Information Updated Successfully.");
                    LoadUsers();
                }
            }
            catch (Exception ex)
            {
                //save to log table
                MessageBox.Show("Update Failed, Please try again.");
            }
        }
예제 #3
0
        private void btnSaveUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValidUser())
                {
                    BusinessLogic.UserManager userManager = new BusinessLogic.UserManager();
                    BusinessEntity.UserEntity user        = new BusinessEntity.UserEntity();
                    user.Username = txtUsername.Text;
                    user.Password = ClassSecurity.HashString(txtPassword.Text).ToString();

                    userManager.Save(user);

                    MessageBox.Show("User Information Saved Successfully.");
                    LoadUsers();
                }
            }
            catch (Exception ex)
            {
                //save to log table
                MessageBox.Show("Save Failed, Please try again.");
            }
        }