Ejemplo n.º 1
0
        private void butCopy_Click(object sender, EventArgs e)
        {
            if (grid1.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an internal HL7Def from the list on the left first.");
                return;
            }
            HL7Def hl7def = ListInternal[grid1.GetSelectedIndex()].Clone();

            hl7def.IsInternal = false;
            hl7def.IsEnabled  = false;
            long hl7DefNum = HL7Defs.Insert(hl7def);

            for (int m = 0; m < hl7def.hl7DefMessages.Count; m++)
            {
                hl7def.hl7DefMessages[m].HL7DefNum = hl7DefNum;
                long hl7DefMessageNum = HL7DefMessages.Insert(hl7def.hl7DefMessages[m]);
                for (int s = 0; s < hl7def.hl7DefMessages[m].hl7DefSegments.Count; s++)
                {
                    hl7def.hl7DefMessages[m].hl7DefSegments[s].HL7DefMessageNum = hl7DefMessageNum;
                    long hl7DefSegmentNum = HL7DefSegments.Insert(hl7def.hl7DefMessages[m].hl7DefSegments[s]);
                    for (int f = 0; f < hl7def.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields.Count; f++)
                    {
                        hl7def.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields[f].HL7DefSegmentNum = hl7DefSegmentNum;
                        HL7DefFields.Insert(hl7def.hl7DefMessages[m].hl7DefSegments[s].hl7DefFields[f]);
                    }
                }
            }
            DataValid.SetInvalid(InvalidType.HL7Defs);
            FillGrid2();
            grid1.SetSelected(false);
        }
Ejemplo n.º 2
0
        private void butCopy_Click(object sender, EventArgs e)
        {
            if (grid1.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an internal sheet from the list above first.");
                return;
            }
            SheetDef sheetdef = internalList[grid1.GetSelectedIndex()].Copy();

            sheetdef.IsNew = true;
            SheetDefs.InsertOrUpdate(sheetdef);
            if (sheetdef.SheetType == SheetTypeEnum.MedicalHistory &&
                (sheetdef.Description == "Medical History New Patient" || sheetdef.Description == "Medical History Update"))
            {
                MsgBox.Show(this, "This is just a template, it may contain allergies and problems that do not exist in your setup.");
            }
            grid1.SetSelected(false);
            FillGrid2();
            for (int i = 0; i < _listSheetDefs.Count; i++)
            {
                if (_listSheetDefs[i].SheetDefNum == sheetdef.SheetDefNum)
                {
                    grid2.SetSelected(i, true);
                }
            }
        }
Ejemplo n.º 3
0
        public static bool HideDef(ODGrid gridDefs, DefCatOptions selectedDefCatOpt)
        {
            if (gridDefs.GetSelectedIndex() == -1)
            {
                MsgBox.Show(_lanThis, "Please select item first,");
                return(false);
            }
            Def selectedDef = (Def)gridDefs.Rows[gridDefs.GetSelectedIndex()].Tag;

            //Warn the user if they are about to hide a billing type currently in use.
            if (selectedDefCatOpt.DefCat == DefCat.BillingTypes && Patients.IsBillingTypeInUse(selectedDef.DefNum))
            {
                if (!MsgBox.Show(_lanThis, MsgBoxButtons.OKCancel, "Warning: Billing type is currently in use by patients, insurance plans, or preferences."))
                {
                    return(false);
                }
            }
            if (selectedDef.Category == DefCat.ProviderSpecialties &&
                (Providers.IsSpecialtyInUse(selectedDef.DefNum) ||
                 Referrals.IsSpecialtyInUse(selectedDef.DefNum)))
            {
                MsgBox.Show(_lanThis, "You cannot hide a specialty if it is in use by a provider or a referral source.");
                return(false);
            }
            if (Defs.IsDefinitionInUse(selectedDef))
            {
                if (selectedDef.DefNum == PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType) ||
                    selectedDef.DefNum == PrefC.GetLong(PrefName.AppointmentTimeArrivedTrigger) ||
                    selectedDef.DefNum == PrefC.GetLong(PrefName.AppointmentTimeSeatedTrigger) ||
                    selectedDef.DefNum == PrefC.GetLong(PrefName.AppointmentTimeDismissedTrigger) ||
                    selectedDef.DefNum == PrefC.GetLong(PrefName.TreatPlanDiscountAdjustmentType) ||
                    selectedDef.DefNum == PrefC.GetLong(PrefName.BillingChargeAdjustmentType) ||
                    selectedDef.DefNum == PrefC.GetLong(PrefName.PracticeDefaultBillType) ||
                    selectedDef.DefNum == PrefC.GetLong(PrefName.FinanceChargeAdjustmentType))
                {
                    MsgBox.Show(_lanThis, "You cannot hide a definition if it is in use within Module Preferences.");
                    return(false);
                }
                else
                {
                    if (!MsgBox.Show(_lanThis, MsgBoxButtons.OKCancel, "Warning: This definition is currently in use within the program."))
                    {
                        return(false);
                    }
                }
            }
            //Stop users from hiding the last definition in categories that must have at least one def in them.
            if (Defs.IsHidable(selectedDef.Category))
            {
                List <Def> listDefsCurNotHidden = Defs.GetDefsForCategory(selectedDefCatOpt.DefCat, true);
                if (listDefsCurNotHidden.Count == 1)
                {
                    MsgBox.Show(_lanThis, "You cannot hide the last definition in this category.");
                    return(false);
                }
            }
            Defs.HideDef(selectedDef);
            return(true);
        }
