Example #1
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            string user     = txtUsername.Text;
            string password = txtPassword.Text;

            password = Encryption.Encrypt(password);
            using (DataTable dttmp = SQLConnector.ExecuteReturnDataTable("sp_checkLogin", "@user", user, "@password", password))
            {
                if (dttmp != null && dttmp.Rows.Count > 0)
                {
                    if (dttmp.Rows[0][0] is int _login && dttmp.Rows[0][1] is bool _admin)
                    {
                        UserInfo.UserID       = _login;
                        this.DialogResult     = DialogResult.OK;
                        SQLConnector.is_login = true;
                        SQLConnector.username = user;
                        SQLConnector.is_admin = _admin;

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("sp_checkLogin wrong");
                    }
                }
Example #2
0
        private void BtnRegis_Click(object sender, EventArgs e)
        {
            string username   = txtUsername.Text;
            string password   = txtPassword.Text;
            string repeatPass = txtRepeat.Text;
            bool   is_admin   = false;

            if (password == repeatPass)
            {
                txtPassword.Text = Encryption.Encrypt(txtPassword.Text);
                using (DataTable dttmp = SQLConnector.ExecuteReturnDataTable("sp_checkRegistry", "@user", username))
                {
                    if (dttmp != null && dttmp.Rows.Count > 0)
                    {
                        MessageBox.Show("username already taken ! Please choose the other", "message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        SQLConnector.checkRegistry = true;
                    }
                    else
                    {
                        bindingSourceAccount.EndEdit();
                        DialogResult = DialogResult.OK;
                    }
                }
            }
            else
            {
                MessageBox.Show("Password do not match , please fill again!!!", "message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (cb_isAdmin.CheckState == CheckState.Checked)
            {
                is_admin = true;
            }
            else if (cb_isAdmin.CheckState == CheckState.Unchecked)
            {
                is_admin = false;
            }
        }