Exemple #1
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);
                }
            }
        }
Exemple #2
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            int            selected = e.Row;
            FormClaimPrint FormCP;

            FormCP                  = new FormClaimPrint();
            FormCP.ThisPatNum       = listQueue[e.Row].PatNum;
            FormCP.ThisClaimNum     = listQueue[e.Row].ClaimNum;
            FormCP.PrintImmediately = false;
            FormCP.ShowDialog();
            FillGrid();
            gridMain.SetSelected(selected, true);
        }
Exemple #3
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            DataRow         row             = (DataRow)gridMain.ListGridRows[e.Row].Tag;
            long            selectedLabCase = PIn.Long(row["LabCaseNum"].ToString());
            FormLabCaseEdit FormL           = new FormLabCaseEdit();

            FormL.CaseCur = LabCases.GetOne(selectedLabCase);
            FormL.ShowDialog();
            switch (FormL.DialogResult)
            {
            default:
            case DialogResult.Cancel:                    //==Jordan don't refresh unless we have to.  It messes up the user's ordering.
                return;

            case DialogResult.Abort:                    //User was forced out of window due to a null object, refresh grid to remove missing row.
                FillGrid();
                return;

            case DialogResult.OK:
                //Intentionally blank
                break;
            }
            FillGrid();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i]["LabCaseNum"].ToString() == selectedLabCase.ToString())
                {
                    gridMain.SetSelected(i, true);
                    break;
                }
            }
        }
Exemple #4
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);
        }
Exemple #5
0
 private void SetSelectedHelper(bool setToValue, params int[] listIndexs)
 {
     foreach (int row in listIndexs)
     {
         if (setToValue && !ArraySelectedIndices.Contains(row))
         {
             gridMain.SetSelected(row, true);
             continue;
         }
         else if (!setToValue && ArraySelectedIndices.Contains(row))
         {
             gridMain.SetSelected(row, false);
             continue;
         }
     }
     FillText();
 }
Exemple #6
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);
                }
            }
        }
Exemple #7
0
        ///<summary>Only visible when !IsSelectionMode, and disabled if any filtering has been done via the search boxes. </summary>
        private void butUp_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select an item in the grid first.");
                return;
            }
            List <int> listSelectedIndexes = gridMain.SelectedIndices.ToList();

            if (listSelectedIndexes.First() == 0)
            {
                return;
            }
            listSelectedIndexes.ForEach(x => _listDiseaseDefs.Reverse(x - 1, 2));
            for (int i = 0; i < _listDiseaseDefs.Count; i++)
            {
                _listDiseaseDefs[i].ItemOrder = i;              //change itemOrder to reflect order changes.
            }
            FillGrid();
            listSelectedIndexes.ForEach(x => gridMain.SetSelected(x - 1, true));
            _isChanged = true;
        }
        private void butUp_Click(object sender, EventArgs e)
        {
            //These aren't yet optimized for multiselection.
            int selected = gridMain.GetSelectedIndex();

            try{
                DiseaseDefs.MoveUp(gridMain.GetSelectedIndex());
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            FillGrid();
            if (selected == 0)
            {
                gridMain.SetSelected(0, true);
            }
            else
            {
                gridMain.SetSelected(selected - 1, true);
            }
            IsChanged = true;
        }
Exemple #9
0
        private void SelectLabFees(ref ODGrid grid)
        {
            List <long> listSelectedProcNums = grid.SelectedTags <Procedure>().Select(x => x.ProcNum).ToList();

            listSelectedProcNums.AddRange(grid.SelectedTags <Procedure>().Where(x => x.ProcNumLab > 0).Select(x => x.ProcNumLab).ToList());
            //Go through the entire grid and select any procedures that have a ProcNum that matches selected ProcNums or ProcNumLabs.
            List <Procedure> listAllProcs = grid.GetTags <Procedure>();

            for (int i = 0; i < listAllProcs.Count; i++)
            {
                if (listAllProcs[i].ProcNum.In(listSelectedProcNums) || listAllProcs[i].ProcNumLab.In(listSelectedProcNums))
                {
                    grid.SetSelected(i, true);                   //Either a selected procedure or one of the labs associated to a selected procedure.
                }
            }
        }
Exemple #10
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            int             selectedLabCase = PIn.PInt(table.Rows[e.Row]["LabCaseNum"].ToString());
            FormLabCaseEdit FormL           = new FormLabCaseEdit();

            FormL.CaseCur = LabCases.GetOne(selectedLabCase);
            FormL.ShowDialog();
            FillGrid();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i]["LabCaseNum"].ToString() == selectedLabCase.ToString())
                {
                    gridMain.SetSelected(i, true);
                    break;
                }
            }
        }