Ejemplo n.º 4
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (gridMain.GetSelectedIndex() == -1)
     {
         MsgBox.Show(this, "Please select an item first.");
         return;
     }
     SelectedProcNum = ProcList[gridMain.GetSelectedIndex()].ProcNum;
     DialogResult    = DialogResult.OK;
 }
Ejemplo n.º 5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an item first.");
                return;
            }
            ListSelectedSplits.Clear();
            PaySplit paySplit = (PaySplit)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;

            ListSelectedSplits.Add(paySplit);
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 6
0
 ///<summary>If IsSelectionMode, doubleclicking closes the form and returns the selected diseasedef.
 ///If !IsSelectionMode, doubleclicking opens FormDiseaseDefEdit and allows the user to edit or delete the selected diseasedef.
 ///Either way, validation always occurs first.</summary>
 private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
 {
     #region Validation
     if (!IsSelectionMode && !Security.IsAuthorized(Permissions.ProblemEdit))             //trying to double click to edit, but no permission.
     {
         return;
     }
     if (gridMain.SelectedIndices.Length == 0)
     {
         return;
     }
     #endregion
     DiseaseDef selectedDiseaseDef = (DiseaseDef)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
     #region Selection Mode. Close the Form
     if (IsSelectionMode)             //selection mode.
     {
         if (!IsMultiSelect && Snomeds.GetByCode(selectedDiseaseDef.SnomedCode) == null)
         {
             MsgBox.Show(this, "You have selected a problem with an unofficial SNOMED CT code.  Please correct the problem definition by going to "
                         + "Lists | Problems and choosing an official code from the SNOMED CT list.");
             return;
         }
         DialogResult = DialogResult.OK;              //FormClosing takes care of filling ListSelectedDiseaseDefs.
         return;
     }
     #endregion
     #region Not Selection Mode. Open FormDiseaseDefEdit
     //not selection mode. double-click to edit.
     bool hasDelete = true;
     if (_listDiseaseDefsNumsNotDeletable.Contains(selectedDiseaseDef.DiseaseDefNum))
     {
         hasDelete = false;
     }
     //everything below this point is _not_ selection mode.  User guaranteed to have permission for ProblemEdit.
     FormDiseaseDefEdit FormD = new FormDiseaseDefEdit(selectedDiseaseDef, hasDelete);
     FormD.ShowDialog();
     //Security log entry made inside that form.
     if (FormD.DialogResult != DialogResult.OK)
     {
         return;
     }
     #endregion
     _listSecurityLogMsgs.Add(FormD.SecurityLogMsgText);
     if (FormD.DiseaseDefCur == null)           //User deleted the DiseaseDef.
     {
         _listDiseaseDefs.Remove(selectedDiseaseDef);
     }
     _isChanged = true;
     FillGrid();
 }
