private void FormFHIRSetup_Load(object sender, EventArgs e) { Program prog = Programs.GetCur(ProgramName.FHIR); checkEnabled.Checked = prog.Enabled; textSubInterval.Text = ProgramProperties.GetPropVal(prog.ProgramNum, "SubscriptionProcessingFrequency"); comboPayType.Items.AddDefs(Defs.GetDefsForCategory(DefCat.PaymentTypes, true)); comboPayType.SetSelectedDefNum(PrefC.GetLong(PrefName.ApiPaymentType)); //Let the load finish before we call HQ this.BeginInvoke(() => { Cursor = Cursors.WaitCursor; Application.DoEvents(); _listApiKeys = GetApiKeys(); Cursor = Cursors.Default; if (_listApiKeys == null) { DialogResult = DialogResult.Cancel; //We have already shown them an error message. return; } FillGrid(); }); }
private void butOK_Click(object sender, System.EventArgs e) { if (prog == null) { MsgBox.Show(this, "PayConnect entry is missing from the database."); //should never happen return; } if (comboPaymentType.SelectedIndex == -1) { MsgBox.Show(this, "Please select a payment type first."); return; } prog.Enabled = checkEnabled.Checked; Programs.Update(prog); propUsername.PropertyValue = textUsername.Text; ProgramProperties.Update(propUsername); propPassword.PropertyValue = textPassword.Text; ProgramProperties.Update(propPassword); propPayType.PropertyValue = DefC.Short[(int)DefCat.PaymentTypes][comboPaymentType.SelectedIndex].DefNum.ToString(); ProgramProperties.Update(propPayType); DataValid.SetInvalid(InvalidType.Programs); DialogResult = DialogResult.OK; }
private void FormClinics_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (IsSelectionMode) { return; } if (Prefs.UpdateBool(PrefName.ClinicListIsAlphabetical, checkOrderAlphabetical.Checked)) { DataValid.SetInvalid(InvalidType.Prefs); } bool hasClinicChanges = Clinics.Sync(ListClinics, _listClinicsOld); //returns true if clinics were updated/inserted/deleted //Update the ClinicNum on all specialties associated to each clinic. ListClinics.ForEach(x => x.ListClinicSpecialtyDefLinks.ForEach(y => y.FKey = x.ClinicNum)); List <DefLink> listAllClinicSpecialtyDefLinks = ListClinics.SelectMany(x => x.ListClinicSpecialtyDefLinks).ToList(); hasClinicChanges |= DefLinks.Sync(listAllClinicSpecialtyDefLinks, _listClinicDefLinksAllOld); hasClinicChanges |= CorrectItemOrders(); //Joe - Now that we have called sync on ListClinics we want to make sure that each clinic has program properties for PayConnect and XCharge //We are doing this because of a previous bug that caused some customers to have over 3.4 million duplicate rows in their programproperty table long payConnectProgNum = Programs.GetProgramNum(ProgramName.PayConnect); long xChargeProgNum = Programs.GetProgramNum(ProgramName.Xcharge); //Don't need to do this for PaySimple, because these will get generated as needed in FormPaySimpleSetup bool hasChanges = ProgramProperties.InsertForClinic(payConnectProgNum, ListClinics.Select(x => x.ClinicNum).Where(x => ProgramProperties.GetListForProgramAndClinic(payConnectProgNum, x).Count == 0).ToList()); hasChanges |= ProgramProperties.InsertForClinic(xChargeProgNum, ListClinics.Select(x => x.ClinicNum).Where(x => ProgramProperties.GetListForProgramAndClinic(xChargeProgNum, x).Count == 0).ToList()); if (hasChanges) { DataValid.SetInvalid(InvalidType.Programs); } if (hasClinicChanges) { DataValid.SetInvalid(InvalidType.Providers); } }
private void butClose_Click(object sender, EventArgs e) { if (textSubInterval.errorProvider1.GetError(textSubInterval) != "") { MsgBox.Show(this, "Please fix data entry errors first."); return; } bool changed = false; foreach (APIKey apiKeyHQ in _listApiKeysHQ) { APIKey apiKeyLocal = _listApiKeysLocal.FirstOrDefault(x => x.Key == apiKeyHQ.Key); if (apiKeyLocal == null || //A new key was generated but then Cancel was clicked on FormFHIRAPIKeyEdit. apiKeyLocal.DeveloperName != apiKeyHQ.DeveloperName || apiKeyLocal.DeveloperEmail != apiKeyHQ.DeveloperEmail || apiKeyLocal.DeveloperPhone != apiKeyHQ.DeveloperPhone || apiKeyLocal.ListPermissions.Any(x => !apiKeyHQ.ListPermissions.Contains(x)) || apiKeyHQ.ListPermissions.Any(x => !apiKeyLocal.ListPermissions.Contains(x))) { changed = true; break; } } if (changed && !UpdateKeysForOffice(_listApiKeysLocal)) { return; } Program prog = Programs.GetCur(ProgramName.FHIR); prog.Enabled = checkEnabled.Checked; Programs.Update(prog); ProgramProperty progProp = ProgramProperties.GetPropByDesc("SubscriptionProcessingFrequency", ProgramProperties.GetForProgram(prog.ProgramNum)); ProgramProperties.UpdateProgramPropertyWithValue(progProp, textSubInterval.Text); DataValid.SetInvalid(InvalidType.Programs); Close(); }
private void FormPaySimple_Load(object sender, EventArgs e) { _progCur = Programs.GetCur(ProgramName.PaySimple); if (_progCur == null) { MsgBox.Show(this, "PaySimple does not exist in the database."); DialogResult = DialogResult.Cancel; return; } if (_patCur == null || _patCur.PatNum == 0) //Prepaid card { radioAuthorization.Enabled = false; checkOneTimePayment.Checked = true; checkOneTimePayment.Enabled = false; } else { checkOneTimePayment.Checked = !PrefC.GetBool(PrefName.StoreCCtokens); textZipCode.Text = _patCur.Zip; textNameOnCard.Text = _patCur.GetNameFL(); if (_creditCardCur != null) { FillFieldsFromCard(); } } if (_isAddingCard) { radioAuthorization.Checked = true; _trantype = PaySimple.TransType.AUTH; groupTransType.Enabled = false; labelAmount.Visible = false; textAmount.Visible = false; checkOneTimePayment.Checked = false; checkOneTimePayment.Enabled = false; } textCardNumber.Select(); }
private void FormInsTemplates_Load(object sender, System.EventArgs e) { if (!IsSelectMode) { butCancel.Text = Lan.g(this, "Close"); butOK.Visible = false; } Program prog = Programs.GetCur(ProgramName.Trojan); if (prog != null && prog.Enabled) { trojan = true; } else { labelTrojanID.Visible = false; textTrojanID.Visible = false; } textEmployer.Text = empText; textCarrier.Text = carrierText; textGroupName.Text = groupNameText; textGroupNum.Text = groupNumText; FillGrid(); }
private void FormXchargeSetup_Load(object sender, EventArgs e) { prog = Programs.GetCur(ProgramName.PayConnect); if (prog == null) { return; } checkEnabled.Checked = prog.Enabled; List <ProgramProperty> props = ProgramProperties.GetListForProgram(prog.ProgramNum); for (int i = 0; i < props.Count; i++) { if (props[i].PropertyDesc == "Username") { propUsername = props[i]; } else if (props[i].PropertyDesc == "Password") { propPassword = props[i]; } else if (props[i].PropertyDesc == "PaymentType") { propPayType = props[i]; } } textUsername.Text = propUsername.PropertyValue; textPassword.Text = propPassword.PropertyValue; for (int i = 0; i < DefC.Short[(int)DefCat.PaymentTypes].Length; i++) { comboPaymentType.Items.Add(DefC.Short[(int)DefCat.PaymentTypes][i].ItemName); if (DefC.Short[(int)DefCat.PaymentTypes][i].DefNum.ToString() == propPayType.PropertyValue) { comboPaymentType.SelectedIndex = i; } } }
private void FormXchargeSetup_Load(object sender, EventArgs e) { prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null) { return; } checkEnabled.Checked = prog.Enabled; textPath.Text = prog.Path; pathOverrideOld = ProgramProperties.GetLocalPathOverrideForProgram(prog.ProgramNum); textOverride.Text = pathOverrideOld; textUser.Text = ProgramProperties.GetPropVal(prog.ProgramNum, "Username"); textPassword.Text = ProgramProperties.GetPropVal(prog.ProgramNum, "Password"); string paymentType = ProgramProperties.GetPropVal(prog.ProgramNum, "PaymentType"); for (int i = 0; i < DefC.Short[(int)DefCat.PaymentTypes].Length; i++) { comboPaymentType.Items.Add(DefC.Short[(int)DefCat.PaymentTypes][i].ItemName); if (DefC.Short[(int)DefCat.PaymentTypes][i].DefNum.ToString() == paymentType) { comboPaymentType.SelectedIndex = i; } } }
private void FormXchargeTrans_Load(object sender, EventArgs e) { CashBackAmount = 0; textCashBackAmt.Text = CashBackAmount.ToString("F2"); listTransType.Items.Clear(); listTransType.Items.Add("Purchase"); listTransType.Items.Add("Return"); listTransType.Items.Add("Debit Purchase"); listTransType.Items.Add("Debit Return"); listTransType.Items.Add("Force"); listTransType.Items.Add("Pre-Authorization"); listTransType.Items.Add("Adjustment"); listTransType.Items.Add("Void"); listTransType.SelectedIndex = 0; checkSaveToken.Checked = PrefC.GetBool(PrefName.StoreCCtokens); Program prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null) { return; } checkSignature.Checked = PromptSignature; checkPrintReceipt.Checked = PrintReceipt; }
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 FormTransworldSetup_Load(object sender, EventArgs e) { _progCur = Programs.GetCur(ProgramName.Transworld); if (_progCur == null) { MsgBox.Show(this, "The Transworld entry is missing from the database. Please contact support."); //should never happen return; } checkEnabled.Checked = _progCur.Enabled; if (!PrefC.HasClinicsEnabled) //clinics are not enabled, use ClinicNum 0 to indicate 'Headquarters' or practice level program properties { checkEnabled.Text = Lan.g(this, "Enabled"); groupClinicSettings.Text = Lan.g(this, "Transworld Settings"); comboClinic.Visible = false; labelClinic.Visible = false; labelClinicEnable.Visible = false; _listUserClinicNums = new List <long>() { 0 }; //if clinics are disabled, programproperty.ClinicNum will be set to 0 groupSendActivity.Text = Lan.g(this, "Account Activity Updates"); //remove '(affects all clinics)' from text _selectedClinicNum = 0; } else //Using clinics { groupClinicSettings.Text = Lan.g(this, "Transworld Clinic Settings"); _listUserClinicNums = new List <long>(); //if Transworld is enabled and the user is restricted to a clinic, don't allow the user to disable for all clinics if (Security.CurUser.ClinicIsRestricted) { if (checkEnabled.Checked) { checkEnabled.Enabled = false; } } else { comboClinic.Items.Add(Lan.g(this, "Headquarters")); //this way both lists have the same number of items in it and if 'Headquarters' is selected the programproperty.ClinicNum will be set to 0 _listUserClinicNums.Add(0); comboClinic.SelectedIndex = 0; } List <Clinic> listClinics = Clinics.GetForUserod(Security.CurUser); foreach (Clinic clinicCur in listClinics) { comboClinic.Items.Add(clinicCur.Abbr); _listUserClinicNums.Add(clinicCur.ClinicNum); if (Clinics.ClinicNum == clinicCur.ClinicNum) //set selected index to the currently selected clinic in FormOpenDental { _selectedClinicNum = clinicCur.ClinicNum; comboClinic.SelectedIndex = comboClinic.Items.Count - 1; } } } _dictClinicListProgProps = ProgramProperties.GetForProgram(_progCur.ProgramNum) //get list of all props for the program .GroupBy(x => x.ClinicNum) //group each clinic .ToDictionary(x => x.Key, x => x.ToList()); //turn list into a dictionary of key=ClinicNum, value=List<ProgramProperty> for the clinic DateTime dateTSend = PrefC.GetDateT(PrefName.TransworldServiceTimeDue); if (dateTSend != DateTime.MinValue) { textUpdatesTimeOfDay.Text = dateTSend.ToShortTimeString(); } comboSendFrequencyUnits.Items.AddRange(Enum.GetNames(typeof(FrequencyUnit))); string[] sendFreqStrs = PrefC.GetString(PrefName.TransworldServiceSendFrequency).Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (sendFreqStrs.Length == 2) { int sendFreq = PIn.Int(sendFreqStrs[0], false); FrequencyUnit sendFreqUnit; if (sendFreq > 0 && Enum.TryParse(sendFreqStrs[1], out sendFreqUnit)) { numericSendFrequency.Value = sendFreq; comboSendFrequencyUnits.SelectedIndex = (int)sendFreqUnit; } } else //if not set, default to repeat once a day { comboSendFrequencyUnits.SelectedIndex = (int)FrequencyUnit.Days; numericSendFrequency.Value = 1; } FillComboBoxes(); FillFields(); }
private void FilterCardList() { int verified = 0; int invalid = 0; textVerified.Text = "0"; textInvalid.Text = "0"; for (int i = _listCreditCards.Count - 1; i >= 0; i--) //looping backwards to remove cards that are valid { Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = PrefC.GetRandomTempFile("txt"); try { File.Delete(resultfile); //delete the old result file. } catch { MsgBox.Show(this, "Could not delete XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have sufficient permissions."); break; } info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTQUERY "; info.Arguments += "/XCACCOUNTID:" + _listCreditCards[i].XChargeToken + " "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum) + " "; info.Arguments += "/PASSWORD:"******"Password", Clinics.ClinicNum)) + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/NORESULTDIALOG "; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. string resulttext = ""; string line = ""; string account = ""; string exp = ""; try { using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("ACCOUNT=")) { account = line.Substring(8); } else if (line.StartsWith("EXPIRATION=")) { exp = line.Substring(11); } line = reader.ReadLine(); } if (_listCreditCards[i].CCNumberMasked.Length > 4 && account.Length > 4 && _listCreditCards[i].CCNumberMasked.Substring(_listCreditCards[i].CCNumberMasked.Length - 4) == account.Substring(account.Length - 4) && _listCreditCards[i].CCExpiration.ToString("MMyy") == exp) { //The credit card on file matches the one in X-Charge, so remove from the list. _listCreditCards.RemoveAt(i); verified++; } else { invalid++; } } } catch { MsgBox.Show(this, "Something went wrong validating X-Charge tokens. Please try again."); break; } textVerified.Text = verified.ToString(); textInvalid.Text = invalid.ToString(); } }
private void FormPodiumSetup_Load(object sender, EventArgs e) { if (PrefC.HasClinicsEnabled) //Using clinics { _listUserClinicNums = new List <long>(); comboClinic.Items.Clear(); if (Security.CurUser.ClinicIsRestricted) { if (checkEnabled.Checked) { checkEnabled.Enabled = false; _clinicNumCur = 0; } } else { comboClinic.Items.Add(Lan.g(this, "Headquarters")); //this way both lists have the same number of items in it and if 'Headquarters' is selected the programproperty.ClinicNum will be set to 0 _listUserClinicNums.Add(0); comboClinic.SelectedIndex = 0; _clinicNumCur = 0; } List <Clinic> listClinics = Clinics.GetForUserod(Security.CurUser); for (int i = 0; i < listClinics.Count; i++) { comboClinic.Items.Add(listClinics[i].Abbr); _listUserClinicNums.Add(listClinics[i].ClinicNum); if (Clinics.ClinicNum == listClinics[i].ClinicNum) { comboClinic.SelectedIndex = i; if (!Security.CurUser.ClinicIsRestricted) { comboClinic.SelectedIndex++; //increment the SelectedIndex to account for 'Headquarters' in the list at position 0 if the user is not restricted. } _clinicNumCur = _listUserClinicNums[comboClinic.SelectedIndex]; } } } else //clinics are not enabled, use ClinicNum 0 to indicate 'Headquarters' or practice level program properties { comboClinic.Visible = false; labelClinic.Visible = false; _listUserClinicNums = new List <long>() { 0 }; //if clinics are disabled, programproperty.ClinicNum will be set to 0 _clinicNumCur = 0; } _progCur = Programs.GetCur(ProgramName.Podium); if (_progCur == null) { MsgBox.Show(this, "The Podium bridge is missing from the database."); //should never happen DialogResult = DialogResult.Cancel; return; } try { long clinicNum = 0; if (comboClinic.SelectedIndex > 0) //0 is always "All" so only check for greater than 0. { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } _listProgramProperties = ProgramProperties.GetListForProgramAndClinicWithDefault(_progCur.ProgramNum, clinicNum); _useService = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.UseService); _disableAdvertising = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.DisableAdvertising); _apptSetCompleteMins = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.ApptSetCompletedMinutes); _apptTimeArrivedMins = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.ApptTimeArrivedMinutes); _apptTimeDismissedMins = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.ApptTimeDismissedMinutes); _compName = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.ComputerNameOrIP); _apiToken = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.APIToken); List <ProgramProperty> listLocationIDs = ProgramProperties.GetForProgram(_progCur.ProgramNum).FindAll(x => x.PropertyDesc == Podium.PropertyDescs.LocationID); _dictLocationIDs.Clear(); foreach (ProgramProperty ppCur in listLocationIDs) //If clinics is off, this will only grab the program property with a 0 clinic num (_listUserClinicNums will only have 0). { if (_dictLocationIDs.ContainsKey(ppCur.ClinicNum) || !_listUserClinicNums.Contains(ppCur.ClinicNum)) { continue; } _dictLocationIDs.Add(ppCur.ClinicNum, ppCur); } _newPatTriggerType = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.NewPatientTriggerType); _existingPatTriggerType = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.ExistingPatientTriggerType); _showCommlogsInChartAndAccount = _listProgramProperties.FirstOrDefault(x => x.PropertyDesc == Podium.PropertyDescs.ShowCommlogsInChartAndAccount); } catch (Exception) { MsgBox.Show(this, "You are missing a program property for Podium. Please contact support to resolve this issue."); DialogResult = DialogResult.Cancel; return; } FillForm(); SetAdvertising(); }
///<summary>The DataTable used to fill the grid will only be refreshed from the db if isFromDb is true. Otherwise the grid will be refilled using ///the existing table. Only get from the db on load or if the Refresh button is pressed, not when the user is selecting the clinic(s).</summary> private void FillGrid(bool isFromDb = false) { Cursor = Cursors.WaitCursor; if (isFromDb) { _charger.FillCharges(_listUserClinics); } List <long> listSelectedClinicNums = listClinics.SelectedIndices.OfType <int>().Select(x => _listUserClinics[x].ClinicNum).ToList(); List <RecurringChargeData> listChargesCur; if (PrefC.HasClinicsEnabled) { listChargesCur = _charger.ListRecurringChargeData.Where(x => listSelectedClinicNums.Contains(x.RecurringCharge.ClinicNum)).ToList(); } else { listChargesCur = _charger.ListRecurringChargeData; } gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "PatNum"), 55)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Name"), PrefC.HasClinicsEnabled?190:220)); if (PrefC.HasClinicsEnabled) { gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Clinic"), 65)); } gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Date"), PrefC.HasClinicsEnabled?80:80, HorizontalAlignment.Right)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Family Bal"), PrefC.HasClinicsEnabled?70:85, HorizontalAlignment.Right)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "PayPlan Due"), PrefC.HasClinicsEnabled?75:85, HorizontalAlignment.Right)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Total Due"), PrefC.HasClinicsEnabled?65:80, HorizontalAlignment.Right)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Repeat Amt"), PrefC.HasClinicsEnabled?75:90, HorizontalAlignment.Right)); //RptChrgAmt gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Charge Amt"), PrefC.HasClinicsEnabled?85:100, HorizontalAlignment.Right)); if (Programs.HasMultipleCreditCardProgramsEnabled()) { if (Programs.IsEnabled(ProgramName.Xcharge)) { gridMain.ListGridColumns.Add(new GridColumn("X-Charge", PrefC.HasClinicsEnabled ? 70 : 80, HorizontalAlignment.Center)); } if (Programs.IsEnabled(ProgramName.PayConnect)) { gridMain.ListGridColumns.Add(new GridColumn("PayConnect", PrefC.HasClinicsEnabled ? 85 : 95, HorizontalAlignment.Center)); } if (Programs.IsEnabled(ProgramName.PaySimple)) { gridMain.ListGridColumns.Add(new GridColumn("PaySimple", PrefC.HasClinicsEnabled ? 80 : 90, HorizontalAlignment.Center)); } } gridMain.ListGridRows.Clear(); GridRow row; foreach (RecurringChargeData chargeCur in listChargesCur) { row = new GridRow(); double famBalTotal = chargeCur.RecurringCharge.FamBal; //pat bal+payplan due, but if pat bal<0 and payplan due>0 then just payplan due double payPlanDue = chargeCur.RecurringCharge.PayPlanDue; double chargeAmt = chargeCur.RecurringCharge.ChargeAmt; double rptChargeAmt = chargeCur.RecurringCharge.RepeatAmt; //includes repeat charge (from procs if ODHQ) and attached payplan row.Cells.Add(chargeCur.RecurringCharge.PatNum.ToString()); row.Cells.Add(chargeCur.PatName); if (PrefC.HasClinicsEnabled) { Clinic clinicCur = _listUserClinics.FirstOrDefault(x => x.ClinicNum == chargeCur.RecurringCharge.ClinicNum); row.Cells.Add(clinicCur != null?clinicCur.Description:""); //get description from cache if clinics are enabled } int billingDay = 0; if (PrefC.GetBool(PrefName.BillingUseBillingCycleDay)) { billingDay = chargeCur.BillingCycleDay; } else { billingDay = chargeCur.RecurringChargeDate.Day; } DateTime startBillingCycle = DateTimeOD.GetMostRecentValidDate(DateTime.Today.Year, DateTime.Today.Month, billingDay); if (startBillingCycle > DateTime.Today) { startBillingCycle = startBillingCycle.AddMonths(-1); //Won't give a date with incorrect day. AddMonths will give the end of the month if needed. } DateTime dateExcludeIfBefore = PIn.Date(textDate.Text); //If entry is invalid, all charges will be included because this will be MinDate. if (startBillingCycle < dateExcludeIfBefore) { continue; //Don't show row in grid } row.Cells.Add(startBillingCycle.ToShortDateString()); row.Cells.Add(famBalTotal.ToString("c")); if (!payPlanDue.IsZero()) { row.Cells.Add(payPlanDue.ToString("c")); } else { row.Cells.Add(""); } row.Cells.Add(chargeCur.RecurringCharge.TotalDue.ToString("c")); row.Cells.Add(rptChargeAmt.ToString("c")); row.Cells.Add(chargeAmt.ToString("c")); if (!checkHideBold.Checked) { double diff = (Math.Max(famBalTotal, 0) + Math.Max(payPlanDue, 0)) - rptChargeAmt; if (diff.IsZero() || (diff < 0 && RecurringCharges.CanChargeWhenNoBal(chargeCur.CanChargeWhenNoBal))) { //don't bold anything } else if (diff > 0) { row.Cells[6].Bold = YN.Yes; //"Repeating Amt" row.Cells[7].Bold = YN.Yes; //"Charge Amt" } else if (diff < 0) { row.Cells[5].Bold = YN.Yes; //"Total Due" row.Cells[7].Bold = YN.Yes; //"Charge Amt" } } if (Programs.HasMultipleCreditCardProgramsEnabled()) { if (Programs.IsEnabled(ProgramName.Xcharge)) { row.Cells.Add(!string.IsNullOrEmpty(chargeCur.XChargeToken) ? "X" : ""); } if (Programs.IsEnabled(ProgramName.PayConnect)) { row.Cells.Add(!string.IsNullOrEmpty(chargeCur.PayConnectToken) ? "X" : ""); } if (Programs.IsEnabled(ProgramName.PaySimple)) { row.Cells.Add(!string.IsNullOrEmpty(chargeCur.PaySimpleToken) ? "X" : ""); } } row.Tag = chargeCur; gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); labelTotal.Text = Lan.g(this, "Total=") + gridMain.ListGridRows.Count.ToString(); labelSelected.Text = Lan.g(this, "Selected=") + gridMain.SelectedIndices.Length.ToString(); Cursor = Cursors.Default; }
private void gridMain_CellClick(object sender, ODGridClickEventArgs e) { ODGridCell gridCellCur = gridMain.Rows[e.Row].Cells[e.Col]; //Only grid cells with phone numbers are blue and underlined. if (gridCellCur.ColorText == System.Drawing.Color.Blue && gridCellCur.Underline == YN.Yes && Programs.GetCur(ProgramName.DentalTekSmartOfficePhone).Enabled) { DentalTek.PlaceCall(gridCellCur.Text); } }
public FormBencoSetup() { InitializeComponent(); _prog = Programs.GetCur(ProgramName.BencoPracticeManagement); _listToolButs = ToolButItems.GetForProgram(_prog.ProgramNum); //Only set up for Main Toolbar }
private void butOK_Click(object sender, System.EventArgs e) { bool usingEcw = Programs.UsingEcwTightOrFullMode(); Userod selectedUser = null; if (PrefC.GetBool(PrefName.UserNameManualEntry)) { for (int i = 0; i < listUser.Items.Count; i++) { //Check the user name typed in using ToLower and Trim because Open Dental is case insensitive and does not allow white-space in regards to user names. if (textUser.Text.Trim().ToLower() == listUser.Items[i].ToString().Trim().ToLower()) { selectedUser = (Userod)listUser.Items[i]; //Found the typed username break; } } if (selectedUser == null) { MsgBox.Show(this, "Login failed"); return; } } else { selectedUser = (Userod)listUser.SelectedItem; } string password = textPassword.Text; if (usingEcw) //ecw requires hash, but non-ecw requires actual password { password = Userods.HashPassword(password, true); } if (selectedUser.UserName == "Stay Open" && IsSimpleSwitch && PrefC.IsODHQ) { // No need to check password when changing task users at HQ to user "Stay Open". } else { try { Userods.CheckUserAndPassword(selectedUser.UserName, password, usingEcw); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "") { MsgBox.Show(this, "When using the web service, not allowed to log in with no password. A password should be added for this user."); return; } //successful login. if (!IsSimpleSwitch) { Security.CurUser = selectedUser.Copy(); Security.IsUserLoggedIn = true; //Jason approved always storing the cleartext password that the user typed in //since this is necessary for Reporting Servers over middle tier and was already happening when a user logged in over middle tier. Security.PasswordTyped = password; if (PrefC.GetBool(PrefName.PasswordsMustBeStrong) && PrefC.GetBool(PrefName.PasswordsWeakChangeToStrong)) { if (Userods.IsPasswordStrong(textPassword.Text) != "") //Password is not strong { MsgBox.Show(this, "You must change your password to a strong password due to the current Security settings."); FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1. if (!FormOD.ChangePassword(true)) //Failed password update. { return; } } } } else { CurUserSimpleSwitch = selectedUser.Copy(); } if (!IsSimpleSwitch) { SecurityLogs.MakeLogEntry(Permissions.UserLogOnOff, 0, "User: "******" has logged on."); } Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end"); DialogResult = DialogResult.OK; }
private void FormPayConnect_Load(object sender, EventArgs e) { _progCur = Programs.GetCur(ProgramName.PayConnect); if (_progCur == null) { MsgBox.Show(this, "PayConnect does not exist in the database."); DialogResult = DialogResult.Cancel; return; } if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, "TerminalProcessingEnabled", _clinicNum))) { try { //If the config file for the DentalXChange credit card processing .dll doesn't exist, construct it from the included resource. if (!File.Exists("DpsPos.dll.config")) { File.WriteAllText("DpsPos.dll.config", Properties.Resources.DpsPos_dll_config); } } catch (Exception ex) { FriendlyException.Show("Unable to create the config file for the terminal. Trying running the program as an administrator.", ex); //We will still allow them to run the transaction. Probably the worse that will happen is the timeout variable will be less than desired. } } if (!PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, "TerminalProcessingEnabled", _clinicNum)) || _isAddingCard) //When adding a card, the web service must be used. { groupProcessMethod.Visible = false; Height -= 55; //All the controls except for the Transaction Type group box should be anchored to the bottom, so they will move themselves up. } else { string procMethod = ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum, PayConnect.ProgramProperties.DefaultProcessingMethod, _clinicNum); if (procMethod == "0") { radioWebService.Checked = true; } else if (procMethod == "1") { radioTerminal.Checked = true; } } textAmount.Text = POut.Decimal(_amountInit); if (_patCur == null) //Prepaid card { radioAuthorization.Enabled = false; radioVoid.Enabled = false; radioReturn.Enabled = false; textZipCode.ReadOnly = true; textNameOnCard.ReadOnly = true; checkSaveToken.Enabled = false; sigBoxWrapper.Enabled = false; } else //Other cards { textZipCode.Text = _patCur.Zip; textNameOnCard.Text = _patCur.GetNameFL(); checkSaveToken.Checked = PrefC.GetBool(PrefName.StoreCCtokens); if (PrefC.GetBool(PrefName.StoreCCnumbers)) { labelStoreCCNumWarning.Visible = true; } FillFieldsFromCard(); } if (_isAddingCard) //We will run a 0.01 authorization so we will not allow the user to change the transaction type or the amount. { radioAuthorization.Checked = true; _trantype = PayConnectService.transType.AUTH; groupTransType.Enabled = false; labelAmount.Visible = false; textAmount.Visible = false; checkSaveToken.Checked = true; checkSaveToken.Enabled = false; checkForceDuplicate.Checked = true; checkForceDuplicate.Enabled = false; } if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, _clinicNum))) { textCardNumber.ReadOnly = true; } }
private List <CreditCard> FilterCardList() { int verified = 0; int invalid = 0; textVerified.Text = verified.ToString(); textInvalid.Text = invalid.ToString(); for (int i = CardList.Count - 1; i >= 0; i--) { Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); ProgramProperty prop = (ProgramProperty)ProgramProperties.GetForProgram(prog.ProgramNum)[0]; ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = Path.Combine(Path.GetDirectoryName(path), "XResult.txt"); File.Delete(resultfile); //delete the old result file. info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTQUERY "; info.Arguments += "/XCACCOUNTID:" + CardList[i].XChargeToken + " "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " "; info.Arguments += "/PASSWORD:"******"Password") + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/NORESULTDIALOG "; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. string resulttext = ""; string line = ""; string account = ""; string exp = ""; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("ACCOUNT=")) { account = line.Substring(8); } else if (line.StartsWith("EXPIRATION=")) { exp = line.Substring(11); } line = reader.ReadLine(); } if (CardList[i].CCNumberMasked.Length > 4 && account.Length > 4 && CardList[i].CCNumberMasked.Substring(CardList[i].CCNumberMasked.Length - 4) == account.Substring(account.Length - 4) && CardList[i].CCExpiration.ToString("MMyy") == exp) { //The credit card on file matches the one in X-Charge, so remove from the list. CardList.Remove(CardList[i]); verified++; } else { invalid++; } } textVerified.Text = verified.ToString(); textInvalid.Text = invalid.ToString(); } return(CardList); }
private void butOK_Click(object sender, EventArgs e) { if (!VerifyData()) { return; } CreditCardCur.Address = textAddress.Text; CreditCardCur.CCNumberMasked = textCardNumber.Text; CreditCardCur.PatNum = PatCur.PatNum; CreditCardCur.Zip = textZip.Text; if (IsXCharge) //Only update recurring if using X-Charge. { CreditCardCur.ChargeAmt = PIn.Double(textChargeAmt.Text); CreditCardCur.DateStart = PIn.Date(textDateStart.Text); CreditCardCur.DateStop = PIn.Date(textDateStop.Text); CreditCardCur.Note = textNote.Text; if (comboPaymentPlans.SelectedIndex > 0) { CreditCardCur.PayPlanNum = PayPlanList[comboPaymentPlans.SelectedIndex - 1].PayPlanNum; } else { CreditCardCur.PayPlanNum = 0; //Allows users to change from a recurring payplan charge to a normal one. } } if (CreditCardCur.IsNew) { List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); CreditCardCur.ItemOrder = itemOrderCount.Count; CreditCards.Insert(CreditCardCur); } else { #region X-Charge //Special logic for had a token and changed number or expiration date if (CreditCardCur.XChargeToken != "" && IsXCharge && (CreditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked || CreditCardOld.CCExpiration != CreditCardCur.CCExpiration)) { Program prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null) { MsgBox.Show(this, "X-Charge entry is missing from the database."); //should never happen return; } if (!prog.Enabled) { if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } if (!File.Exists(prog.Path)) { MsgBox.Show(this, "Path is not valid."); if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); } return; } //Either update the exp date or update credit card number by deleting archive so new token can be created next time it's used. ProgramProperty prop = (ProgramProperty)ProgramProperties.GetForProgram(prog.ProgramNum)[0]; ProcessStartInfo info = new ProcessStartInfo(prog.Path); string resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt"); File.Delete(resultfile); //delete the old result file. if (CreditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked) //They changed card number which we have to delete archived token which will create a new one next time card is charged. { info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTDELETE "; info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " "; info.Arguments += "/PASSWORD:"******"Password") + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; CreditCardCur.XChargeToken = ""; //Clear the XChargeToken in our db. } else //We can only change exp date for X-Charge via ARCHIVEAULTUPDATE. { info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTUPDATE "; info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " "; if (CreditCardCur.CCExpiration != null && CreditCardCur.CCExpiration.Year > 2005) { info.Arguments += "/EXP:" + CreditCardCur.CCExpiration.ToString("MMyy") + " "; } info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " "; info.Arguments += "/PASSWORD:"******"Password") + " "; info.Arguments += "/AUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; } Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { CreditCardCur = CreditCards.GetOne(CreditCardCur.CreditCardNum); FillData(); return; } } line = reader.ReadLine(); } } } //End of special token logic #endregion CreditCards.Update(CreditCardCur); } DialogResult = DialogResult.OK; }
private void FormRecurringCharges_Load(object sender, EventArgs e) { if (Programs.HasMultipleCreditCardProgramsEnabled()) { gridMain.HScrollVisible = true; } if (!PrefC.IsODHQ) { checkHideBold.Checked = true; checkHideBold.Visible = false; } Program progCur = null; if (Programs.IsEnabled(ProgramName.PaySimple)) { progCur = Programs.GetCur(ProgramName.PaySimple); labelUpdated.Visible = false; checkForceDuplicates.Checked = false; checkForceDuplicates.Visible = false; //PaySimple always rejects identical transactions made within 5 minutes of eachother. } if (Programs.IsEnabled(ProgramName.PayConnect)) { progCur = Programs.GetCur(ProgramName.PayConnect); labelUpdated.Visible = false; checkForceDuplicates.Visible = true; checkForceDuplicates.Checked = PIn.Bool(ProgramProperties.GetPropValForClinicOrDefault(progCur.ProgramNum, PayConnect.ProgramProperties.PayConnectForceRecurringCharge, Clinics.ClinicNum)); } if (Programs.IsEnabled(ProgramName.Xcharge)) { progCur = Programs.GetCur(ProgramName.Xcharge); labelUpdated.Visible = true; checkForceDuplicates.Visible = true; string xPath = Programs.GetProgramPath(progCur); checkForceDuplicates.Checked = PIn.Bool(ProgramProperties.GetPropValForClinicOrDefault(progCur.ProgramNum, ProgramProperties.PropertyDescs.XCharge.XChargeForceRecurringCharge, Clinics.ClinicNum)); if (!File.Exists(xPath)) //program path is invalid //if user has setup permission and they want to edit the program path, show the X-Charge setup window { if (Security.IsAuthorized(Permissions.Setup) && MsgBox.Show(this, MsgBoxButtons.YesNo, "The X-Charge path is not valid. Would you like to edit the path?")) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); if (FormX.DialogResult == DialogResult.OK) { //The user could have correctly enabled the X-Charge bridge, we need to update our local _programCur and _xPath variable2 progCur = Programs.GetCur(ProgramName.Xcharge); xPath = Programs.GetProgramPath(progCur); } } //if the program path still does not exist, whether or not they attempted to edit the program link, tell them to edit and close the form if (!File.Exists(xPath)) { MsgBox.Show(this, "The X-Charge program path is not valid. Edit the program link in order to use the CC Recurring Charges feature."); Close(); return; } } } if (progCur == null) { MsgBox.Show(this, "The PayConnect, PaySimple, or X-Charge program link must be enabled in order to use the CC Recurring Charges feature."); Close(); return; } _isSelecting = true; _listUserClinics = new List <Clinic>(); if (PrefC.HasClinicsEnabled) { if (!Security.CurUser.ClinicIsRestricted) { _listUserClinics.Add(new Clinic() { Description = Lan.g(this, "Unassigned") }); } Clinics.GetForUserod(Security.CurUser).ForEach(x => _listUserClinics.Add(x)); for (int i = 0; i < _listUserClinics.Count; i++) { listClinics.Items.Add(_listUserClinics[i].Description); listClinics.SetSelected(i, true); } //checkAllClin.Checked=true;//checked true by default in designer so we don't trigger the event to select all and fill grid } else { groupClinics.Visible = false; } _charger = new RecurringChargerator(new ShowErrors(this), true); _charger.SingleCardFinished = new Action(() => { this.Invoke(() => { labelCharged.Text = Lans.g(this, "Charged=") + _charger.Success; labelFailed.Text = Lans.g(this, "Failed=") + _charger.Failed; labelUpdated.Text = Lans.g(this, "Updated=") + _charger.Updated; }); }); GeneralProgramEvent.Fired += StopRecurringCharges; //This is so we'll be alerted in case of a shutdown. labelCharged.Text = Lan.g(this, "Charged=") + "0"; labelFailed.Text = Lan.g(this, "Failed=") + "0"; FillGrid(true); gridMain.SetSelected(true); labelSelected.Text = Lan.g(this, "Selected=") + gridMain.SelectedIndices.Length.ToString(); }
///<summary>This reduces the number of places where Programs.UsingEcwTight() is called. This helps with organization. All calls within this class must pass through here. </summary> private static bool UsingEcwTight() { return(Programs.UsingEcwTight()); }
private void FormPractice_Load(object sender, System.EventArgs e) { checkIsMedicalOnly.Checked = PrefC.GetBool(PrefName.PracticeIsMedicalOnly); if (Programs.UsingEcwTightOrFullMode()) { checkIsMedicalOnly.Visible = false; } textPracticeTitle.Text = PrefC.GetString(PrefName.PracticeTitle); textAddress.Text = PrefC.GetString(PrefName.PracticeAddress); textAddress2.Text = PrefC.GetString(PrefName.PracticeAddress2); textCity.Text = PrefC.GetString(PrefName.PracticeCity); textST.Text = PrefC.GetString(PrefName.PracticeST); textZip.Text = PrefC.GetString(PrefName.PracticeZip); textPhone.Text = TelephoneNumbers.ReFormat(PrefC.GetString(PrefName.PracticePhone)); textFax.Text = TelephoneNumbers.ReFormat(PrefC.GetString(PrefName.PracticeFax)); checkUseBillingAddressOnClaims.Checked = PrefC.GetBool(PrefName.UseBillingAddressOnClaims); textBillingAddress.Text = PrefC.GetString(PrefName.PracticeBillingAddress); textBillingAddress2.Text = PrefC.GetString(PrefName.PracticeBillingAddress2); textBillingCity.Text = PrefC.GetString(PrefName.PracticeBillingCity); textBillingST.Text = PrefC.GetString(PrefName.PracticeBillingST); textBillingZip.Text = PrefC.GetString(PrefName.PracticeBillingZip); textPayToAddress.Text = PrefC.GetString(PrefName.PracticePayToAddress); textPayToAddress2.Text = PrefC.GetString(PrefName.PracticePayToAddress2); textPayToCity.Text = PrefC.GetString(PrefName.PracticePayToCity); textPayToST.Text = PrefC.GetString(PrefName.PracticePayToST); textPayToZip.Text = PrefC.GetString(PrefName.PracticePayToZip); textBankNumber.Text = PrefC.GetString(PrefName.PracticeBankNumber); if (CultureInfo.CurrentCulture.Name.EndsWith("CH")) //CH is for switzerland. eg de-CH { textBankRouting.Text = PrefC.GetString(PrefName.BankRouting); textBankAddress.Text = PrefC.GetString(PrefName.BankAddress); } else { groupSwiss.Visible = false; } listProvider.Items.Clear(); _listProviders = Providers.GetDeepCopy(true); for (int i = 0; i < _listProviders.Count; i++) { listProvider.Items.Add(_listProviders[i].GetLongDesc()); if (_listProviders[i].ProvNum == PrefC.GetLong(PrefName.PracticeDefaultProv)) { listProvider.SelectedIndex = i; } } listBillType.Items.Clear(); _listBillingTypeDefs = Defs.GetDefsForCategory(DefCat.BillingTypes, true); for (int i = 0; i < _listBillingTypeDefs.Count; i++) { listBillType.Items.Add(_listBillingTypeDefs[i].ItemName); if (_listBillingTypeDefs[i].DefNum == PrefC.GetLong(PrefName.PracticeDefaultBillType)) { listBillType.SelectedIndex = i; } } if (PrefC.GetBool(PrefName.EasyHidePublicHealth)) { labelPlaceService.Visible = false; listPlaceService.Visible = false; } listPlaceService.Items.Clear(); for (int i = 0; i < Enum.GetNames(typeof(PlaceOfService)).Length; i++) { listPlaceService.Items.Add(Lan.g("enumPlaceOfService", Enum.GetNames(typeof(PlaceOfService))[i])); } listPlaceService.SelectedIndex = PrefC.GetInt(PrefName.DefaultProcedurePlaceService); _selectedBillingProvNum = PrefC.GetLong(PrefName.InsBillingProv); _insBillingProvNum = _selectedBillingProvNum; FillComboInsBillingProv(); }
private void FormErxSetup_Load(object sender, EventArgs e) { try { _progCur = Programs.GetCur(ProgramName.eRx); if (_progCur == null) { throw new Exception("The eRx bridge is missing from the database."); } _listProgramProperties = ProgramProperties.GetForProgram(_progCur.ProgramNum); checkEnabled.Checked = _progCur.Enabled; _eRxOption = PIn.Enum <ErxOption>(ErxOptionPP.PropertyValue); if (_eRxOption == ErxOption.Legacy) { radioNewCrop.Checked = true; } else if (_eRxOption == ErxOption.DoseSpot) { radioDoseSpot.Checked = true; //HideLegacy(); } else if (_eRxOption == ErxOption.DoseSpotWithLegacy) { radioDoseSpotLegacy.Checked = true; //HideLegacy(); } textNewCropAccountID.Text = PrefC.GetString(PrefName.NewCropAccountId); List <ProgramProperty> listClinicIDs = _listProgramProperties.FindAll(x => x.PropertyDesc == Erx.PropertyDescs.ClinicID); List <ProgramProperty> listClinicKeys = _listProgramProperties.FindAll(x => x.PropertyDesc == Erx.PropertyDescs.ClinicKey); //Always make sure clinicnum 0 (HQ) exists, regardless of if clinics are enabled if (!listClinicIDs.Exists(x => x.ClinicNum == 0)) { ProgramProperty ppClinicID = new ProgramProperty(); ppClinicID.ProgramNum = _progCur.ProgramNum; ppClinicID.ClinicNum = 0; ppClinicID.PropertyDesc = Erx.PropertyDescs.ClinicID; ppClinicID.PropertyValue = ""; _listProgramProperties.Add(ppClinicID); } if (!listClinicKeys.Exists(x => x.ClinicNum == 0)) { ProgramProperty ppClinicKey = new ProgramProperty(); ppClinicKey.ProgramNum = _progCur.ProgramNum; ppClinicKey.ClinicNum = 0; ppClinicKey.PropertyDesc = Erx.PropertyDescs.ClinicKey; ppClinicKey.PropertyValue = ""; _listProgramProperties.Add(ppClinicKey); } if (PrefC.HasClinicsEnabled) { foreach (Clinic clinicCur in Clinics.GetAllForUserod(Security.CurUser)) { if (!listClinicIDs.Exists(x => x.ClinicNum == clinicCur.ClinicNum)) //Only add a program property if it doesn't already exist. { ProgramProperty ppClinicID = new ProgramProperty(); ppClinicID.ProgramNum = _progCur.ProgramNum; ppClinicID.ClinicNum = clinicCur.ClinicNum; ppClinicID.PropertyDesc = Erx.PropertyDescs.ClinicID; ppClinicID.PropertyValue = ""; _listProgramProperties.Add(ppClinicID); } if (!listClinicKeys.Exists(x => x.ClinicNum == clinicCur.ClinicNum)) //Only add a program property if it doesn't already exist. { ProgramProperty ppClinicKey = new ProgramProperty(); ppClinicKey.ProgramNum = _progCur.ProgramNum; ppClinicKey.ClinicNum = clinicCur.ClinicNum; ppClinicKey.PropertyDesc = Erx.PropertyDescs.ClinicKey; ppClinicKey.PropertyValue = ""; _listProgramProperties.Add(ppClinicKey); } } } else { checkShowHiddenClinics.Visible = false; } FillGridDoseSpot(); SetRadioButtonChecked(_eRxOption); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Error loading the eRx program: ") + ex.Message); DialogResult = DialogResult.Cancel; return; } }
private string verifyAsSIUMessage(int interfaceID, int messageID, out int errors, bool verbose) { string retVal = ""; errors = 0; bool validMessage = true; List <string> segmentsContained = new List <string>(); DataTable hl7Segments = MySqlHelper.ExecuteDataset(connString, "SELECT SegmentData FROM hl7segment_details WHERE InterfaceID=" + interfaceID + " AND Messageid=" + messageID + ";").Tables[0]; //validate segments based on content foreach (DataRow segment in hl7Segments.Rows) { string[] segmentFields = segment["SegmentData"].ToString().Split('|'); segmentsContained.Add(segmentFields[0]); //used later to validate existance of segments. switch (segmentFields[0]) { case "MSH": //validation? continue; case "SCH": if (segmentFields[2] != "{ENCID}") //eCW's documentation is wrong. SCH.01 is not used as appointment num, instead SCH.02 is used for appointment num. { retVal += "SIU HL7 message is not sending visit number in field SCH.01\r\n"; errors++; validMessage = false; } if (segmentFields[7] != "{ENCREASON}") { retVal += "SIU HL7 message is not sending visit reason in field SCH.07\r\n"; errors++; validMessage = false; } if (segmentFields[8] != "{VISITTYPE}") { retVal += "SIU HL7 message is not sending visit type in field SCH.08\r\n"; errors++; validMessage = false; } if (false) //segmentFields[9]!="{???}") { //Don't know what this should look like when properly configured. TODO { retVal += "SIU HL7 message is not sending appointment duration in minutes in field SCH.09\r\n"; errors++; validMessage = false; } if (false) //segmentFields[10]!="{???}") { //Don't know what this should look like when properly configured. TODO { retVal += "SIU HL7 message is not sending appointment duration units in field SCH.10\r\n"; errors++; validMessage = false; } string[] SCH11 = segmentFields[11].Split('^'); if (false) //SCH11[2]!="{???}") { //Don't { retVal += "SIU HL7 message is not sending appointment duration in field SCH.11.02\r\n"; errors++; validMessage = false; } if (SCH11[3] != "{ENCSDATETIME}") { retVal += "SIU HL7 message is not sending appointment start time in field SCH.11.03\r\n"; errors++; validMessage = false; } if (SCH11[4] != "{ENCEDATETIME}") { retVal += "SIU HL7 message is not sending appointment end time in field SCH.11.04\r\n"; errors++; validMessage = false; } //if(segmentFields[25]!="{STATUS}") {//according to documentation, we need this, but actually we never try to reference it. // retVal+="SIU HL7 message is not sending visit status in field SCH.25\r\n"; // errors++; // validMessage=false; //} continue; case "PID": if (segmentFields[2] != "{PID}") { retVal += "SIU HL7 message is not sending eCW's internal patient number in field PID.02\r\n"; errors++; validMessage = false; } if (segmentFields[4] != "{CONTNO}" && !Programs.UsingEcwTightOrFullMode()) { retVal += "SIU HL7 message is not sending eCW's account number in field PID.04\r\n"; errors++; validMessage = false; } if (segmentFields[5] != "{PLN}^{PFN}^{PMN}") { retVal += "SIU HL7 message is not sending patient's name correctly in field PID.05\r\n"; errors++; validMessage = false; } if (segmentFields[7] != "{PDOB}") { retVal += "SIU HL7 message is not sending patient's date of birth in field PID.07\r\n"; errors++; validMessage = false; } if (segmentFields[8] != "{PSEX}") { retVal += "SIU HL7 message is not sending patient's gender in field PID.08\r\n"; errors++; validMessage = false; } //No checking of optional fields. continue; case "PV1": if (segmentFields[7] != "{ODDRID}^{ODLN}^{ODFN}") { retVal += "SIU HL7 message is not sending provider id in field PV1.07\r\n"; errors++; validMessage = false; } continue; case "AIG": if (segmentFields[3] != "{RSDRID}^{RSLN}^{RSFN}") { retVal += "SIU HL7 message is not sending provider/resource id in field AIG.03\r\n"; errors++; validMessage = false; } continue; default: continue; } } //Validate existance of segments if (!segmentsContained.Contains("SCH")) { retVal += "No SCH segment found in SIU HL7 message.\r\n"; errors += 7; //no segment plus 6 sub errors. validMessage = false; } if (!segmentsContained.Contains("PID")) { retVal += "No PID segment found in SIU HL7 message.\r\n"; if (!Programs.UsingEcwTightOrFullMode()) { errors++; //to account for not sending eCW's account number } errors += 5; //no segment plus 4 sub errors. validMessage = false; } if (!segmentsContained.Contains("AIG") && !segmentsContained.Contains("PV1")) { retVal += "No AIG or PV1 segments found in SIU HL7 message. Appointments will use patient's default primary provider.\r\n"; //ecwSIU.cs sets this when in-processing SIU message. validMessage = false; } //If everything above checks out return a success message if (validMessage && verbose) { retVal += "Found properly formed SIU HL7 message definition.\r\n"; } return(retVal); }
private bool SaveToDb() { if ((radioModeTight.Checked || radioModeFull.Checked) && comboDefaultUserGroup.SelectedIndex == -1) { MsgBox.Show(this, "Please select a default user group first."); return(false); } if (checkEnabled.Checked) { if (textProgDesc.Text == "") { MsgBox.Show(this, "Description may not be blank."); return(false); } if (!HL7Defs.IsExistingHL7Enabled()) { if ((radioModeTight.Checked || radioModeFull.Checked) && textHL7FolderIn.Text == "") { MsgBox.Show(this, "HL7 in folder may not be blank."); return(false); } if (textHL7FolderOut.Text == "") { MsgBox.Show(this, "HL7 out folder may not be blank."); return(false); } if (textHL7Server.Text == "") { MsgBox.Show(this, "HL7 Server may not be blank."); return(false); } if (textHL7ServiceName.Text == "") { MsgBox.Show(this, "HL7 Service Name may not be blank."); return(false); } } } ProgramCur.ProgDesc = textProgDesc.Text; ProgramCur.Enabled = checkEnabled.Checked; Programs.Update(ProgramCur); Prefs.UpdateString(PrefName.HL7FolderOut, textHL7FolderOut.Text); ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HL7Server", textHL7Server.Text); ProgramProperties.SetProperty(ProgramCur.ProgramNum, "HL7ServiceName", textHL7ServiceName.Text); ProgramProperties.SetProperty(ProgramCur.ProgramNum, "MedicalPanelUrl", textMedPanelURL.Text); if (radioModeTight.Checked || radioModeFull.Checked) { if (radioModeTight.Checked) { ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "0"); //Tight } else { ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "2"); //Full } ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eCWServer", textECWServer.Text); Prefs.UpdateString(PrefName.HL7FolderIn, textHL7FolderIn.Text); ProgramProperties.SetProperty(ProgramCur.ProgramNum, "DefaultUserGroup", UserGroups.List[comboDefaultUserGroup.SelectedIndex].UserGroupNum.ToString()); if (checkShowImages.Checked) { ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "1"); } else { ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "0"); } if (this.checkFeeSchedules.Checked) { ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "1"); } else { ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "0"); } } else if (radioModeStandalone.Checked) { ProgramProperties.SetProperty(ProgramCur.ProgramNum, "eClinicalWorksMode", "1"); Prefs.UpdateString(PrefName.HL7FolderIn, ""); ProgramProperties.SetProperty(ProgramCur.ProgramNum, "DefaultUserGroup", "0"); ProgramProperties.SetProperty(ProgramCur.ProgramNum, "ShowImagesModule", "1"); ProgramProperties.SetProperty(ProgramCur.ProgramNum, "FeeSchedulesSetManually", "0"); } DataValid.SetInvalid(InvalidType.Programs, InvalidType.Prefs); return(true); }
private void checkPatientPortalPayEnabled_Click(object sender, EventArgs e) { if (checkPatientPortalPayEnabled.Checked) { long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = _listUserClinicNums[comboClinic.SelectedIndex]; } OpenDentBusiness.WebTypes.Shared.XWeb.WebPaymentProperties xwebProperties = new OpenDentBusiness.WebTypes.Shared.XWeb.WebPaymentProperties(); try { ProgramProperties.GetXWebCreds(clinicNum, out xwebProperties); } catch (Exception ex) { ex.DoNothing(); } string msg = "Online payments is already enabled for XWeb and must be disabled in order to use PayConnect online payments. " + "Would you like to disable XWeb online payments?"; if (xwebProperties != null && xwebProperties.IsPaymentsAllowed && MessageBox.Show(msg, "", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { checkPatientPortalPayEnabled.Checked = false; return; } //User wants to disable XWeb online payments and use PayConnect online payments ProgramProperty ppOnlinePaymentEnabled = ProgramProperties.GetWhere(x => x.ProgramNum == Programs.GetCur(ProgramName.Xcharge).ProgramNum && x.ClinicNum == clinicNum && x.PropertyDesc == "IsOnlinePaymentsEnabled") .FirstOrDefault(); if (ppOnlinePaymentEnabled == null) { return; //Should never happen since we successfully found it in the GetXWebCreds method. } _listXWebWebPayProgProps.Add(ppOnlinePaymentEnabled); } }
private void butAdd_Click(object sender, EventArgs e) { if (!PrefC.GetBool(PrefName.StoreCCnumbers)) { bool hasXCharge = false; bool hasPayConnect = false; bool hasPaySimple = false; Dictionary <string, int> dictEnabledProcessors = new Dictionary <string, int>(); int idx = 0; bool hasXChargePreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.Xcharge).ProgramNum, ProgramProperties.PropertyDescs.XCharge.XChargePreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd) { dictEnabledProcessors["X-Charge"] = idx++; } bool hasPayConnectPreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PayConnect).ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd) { dictEnabledProcessors["PayConnect"] = idx++; } bool hasPaySimplePreventCCAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PaySimple).ProgramNum, PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, Clinics.ClinicNum)); if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd) { dictEnabledProcessors["PaySimple"] = idx++; } if (dictEnabledProcessors.Count > 1) { List <string> listCCProcessors = dictEnabledProcessors.Select(x => x.Key).ToList(); InputBox chooseProcessor = new InputBox(Lan.g(this, "For which credit card processing company would you like to add this card?"), listCCProcessors, true); if (chooseProcessor.ShowDialog() == DialogResult.Cancel) { return; } hasXCharge = dictEnabledProcessors.ContainsKey("X-Charge") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["X-Charge"]); hasPayConnect = dictEnabledProcessors.ContainsKey("PayConnect") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PayConnect"]); hasPaySimple = dictEnabledProcessors.ContainsKey("PaySimple") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PaySimple"]); } else if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd) { hasXCharge = true; } else if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd) { hasPayConnect = true; } else if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd) { hasPaySimple = true; } else //not storing CC numbers and both PayConnect and X-Charge are disabled { MsgBox.Show(this, "Not allowed to store credit cards."); return; } CreditCard creditCardCur = null; if (hasXCharge) { if (ODBuild.IsWeb()) { MsgBox.Show(this, "XCharge is not available while viewing through the web."); return; } Program prog = Programs.GetCur(ProgramName.Xcharge); string path = Programs.GetProgramPath(prog); string xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim(); string xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim(); //Force user to retry entering information until it's correct or they press cancel while (!File.Exists(path) || string.IsNullOrEmpty(xPassword) || string.IsNullOrEmpty(xUsername)) { MsgBox.Show(this, "The Path, Username, and/or Password for X-Charge have not been set or are invalid."); if (!Security.IsAuthorized(Permissions.Setup)) { return; } FormXchargeSetup FormX = new FormXchargeSetup(); //refreshes program and program property caches on OK click FormX.ShowDialog(); if (FormX.DialogResult != DialogResult.OK) //if user presses cancel, return { return; } prog = Programs.GetCur(ProgramName.Xcharge); //refresh local variable prog to reflect any changes made in setup window path = Programs.GetProgramPath(prog); xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim(); xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim(); } xPassword = CodeBase.MiscUtils.Decrypt(xPassword); ProcessStartInfo info = new ProcessStartInfo(path); string resultfile = PrefC.GetRandomTempFile("txt"); try { File.Delete(resultfile); //delete the old result file. } catch { MsgBox.Show(this, "Could not delete XResult.txt file. It may be in use by another program, flagged as read-only, or you might not have sufficient permissions."); return; } info.Arguments = ""; info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + xUsername + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT "; info.Arguments += "/STAYONTOP "; info.Arguments += "/SMARTAUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/HIDEMAINWINDOW "; info.Arguments += "/SMALLWINDOW "; info.Arguments += "/NORESULTDIALOG "; info.Arguments += "/TOOLBAREXITBUTTON "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; string xChargeToken = ""; string accountMasked = ""; string exp = "";; bool insertCard = false; try { using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { throw new Exception(); } insertCard = true; } if (line.StartsWith("XCACCOUNTID=")) { xChargeToken = PIn.String(line.Substring(12)); } if (line.StartsWith("ACCOUNT=")) { accountMasked = PIn.String(line.Substring(8)); } if (line.StartsWith("EXPIRATION=")) { exp = PIn.String(line.Substring(11)); } line = reader.ReadLine(); } if (insertCard && xChargeToken != "") //Might not be necessary but we've had successful charges with no tokens returned before. { creditCardCur = new CreditCard(); List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); creditCardCur.PatNum = PatCur.PatNum; creditCardCur.ItemOrder = itemOrderCount.Count; creditCardCur.CCNumberMasked = accountMasked; creditCardCur.XChargeToken = xChargeToken; creditCardCur.CCExpiration = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1); creditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs); creditCardCur.CCSource = CreditCardSource.XServer; creditCardCur.ClinicNum = Clinics.ClinicNum; CreditCards.Insert(creditCardCur); } } } catch (Exception) { MsgBox.Show(this, "There was a problem adding the credit card. Please try again."); } } if (hasPayConnect) { FormPayConnect FormPC = new FormPayConnect(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true); FormPC.ShowDialog(); } if (hasPaySimple) { FormPaySimple formPS = new FormPaySimple(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true); formPS.ShowDialog(); } FillGrid(); if (gridMain.ListGridRows.Count > 0 && creditCardCur != null) { gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true); } return; } //storing CC numbers allowed from here down FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur); FormCCE.CreditCardCur = new CreditCard(); FormCCE.CreditCardCur.IsNew = true; FormCCE.CreditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs); FormCCE.ShowDialog(); if (FormCCE.DialogResult == DialogResult.OK) { FillGrid(); if (gridMain.ListGridRows.Count > 0) { gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true); } } }
private void butAdd_Click(object sender, EventArgs e) { if (!PrefC.GetBool(PrefName.StoreCCnumbers)) { if (Programs.IsEnabled(ProgramName.Xcharge)) { Program prog = Programs.GetCur(ProgramName.Xcharge); if (!File.Exists(prog.Path)) { MsgBox.Show(this, "Path is not valid."); if (Security.IsAuthorized(Permissions.Setup)) { FormXchargeSetup FormX = new FormXchargeSetup(); FormX.ShowDialog(); if (FormX.DialogResult != DialogResult.OK) { return; } } } string user = ProgramProperties.GetPropVal(prog.ProgramNum, "Username"); string password = ProgramProperties.GetPropVal(prog.ProgramNum, "Password"); ProcessStartInfo info = new ProcessStartInfo(prog.Path); string resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt"); File.Delete(resultfile); //delete the old result file. info.Arguments = ""; info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE "; info.Arguments += "/RESULTFILE:\"" + resultfile + "\" "; info.Arguments += "/USERID:" + user + " "; info.Arguments += "/PASSWORD:"******" "; info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT "; info.Arguments += "/STAYONTOP "; info.Arguments += "/SMARTAUTOPROCESS "; info.Arguments += "/AUTOCLOSE "; info.Arguments += "/HIDEMAINWINDOW "; info.Arguments += "/SMALLWINDOW "; info.Arguments += "/NORESULTDIALOG "; info.Arguments += "/TOOLBAREXITBUTTON "; Cursor = Cursors.WaitCursor; Process process = new Process(); process.StartInfo = info; process.EnableRaisingEvents = true; process.Start(); while (!process.HasExited) { Application.DoEvents(); } Thread.Sleep(200); //Wait 2/10 second to give time for file to be created. Cursor = Cursors.Default; string resulttext = ""; string line = ""; string xChargeToken = ""; string accountMasked = ""; string exp = "";; bool insertCard = false; using (TextReader reader = new StreamReader(resultfile)) { line = reader.ReadLine(); while (line != null) { if (resulttext != "") { resulttext += "\r\n"; } resulttext += line; if (line.StartsWith("RESULT=")) { if (line != "RESULT=SUCCESS") { break; } insertCard = true; } if (line.StartsWith("XCACCOUNTID=")) { xChargeToken = PIn.String(line.Substring(12)); } if (line.StartsWith("ACCOUNT=")) { accountMasked = PIn.String(line.Substring(8)); } if (line.StartsWith("EXPIRATION=")) { exp = PIn.String(line.Substring(11)); } line = reader.ReadLine(); } if (insertCard && xChargeToken != "") //Might not be necessary but we've had successful charges with no tokens returned before. { CreditCard creditCardCur = new CreditCard(); List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum); creditCardCur.PatNum = PatCur.PatNum; creditCardCur.ItemOrder = itemOrderCount.Count; creditCardCur.CCNumberMasked = accountMasked; creditCardCur.XChargeToken = xChargeToken; creditCardCur.CCExpiration = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1); CreditCards.Insert(creditCardCur); } } RefreshCardList(); return; } else { MsgBox.Show(this, "Not allowed to store credit cards."); return; } } bool remember = false; int placement = listCreditCards.SelectedIndex; if (placement != -1) { remember = true; } FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur); FormCCE.CreditCardCur = new CreditCard(); FormCCE.CreditCardCur.IsNew = true; FormCCE.ShowDialog(); RefreshCardList(); if (remember) //in case they canceled and had one selected { listCreditCards.SelectedIndex = placement; } if (FormCCE.DialogResult == DialogResult.OK && creditCards.Count > 0) { listCreditCards.SelectedIndex = 0; } }
private void FillGrid() { gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); gridMain.ListGridColumns.Add(new GridColumn("Card Number", 140)); if (Programs.IsEnabled(ProgramName.Xcharge)) { gridMain.ListGridColumns.Add(new GridColumn("X-Charge", 70, HorizontalAlignment.Center)); } if (Programs.IsEnabled(ProgramName.PayConnect)) { gridMain.ListGridColumns.Add(new GridColumn("PayConnect", 85, HorizontalAlignment.Center)); } if (Programs.IsEnabled(ProgramName.PaySimple)) { gridMain.ListGridColumns.Add(new GridColumn("PaySimple", 80, HorizontalAlignment.Center)); gridMain.ListGridColumns.Add(new GridColumn("ACH", 40, HorizontalAlignment.Center)); } if (PrefC.HasOnlinePaymentEnabled(out ProgramName progNameForPayments)) { if (progNameForPayments == ProgramName.Xcharge) { gridMain.ListGridColumns.Add(new GridColumn("XWeb", 45, HorizontalAlignment.Center)); } else { gridMain.ListGridColumns.Add(new GridColumn("PayConnect\r\nPortal", 85, HorizontalAlignment.Center)); } } if (gridMain.ListGridColumns.Sum(x => x.ColWidth) > gridMain.Width) { gridMain.HScrollVisible = true; } gridMain.ListGridRows.Clear(); GridRow row; _listCreditCards = CreditCards.Refresh(PatCur.PatNum); foreach (CreditCard cc in _listCreditCards) { row = new GridRow(); string ccNum = cc.CCNumberMasked; if (Regex.IsMatch(ccNum, "^\\d{12}(\\d{0,7})")) //Credit cards can have a minimum of 12 digits, maximum of 19 { int idxLast4Digits = (ccNum.Length - 4); ccNum = (new string('X', 12)) + ccNum.Substring(idxLast4Digits); //replace the first 12 with 12 X's } row.Cells.Add(ccNum); if (Programs.IsEnabled(ProgramName.Xcharge)) { row.Cells.Add(!string.IsNullOrEmpty(cc.XChargeToken) && !cc.IsXWeb()?"X":""); } if (Programs.IsEnabled(ProgramName.PayConnect)) { row.Cells.Add(!string.IsNullOrEmpty(cc.PayConnectToken) && !cc.IsPayConnectPortal() ? "X" : ""); } if (Programs.IsEnabled(ProgramName.PaySimple)) { row.Cells.Add(!string.IsNullOrEmpty(cc.PaySimpleToken) ? "X" : ""); row.Cells.Add(cc.CCSource == CreditCardSource.PaySimpleACH ? "X" : ""); } if (PrefC.HasOnlinePaymentEnabled(out progNameForPayments)) { if (progNameForPayments == ProgramName.Xcharge) { row.Cells.Add(!string.IsNullOrEmpty(cc.XChargeToken) && cc.IsXWeb() ? "X" : ""); } else //PayConnectPortal { row.Cells.Add(!string.IsNullOrEmpty(cc.PayConnectToken) && cc.IsPayConnectPortal() ? "X" : ""); } } row.Tag = cc; gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); }