protected void Save(out bool bSaved) { bSaved = false; bool bNotify = false; if (bAllowUpdate) { if (!String.IsNullOrEmpty(txtUserId.Text) && txtUserId.Text.Trim().Length > 0) { #region SaveUser ////////////////////////////////////////////////////// //user account is valid so press on with the saves... CPatient patSave = new CPatient(); //fx sec helper CSec sec = new CSec(); if (chkResetPasswd.Checked || String.IsNullOrEmpty(htxtPatientID.Value)) { //make sure pwd and verify pwd match if (txtPassword.Text != txtVerifyPassword.Text) { BaseMstr.StatusCode = 1; BaseMstr.StatusComment = "Password and verify password must match!"; ShowSysFeedback(); return; } //check all the account rules for the account... if (!sec.ValidateUserAccountRules(BaseMstr, txtUserId.Text, txtPassword.Text)) { BaseMstr.StatusCode = 1; //Note: ValidateUserAccountRules will set StatusCode/StatusComment info ShowSysFeedback(); return; } } //if a user is looked up, then SelectedPatientID will be set //otherwise we are creating a new user if (htxtPatientID.Value == "")//this is a new user { return; } else if (htxtPatientID.Value != "") { BaseMstr.SelectedPatientID = htxtPatientID.Value; long lFXUserID = 0; BaseMstr.SetVSValue("FXUserIDExists", CheckIfFXUserRecExists()); blnFXUserIDExists = BaseMstr.GetVSBoolValue("FXUserIDExists"); if (!blnFXUserIDExists) { //insert a record into the fx_user table and update //the fx_user_id in the patient table sec.InsertPatientFXUser(BaseMstr, BaseMstr.SelectedPatientID, txtUserId.Text, txtPassword.Text, chkbxAccountLocked.Checked, chkbxAccountInactive.Checked, out lFXUserID); if (BaseMstr.StatusCode == 0) { txtUserId.Enabled = false; chkResetPasswd.Checked = false; txtPassword.Text = String.Empty; txtVerifyPassword.Text = String.Empty; txtPassword.Enabled = false; txtVerifyPassword.Enabled = false; bSaved = true; } bSaved = (BaseMstr.StatusCode == 0); if (bSaved) { bNotify = true; } } else { //update a record into the fx_user table and update //the fx_user_id in the suat user table lFXUserID = getFXUserID(); } //ONLY if we changed the users account info, update the //record in the FX_USER table if (chkResetPasswd.Checked) { sec.UpdatePatientFXUserPWD(BaseMstr, lFXUserID, txtUserId.Text, txtPassword.Text, chkbxAccountLocked.Checked, chkbxAccountInactive.Checked ); if (BaseMstr.StatusCode == 0) { txtUserId.Enabled = false; chkResetPasswd.Checked = false; txtPassword.Text = String.Empty; txtVerifyPassword.Text = String.Empty; txtPassword.Enabled = false; txtVerifyPassword.Enabled = false; } bSaved = (BaseMstr.StatusCode == 0); if (bSaved) { bNotify = true; } } else { bSaved = sec.UpdatePatientFXUserOptions(BaseMstr, lFXUserID, chkbxAccountLocked.Checked, chkbxAccountInactive.Checked ); } bSaved = (BaseMstr.StatusCode == 0); } if (bNotify) { //Add all patient events CPatientEvent evt = new CPatientEvent(BaseMstr); evt.AddSpecificEvent(cnChgPSWDEventID); //Password Changed if (BaseMstr.StatusCode == 0) { evt.CompletedSpecificEvent(cnChgPSWDEventID); //Password Changed Event ID } } LoadPatientsData(); #endregion } else { return; } } else { BaseMstr.StatusCode = 1; BaseMstr.StatusComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> You have <b>Read-Only Access</b> to this section."; } ShowSysFeedback(); return; }
protected void Save(out bool bSaved) { bSaved = false; if (bAllowUpdate) { if (!String.IsNullOrEmpty(txtUserId.Text) && txtUserId.Text.Trim().Length > 0) { #region SaveUser strMessage = ""; ////////////////////////////////////////////////////// //user account is valid so press on with the saves... CUserAdmin usrSave = new CUserAdmin(); int iUserType = 0; //get the user rights for storing long lUserRights = 0; long lReadOnly = 0; GetUserRights(out lUserRights, out lReadOnly); strMessage = CheckUserDemoErrors(); if (strMessage != "") { BaseMstr.StatusCode = 1; BaseMstr.StatusComment = strMessage; ShowSysFeedback(); return; } //User Type Selected iUserType = Convert.ToInt32(rblUserType.SelectedItem.Value); int lService = 0; //fx sec helper CSec sec = new CSec(); if (chkResetPasswd.Checked || String.IsNullOrEmpty(htxtProviderID.Value)) { //make sure pwd and verify pwd match if (txtPassword.Text != txtVerifyPassword.Text) { BaseMstr.StatusCode = 1; BaseMstr.StatusComment = "Password and verify password must match!"; ShowSysFeedback(); return; } //check all the account rules for the account... if (!sec.ValidateUserAccountRules(BaseMstr, txtUserId.Text, txtPassword.Text)) { BaseMstr.StatusCode = 1; //Note: ValidateUserAccountRules will set StatusCode/StatusComment info ShowSysFeedback(); return; } } //////////////////////////////////////////////////////// ////user account is valid so press on with the saves... //is a user is looked up, then SelectedProviderID will be set //otherwise we are creating a new user if (htxtProviderID.Value == "")//this is a new user { if (BaseMstr.StatusCode == 0) { //note: user name and pwd are valid so do the inserts //make sure user name does not already exist since //we are doing an insert if (sec.UserNameExists(BaseMstr, txtUserId.Text)) { BaseMstr.StatusCode = 1; BaseMstr.StatusComment = "Please choose a different user name!"; ShowSysFeedback(); return; } //get a new provider id strNewProviderID = BaseMstr.APPMaster.GetNewProviderID(); //insert a record into the suat user table usrSave.InsertSuatUser(BaseMstr, strNewProviderID, 0, //n/a now that we have fx-user - Locked txtName.Text, "N/A", //Not Used Rank 0, //Not Used Service, txtTitle.Text, "N/A", //Not Used Corps, "N/A", //Not Used Squadron, "N/A", //Not Used OfficeSymbol, txtPhone.Text, txtEmail.Text, cboSite.SelectedValue, "N/A", //- Not Used UIDPWD 0, //n/a now that we have fx_user - Not Used MustChgPWD "N/A"); //Not Used SupervisorID); if (BaseMstr.StatusCode == 0) { BaseMstr.SelectedProviderID = strNewProviderID; htxtProviderID.Value = strNewProviderID; //insert a record into the fx_user table and update //the fx_user_id in the suat user table long lFXUserID = 0; sec.InsertFXUser(BaseMstr, BaseMstr.SelectedProviderID, txtUserId.Text, txtPassword.Text, chkbxAccountLocked.Checked, chkbxAccountInactive.Checked, out lFXUserID); if (BaseMstr.StatusCode == 0) { sec.UpdateFXUserRights(BaseMstr, lFXUserID, iUserType, lUserRights, lReadOnly); txtUserId.Enabled = false; chkResetPasswd.Checked = false; txtPassword.Text = String.Empty; txtVerifyPassword.Text = String.Empty; txtPassword.Enabled = false; txtVerifyPassword.Enabled = false; } bSaved = (BaseMstr.StatusCode == 0); } } } else //if is existing user { //user is selected for edit if (htxtProviderID.Value != "") { BaseMstr.SelectedProviderID = htxtProviderID.Value; if (BaseMstr.StatusCode == 0) { //update the users record in the SUAT_USER table usrSave.UpdateSuatUser(BaseMstr, 0, //n.a now that we have fx_user - Locked txtName.Text, "N/A", //Not Used Rank 0, //Not Used Service, txtTitle.Text, "N/A", //Not Used Corps "N/A", //Not Used Squadron "N/A", //Not Used OfficeSymbol txtPhone.Text, txtEmail.Text, cboSite.SelectedValue, "N/A", //Not Used UIDPWD 0, //n/a now that we have fx_user -Not Used MustChgPWD "N/A"); //Not Used SupervisorID); if (BaseMstr.StatusCode == 0) { long lFXUserID = 0; BaseMstr.SetVSValue("FXUserIDExists", CheckIfFXUserRecExists()); blnFXUserIDExists = BaseMstr.GetVSBoolValue("FXUserIDExists"); if (!blnFXUserIDExists) { //insert a record into the fx_user table and update //the fx_user_id in the patient table sec.InsertFXUser(BaseMstr, BaseMstr.SelectedProviderID, txtUserId.Text, txtPassword.Text, chkbxAccountLocked.Checked, chkbxAccountInactive.Checked, out lFXUserID); if (BaseMstr.StatusCode == 0) { txtUserId.Enabled = false; chkResetPasswd.Checked = false; txtPassword.Text = String.Empty; txtVerifyPassword.Text = String.Empty; txtPassword.Enabled = false; txtVerifyPassword.Enabled = false; bSaved = true; } bSaved = (BaseMstr.StatusCode == 0); } else { //update a record into the fx_user table and update //the fx_user_id in the suat user table lFXUserID = getFXUserID(); } //ONLY if we changed the users account info, update the //record in the FX_USER table if (chkResetPasswd.Checked) { sec.UpdateFXUserPWD(BaseMstr, lFXUserID, txtUserId.Text, txtPassword.Text, chkbxAccountLocked.Checked, chkbxAccountInactive.Checked ); if (BaseMstr.StatusCode == 0) { txtUserId.Enabled = false; chkResetPasswd.Checked = false; txtPassword.Text = String.Empty; txtVerifyPassword.Text = String.Empty; txtPassword.Enabled = false; txtVerifyPassword.Enabled = false; } bSaved = (BaseMstr.StatusCode == 0); } else { bSaved = sec.UpdateFXUserOptions(BaseMstr, lFXUserID, chkbxAccountLocked.Checked, chkbxAccountInactive.Checked ); } //update fx_user_rights bSaved = sec.UpdateFXUserRights(BaseMstr, lFXUserID, iUserType, lUserRights, lReadOnly); } bSaved = (BaseMstr.StatusCode == 0); } } } LoadUsersData(); #endregion } else { BaseMstr.StatusCode = 1; BaseMstr.StatusComment = "<b>Username</b> and <b>Password</b> are required for the new user account."; } } else { BaseMstr.StatusCode = 1; BaseMstr.StatusComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> You have <b>Read-Only Access</b> to this section."; } ShowSysFeedback(); return; }