Ejemplo n.º 7
0
        private void butAdd2_Click(object sender, System.EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select item first"));
                return;
            }
            RxDef RxDefCur = RxDefList[gridMain.GetSelectedIndex()].Copy();

            RxDefs.Insert(RxDefCur);            //Now it has a new id.  It gets deleted if user clicks cancel. Alerts not copied.
            FormRxDefEdit FormE = new FormRxDefEdit(RxDefCur);

            FormE.IsNew = true;
            FormE.ShowDialog();
            FillGrid();
        }
Ejemplo n.º 8
0
        private void TryViewTask(ODGrid grid)
        {
            int index = grid.GetSelectedIndex();

            if (index == -1)
            {
                return;
            }
            Bug         selectedBug  = (Bug)grid.ListGridRows[index].Tag;
            List <long> listTaskNums = JobLinks.GetTaskNumsForBug(selectedBug.BugId);

            switch (listTaskNums.Count)
            {
            case 0:
                MsgBox.Show(this, "There are not task assocaited to a job for this bug.");
                return;

            case 1:
                FormTaskEdit formTaskEdit = new FormTaskEdit(Tasks.GetOne(listTaskNums[0]));
                formTaskEdit.Show();
                break;

            default:
                FormTaskSearch formTaskSearch = new FormTaskSearch(listTaskNums);
                formTaskSearch.ShowDialog();
                break;
            }
        }
Ejemplo n.º 9
0
        private void gridAllergies_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormAllergyEdit FAE = new FormAllergyEdit();

            FAE.AllergyCur = allergyList[gridAllergies.GetSelectedIndex()];
            FAE.ShowDialog();
            FillAllergies();
        }
Ejemplo n.º 10
0
        public static bool DownClick(ODGrid gridDefs, List <Def> listDefsCur)
        {
            if (gridDefs.GetSelectedIndex() == -1)
            {
                MessageBox.Show(Lan.g("Defs", "Please select an item first."));
                return(false);
            }
            if (gridDefs.GetSelectedIndex() == gridDefs.Rows.Count - 1)
            {
                return(false);
            }
            Def defSelected = listDefsCur[gridDefs.GetSelectedIndex()];
            Def deBelow     = listDefsCur[gridDefs.GetSelectedIndex() + 1];

            defSelected.ItemOrder++;
            deBelow.ItemOrder--;
            Defs.Update(defSelected);
            Defs.Update(deBelow);
            return(true);
        }
Ejemplo n.º 11
0
        public static bool UpClick(ODGrid gridDefs, List <Def> listDefsCur)
        {
            if (gridDefs.GetSelectedIndex() == -1)
            {
                MessageBox.Show(Lan.g("Defs", "Please select an item first."));
                return(false);
            }
            if (gridDefs.GetSelectedIndex() == 0)
            {
                return(false);
            }
            Def defSelected = listDefsCur[gridDefs.GetSelectedIndex()];
            Def defAbove    = listDefsCur[gridDefs.GetSelectedIndex() - 1];

            defSelected.ItemOrder--;
            defAbove.ItemOrder++;
            Defs.Update(defSelected);
            Defs.Update(defAbove);
            return(true);
        }
