private void btnSave_Click(object sender, EventArgs e) { try { if (!_isChanged) { return; } if (!ValidateModel()) { return; } SetModel(); if (_isAddNewMode) { _userInformation.Id = _userInformationService.Insert(_userInformation); } else { _userInformationService.Update(_userInformation); } LoadDataGridView(); _currentIndex = _userInformationList.FindIndex(r => r.Id == _userInformation.Id); LoadFormWithData(); MessageBox.Show(POSText.SaveMessage, MessageBoxCaptions.Success.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exception) { MessageBox.Show(POSText.ErrorMessage, MessageBoxCaptions.Error.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public JsonResult Save([Bind(Include = "Id, UserTypeId, EmployeeId, RoleId, Username, Password, PasswordAgeLimit, IsPasswordChanged, IsLocked, WrongPasswordTryLimit, IsSuperAdmin, IsActive")] UserInformationModel userInformation, bool isInsert) { if (isInsert) { userInformation.SetCreateProperties(LoginInformation.UserInformation.Id); userInformation.Id = _userInformationService.Insert(userInformation); } else { userInformation.SetUpdateProperties(LoginInformation.UserInformation.Id); _userInformationService.Update(userInformation); } return(new JsonResult { Data = _userInformationService.GetById(userInformation.Id) }); }