private void butOK_Click(object sender, System.EventArgs e) { #region Validation //if clinics are not enabled and the PaySimple program link is enabled, make sure there is a username and key set //if clinics are enabled, the program link can be enabled with blank username and/or key fields for some clinics //clinics with blank username and/or key will essentially not have PaySimple enabled if (checkEnabled.Checked && !IsClinicCurSetupDone()) //Also works for offices not using clinics { MsgBox.Show(this, "Please enter a username, key, and/or payment type first."); return; } SynchWithHQ(); //if the user changes the HQ credentials, any clinic that had the same credentials will be kept in synch with HQ long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } string payTypeSelected = ""; if (comboPaymentType.SelectedIndex > -1) { payTypeSelected = _listPaymentTypeDefs[comboPaymentType.SelectedIndex].DefNum.ToString(); } //set the values in the list for this clinic _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimpleApiUserName) .ForEach(x => x.PropertyValue = textUsername.Text); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimpleApiKey) .ForEach(x => x.PropertyValue = textKey.Text); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimplePayType) .ForEach(x => x.PropertyValue = payTypeSelected); //always 1 item; null safe string payTypeCur; //make sure any other clinics with PaySimple enabled also have a payment type selected for (int i = 0; i < _listUserClinicNums.Count; i++) { if (!checkEnabled.Checked) //if program link is not enabled, do not bother checking the payment type selected { break; } payTypeCur = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayType, _listUserClinicNums[i]); //if the program is enabled and the username and key fields are not blank, //PaySimple is enabled for this clinic so make sure the payment type is also set if (ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiUserName, _listUserClinicNums[i]) != "" && //if username set ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiKey, _listUserClinicNums[i]) != "" && //and key set !_listPaymentTypeDefs.Any(x => x.DefNum.ToString() == payTypeCur)) //and paytype is not a valid DefNum { MsgBox.Show(this, "Please select the payment type for all clinics with PaySimple username and key set."); return; } } #endregion Validation #region Save if (_progCur.Enabled != checkEnabled.Checked) //only update the program if the IsEnabled flag has changed { _progCur.Enabled = checkEnabled.Checked; Programs.Update(_progCur); } ProgramProperties.Sync(_listProgProps, _progCur.ProgramNum); #endregion Save DataValid.SetInvalid(InvalidType.Programs); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textSftpPort.errorProvider1.GetError(textSftpPort))) { MsgBox.Show(this, "Please enter a valid integer for the Sftp Server Port."); return; } int sendFreq = (int)numericSendFrequency.Value; DateTime accountUpdatesRuntime = DateTime.MinValue; if (!string.IsNullOrWhiteSpace(textUpdatesTimeOfDay.Text) && !DateTime.TryParse(textUpdatesTimeOfDay.Text, out accountUpdatesRuntime)) { MsgBox.Show(this, "Account Updates Run Time must be blank or a valid time of day."); return; } if (comboSendFrequencyUnits.SelectedIndex < 0 || comboSendFrequencyUnits.SelectedIndex >= Enum.GetNames(typeof(FrequencyUnit)).Length) { //shouldn't be possible, but just in case MsgBox.Show(this, "Please select a valid unit of measurement for the Account Activity Updates repeat frequency."); return; } if (numericSendFrequency.Value < 1 || numericSendFrequency.Value > new[] { 30, 24, 60 }[comboSendFrequencyUnits.SelectedIndex]) { //shouldn't be possible, but just in case MsgBox.Show(this, "Please enter a valid value for the Account Activity Updates repeat frequency."); return; } long billTypePaidInFullDefNum = comboPaidInFullBillType.GetSelectedDefNum(); if (billTypePaidInFullDefNum == 0 && checkEnabled.Checked) { MsgBox.Show(this, "Please select a Paid in Full Billing Type."); return; } SyncWithHQ(); //will remove any clinic from the dict if all props exactly match the HQ props, or add clinic props if different if (_progCur.Enabled != checkEnabled.Checked) //only update the program if the IsEnabled flag has changed { _progCur.Enabled = checkEnabled.Checked; Programs.Update(_progCur); } ProgramProperties.Sync(_dictClinicListProgProps.Where(x => _listUserClinicNums.Contains(x.Key)).SelectMany(x => x.Value).ToList(), _progCur.ProgramNum, _listUserClinicNums); DataValid.SetInvalid(InvalidType.Programs); string updateFreq = numericSendFrequency.Value + " " + (FrequencyUnit)comboSendFrequencyUnits.SelectedIndex; bool hasChanged = false; if (Prefs.UpdateString(PrefName.TransworldServiceTimeDue, accountUpdatesRuntime == DateTime.MinValue?"":POut.Time(accountUpdatesRuntime.TimeOfDay, false)) | Prefs.UpdateString(PrefName.TransworldServiceSendFrequency, updateFreq)) { Prefs.UpdateDateT(PrefName.TransworldDateTimeLastUpdated, DateTime.MinValue); hasChanged = true; } if (Prefs.UpdateLong(PrefName.TransworldPaidInFullBillingType, billTypePaidInFullDefNum) | hasChanged) { DataValid.SetInvalid(InvalidType.Prefs); } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { ErxOptionPP.PropertyValue = POut.Int((int)_eRxOption); _progCur.Enabled = checkEnabled.Checked; Programs.Update(_progCur); ProgramProperties.Sync(_listProgramProperties, _progCur.ProgramNum); DataValid.SetInvalid(InvalidType.Programs); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { #region Validation //if clinics are not enabled and the PayConnect program link is enabled, make sure there is a username and password set //if clinics are enabled, the program link can be enabled with blank username and/or password fields for some clinics //clinics with blank username and/or password will essentially not have PayConnect enabled //if 'Enable terminal processing' is checked then the practice/clinic will not need a username and password. if (checkEnabled.Checked && !checkTerminal.Checked && !PrefC.HasClinicsEnabled && (textUsername.Text == "" || textPassword.Text == "")) { MsgBox.Show(this, "Please enter a username and password first."); return; } if (checkEnabled.Checked && //if PayConnect is enabled comboPaymentType.SelectedIndex < 0 && //and the payment type is not set (!PrefC.HasClinicsEnabled || //and either clinics are not enabled (meaning this is the only set of username, password, payment type values) (textUsername.Text != "" && textPassword.Text != ""))) //or clinics are enabled and this clinic's link has a username and password set { MsgBox.Show(this, "Please select a payment type first."); return; } if (checkEnabled.Checked && //if PayConnect is enabled comboDefaultProcessing.SelectedIndex < 0) { MsgBox.Show(this, "Please select a default processing method type first."); return; } SynchWithHQ(); //if the user changes the HQ credentials, any clinic that had the same credentials will be kept in synch with HQ long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } UpdateListProgramPropertiesForClinic(clinicNum); string payTypeCur; //make sure any other clinics with PayConnect enabled also have a payment type selected for (int i = 0; i < _listUserClinicNums.Count; i++) { if (!checkEnabled.Checked) //if program link is not enabled, do not bother checking the payment type selected { break; } payTypeCur = ProgramProperties.GetPropValFromList(_listProgProps, "PaymentType", _listUserClinicNums[i]); //if the program is enabled and the username and password fields are not blank, //PayConnect is enabled for this clinic so make sure the payment type is also set if (((ProgramProperties.GetPropValFromList(_listProgProps, "Username", _listUserClinicNums[i]) != "" && //if username set ProgramProperties.GetPropValFromList(_listProgProps, "Password", _listUserClinicNums[i]) != "") || //and password set ProgramProperties.GetPropValFromList(_listProgProps, "TerminalProcessingEnabled", _listUserClinicNums[i]) == "1") && //or terminal enabled !_listPaymentTypeDefs.Any(x => x.DefNum.ToString() == payTypeCur)) //and paytype is not a valid DefNum { MsgBox.Show(this, "Please select the payment type for all clinics with PayConnect username and password set."); return; } } #endregion Validation #region Save if (_progCur.Enabled != checkEnabled.Checked) //only update the program if the IsEnabled flag has changed { _progCur.Enabled = checkEnabled.Checked; Programs.Update(_progCur); } ProgramProperties.Sync(_listProgProps, _progCur.ProgramNum); //Find all clinics that have PayConnect online payments enabled _listProgProps.FindAll(x => x.PropertyDesc == PayConnect.ProgramProperties.PatientPortalPaymentsEnabled && PIn.Bool(x.PropertyValue)).ForEach(x => { //Find all XWeb program properties that we saved in this session. Only clinics that have changes will have an XWeb property in memory. //This is needed to ensure that we don't disable XWeb online payments if someone // checks to use PayConnect online payments and then decides to keep it disabled during the same session. ProgramProperty ppXWebOnlinePayments = _listXWebWebPayProgProps.FirstOrDefault(y => y.ClinicNum == x.ClinicNum); if (ppXWebOnlinePayments != null) { ProgramProperties.UpdateProgramPropertyWithValue(ppXWebOnlinePayments, POut.Bool(false)); } }); #endregion Save DataValid.SetInvalid(InvalidType.Programs); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { #region Validation //if clinics are not enabled and the PayConnect program link is enabled, make sure there is a username and password set //if clinics are enabled, the program link can be enabled with blank username and/or password fields for some clinics //clinics with blank username and/or password will essentially not have PayConnect enabled //if 'Enable terminal processing' is checked then the practice/clinic will not need a username and password. if (checkEnabled.Checked && !checkTerminal.Checked && !PrefC.HasClinicsEnabled && (textUsername.Text == "" || textPassword.Text == "")) { MsgBox.Show(this, "Please enter a username and password first."); return; } if (checkEnabled.Checked && //if PayConnect is enabled comboPaymentType.SelectedIndex < 0 && //and the payment type is not set (!PrefC.HasClinicsEnabled || //and either clinics are not enabled (meaning this is the only set of username, password, payment type values) (textUsername.Text != "" && textPassword.Text != ""))) //or clinics are enabled and this clinic's link has a username and password set { MsgBox.Show(this, "Please select a payment type first."); return; } if (checkEnabled.Checked && //if PayConnect is enabled comboDefaultProcessing.SelectedIndex < 0) { MsgBox.Show(this, "Please select a default processing method type first."); return; } SynchWithHQ(); //if the user changes the HQ credentials, any clinic that had the same credentials will be kept in synch with HQ long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } string payTypeSelected = ""; if (comboPaymentType.SelectedIndex > -1) { payTypeSelected = _listPaymentTypeDefs[comboPaymentType.SelectedIndex].DefNum.ToString(); } string processingMethodSelected = comboDefaultProcessing.SelectedIndex.ToString(); //set the values in the list for this clinic _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == "Username") .ForEach(x => x.PropertyValue = textUsername.Text); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == "Password") .ForEach(x => x.PropertyValue = textPassword.Text); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == "PaymentType") .ForEach(x => x.PropertyValue = payTypeSelected); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PayConnect.ProgramProperties.DefaultProcessingMethod) .ForEach(x => x.PropertyValue = processingMethodSelected); _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == "TerminalProcessingEnabled") .ForEach(x => x.PropertyValue = POut.Bool(checkTerminal.Checked)); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PayConnect.ProgramProperties.PayConnectForceRecurringCharge) .ForEach(x => x.PropertyValue = POut.Bool(checkForceRecurring.Checked)); //Patient portal payments with PayConnect are currently not supported, checkWebPayEnabled is never visible, so always set to 0, //but we'll leave this here for future functionality //_listProgProps.FindAll(x => x.ClinicNum==clinicNum && x.PropertyDesc=="IsOnlinePaymentsEnabled") // .ForEach(x => x.PropertyValue=POut.Bool(checkWebPayEnabled.Checked));//always 1 item; null safe string payTypeCur; //make sure any other clinics with PayConnect enabled also have a payment type selected for (int i = 0; i < _listUserClinicNums.Count; i++) { if (!checkEnabled.Checked) //if program link is not enabled, do not bother checking the payment type selected { break; } payTypeCur = ProgramProperties.GetPropValFromList(_listProgProps, "PaymentType", _listUserClinicNums[i]); //if the program is enabled and the username and password fields are not blank, //PayConnect is enabled for this clinic so make sure the payment type is also set if (((ProgramProperties.GetPropValFromList(_listProgProps, "Username", _listUserClinicNums[i]) != "" && //if username set ProgramProperties.GetPropValFromList(_listProgProps, "Password", _listUserClinicNums[i]) != "") || //and password set ProgramProperties.GetPropValFromList(_listProgProps, "TerminalProcessingEnabled", _listUserClinicNums[i]) == "1") && //or terminal enabled !_listPaymentTypeDefs.Any(x => x.DefNum.ToString() == payTypeCur)) //and paytype is not a valid DefNum { MsgBox.Show(this, "Please select the payment type for all clinics with PayConnect username and password set."); return; } } #endregion Validation #region Save if (_progCur.Enabled != checkEnabled.Checked) //only update the program if the IsEnabled flag has changed { _progCur.Enabled = checkEnabled.Checked; Programs.Update(_progCur); } ProgramProperties.Sync(_listProgProps, _progCur.ProgramNum); #endregion Save DataValid.SetInvalid(InvalidType.Programs); DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { #region Validation //if clinics are not enabled and the PaySimple program link is enabled, make sure there is a username and key set //if clinics are enabled, the program link can be enabled with blank username and/or key fields for some clinics //clinics with blank username and/or key will essentially not have PaySimple enabled if (checkEnabled.Checked && !IsClinicCurSetupDone()) //Also works for offices not using clinics { MsgBox.Show(this, "Please enter a username, key, and/or payment type first."); return; } SynchWithHQ(); //if the user changes the HQ credentials, any clinic that had the same credentials will be kept in synch with HQ long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } string payTypeCCSelected = ""; if (comboPaymentTypeCC.SelectedIndex > -1) { payTypeCCSelected = comboPaymentTypeCC.GetSelected <Def>().DefNum.ToString(); } string payTypeACHSelected = ""; if (comboPaymentTypeACH.SelectedIndex > -1) { payTypeACHSelected = comboPaymentTypeACH.GetSelected <Def>().DefNum.ToString(); } //set the values in the list for this clinic _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimpleApiUserName) .ForEach(x => x.PropertyValue = textUsername.Text); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimpleApiKey) .ForEach(x => x.PropertyValue = textKey.Text); //always 1 item; null safe _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimplePayTypeCC) .ForEach(x => x.PropertyValue = payTypeCCSelected); //always 1 item _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimplePayTypeACH) .ForEach(x => x.PropertyValue = payTypeACHSelected); //always 1 item _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimplePreventSavingNewCC) .ForEach(x => x.PropertyValue = POut.Bool(checkPreventSavingNewCC.Checked)); string payTypeCC; string payTypeACH; //make sure any other clinics with PaySimple enabled also have a payment type selected for (int i = 0; i < _listUserClinicNums.Count; i++) { if (!checkEnabled.Checked) //if program link is not enabled, do not bother checking the payment type selected { break; } payTypeCC = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayTypeCC, _listUserClinicNums[i]); payTypeACH = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayTypeACH, _listUserClinicNums[i]); //if the program is enabled and the username and key fields are not blank, //PaySimple is enabled for this clinic so make sure the payment type is also set if (ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiUserName, _listUserClinicNums[i]) != "" && //if username set ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiKey, _listUserClinicNums[i]) != "" //and key set //and either paytype is not a valid DefNum && (!_listPaymentTypeDefs.Any(x => x.DefNum.ToString() == payTypeCC) || !_listPaymentTypeDefs.Any(x => x.DefNum.ToString() == payTypeACH))) { MsgBox.Show(this, "Please select payment types for all clinics with PaySimple username and key set."); return; } } #endregion Validation #region Save if (_progCur.Enabled != checkEnabled.Checked) //only update the program if the IsEnabled flag has changed { _progCur.Enabled = checkEnabled.Checked; Programs.Update(_progCur); } ProgramProperties.Sync(_listProgProps, _progCur.ProgramNum); #endregion Save DataValid.SetInvalid(InvalidType.Programs); //Webhooks calls validation. This code needs to be under the validation section so people enabling the program for the first time will //be able to save their fields and the program properties will get filled correctly. //get url for webhooks, then create the webhooks if not already present. Has to be done after validation so new user enables are able to save. //for each clinic that has a username and api key, make a call to paysimple's api to see what webhooks this api account has. if (PrefC.HasClinicsEnabled) { foreach (long clinic in _listUserClinicNums) { WebhookHelper(GetUsernameForClinic(clinic), GetKeyForClinic(clinic), clinic); } } else { WebhookHelper(textUsername.Text, textKey.Text, 0); } DialogResult = DialogResult.OK; }