private void btnAddUser_Click(object sender, EventArgs e) { User _user = new User(); if (IsEditMode == true) { _user = _db.GetUserById(UserId); } _user.UserName = txtUserName.Text; _user.Pasword = txtpassword.Text; _user.FullName = txtFullename.Text; _user.isAdmin = isAdmin.Checked; _user.isActive = isActive.Checked; if (IsEditMode == true) { _db.SaveUser(_user); _db.SaveChanges(); MessageBox.Show("User(s) Saved", "User(s) has been updated ", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _db.AddToUsers(_user); _db.SaveChanges(); MessageBox.Show("User(s) Saved", "User(s) has been Created ", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Close(); }