///<summary>Opens FormProcCodes in SelectionMode. Creates a new SubstitutionLink for the selected Procedure.</summary>
        private void ButAdd_Click(object sender, EventArgs e)
        {
            FormProcCodes FormP = new FormProcCodes();

            FormP.IsSelectionMode = true;
            FormP.ShowDialog();
            if (FormP.DialogResult != DialogResult.OK)
            {
                return;
            }
            _listAllProcCodes = ProcedureCodes.GetAllCodes();          //in case they added a new proc code
            ProcedureCode procSelected = _listAllProcCodes.FirstOrDefault(x => x.CodeNum == FormP.SelectedCodeNum);

            if (procSelected == null)
            {
                return;                //should never happen, just in case
            }
            //Valid procedure selected. Create a new SubstitutionLink.  The user will be able to add the substition code on the cell grid.
            SubstitutionLink subLink = new SubstitutionLink();

            subLink.CodeNum          = procSelected.CodeNum;
            subLink.PlanNum          = _insPlan.PlanNum;
            subLink.SubstOnlyIf      = SubstitutionCondition.Always;
            subLink.SubstitutionCode = "";          //Set to blank. The user will be able to add in the cell grid
            //The substitution link will be synced on OK click.
            _listSubstLinks.Add(subLink);
            FillGridMain();
            //Set the substitution link we just added as selected. The X pos at 3 is the SubstCode column.
            gridMain.SetSelected(new Point(3, gridMain.ListGridRows.ToList().FindIndex(x => (x.Tag as ProcedureCode).CodeNum == subLink.CodeNum)));
        }
 private void FormInsPlanSubstitution_Load(object sender, EventArgs e)
 {
     _listAllProcCodes   = ProcedureCodes.GetAllCodes();
     _listSubstProcCodes = _listAllProcCodes.FindAll(x => !String.IsNullOrEmpty(x.SubstitutionCode));
     _listDbSubstLinks   = SubstitutionLinks.GetAllForPlans(_insPlan.PlanNum);
     FillGridSubstituionInclude();
     FillGridSubstituionExclude();
 }
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TableInvoiceItems", "Date"), 70);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInvoiceItems", "PatName"), 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInvoiceItems", "Prov"), 55);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInvoiceItems", "Code"), 55);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInvoiceItems", "Tooth"), 50);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInvoiceItems", "Description"), 150);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableInvoiceItems", "Fee"), 60, HorizontalAlignment.Right);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;
            List <ProcedureCode> listProcCodes = ProcedureCodes.GetAllCodes();

            foreach (DataRow tableRow in _tableSuperFamAcct.Rows)
            {
                row = new GridRow();
                row.Cells.Add(PIn.DateT(tableRow["Date"].ToString()).ToShortDateString());
                row.Cells.Add(tableRow["PatName"].ToString());
                row.Cells.Add(Providers.GetAbbr(PIn.Long(tableRow["Prov"].ToString())));
                if (!string.IsNullOrWhiteSpace(tableRow["AdjType"].ToString()))                             //It's an adjustment
                {
                    row.Cells.Add(Lan.g(this, "Adjust"));                                                   //Adjustment
                    row.Cells.Add(Tooth.ToInternat(tableRow["Tooth"].ToString()));
                    row.Cells.Add(Defs.GetName(DefCat.AdjTypes, PIn.Long(tableRow["AdjType"].ToString()))); //Adjustment type
                }
                else if (!string.IsNullOrWhiteSpace(tableRow["ChargeType"].ToString()))                     //It's a payplan charge
                {
                    if (PrefC.GetInt(PrefName.PayPlansVersion) != (int)PayPlanVersions.AgeCreditsAndDebits)
                    {
                        continue;                        //They can only attach debits to invoices and they can only do so if they're on version 2.
                    }
                    row.Cells.Add(Lan.g(this, "Pay Plan"));
                    row.Cells.Add(Tooth.ToInternat(tableRow["Tooth"].ToString()));
                    row.Cells.Add(PIn.Enum <PayPlanChargeType>(PIn.Int(tableRow["ChargeType"].ToString())).GetDescription()); //Pay Plan charge type
                }
                else                                                                                                          //It's a procedure
                {
                    ProcedureCode procCode = ProcedureCodes.GetProcCode(PIn.Long(tableRow["Code"].ToString()), listProcCodes);
                    row.Cells.Add(procCode.ProcCode);
                    row.Cells.Add(Tooth.ToInternat(tableRow["Tooth"].ToString()));
                    row.Cells.Add(procCode.Descript);
                }
                row.Cells.Add(PIn.Double(tableRow["Amount"].ToString()).ToString("F"));
                row.Tag = tableRow;
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
 private void FormInsPlanSubstitution_Load(object sender, EventArgs e)
 {
     _listAllProcCodes   = ProcedureCodes.GetAllCodes();
     _listSubstProcCodes = _listAllProcCodes.FindAll(x => !String.IsNullOrEmpty(x.SubstitutionCode));
     _listSubstLinks     = SubstitutionLinks.GetAllForPlans(_insPlan.PlanNum);
     _listSubstLinksOld  = _listSubstLinks.DeepCopyList <SubstitutionLink, SubstitutionLink>();
     _listSubConditions  = new List <string>();
     for (int i = 0; i < Enum.GetNames(typeof(SubstitutionCondition)).Length; i++)
     {
         _listSubConditions.Add(Lan.g("enumSubstitutionCondition", Enum.GetNames(typeof(SubstitutionCondition))[i]));
     }
     FillGridMain();
 }