Ejemplo n.º 12
0
        private void RefreshBreakdown()
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                labelAmtOriginal.Text    = (0).ToString("f");
                labelPositiveAdjs.Text   = (0).ToString("f");
                labelNegativeAdjs.Text   = (0).ToString("f");
                labelPayPlanCredits.Text = (0).ToString("f");
                labelPaySplits.Text      = (0).ToString("f");
                labelInsEst.Text         = (0).ToString("f");
                labelInsPay.Text         = (0).ToString("f");
                labelOther.Text          = (0).ToString("f");
                labelAmtStart.Text       = (0).ToString("f");
                labelWriteOff.Text       = (0).ToString("f");
                labelWriteOffEst.Text    = (0).ToString("f");
                labelCurrentSplits.Text  = (0).ToString("f");
                labelAmtEnd.Text         = (0).ToString("f");
                return;
            }
            //there could be more than one proc selected if IsMultiSelect = true.
            List <AccountEntry> clickedEntries = gridMain.SelectedGridRows
                                                 .Select(x => (AccountEntry)x.Tag)
                                                 .Where(x => x.GetType() == typeof(ProcExtended))
                                                 .ToList();
            List <ProcExtended> listSelectedProcE = clickedEntries.Select(x => (ProcExtended)x.Tag).ToList();

            labelAmtOriginal.Text    = listSelectedProcE.Sum(x => x.AmountOriginal).ToString("f");
            labelPositiveAdjs.Text   = Stringify(listSelectedProcE.Sum(x => x.PositiveAdjTotal));
            labelNegativeAdjs.Text   = Stringify((listSelectedProcE.Sum(x => x.NegativeAdjTotals)));
            labelPayPlanCredits.Text = Stringify((-listSelectedProcE.Sum(x => x.PayPlanCreditTotal)));
            labelPaySplits.Text      = Stringify((-listSelectedProcE.Sum(x => x.PaySplitTotal)));
            labelInsEst.Text         = Stringify((-listSelectedProcE.Sum(x => x.InsEstTotal)));
            labelInsPay.Text         = Stringify((-listSelectedProcE.Sum(x => x.InsPayTotal)));
            labelWriteOff.Text       = Stringify((-listSelectedProcE.Sum(x => x.WriteOffTotal)));
            labelWriteOffEst.Text    = Stringify((-listSelectedProcE.Sum(x => x.WriteOffEstTotal)));
            //other credits apply when calculating using FIFO.
            labelOther.Text         = Stringify((double)(-(listSelectedProcE.Sum(x => (decimal)x.AmountStart) - clickedEntries.Sum(y => y.AmountStart))));
            labelAmtStart.Text      = clickedEntries.Sum(y => y.AmountStart).ToString("f");
            labelCurrentSplits.Text = Stringify((-listSelectedProcE.Sum(x => x.SplitsCurTotal)));
            labelAmtEnd.Text        = clickedEntries.Sum(y => y.AmountEnd).ToString("f");
        }
Ejemplo n.º 13
0
        public static bool DownClick(ODGrid gridDefs)
        {
            if (gridDefs.GetSelectedIndex() == -1)
            {
                MessageBox.Show(Lan.g("Defs", "Please select an item first."));
                return(false);
            }
            if (gridDefs.GetSelectedIndex() == gridDefs.ListGridRows.Count - 1)
            {
                return(false);
            }
            Def defSelected = (Def)gridDefs.ListGridRows[gridDefs.GetSelectedIndex()].Tag;
            Def defBelow    = (Def)gridDefs.ListGridRows[gridDefs.GetSelectedIndex() + 1].Tag;
            int indexDefSelectedItemOrder = defSelected.ItemOrder;

            defSelected.ItemOrder = defBelow.ItemOrder;
            defBelow.ItemOrder    = indexDefSelectedItemOrder;
            Defs.Update(defSelected);
            Defs.Update(defBelow);
            return(true);
        }
Ejemplo n.º 14
0
        private void butCopy_Click(object sender, EventArgs e)
        {
            if (grid1.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an internal sheet from the list above first.");
                return;
            }
            SheetDef sheetdef = internalList[grid1.GetSelectedIndex()].Copy();

            sheetdef.IsNew = true;
            SheetDefs.InsertOrUpdate(sheetdef);
            grid1.SetSelected(false);
            FillGrid2();
            for (int i = 0; i < SheetDefC.Listt.Count; i++)
            {
                if (SheetDefC.Listt[i].SheetDefNum == sheetdef.SheetDefNum)
                {
                    grid2.SetSelected(i, true);
                }
            }
        }
Ejemplo n.º 15
0
        private void OnPreview_Click()
        {
            FormClaimPrint FormCP;

            FormCP = new FormClaimPrint();
            if (gridMain.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "Please select an item first."));
                return;
            }
            if (gridMain.SelectedIndices.Length > 1)
            {
                MessageBox.Show(Lan.g(this, "Please select only one claim."));
                return;
            }
            FormCP.ThisPatNum       = listQueue[gridMain.GetSelectedIndex()].PatNum;
            FormCP.ThisClaimNum     = listQueue[gridMain.GetSelectedIndex()].ClaimNum;
            FormCP.PrintImmediately = false;
            FormCP.ShowDialog();
            FillGrid();
        }