Exemple #11
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            DataRow         row             = (DataRow)gridMain.Rows[e.Row].Tag;
            long            selectedLabCase = PIn.Long(row["LabCaseNum"].ToString());
            FormLabCaseEdit FormL           = new FormLabCaseEdit();

            FormL.CaseCur = LabCases.GetOne(selectedLabCase);
            FormL.ShowDialog();
            if (FormL.DialogResult != DialogResult.OK)
            {
                return;                //don't refresh unless we have to.  It messes up the user's ordering.
            }
            FillGrid();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i]["LabCaseNum"].ToString() == selectedLabCase.ToString())
                {
                    gridMain.SetSelected(i, true);
                    break;
                }
            }
        }
Exemple #12
0
        ///<summary>Fills either grid since both grids contain the same data type and thus the same columns.</summary>
        private void FillGrid(ODGrid grid, List <SheetDef> listSheetDefs, long selectedSheetNum = -1)
        {
            grid.BeginUpdate();
            grid.ListGridColumns.Clear();
            grid.ListGridColumns.Add(new GridColumn("Description", 0));
            grid.ListGridColumns.Add(new GridColumn("User", 120));
            grid.ListGridRows.Clear();
            int selectedRowIndex = -1;

            foreach (SheetDef sheetDef in listSheetDefs)
            {
                if (sheetDef.SheetDefNum == selectedSheetNum)
                {
                    selectedRowIndex = grid.ListGridRows.Count;
                }
                //grid.Rows.Add(new ODGridRow(sheetDef.Description,Userods.GetName(sheetDef.UserNum)));
            }
            grid.EndUpdate();
            if (selectedRowIndex != -1)
            {
                grid.SetSelected(selectedRowIndex, true);
            }
        }
 private void butAll_Click(object sender, System.EventArgs e)
 {
     gridMain.SetSelected(true);
 }
        ///<summary>If any columns are reordered or added to this grid, they will need to be considered in the GridCell_Click event below.
        ///This refreshes every grid on the form.</summary>
        private void FillGrids()
        {
            ListDisplayReportAll = ListDisplayReportAll.OrderBy(x => x.ItemOrder).ToList();
            //Begin Update
            gridProdInc.BeginUpdate();
            gridDaily.BeginUpdate();
            gridMonthly.BeginUpdate();
            gridLists.BeginUpdate();
            gridPublicHealth.BeginUpdate();
            //Add Columns
            int widthDisplayNameCol = 140;

            gridProdInc.Columns.Clear();
            string displayColumnTitle = Lans.g(this, "Display Name");
            string allowedColumnTitle = Lans.g(this, "Allowed");
            string subMenuColumnTitle = Lans.g(this, "Sub\r\nMenu");
            string hiddenColumnTitle  = Lans.g(this, "Hidden");

            gridProdInc.Columns.Add(new ODGridColumn(displayColumnTitle, widthDisplayNameCol, !_isPermissionMode));
            if (_isPermissionMode)
            {
                gridProdInc.Columns.Add(new ODGridColumn(allowedColumnTitle, 0, HorizontalAlignment.Center));
            }
            else
            {
                gridProdInc.Columns.Add(new ODGridColumn(subMenuColumnTitle, 0, HorizontalAlignment.Center));
                gridProdInc.Columns.Add(new ODGridColumn(hiddenColumnTitle, 0, HorizontalAlignment.Center));
            }
            gridDaily.Columns.Clear();
            gridDaily.Columns.Add(new ODGridColumn(displayColumnTitle, widthDisplayNameCol, !_isPermissionMode));
            if (_isPermissionMode)
            {
                gridDaily.Columns.Add(new ODGridColumn(allowedColumnTitle, 0, HorizontalAlignment.Center));
            }
            else
            {
                gridDaily.Columns.Add(new ODGridColumn(subMenuColumnTitle, 0, HorizontalAlignment.Center));
                gridDaily.Columns.Add(new ODGridColumn(hiddenColumnTitle, 0, HorizontalAlignment.Center));
            }
            gridMonthly.Columns.Clear();
            gridMonthly.Columns.Add(new ODGridColumn(displayColumnTitle, widthDisplayNameCol, !_isPermissionMode));
            if (_isPermissionMode)
            {
                gridMonthly.Columns.Add(new ODGridColumn(allowedColumnTitle, 0, HorizontalAlignment.Center));
            }
            else
            {
                gridMonthly.Columns.Add(new ODGridColumn(subMenuColumnTitle, 0, HorizontalAlignment.Center));
                gridMonthly.Columns.Add(new ODGridColumn(hiddenColumnTitle, 0, HorizontalAlignment.Center));
            }
            gridLists.Columns.Clear();
            gridLists.Columns.Add(new ODGridColumn(displayColumnTitle, widthDisplayNameCol, !_isPermissionMode));
            if (_isPermissionMode)
            {
                gridLists.Columns.Add(new ODGridColumn(allowedColumnTitle, 0, HorizontalAlignment.Center));
            }
            else
            {
                gridLists.Columns.Add(new ODGridColumn(subMenuColumnTitle, 0, HorizontalAlignment.Center));
                gridLists.Columns.Add(new ODGridColumn(hiddenColumnTitle, 0, HorizontalAlignment.Center));
            }
            gridPublicHealth.Columns.Clear();
            gridPublicHealth.Columns.Add(new ODGridColumn(displayColumnTitle, widthDisplayNameCol, !_isPermissionMode));
            if (_isPermissionMode)
            {
                gridPublicHealth.Columns.Add(new ODGridColumn(allowedColumnTitle, 0, HorizontalAlignment.Center));
            }
            else
            {
                gridPublicHealth.Columns.Add(new ODGridColumn(subMenuColumnTitle, 0, HorizontalAlignment.Center));
                gridPublicHealth.Columns.Add(new ODGridColumn(hiddenColumnTitle, 0, HorizontalAlignment.Center));
            }
            //Add Rows
            gridProdInc.Rows.Clear();
            gridDaily.Rows.Clear();
            gridMonthly.Rows.Clear();
            gridLists.Rows.Clear();
            gridPublicHealth.Rows.Clear();
            foreach (DisplayReport reportCur in ListDisplayReportAll)
            {
                ODGridRow row = new ODGridRow();
                if (_isPermissionMode)
                {
                    row.Cells.Add(reportCur.Description + (reportCur.IsHidden ? " (hidden)" : ""));
                    row.Cells.Add(ListGroupPermissionsForReports.Exists(x => x.FKey == reportCur.DisplayReportNum && x.UserGroupNum == _listUserGroups[comboUserGroup.SelectedIndex].UserGroupNum) ? "X" : "");
                }
                else
                {
                    row.Cells.Add(reportCur.Description);
                    row.Cells.Add(reportCur.IsVisibleInSubMenu ? "X" : "");
                    row.Cells.Add(reportCur.IsHidden ? "X" : "");
                }
                row.Tag = reportCur;
                switch (reportCur.Category)
                {
                case DisplayReportCategory.ProdInc:
                    gridProdInc.Rows.Add(row);
                    break;

                case DisplayReportCategory.Daily:
                    gridDaily.Rows.Add(row);
                    break;

                case DisplayReportCategory.Monthly:
                    gridMonthly.Rows.Add(row);
                    break;

                case DisplayReportCategory.Lists:
                    gridLists.Rows.Add(row);
                    break;

                case DisplayReportCategory.PublicHealth:
                    gridPublicHealth.Rows.Add(row);
                    break;

                case DisplayReportCategory.ArizonaPrimaryCare:
                default:
                    break;
                }
            }
            //End Update
            gridProdInc.EndUpdate();
            gridDaily.EndUpdate();
            gridMonthly.EndUpdate();
            gridLists.EndUpdate();
            gridPublicHealth.EndUpdate();
            if (_selectedGrid != null && _selectedCell.Y != -1)
            {
                _selectedGrid.Rows[_selectedCell.Y].ColorBackG = Color.LightCyan;
                _selectedGrid.SetSelected(_selectedCell);
            }
        }
