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; }
///<summary>For each clinic, if the Username and Key are the same as the HQ (ClinicNum=0) Username and Key, update the clinic with the ///values in the text boxes. Only modifies other clinics if _indexClinicRevert=0, meaning user just modified the HQ clinic credentials.</summary> private void SynchWithHQ() { if (!PrefC.HasClinicsEnabled || _listUserClinicNums[_indexClinicRevert] > 0) //using clinics, and modifying the HQ clinic. otherwise return. { return; } string hqUsername = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiUserName, 0); //HQ Username before updating to value in textbox string hqKey = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiKey, 0); //HQ Key before updating to value in textbox string hqPayTypeCC = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayTypeCC, 0); //HQ PaymentType before updating to combo box selection string payTypeCC = ""; if (comboPaymentTypeCC.SelectedIndex > -1) { payTypeCC = comboPaymentTypeCC.GetSelected <Def>().DefNum.ToString(); } string hqPayTypeACH = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayTypeACH, 0); //HQ PaymentType before updating to combo box selection string payTypeACH = ""; if (comboPaymentTypeACH.SelectedIndex > -1) { payTypeACH = comboPaymentTypeACH.GetSelected <Def>().DefNum.ToString(); } //for each distinct ClinicNum in the prog property list for PaySimple except HQ foreach (long clinicNum in _listProgProps.Select(x => x.ClinicNum).Where(x => x > 0).Distinct()) { //if this clinic has a different username or key, skip it if (!_listProgProps.Exists(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimpleApiUserName && x.PropertyValue == hqUsername) || !_listProgProps.Exists(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimpleApiKey && x.PropertyValue == hqKey)) { continue; } //this clinic had a matching username and key, so update the username and key to keep it synched with HQ _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 if (!string.IsNullOrEmpty(payTypeCC)) { //update clinic payment type if it originally matched HQ's payment type and the selected payment type is valid _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimplePayTypeCC && x.PropertyValue == hqPayTypeCC) .ForEach(x => x.PropertyValue = payTypeCC); } if (!string.IsNullOrEmpty(payTypeACH)) { //update clinic payment type if it originally matched HQ's payment type and the selected payment type is valid _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == PaySimple.PropertyDescs.PaySimplePayTypeACH && x.PropertyValue == hqPayTypeACH) .ForEach(x => x.PropertyValue = payTypeACH); } } }
///<summary>For each clinic, if the Username and Password are the same as the HQ (ClinicNum=0) Username and Password, update the clinic with the ///values in the text boxes. Only modifies other clinics if _indexClinicRevert=0, meaning user just modified the HQ clinic credentials.</summary> private void SynchWithHQ() { if (!PrefC.HasClinicsEnabled || _listUserClinicNums[_indexClinicRevert] > 0) //using clinics, and modifying the HQ clinic. otherwise return. { return; } string hqUsername = ProgramProperties.GetPropValFromList(_listProgProps, "Username", 0); //HQ Username before updating to value in textbox string hqPassword = ProgramProperties.GetPropValFromList(_listProgProps, "Password", 0); //HQ Password before updating to value in textbox string hqPayType = ProgramProperties.GetPropValFromList(_listProgProps, "PaymentType", 0); //HQ PaymentType before updating to combo box selection //IsOnlinePaymentsEnabled will not be synced with HQ, since some clinics may need to disable patient portal payments //Token will not be synced with HQ, since some clinics may need to disable patient portal payments string payTypeCur = ""; if (comboPaymentType.SelectedIndex > -1) { payTypeCur = _listPaymentTypeDefs[comboPaymentType.SelectedIndex].DefNum.ToString(); } //for each distinct ClinicNum in the prog property list for PayConnect except HQ foreach (long clinicNum in _listProgProps.Select(x => x.ClinicNum).Where(x => x > 0).Distinct()) { //if this clinic has a different username or password, skip it if (!_listProgProps.Exists(x => x.ClinicNum == clinicNum && x.PropertyDesc == "Username" && x.PropertyValue == hqUsername) || !_listProgProps.Exists(x => x.ClinicNum == clinicNum && x.PropertyDesc == "Password" && x.PropertyValue == hqPassword)) { continue; } //this clinic had a matching username and password, so update the username and password to keep it synched with HQ _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 if (string.IsNullOrEmpty(payTypeCur)) { continue; } //update clinic payment type if it originally matched HQ's payment type and the selected payment type is valid _listProgProps.FindAll(x => x.ClinicNum == clinicNum && x.PropertyDesc == "PaymentType" && x.PropertyValue == hqPayType) .ForEach(x => x.PropertyValue = payTypeCur); //always 1 item; null safe } }
private void FillFields() { long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } textUsername.Text = ProgramProperties.GetPropValFromList(_listProgProps, "Username", clinicNum); textPassword.Text = ProgramProperties.GetPropValFromList(_listProgProps, "Password", clinicNum); textPassword.UseSystemPasswordChar = textPassword.Text.Trim().Length > 0; string payTypeDefNum = ProgramProperties.GetPropValFromList(_listProgProps, "PaymentType", clinicNum); string processingMethod = ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.DefaultProcessingMethod, clinicNum); checkTerminal.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, "TerminalProcessingEnabled", clinicNum)); checkForceRecurring.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PayConnectForceRecurringCharge, clinicNum)); checkPreventSavingNewCC.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, clinicNum)); checkPatientPortalPayEnabled.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PatientPortalPaymentsEnabled, clinicNum)); textToken.Text = PIn.String(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PatientPortalPaymentsToken, clinicNum)); comboPaymentType.Items.Clear(); _listPaymentTypeDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true); for (int i = 0; i < _listPaymentTypeDefs.Count; i++) { comboPaymentType.Items.Add(_listPaymentTypeDefs[i].ItemName); if (_listPaymentTypeDefs[i].DefNum.ToString() == payTypeDefNum) { comboPaymentType.SelectedIndex = i; } } comboDefaultProcessing.Items.Clear(); comboDefaultProcessing.Items.Add(Lan.g(this, PayConnectProcessingMethod.WebService.GetDescription())); comboDefaultProcessing.Items.Add(Lan.g(this, PayConnectProcessingMethod.Terminal.GetDescription())); if (processingMethod == "0" || processingMethod == "1") { comboDefaultProcessing.SelectedIndex = PIn.Int(processingMethod); } }
private void FillFields() { long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } textUsername.Text = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiUserName, clinicNum); textKey.Text = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiKey, clinicNum); string payTypeDefNum = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayType, clinicNum); comboPaymentType.Items.Clear(); _listPaymentTypeDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true); for (int i = 0; i < _listPaymentTypeDefs.Count; i++) { comboPaymentType.Items.Add(_listPaymentTypeDefs[i].ItemName); if (_listPaymentTypeDefs[i].DefNum.ToString() == payTypeDefNum) { comboPaymentType.SelectedIndex = i; } } }
private void FillFields() { long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } textUsername.Text = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiUserName, clinicNum); textKey.Text = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiKey, clinicNum); string payTypeDefNumCC = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayTypeCC, clinicNum); string payTypeDefNumACH = ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePayTypeACH, clinicNum); checkPreventSavingNewCC.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, clinicNum)); _listPaymentTypeDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true); comboPaymentTypeCC.Items.Clear(); comboPaymentTypeCC.Items.AddDefs(_listPaymentTypeDefs); comboPaymentTypeCC.SetSelectedDefNum(PIn.Long(payTypeDefNumCC)); comboPaymentTypeACH.Items.Clear(); comboPaymentTypeACH.Items.AddDefs(_listPaymentTypeDefs); comboPaymentTypeACH.SetSelectedDefNum(PIn.Long(payTypeDefNumACH)); }
private void FillFields() { long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } textUsername.Text = ProgramProperties.GetPropValFromList(_listProgProps, "Username", clinicNum); textPassword.Text = ProgramProperties.GetPropValFromList(_listProgProps, "Password", clinicNum); string payTypeDefNum = ProgramProperties.GetPropValFromList(_listProgProps, "PaymentType", clinicNum); string processingMethod = ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.DefaultProcessingMethod, clinicNum); checkTerminal.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, "TerminalProcessingEnabled", clinicNum)); checkForceRecurring.Checked = PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps, PayConnect.ProgramProperties.PayConnectForceRecurringCharge, clinicNum)); //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 //checkWebPayEnabled.Checked=PIn.Bool(ProgramProperties.GetPropValFromList(_listProgProps,"IsOnlinePaymentsEnabled",clinicNum)); comboPaymentType.Items.Clear(); _listPaymentTypeDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true); for (int i = 0; i < _listPaymentTypeDefs.Count; i++) { comboPaymentType.Items.Add(_listPaymentTypeDefs[i].ItemName); if (_listPaymentTypeDefs[i].DefNum.ToString() == payTypeDefNum) { comboPaymentType.SelectedIndex = i; } } comboDefaultProcessing.Items.Clear(); comboDefaultProcessing.Items.Add(Lan.g(this, PayConnectProcessingMethod.WebService.GetDescription())); comboDefaultProcessing.Items.Add(Lan.g(this, PayConnectProcessingMethod.Terminal.GetDescription())); if (processingMethod == "0" || processingMethod == "1") { comboDefaultProcessing.SelectedIndex = PIn.Int(processingMethod); } }
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; }
private string GetKeyForClinic(long clinicNum) { return(ProgramProperties.GetPropValFromList(_listProgProps, PaySimple.PropertyDescs.PaySimpleApiKey, clinicNum)); }