Ejemplo n.º 16
0
        private void menuItemGoTo_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a lab case first.");
                return;
            }
            if (table.Rows[gridMain.GetSelectedIndex()]["AptNum"].ToString() == "0")
            {
                MsgBox.Show(this, "There are no appointments for unattached lab cases.");
                return;
            }
            Appointment apt = Appointments.GetOneApt(PIn.Long(table.Rows[gridMain.GetSelectedIndex()]["AptNum"].ToString()));

            if (apt.AptStatus == ApptStatus.UnschedList)
            {
                MsgBox.Show(this, "Cannot go to an unscheduled appointment");
                return;
            }
            GoToAptNum = apt.AptNum;
            Close();
        }
Ejemplo n.º 17
0
        private void menuItemGridGoToAccount_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Please select exactly one patient.");
                return;
            }
            DataRow row    = (DataRow)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
            long    patNum = PIn.Long(row["PatNum"].ToString());

            GotoModule.GotoAccount(patNum);
            SendToBack();
        }
Ejemplo n.º 18
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            if (!IsSelectionMode && !Security.IsAuthorized(Permissions.ProblemEdit))             //trying to double click to edit, but no permission.
            {
                return;
            }
            if (gridMain.SelectedIndices.Length == 0)
            {
                return;
            }
            if (IsSelectionMode)
            {
                if (IsMultiSelect)
                {
                    SelectedDiseaseDefNums = new List <long>();
                    SelectedDiseaseDefNums.Add(DiseaseDefs.List[gridMain.GetSelectedIndex()].DiseaseDefNum);
                }
                else
                {
                    SelectedDiseaseDefNum = DiseaseDefs.List[gridMain.GetSelectedIndex()].DiseaseDefNum;
                }
                DialogResult = DialogResult.OK;
                return;
            }
            //everything below this point is _not_ selection mode.  User guaranteed to have permission for ProblemEdit.
            FormDiseaseDefEdit FormD = new FormDiseaseDefEdit(DiseaseDefs.ListLong[gridMain.GetSelectedIndex()]);

            FormD.ShowDialog();
            //Security log entry made inside that form.
            if (FormD.DialogResult != DialogResult.OK)
            {
                return;
            }
            IsChanged = true;
            FillGrid();
        }
Ejemplo n.º 19
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (gridMain.GetSelectedIndex() == -1)
     {
         MsgBox.Show(this, "Please select an item first.");
         return;
     }
     for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
     {
         DataRow row  = (DataRow)gridMain.ListGridRows[gridMain.SelectedIndices[i]].Tag;
         string  type = "";
         if (!string.IsNullOrWhiteSpace(row["AdjType"].ToString()))                      //It's an adjustment
         {
             type = "Adj";
         }
         else if (!string.IsNullOrWhiteSpace(row["ChargeType"].ToString()))                      //It's a payplan charge
         {
             type = "Pay Plan";
         }
         else                    //It's a procedure
         {
             type = "Proc";
         }
         long        priKey = PIn.Long(row["PriKey"].ToString());
         List <long> listPriKeys;
         if (DictSelectedItems.TryGetValue(type, out listPriKeys)) //If an entry with Proc or Adj already exists, grab its list
         {
             listPriKeys.Add(priKey);                              //Add the primary key to the list
         }
         else                                                      //No entry with Proc or Adj
         {
             DictSelectedItems.Add(type, new List <long>()
             {
                 priKey
             });                                                                         //Make a new dict entry
         }
     }
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 20
0
        private void FillGrid(bool isPrinting = false, bool isResizing = false)
        {
            if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" || textDateTo.errorProvider1.GetError(textDateTo) != "")
            {
                return;
            }
            ODGrid gridToFill           = isPrinting?gridMainPrint:gridMain;
            long   firstVisibleTransNum = 0;

            if (!isPrinting && gridToFill.VisibleRows.Count > 0)           //don't scroll into view if printing
            {
                firstVisibleTransNum = (long)gridToFill.VisibleRows[0].Tag;
            }
            long selectedTransNum = 0;

            if (!isPrinting && gridToFill.GetSelectedIndex() > -1)           //no need to reselect an index if printing
            {
                selectedTransNum = gridToFill.SelectedTag <long>();
            }
            //Resize grid to fit, important for later resizing
            gridToFill.BeginUpdate();
            gridToFill.Title = _acctCur.Description + " (" + Lan.g("enumAccountType", _acctCur.AcctType.ToString()) + ")";
            FillColumns(isPrinting, isResizing);
            DateTime dateFrom  = PIn.Date(textDateFrom.Text);
            DateTime dateTo    = string.IsNullOrEmpty(textDateTo.Text)?DateTime.MaxValue:PIn.Date(textDateTo.Text);
            double   filterAmt = string.IsNullOrEmpty(textAmt.errorProvider1.GetError(textAmt))?PIn.Double(textAmt.Text):0;

            if (!isResizing || _listJEntries == null || _dictTransUsers == null)
            {
                _listJEntries   = JournalEntries.GetForAccount(_acctCur.AccountNum);
                _dictTransUsers = Transactions.GetManyTrans(_listJEntries.Select(x => x.TransactionNum).ToList())
                                  .ToDictionary(x => x.TransactionNum, x => x.UserNum);
            }
            gridToFill.ListGridRows.Clear();
            GridRow row;
            decimal bal = 0;
            int     firstVisibleRowIndex = -1;
            int     selectedIndex        = -1;

            foreach (JournalEntry jeCur in _listJEntries)
            {
                if (jeCur.DateDisplayed > dateTo)
                {
                    break;
                }
                if (new[] { AccountType.Income, AccountType.Expense }.Contains(_acctCur.AcctType) && jeCur.DateDisplayed < dateFrom)
                {
                    continue;                    //for income and expense accounts, previous balances are not included. Only the current timespan.
                }
                //DebitIsPos=true for checking acct, bal+=DebitAmt-CreditAmt
                bal += (Accounts.DebitIsPos(_acctCur.AcctType)?1:-1) * ((decimal)jeCur.DebitAmt - (decimal)jeCur.CreditAmt);
                if (new[] { AccountType.Asset, AccountType.Liability, AccountType.Equity }.Contains(_acctCur.AcctType) && jeCur.DateDisplayed < dateFrom)
                {
                    continue;                    //for asset, liability, and equity accounts, older entries do affect the current balance.
                }
                if (filterAmt != 0 && filterAmt != jeCur.CreditAmt && filterAmt != jeCur.DebitAmt)
                {
                    continue;
                }
                if (textFindText.Text != "" && new[] { jeCur.Memo, jeCur.CheckNumber, jeCur.Splits }.All(x => !x.ToUpper().Contains(textFindText.Text.ToUpper())))
                {
                    continue;
                }
                row = new GridRow();
                row.Cells.Add(jeCur.CheckNumber);
                row.Cells.Add(jeCur.DateDisplayed.ToShortDateString());
                row.Cells.Add(jeCur.Memo);
                row.Cells.Add(jeCur.Splits);
                row.Cells.Add(jeCur.DebitAmt == 0?"":jeCur.DebitAmt.ToString("n"));
                row.Cells.Add(jeCur.CreditAmt == 0?"":jeCur.CreditAmt.ToString("n"));
                row.Cells.Add(bal.ToString("n"));
                long userNum;
                row.Cells.Add(Userods.GetName(_dictTransUsers.TryGetValue(jeCur.TransactionNum, out userNum)?userNum:0));
                row.Cells.Add(Userods.GetName(jeCur.SecUserNumEdit));
                row.Cells.Add(jeCur.ReconcileNum == 0?"":"X");
                row.Tag = jeCur.TransactionNum;
                gridToFill.ListGridRows.Add(row);
                if (firstVisibleTransNum > 0 && jeCur.TransactionNum == firstVisibleTransNum)
                {
                    firstVisibleRowIndex = gridToFill.ListGridRows.Count - 1;
                }
                if (selectedTransNum > 0 && jeCur.TransactionNum == selectedTransNum)
                {
                    selectedIndex = gridToFill.ListGridRows.Count - 1;
                }
            }
            gridToFill.EndUpdate();
            if (selectedIndex > -1)
            {
                gridToFill.SetSelected(selectedIndex, true);
            }
            if (firstVisibleRowIndex > -1)
            {
                gridToFill.ScrollToIndex(firstVisibleRowIndex);
            }
            else
            {
                gridToFill.ScrollToEnd();
            }
        }
Ejemplo n.º 21
0
        ///<summary>Creates a list box under given textBox filled with filtered list of recommended emails based on textBox.Text values.
        ///Key is used to navigate list indirectly.</summary>
        private void RecommendedEmailHelper(ODtextBox textBox, Keys key)
        {
            if (_listHistoricContacts.Count == 0)           //No recommendations to show.
            {
                return;
            }
            //The passed in textBox's tag points to the grid of options.
            //The created grid's tag will point to the textBox.
            if (textBox.Tag == null)
            {
                textBox.Tag = new ODGrid()
                {
                    TranslationName = "",
                };
            }
            ODGrid gridContacts = (ODGrid)textBox.Tag;
            //textBox.Text could contain multiple email addresses.
            //We only want to grab the last few characters as the filter string.
            //[email protected],[email protected],emai => "emai" is the filter.
            //When there is no comma, will just use what is currently in the textbox.
            string emailFilter = textBox.Text.ToLower().Split(',').Last();

            if (emailFilter.Length < 2)          //Require at least 2 characters for now.
            {
                gridContacts.Hide();             //Even if not showing .Hide() won't harm anything.
                textBox.Tag = null;              //Reset tag so that initial logic runs again.
                return;
            }
            #region Key navigation and filtering
            switch (key)
            {
            case Keys.Enter:                    //Select currently highlighted recommendation.
                if (gridContacts.Rows.Count == 0)
                {
                    return;
                }
                CloseAndSetRecommendedContacts(gridContacts, true);
                return;

            case Keys.Up:                    //Navigate the recommendations from the textBox indirectly.
                if (gridContacts.Rows.Count == 0)
                {
                    return;
                }
                //gridContacts is multi select. We are navigating 1 row at a time so clear and set the selected index.
                int index = Math.Max(gridContacts.GetSelectedIndex() - 1, 0);
                gridContacts.SetSelected(false);
                gridContacts.SetSelected(new int[] { index }, true);
                gridContacts.ScrollToIndex(index);
                break;

            case Keys.Down:                    //Navigate the recommendations from the textBox indirectly.
                if (gridContacts.Rows.Count == 0)
                {
                    return;
                }
                //gridContacts is multi select. We are navigating 1 row at a time so clear and set the selected index.
                index = Math.Min(gridContacts.GetSelectedIndex() + 1, gridContacts.Rows.Count - 1);
                gridContacts.SetSelected(false);
                gridContacts.SetSelected(new int[] { index }, true);
                gridContacts.ScrollToIndex(index);
                break;

            default:
                #region Filter recommendations
                List <string> listFilteredContacts = _listHistoricContacts.FindAll(x => x.ToLower().Contains(emailFilter.ToLower()));
                if (listFilteredContacts.Count == 0)
                {
                    gridContacts.Hide();                         //No options to show so make sure and hide the list box
                    textBox.Tag = null;                          //Reset tag.
                    return;
                }
                listFilteredContacts.Sort();
                gridContacts.BeginUpdate();
                if (gridContacts.Columns.Count == 0)                       //First time loading.
                {
                    gridContacts.Columns.Add(new ODGridColumn());
                }
                gridContacts.Rows.Clear();
                foreach (string email in listFilteredContacts)
                {
                    ODGridRow row = new ODGridRow(email);
                    row.Tag = email;
                    gridContacts.Rows.Add(row);
                }
                gridContacts.EndUpdate();
                gridContacts.SetSelected(0, true);                       //Force a selection.
                #endregion
                break;
            }
            #endregion
            if (gridContacts.Tag != null)           //Already initialized
            {
                return;
            }
            //When the text box losses focus, we close/hide the grid.
            //TextBox_LostFocus event fires after the EmailAuto_Click event.
            textBox.Leave += TextBox_LostFocus;
            #region Grid Init
            gridContacts.HeaderHeight  = 0;
            gridContacts.SelectionMode = GridSelectionMode.MultiExtended;
            gridContacts.MouseClick   += EmailAuto_Click;
            gridContacts.Tag           = textBox;
            gridContacts.TitleHeight   = 0;
            gridContacts.Parent        = this;
            gridContacts.BringToFront();
            Point menuPosition = textBox.Location;
            menuPosition.X       += 10;
            menuPosition.Y       += textBox.Height - 1;
            gridContacts.Location = menuPosition;
            gridContacts.Width    = (int)(textBox.Width * 0.75);
            gridContacts.SetSelected(0, true);
            #endregion
            gridContacts.Show();
        }
