private void butDelete_Click(object sender, EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; return; } if (EmailAddressCur.EmailAddressNum == PrefC.GetLong(PrefName.EmailDefaultAddressNum)) { MsgBox.Show(this, "Cannot delete the default email address."); return; } if (EmailAddressCur.EmailAddressNum == PrefC.GetLong(PrefName.EmailNotifyAddressNum)) { MsgBox.Show(this, "Cannot delete the notify email address."); return; } Clinic clinic = Clinics.GetFirstOrDefault(x => x.EmailAddressNum == EmailAddressCur.EmailAddressNum); if (clinic != null) { MessageBox.Show(Lan.g(this, "Cannot delete the email address because it is used by clinic") + " " + clinic.Description); return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete this email address?")) { return; } EmailAddresses.Delete(EmailAddressCur.EmailAddressNum); DialogResult = DialogResult.OK; //OK triggers a refresh for the grid. }
///<summary>Will refresh charges from the database if necessary.</summary> private void FillGrid() { if (!_previousDateRange.IsInRange(datePicker.GetDateTimeFrom()) || !_previousDateRange.IsInRange(datePicker.GetDateTimeTo()) || comboClinics.ListSelectedClinicNums.Any(x => !_listPreviousClinicNums.Contains(x))) { RefreshRecurringCharges(); } gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "PatNum"), 55, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Name"), 185)); if (PrefC.HasClinicsEnabled) { gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Clinic"), 65)); } gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Date Charge"), 135, HorizontalAlignment.Center, GridSortingStrategy.DateParse)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Charge Status"), 90)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "User"), 90)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Family Bal"), PrefC.HasClinicsEnabled ? 70 : 85, HorizontalAlignment.Right, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "PayPlan Due"), PrefC.HasClinicsEnabled ? 80 : 90, HorizontalAlignment.Right, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Total Due"), PrefC.HasClinicsEnabled ? 65 : 80, HorizontalAlignment.Right, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Repeat Amt"), PrefC.HasClinicsEnabled ? 75 : 90, HorizontalAlignment.Right, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Charge Amt"), PrefC.HasClinicsEnabled ? 85 : 95, HorizontalAlignment.Right, GridSortingStrategy.AmountParse)); if (gridMain.WidthAllColumns > gridMain.Width) { gridMain.HScrollVisible = true; } gridMain.ListGridRows.Clear(); foreach (RecurringCharge charge in _listRecurringCharges.OrderBy(x => x.DateTimeCharge)) { bool isAutomated = (charge.UserNum == 0); if (!datePicker.IsInDateRange(charge.DateTimeCharge) || (PrefC.HasClinicsEnabled && !charge.ClinicNum.In(comboClinics.ListSelectedClinicNums)) || !charge.ChargeStatus.In(comboStatuses.SelectedTags <RecurringChargeStatus>()) || (comboAutomated.SelectedIndex == 1 && !isAutomated) || (comboAutomated.SelectedIndex == 2 && isAutomated)) { continue; } GridRow row = new GridRow(); row.Cells.Add(charge.PatNum.ToString()); string patName; if (!_dictPatNames.TryGetValue(charge.PatNum, out patName)) { patName = Lans.g(this, "UNKNOWN"); } row.Cells.Add(patName); if (PrefC.HasClinicsEnabled) { row.Cells.Add(Clinics.GetFirstOrDefault(x => x.ClinicNum == charge.ClinicNum)?.Description ?? ""); } row.Cells.Add(charge.DateTimeCharge.ToString()); row.Cells.Add(Lans.g(this, charge.ChargeStatus.GetDescription())); row.Cells.Add(Userods.GetFirstOrDefault(x => x.UserNum == charge.UserNum)?.UserName ?? ""); row.Cells.Add(charge.FamBal.ToString("c")); row.Cells.Add(charge.PayPlanDue.ToString("c")); row.Cells.Add(charge.TotalDue.ToString("c")); row.Cells.Add(charge.RepeatAmt.ToString("c")); row.Cells.Add(charge.ChargeAmt.ToString("c")); row.Tag = charge; gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); }
///<summary>Validates that PrefName.EasyNoClinics is ok to be changed and changes it when necessary. Tells HQ about changes and re-syncs with new HQ clinic preference for this practice. ///If fails then restores checkEnableClinics to original value when form was opened.</summary> private bool IsClinicCheckBoxOk() { try { if (!_hasClinicsEnabledChanged) //No change. { return(true); } //Make sure signup info was retrieved from HQ. ValidateHqValidationComplete(); //Find any eServices that HQ says are enabled. var clinicsEnabled = _signupOut.EServices .FindAll(x => x.IsEnabled) .GroupBy(x => x.ClinicNum) .ToList(); //Build the prompt. string prompt = ""; foreach (var clinicEnabled in clinicsEnabled) { if (clinicEnabled.Key != 0) { prompt += ODMethodsT.Coalesce(Clinics.GetFirstOrDefault(x => x.ClinicNum == clinicEnabled.Key) , new Clinic() { Abbr = "Undefined Clinic" }).Abbr + "\r\n"; } else { prompt += Lan.g(this, "Practice") + "\r\n"; } //If bundle then don't show others. if (clinicEnabled.Any(x => x.EService == eServiceCode.Bundle)) { prompt += " - " + eServiceCode.Bundle.GetDescription() + "\r\n"; } else //Show all enabled eServices. { foreach (var eService in clinicEnabled.ToList()) { prompt += " - " + eService.EService.GetDescription() + "\r\n"; } } } //Prompt and take action when necessary. if (!string.IsNullOrEmpty(prompt)) { if (checkEnableClinics.Checked) //Will be switching clinics on. { prompt = Lan.g(this, "Your eServices will need to be reassigned to your clinics once you have created at least one clinic.") + "\r\n\r\n" + Lan.g(this, "Once have created at least one clinic, please visit the Signup Portal using eServices | Signup in order to make the appropriate changes to your service agreement.") + "\r\n\r\n" + Lan.g(this, "You are currently subscribed to the following eServices. Click OK to continue.") + "\r\n\r\n" + prompt; } else //Will be switching clinics off. { prompt = Lan.g(this, "Your eServices will all be transferred from individual clinics to your practice.") + "\r\n\r\n" + Lan.g(this, "Once you approve this change, please visit the Signup Portal using eServices | Signup in order to verify the changes to your service agreement are correct.") + "\r\n\r\n" + Lan.g(this, "You are currently subscribed to the following eServices. Click OK to approve this change.") + "\r\n\r\n" + prompt; } if (MessageBox.Show(prompt, "", MessageBoxButtons.OKCancel) != DialogResult.OK) { throw new Exception(Lan.g(this, "Clinic feature modification canceled")); } } //Turn clinics on/off locally and send the signal to other workstations. This must happen before we call HQ so we tell HQ the new value. Prefs.UpdateBool(PrefName.EasyNoClinics, !checkEnableClinics.Checked); DataValid.SetInvalid(InvalidType.Prefs); //This call will perform the changes to the local clinic pref at HQ. It will also re-sync local prefs and table infor HQ's info. WebServiceMainHQProxy.GetEServiceSetupFull(SignupPortalPermission.FullPermission, true); return(true); } catch (Exception ex) { //Change it back to what the db has. RestoreClinicCheckBox(); MessageBox.Show(ex.Message); return(false); } }