Exemplo n.º 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            User user       = _db.Users.First(u => u.Email == txtUserEmail.Text.Trim());
            int  SelectCase = cmbCase.SelectedIndex;

            switch (SelectCase)
            {
            case (int)Grant.Activate:
                user.IsActivated = true;
                break;

            case (int)Grant.Admin:
                user.IsAdmin     = true;
                user.IsActivated = true;
                break;

            case (int)Grant.Delete:
                user.IsDeleted = true;

                break;

            default:
                break;
            }
            await _db.SaveChangeAsync();

            RefreshDgv();
            txtUserEmail.Text = "";
        }
Exemplo n.º 2
0
        private async Task textBox2_TextChangedAsync(object sender, EventArgs e)
        {
            string email         = txtRgsEmail.Text.Trim();
            string fullname      = txtRgsname.Text.Trim();
            string password      = txtRgsPassword.Text.Trim();
            string checkpassword = txtRgsRepeatePassword.Text.Trim();

            if (IsValid(email, fullname, password, checkpassword))
            {
                return;
            }
            bool emailInDb = _db.Users.Any(u => u.Email == email);

            if (emailInDb)
            {
                MessageBox.Show("this email already exits!!!", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return;
            }



            User user = new User
            {
                Email    = email,
                Fullname = fullname,
                Password = password.HashPassword,
            };

            _db.Users.Add(user);
            await _db.SaveChangeAsync();

            MessageBox.Show("Successfully regiter. Please wait confirmation!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }