private void btnSave_Click(object sender, EventArgs e) { try { //update user TblUser tblUser = new TblUser(); TblUserAccess tblUserAccess = new TblUserAccess(); int selectedUser = Convert.ToInt32(cmbUser.SelectedValue); tblUser.UserId = selectedUser; tblUser.FirstName = txtFirstName.Text.Trim(); tblUser.MiddleName = txtMiddleName.Text.Trim(); tblUser.LastName = txtLastName.Text.Trim(); tblUserAccess.UserName = txtUserName.Text.Trim(); tblUserAccess.Password = txtPassword.Text.Trim(); tblUserAccess.UserId = selectedUser; _userAccessService.UpdateUserAccess(tblUserAccess); _userService.UpdateUser(tblUser); MessageBox.Show("User updated successfully"); } catch { throw; } }
public void DeleteUserAccess(int userAccessId) { TblUserAccess tblUserAccess = GetUserAccessById(userAccessId); tblUserAccess.isDeleted = true; dbContext.SaveChanges(); }
public TblUserAccess GetUserAccessById(int userId) { TblUserAccess tblUserAccess = (from p in dbContext.TblUserAccess where p.UserId == userId select p).FirstOrDefault(); return(tblUserAccess); }
public void UpdateUserAccess(TblUserAccess userAccess) { TblUserAccess tblUserAccess = GetUserAccessById(userAccess.UserId); tblUserAccess.UserName = userAccess.UserName; tblUserAccess.Password = userAccess.Password; dbContext.SaveChanges(); }
public void SaveUserAccess(TblUserAccess tblUserAccess) { TblUserAccess access = new TblUserAccess(); access.UserName = tblUserAccess.UserName; access.Password = tblUserAccess.Password; access.Attempts = 0; access.IsLocked = false; access.IsActive = true; access.CreatedDate = DateTime.Now.Date; access.isDeleted = false; access.UserId = tblUserAccess.UserId; dbContext.TblUserAccess.Add(access); dbContext.SaveChanges(); }
private void btnAdd_Click(object sender, EventArgs e) { //add user try { TblUser tblUser = new TblUser(); TblUserAccess tblUserAccess = new TblUserAccess(); tblUser.FirstName = txtFirstName.Text.Trim(); tblUser.MiddleName = txtMiddleName.Text.Trim(); tblUser.LastName = txtLastName.Text.Trim(); //save user and return id newUserId = _userService.SaveUser(tblUser); tblUserAccess.UserName = txtUserName.Text.Trim(); tblUserAccess.Password = txtPassword.Text.Trim(); tblUserAccess.UserAccessId = newUserId; _userAccessService.SaveUserAccess(tblUserAccess); MessageBox.Show("User Saved"); } catch (Exception a) { throw a; } }
private void btnLogin_Click(object sender, EventArgs e) { using (var dbcontext = new SCIMContext()) { loginAccess = _loginService.GetUserLogin(txtUsername.Text, txtPassword.Text); //var a = (from p in dbcontext.tblUserAccess // where p.UserName == txtUsername.Text // && txtPassword.Text == p.Password // && p.isDeleted != false // select p).FirstOrDefault(); if (loginAccess != null) { this.Hide(); var parent = new SCIM_Dashboard(); // Global.loggedUserId = loginAccess.UserId; //Global.loggedUserAccess = loginAccess.AccessId; //Parent_SVM parent = new Parent_SVM(); parent.Closed += (s, args) => this.Close(); parent.Show(); } else { MessageBox.Show("Login Failed"); } } //SCIM_Dashboard dashboard = new SCIM_Dashboard(); //dashboard.Closed += (s, args) => this.Close(); //dashboard.Show(); }