private void btnSave_Click(object sender, EventArgs e) { tbluseraccess employee = _userAccessService.GetAccess(Global.loggedUserId); //check if no blanks if (txtCurrentPassword.Text != string.Empty && txtNewPassword.Text != string.Empty && txtRepeatPassword.Text != string.Empty ) { if (txtCurrentPassword.Text.Trim() != employee.Password) { MessageBox.Show("Incorrect Password"); } else { if (txtNewPassword.Text.Trim() != txtRepeatPassword.Text.Trim()) { MessageBox.Show("Passwords do not match"); txtNewPassword.Focus(); } else { _userAccessService.UpdatePassword(Global.loggedUserId, txtNewPassword.Text.Trim()); MessageBox.Show("Password Updated"); this.Close(); } } } //else do not insert else { } }
private void btnLogin_Click(object sender, EventArgs e) { loginAccess = LoginUser(txtLogin.Text, txtPassword.Text); //SVMContext dbContext = new SVMContext(); using (var dbcontext = new SVMContext()) { //var a = (from p in dbcontext.tbluseraccess // where p.UserName == txtLogin.Text // && txtPassword.Text == p.Password // && p.isDeleted != false // select p).FirstOrDefault(); if (loginAccess != null) { this.Hide(); var parent = new Parent_SVM(); 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"); } } }
public tbluseraccess GetAccess(int userId) { tbluseraccess userAccess = (from p in svmContext.tbluseraccess where p.UserId == userId select p).FirstOrDefault(); return(userAccess); }
public void UpdatePassword(int userId, string password) { tbluseraccess tblUserAccess = GetAccess(userId); tblUserAccess.Password = password.Trim(); svmContext.SaveChanges(); }
public void UpdateUserAccess(int accessId, int userId, string userName, string password, int attempts, bool isLocked, bool isActive, DateTime?createdDate, int?createdBy, int?lastModifiedBy, bool isDeleted) { tbluseraccess tblUserAccess = GetAccess(userId); tblUserAccess.AccessId = accessId; tblUserAccess.UserId = userId; tblUserAccess.UserName = userName.Trim(); tblUserAccess.Password = password.Trim(); tblUserAccess.Attempts = attempts; tblUserAccess.IsLocked = isLocked; tblUserAccess.IsActive = isActive; tblUserAccess.CreatedDate = DateTime.Now; tblUserAccess.CreatedBy = createdBy; tblUserAccess.LastModifiedBy = lastModifiedBy; tblUserAccess.isDeleted = isDeleted; svmContext.SaveChanges(); }
private void FrmUserMaintenance_Load(object sender, EventArgs e) { btnEdit.Visible = false; lstAccess = _userAccessService.LoadAccess(); cmbAccessLevel.DataSource = lstAccess; cmbAccessLevel.ValueMember = "AccessId"; cmbAccessLevel.DisplayMember = "AccessName"; if (Global.isUserEdit == true) { //edit user //if valid existing employee number for edit tbluser empDetails = new tbluser(); tbluseraccess empUserAccess = new tbluseraccess(); empDetails = _userService.GetEmployee(Global.selectedUser); empUserAccess = _userAccessService.GetAccess(Global.selectedUser); cmbAccessLevel.SelectedValue = empUserAccess.AccessId; txtUsername.Text = empDetails.UserId.ToString(); txtEmpNo.Text = empDetails.EmployeeNo; txtContact.Text = empDetails.MobileNo; txtFirstName.Text = empDetails.FirstName; txtMiddleName.Text = empDetails.MiddleName; txtLastName.Text = empDetails.LastName; // cmbSuffix.SelectedValue = empDetails.Suffix; txtEmail.Text = empDetails.Email; txtContact.Text = empDetails.MobileNo; //disable the fields txtEmpNo.Enabled = false; txtFirstName.Enabled = false; txtMiddleName.Enabled = false; txtLastName.Enabled = false; txtEmail.Enabled = false; txtContact.Enabled = false; txtUsername.Enabled = false; btnUpload.Enabled = false; //cmbSuffix.Enabled = false; pbUserImage.Image = Image.FromFile(String.IsNullOrEmpty(empDetails.Path) ? defaultImage : empDetails.Path); btnSave.Hide(); btnEdit.Show(); } else if (Global.isUserEdit == false) { //new input pbUserImage.Image = Image.FromFile(@"D:\Projects\dotnet\SVM_Suite\SVM_Suite\SVM_Contracts\imgresource\images.png"); lstAccess = _userAccessService.LoadAccess(); cmbAccessLevel.Enabled = true; txtEmpNo.Focus(); } //cmbEmployeeNo.DataSource = _userService.LoadUsers(); //cmbEmployeeNo.Enabled = true; btnEdit.Show(); btnSave.Hide(); }