Exemple #15
0
 public void SetSelected(bool setToValue)
 {
     SynchronizeGrid();
     gridMain.SetSelected(setToValue);
     FillText();
 }
Exemple #16
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;
        }
        private void Run(ODGrid gridCur, DbmMode modeCur)
        {
            if (_patNum < 1)
            {
                MsgBox.Show(this, "Select a patient first.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            //Clear out the result column for all rows before every "run"
            for (int i = 0; i < gridCur.ListGridRows.Count; i++)
            {
                //gridMain and gridOld have a different number of columns, but their matching columns will be named the same.
                gridCur.ListGridRows[i].Cells[gridCur.ListGridColumns.GetIndex(RESULTS_COLUMN_NAME)].Text = "";              //Don't use UpdateResultTextForRow here because users will see the rows clearing out one by one.
            }
            bool          verbose = checkShow.Checked;
            StringBuilder logText = new StringBuilder();

            //No longer uses a pre-check for tables.
            if (gridCur.SelectedIndices.Length < 1)
            {
                //No rows are selected so the user wants to run all checks.
                gridCur.SetSelected(true);
            }
            string result;

            int[] selectedIndices = gridCur.SelectedIndices;
            for (int i = 0; i < gridCur.SelectedGridRows.Count; i++)
            {
                DbmMethodAttr methodAttributes = (DbmMethodAttr)Attribute.GetCustomAttribute((MethodInfo)gridCur.SelectedGridRows[i].Tag, typeof(DbmMethodAttr));
                //We always send verbose and modeCur into all DBM methods.
                List <object> parameters = new List <object>()
                {
                    verbose, modeCur
                };
                //There are optional paramaters available to some methods and adding them in the following order is very important.
                if (methodAttributes.HasPatNum)
                {
                    parameters.Add(_patNum);
                }

                try {
                    gridCur.ScrollToIndexBottom(i);
                    UpdateResultTextForRow(i, Lan.g("FormDatabaseMaintenance", "Running") + "...", gridCur);
                    gridCur.SetSelected(selectedIndices, true);                   //Reselect all rows that were originally selected.
                    result = (string)((MethodInfo)gridCur.SelectedGridRows[i].Tag).Invoke(null, parameters.ToArray());
                    if (modeCur == DbmMode.Fix)
                    {
                        DatabaseMaintenances.UpdateDateLastRun(((MethodInfo)gridCur.SelectedGridRows[i].Tag).Name);
                    }
                }
                catch (Exception ex) {
                    if (ex.InnerException != null)
                    {
                        ExceptionDispatchInfo.Capture(ex.InnerException).Throw();                        //This preserves the stack trace of the InnerException.
                    }
                    throw;
                }
                string status = "";
                if (result == "")               //Only possible if running a check / fix in non-verbose mode and nothing happened or needs to happen.
                {
                    status = Lan.g("FormDatabaseMaintenance", "Done.  No maintenance needed.");
                }
                UpdateResultTextForRow(i, result + status, gridCur);
                logText.Append(result);
            }
            gridCur.SetSelected(selectedIndices, true);           //Reselect all rows that were originally selected.
            SaveLogToFile(logText.ToString());
            if (modeCur == DbmMode.Fix)
            {
                //_isCacheInvalid=true;//Flag cache to be invalidated on closing.  Some DBM fixes alter cached tables.
            }
        }
        ///<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();
        }
        private void OnEclaims_Click()
        {
            ArrayList queueItems = new ArrayList();          //a list of queue items to send

            if (gridMain.SelectedIndices.Length == 0)
            {
                for (int i = 0; i < listQueue.Length; i++)
                {
                    if (                                      //(listQueue[i].ClaimStatus=="W" || listQueue[i].ClaimStatus=="P")
                        !listQueue[i].NoSendElect &&
                        gridMain.Rows[i].Cells[3].Text == "") //no Missing Info
                    {
                        gridMain.SetSelected(i, true);
                    }
                }
                if (gridMain.SelectedIndices.Length == 0)
                {
                    MsgBox.Show(this, "No claims to send.");
                    return;
                }
                if (!MsgBox.Show(this, true, "Send all selected e-claims?"))
                {
                    return;
                }
            }
            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                if (gridMain.Rows[gridMain.SelectedIndices[i]].Cells[3].Text != "")
                {
                    //tbQueue.Cell[4,tbQueue.SelectedIndices[i]]!=""){
                    MsgBox.Show(this, "Not allowed to send e-claims with missing information.");
                    return;
                }
                if (listQueue[gridMain.SelectedIndices[i]].NoSendElect)
                {
                    MsgBox.Show(this, "Not allowed to send paper claims electronically.");
                    return;
                }
            }
            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                queueItems.Add(listQueue[gridMain.SelectedIndices[i]]);
            }
            Eclaims.Eclaims.SendBatches(queueItems);
            //statuses changed to S in SendBatches
            FillGrid();
            FillHistory();
            //Now, the cool part.  Highlight all the claims that were just sent in the history grid
            for (int i = 0; i < queueItems.Count; i++)
            {
                for (int j = 0; j < tableHistory.Rows.Count; j++)
                {
                    int claimNum = PIn.PInt(tableHistory.Rows[j]["ClaimNum"].ToString());
                    if (claimNum == ((ClaimSendQueueItem)queueItems[i]).ClaimNum)
                    {
                        gridHistory.SetSelected(j, true);
                        break;
                    }
                }
            }
        }
Exemple #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();
            }
        }