Ejemplo n.º 22
0
        ///<summary>Fills the passed in grid with the definitions in the passed in list.</summary>
        public static void FillGridDefs(ODGrid gridDefs, DefCatOptions selectedDefCatOpt, List <Def> listDefsCur)
        {
            Def selectedDef = null;

            if (gridDefs.GetSelectedIndex() > -1)
            {
                selectedDef = (Def)gridDefs.Rows[gridDefs.GetSelectedIndex()].Tag;
            }
            int scroll = gridDefs.ScrollValue;

            gridDefs.BeginUpdate();
            gridDefs.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g("TableDefs", "Name"), 190);
            gridDefs.Columns.Add(col);
            col = new ODGridColumn(selectedDefCatOpt.ValueText, 190);
            gridDefs.Columns.Add(col);
            col = new ODGridColumn(selectedDefCatOpt.EnableColor ? Lan.g("TableDefs", "Color") : "", 40);
            gridDefs.Columns.Add(col);
            col = new ODGridColumn(selectedDefCatOpt.CanHide ? Lan.g("TableDefs", "Hide") : "", 30, HorizontalAlignment.Center);
            gridDefs.Columns.Add(col);
            gridDefs.Rows.Clear();
            ODGridRow row;

            foreach (Def defCur in listDefsCur)
            {
                if (!PrefC.IsODHQ && defCur.ItemValue == CommItemTypeAuto.ODHQ.ToString())
                {
                    continue;
                }
                if (Defs.IsDefDeprecated(defCur))
                {
                    defCur.IsHidden = true;
                }
                row = new ODGridRow();
                if (selectedDefCatOpt.CanEditName)
                {
                    row.Cells.Add(defCur.ItemName);
                }
                else                                                          //Users cannot edit the item name so let them translate them.
                {
                    row.Cells.Add(Lan.g("FormDefinitions", defCur.ItemName)); //Doesn't use 'this' so that renaming the form doesn't change the translation
                }
                if (selectedDefCatOpt.DefCat == DefCat.ImageCats)
                {
                    row.Cells.Add(GetItemDescForImages(defCur.ItemValue));
                }
                else if (selectedDefCatOpt.DefCat == DefCat.AutoNoteCats)
                {
                    Dictionary <string, string> dictAutoNoteDefs = new Dictionary <string, string>();
                    dictAutoNoteDefs = listDefsCur.ToDictionary(x => x.DefNum.ToString(), x => x.ItemName);
                    string nameCur;
                    row.Cells.Add(dictAutoNoteDefs.TryGetValue(defCur.ItemValue, out nameCur) ? nameCur : defCur.ItemValue);
                }
                else if (selectedDefCatOpt.DefCat == DefCat.WebSchedNewPatApptTypes)
                {
                    AppointmentType appointmentType = AppointmentTypes.GetWebSchedNewPatApptTypeByDef(defCur.DefNum);
                    row.Cells.Add(appointmentType == null ? "" : appointmentType.AppointmentTypeName);
                }
                else if (selectedDefCatOpt.DoShowItemOrderInValue)
                {
                    row.Cells.Add(defCur.ItemOrder.ToString());
                }
                else
                {
                    row.Cells.Add(defCur.ItemValue);
                }
                row.Cells.Add("");
                if (selectedDefCatOpt.EnableColor)
                {
                    row.Cells[row.Cells.Count - 1].CellColor = defCur.ItemColor;
                }
                if (defCur.IsHidden)
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                row.Tag = defCur;
                gridDefs.Rows.Add(row);
            }
            gridDefs.EndUpdate();
            if (selectedDef != null)
            {
                for (int i = 0; i < gridDefs.Rows.Count; i++)
                {
                    if (((Def)gridDefs.Rows[i].Tag).DefNum == selectedDef.DefNum)
                    {
                        gridDefs.SetSelected(i, true);
                        break;
                    }
                }
            }
            gridDefs.ScrollValue = scroll;
        }