private void butOK_Click(object sender, EventArgs e) { if (!_insPlan.CodeSubstNone && gridInsPlanSubstInc.Rows.Count == 0 && gridInsPlanSubstExc.Rows.Count > 0) { if (MsgBox.Show(this, MsgBoxButtons.YesNo, "You have chosen to exclude all substituion codes. " + "The checkbox option named 'Don't Substitute Codes (e.g. posterior composites)' " + "in the Other Ins Info tab of the Edit Insurance Plan window can be used to exclude all substitution codes.\r\n" + "Would you like to enable this option instead of excluding specific codes?")) { _insPlan.CodeSubstNone = true; DialogResult = DialogResult.OK; return; } } List <SubstitutionLink> listSubstLinks = new List <SubstitutionLink>(); foreach (UI.ODGridRow row in gridInsPlanSubstExc.Rows) { ProcedureCode procCode = (ProcedureCode)row.Tag; SubstitutionLink subLink = _listDbSubstLinks.FirstOrDefault(x => x.CodeNum == procCode.CodeNum); if (subLink == null) { subLink = new SubstitutionLink(); subLink.PlanNum = _insPlan.PlanNum; subLink.CodeNum = procCode.CodeNum; } listSubstLinks.Add(subLink); } SubstitutionLinks.Sync(listSubstLinks, _listDbSubstLinks); DialogResult = DialogResult.OK; }
///<summary>Syncs _listDbSubstLinks and _listDbSubstLinksOld. Does not modify any of the procedure level SubstitutionCodes.</summary> private void butOK_Click(object sender, EventArgs e) { string msgText = Lan.g(this, "You have chosen to exclude all substitution codes. " + "The checkbox option named 'Don't Substitute Codes (e.g. posterior composites)' " + "in the Other Ins Info tab of the Edit Insurance Plan window can be used to exclude all substitution codes.\r\n" + "Would you like to enable this option instead of excluding specific codes?"); if (!_insPlan.CodeSubstNone && _listSubstProcCodes.Select(x => x.CodeNum).All(x => _listSubstLinks.Find(y => y.CodeNum == x)?.SubstOnlyIf == SubstitutionCondition.Never) && MessageBox.Show(this, msgText, null, MessageBoxButtons.YesNo) == DialogResult.Yes) { _insPlan.CodeSubstNone = true; } //No need to make changes to the substitution codes at the procedure level. //Only syncing insurance level substitution links. Changes made to the _listSubstLinks have been made already. //All we need to do know is sync the changes made with _listSubstLinksOld. SubstitutionLinks.Sync(_listSubstLinks, _listSubstLinksOld); DialogResult = DialogResult.OK; }