示例#1
0
        private void butDown_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select an item in the grid first.");
                return;
            }
            OrthoChartTabFields orthoChartTabFields = GetSelectedFields();

            if (gridMain.SelectedIndices[gridMain.SelectedIndices.Length - 1] == orthoChartTabFields.ListDisplayFields.Count - 1)
            {
                return;
            }
            int[] arrayIndicies = new int[gridMain.SelectedIndices.Length];
            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                arrayIndicies[i] = gridMain.SelectedIndices[i];
            }
            for (int i = arrayIndicies.Length - 1; i >= 0; i--)     //go backwards
            {
                orthoChartTabFields.ListDisplayFields.Reverse(arrayIndicies[i], 2);
            }
            FillGrids();
            for (int i = 0; i < arrayIndicies.Length; i++)
            {
                gridMain.SetSelected(arrayIndicies[i] + 1, true);
            }
            changed = true;
        }
示例#2
0
        private void butLeft_Click(object sender, EventArgs e)
        {
            if (listAvailable.SelectedItems.Count == 0 && textCustomField.Text == "")
            {
                MsgBox.Show(this, "Please select an item in the list on the right or create a new field first.");
                return;
            }
            OrthoChartTabFields orthoChartTabFields = GetSelectedFields();

            if (textCustomField.Text != "")           //Add new ortho chart field
            //Block adding new field if already showing.
            {
                for (int i = 0; i < orthoChartTabFields.ListDisplayFields.Count; i++)
                {
                    if (textCustomField.Text == orthoChartTabFields.ListDisplayFields[i].Description)
                    {
                        MsgBox.Show(this, "That field is already displaying.");
                        return;
                    }
                }
                //Use available field if user typed in a "new" field name which matches an available field that is not already showing.
                List <DisplayField> listAllFields = GetAllFields();
                foreach (DisplayField df in listAllFields)
                {
                    if (textCustomField.Text == df.Description)
                    {
                        orthoChartTabFields.ListDisplayFields.Add(df);
                        textCustomField.Text = "";
                        changed = true;
                        FillGrids();
                        return;
                    }
                }
                //The new field name is unique.  Create a cached copy in memory to be saved when OK is clicked.
                //This gives the user the option to remove the field before it ever reaches the database.
                DisplayField dfNew = new DisplayField("", 100, DisplayFieldCategory.OrthoChart);
                dfNew.Description = textCustomField.Text;
                orthoChartTabFields.ListDisplayFields.Add(dfNew);
                textCustomField.Text = "";
            }
            else              //Add existing ortho chart field(s).
            {
                OrthoChartTabFields orphanedTab = _listTabDisplayFields.Find(x => x.OrthoChartTab == null);
                for (int i = 0; i < listAvailable.SelectedItems.Count; i++)
                {
                    DisplayField df = _listAvailableFields[listAvailable.SelectedIndices[i]];
                    df.ColumnWidth = 100;
                    orthoChartTabFields.ListDisplayFields.Add(df);
                    if (orphanedTab != null)
                    {
                        //Remove the display field from the orphaned list if there is one.
                        orphanedTab.ListDisplayFields.Remove(df);
                    }
                }
            }
            changed = true;
            FillGrids();
        }
示例#3
0
        private void butRight_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select an item in the grid on the left first.");
                return;
            }
            List <DisplayField> listRemovedFields   = new List <DisplayField>();
            OrthoChartTabFields orthoChartTabFields = GetSelectedFields();

            for (int i = gridMain.SelectedIndices.Length - 1; i >= 0; i--)     //go backwards
            {
                int          index = gridMain.SelectedIndices[i];
                DisplayField df    = (DisplayField)gridMain.Rows[index].Tag;
                listRemovedFields.Add(df);                //Keep track of all display fields removed.
                orthoChartTabFields.ListDisplayFields.Remove(df);
            }
            //Now we need to check all removed fields and see if any are still associated with a tab.
            //If they are not associated with any tabs then we need to remove them from our list.
            //They will show up in the available fields list if a patient in the database has a value for the field.
            foreach (DisplayField field in listRemovedFields)
            {
                bool isFieldOrphaned = true;
                foreach (OrthoChartTabFields tabFields in _listTabDisplayFields)
                {
                    if (tabFields.OrthoChartTab == null)
                    {
                        continue;                        //Do not consider the orphaned tab.
                    }
                    if (tabFields.ListDisplayFields.Exists(x => x.DisplayFieldNum == field.DisplayFieldNum))
                    {
                        isFieldOrphaned = false;
                        break;                        //The field that was removed is still associated with a different tab so no action needed.
                    }
                }
                if (!isFieldOrphaned)
                {
                    continue;
                }
                //No tab has this display field so move it to the list of fields associated with the null tab
                OrthoChartTabFields orphanedTab = _listTabDisplayFields.Find(x => x.OrthoChartTab == null);
                if (orphanedTab == null)               //An orphaned list doesn't exist yet so create one.
                {
                    OrthoChartTabFields orphanedFields = new OrthoChartTabFields();
                    orphanedFields.OrthoChartTab     = null;              //These are fields not associated to any tab.  Purposefully use null.
                    orphanedFields.ListDisplayFields = new List <DisplayField>();
                    orphanedFields.ListDisplayFields.Add(field);
                    _listTabDisplayFields.Add(orphanedFields);
                }
                else
                {
                    orphanedTab.ListDisplayFields.Add(field);
                }
            }
            FillGrids();
            changed = true;
        }
        private void FillGrids()
        {
            labelCategory.Text = _listOrthoChartTabs[0].TabName;          //Placed here so that Up/Down buttons will affect the label text.
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col;

            col = new GridColumn(Lan.g("FormDisplayFields", "Description"), 200);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("FormDisplayFields", "Width"), 80);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            OrthoChartTabFields      orthoChartTabFields = GetSelectedFields();
            List <OrthoChartTabLink> listLinks           = _listOrthoChartTabLinks.FindAll(x => x.OrthoChartTabNum == orthoChartTabFields.OrthoChartTab.OrthoChartTabNum);

            _listAvailableFields = GetAllFields();
            for (int i = 0; i < orthoChartTabFields.ListDisplayFields.Count; i++)
            {
                DisplayField df = orthoChartTabFields.ListDisplayFields[i];
                _listAvailableFields.Remove(df);
                GridRow row = new GridRow();
                row.Tag = df;
                string description = df.Description;
                if (!string.IsNullOrEmpty(df.DescriptionOverride))
                {
                    description += " (" + df.DescriptionOverride + ")";
                }
                row.Cells.Add(description);
                int columnWidth        = df.ColumnWidth;
                OrthoChartTabLink link = listLinks.FirstOrDefault(x => x.DisplayFieldNum == df.DisplayFieldNum);
                if (link != null && link.ColumnWidthOverride > 0)
                {
                    columnWidth = link.ColumnWidthOverride;
                }
                row.Cells.Add(POut.Int(columnWidth));
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            listAvailable.Items.Clear();
            for (int i = 0; i < _listAvailableFields.Count; i++)
            {
                listAvailable.Items.Add(_listAvailableFields[i].Description);
            }
        }
示例#5
0
        private void butSetupTabs_Click(object sender, EventArgs e)
        {
            FormOrthoChartSetup form = new FormOrthoChartSetup();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            List <OrthoChartTabFields> listOldTabDisplayFields = _listTabDisplayFields;

            _listTabDisplayFields = new List <OrthoChartTabFields>();
            //The tab order may have changed.  Also new tabs may have been added.  Tabs were not removed, because they can only be hidden not deleted.
            //If orthocharttabs order changed or new tabs were added, then the cache was updated in FormOrthoChartSetup in OK click.
            _listOrthoChartTabs = OrthoChartTabs.GetDeepCopy(true);
            foreach (OrthoChartTab orthoChartTab in _listOrthoChartTabs)
            {
                OrthoChartTabFields orthoChartTabFieldsOld = listOldTabDisplayFields.FirstOrDefault(
                    x => x.OrthoChartTab != null && x.OrthoChartTab.OrthoChartTabNum == orthoChartTab.OrthoChartTabNum);
                OrthoChartTabFields orthoChartTabFields = new OrthoChartTabFields();
                orthoChartTabFields.OrthoChartTab = orthoChartTab;
                if (orthoChartTabFieldsOld == null)               //Either a new tab was added or a hidden tab was un-hidden.
                {
                    orthoChartTabFields.ListDisplayFields = new List <DisplayField>();
                    List <OrthoChartTabLink> listOrthoChartTabLinks = OrthoChartTabLinks.GetWhere(
                        x => x.OrthoChartTabNum == orthoChartTab.OrthoChartTabNum);
                    foreach (OrthoChartTabLink orthoChartTabLink in listOrthoChartTabLinks)
                    {
                        orthoChartTabFields.ListDisplayFields.AddRange(_listAllDisplayFields.FindAll(x => x.DisplayFieldNum == orthoChartTabLink.DisplayFieldNum));
                    }
                }
                else                  //The tab already existed.  Maintain the display field names and order within the tab, especially if the tab order changed.
                {
                    orthoChartTabFields.ListDisplayFields = orthoChartTabFieldsOld.ListDisplayFields;
                }
                _listTabDisplayFields.Add(orthoChartTabFields);
            }
            //Always add the orphaned OrthoChartTabFields back because they can not be affected from the Tab Setup window.
            _listTabDisplayFields.AddRange(listOldTabDisplayFields.FindAll(x => x.OrthoChartTab == null));
            //Refresh the combo box and the grid because there is a chance that the user was viewing a different tab than the first in the list.
            FillComboOrthoChartTabs();
            FillGrids();
        }
示例#6
0
        private void FillGrids()
        {
            labelCategory.Text = _listOrthoChartTabs[0].TabName;          //Placed here so that Up/Down buttons will affect the label text.
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g("FormDisplayFields", "Description"), 200);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("FormDisplayFields", "Width"), 80);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            OrthoChartTabFields orthoChartTabFields = GetSelectedFields();

            _listAvailableFields = GetAllFields();
            for (int i = 0; i < orthoChartTabFields.ListDisplayFields.Count; i++)
            {
                DisplayField df = orthoChartTabFields.ListDisplayFields[i];
                _listAvailableFields.Remove(df);
                ODGridRow row = new ODGridRow();
                row.Tag = df;
                string description = df.Description;
                if (!string.IsNullOrEmpty(df.DescriptionOverride))
                {
                    description += " (" + df.DescriptionOverride + ")";
                }
                row.Cells.Add(description);
                row.Cells.Add(df.ColumnWidth.ToString());
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            listAvailable.Items.Clear();
            for (int i = 0; i < _listAvailableFields.Count; i++)
            {
                listAvailable.Items.Add(_listAvailableFields[i].Description);
            }
        }
        private void LoadDisplayFields()
        {
            OrthoChartTabs.RefreshCache();
            OrthoChartTabLinks.RefreshCache();
            DisplayFields.RefreshCache();
            _listAllDisplayFields = DisplayFields.GetAllAvailableList(DisplayFieldCategory.OrthoChart);
            _listTabDisplayFields = new List <OrthoChartTabFields>();
            //Add all fields that are actively associated to a tab to our class wide list of tabs and fields.
            for (int i = 0; i < _listOrthoChartTabs.Count; i++)
            {
                OrthoChartTabFields orthoChartTabFields = new OrthoChartTabFields();
                orthoChartTabFields.OrthoChartTab     = _listOrthoChartTabs[i];
                orthoChartTabFields.ListDisplayFields = new List <DisplayField>();
                List <OrthoChartTabLink> listOrthoChartTabLinks = _listOrthoChartTabLinks.FindAll(
                    x => x.OrthoChartTabNum == _listOrthoChartTabs[i].OrthoChartTabNum
                    );
                listOrthoChartTabLinks.OrderBy(x => x.ItemOrder);
                foreach (OrthoChartTabLink orthoChartTabLink in listOrthoChartTabLinks)
                {
                    orthoChartTabFields.ListDisplayFields.AddRange(_listAllDisplayFields.FindAll(x => x.DisplayFieldNum == orthoChartTabLink.DisplayFieldNum));
                }
                _listTabDisplayFields.Add(orthoChartTabFields);
            }
            //Add a dummy OrthoChartTabFields object to the list that represents available fields that are not part of any tab.
            //These "display fields" were previously used at least once. A patient has info for this field, then the office removed the field from all tabs.
            List <DisplayField> listOrphanedFields = _listAllDisplayFields.FindAll(x => x.DisplayFieldNum == 0 ||
                                                                                   !OrthoChartTabLinks.GetExists(y => y.DisplayFieldNum == x.DisplayFieldNum));

            if (listOrphanedFields != null && listOrphanedFields.Count > 0)
            {
                OrthoChartTabFields orphanedFields = new OrthoChartTabFields();
                orphanedFields.OrthoChartTab     = null;          //These are fields not associated to any tab.  Purposefully use null.
                orphanedFields.ListDisplayFields = new List <DisplayField>();
                orphanedFields.ListDisplayFields.AddRange(listOrphanedFields);
                _listTabDisplayFields.Add(orphanedFields);
            }
        }
示例#8
0
        private void butOK_Click(object sender, EventArgs e)
        {
            OrthoChartTabFields orphanedTab = _listTabDisplayFields.Find(x => x.OrthoChartTab == null);

            //No need to do anything if nothing changed and there are no 'orphaned' display fields to delete.
            if (!changed && (orphanedTab != null && orphanedTab.ListDisplayFields.All(x => x.DisplayFieldNum == 0)))
            {
                DialogResult = DialogResult.OK;
                return;
            }
            //Get all fields associated to a tab in order to sync with the database later.
            List <DisplayField> listAllFields = GetAllFields(false);

            if (listAllFields.Count(x => x.InternalName == "Signature") > 1)
            {
                MessageBox.Show(Lan.g(this, "Only one display field can be a signature field.  Fields that have the signature field checkbox checked:") + " "
                                + string.Join(", ", listAllFields.FindAll(x => x.InternalName == "Signature").Select(x => x.Description)));
                return;
            }
            //Ensure all new displayfields have a primary key so that tab links can be created below.  Update existing displayfields.
            foreach (DisplayField df in listAllFields)
            {
                if (df.DisplayFieldNum == 0)               //New displayfield
                {
                    DisplayFields.Insert(df);
                }
                else                  //Existing displayfield.
                {
                    DisplayFields.Update(df);
                }
            }
            DataValid.SetInvalid(InvalidType.DisplayFields);
            //Remove tab links which no longer exist.  Update tab link item order for tab links which still belong to the same tab.
            List <OrthoChartTabLink> listOrthoChartTabLinks = OrthoChartTabLinks.GetDeepCopy();

            for (int i = listOrthoChartTabLinks.Count - 1; i >= 0; i--)
            {
                OrthoChartTabLink   orthoChartTabLink   = listOrthoChartTabLinks[i];
                OrthoChartTabFields orthoChartTabFields = _listTabDisplayFields.FirstOrDefault(
                    x => x.OrthoChartTab != null && x.OrthoChartTab.OrthoChartTabNum == orthoChartTabLink.OrthoChartTabNum);
                if (orthoChartTabFields == null)
                {
                    continue;                    //The tab was hidden and we are going to leave the tab links alone.
                }
                DisplayField df = orthoChartTabFields.ListDisplayFields.FirstOrDefault(x => x.DisplayFieldNum == orthoChartTabLink.DisplayFieldNum);
                if (df == null)               //The tab link no longer exists (was removed).
                {
                    listOrthoChartTabLinks.RemoveAt(i);
                }
                else                  //The tab link still exists.  Update the link with any changes.
                {
                    orthoChartTabLink.ItemOrder = orthoChartTabFields.ListDisplayFields.IndexOf(df);
                }
            }
            //Add new tab links which were just created.
            foreach (OrthoChartTabFields orthoChartTabFields in _listTabDisplayFields)
            {
                //Skip "orphaned" fields that just show in the available fields list.
                if (orthoChartTabFields.OrthoChartTab == null)
                {
                    continue;
                }
                foreach (DisplayField df in orthoChartTabFields.ListDisplayFields)
                {
                    OrthoChartTabLink orthoChartTabLink = listOrthoChartTabLinks.FirstOrDefault(
                        x => x.OrthoChartTabNum == orthoChartTabFields.OrthoChartTab.OrthoChartTabNum && x.DisplayFieldNum == df.DisplayFieldNum);
                    if (orthoChartTabLink != null)
                    {
                        continue;
                    }
                    orthoChartTabLink                  = new OrthoChartTabLink();
                    orthoChartTabLink.ItemOrder        = orthoChartTabFields.ListDisplayFields.IndexOf(df);
                    orthoChartTabLink.OrthoChartTabNum = orthoChartTabFields.OrthoChartTab.OrthoChartTabNum;
                    orthoChartTabLink.DisplayFieldNum  = df.DisplayFieldNum;
                    listOrthoChartTabLinks.Add(orthoChartTabLink);
                }
            }
            //Delete any display fields that have a valid PK and are in the "orphaned" list.
            //This is fine to do because the field will show back up in the available list of display fields if a patient is still using the field.
            //This is because we link the ortho chart display fields by their name instead of by their PK.
            if (orphanedTab != null)           //An orphaned list actually exists.
            //Look for any display fields that have a valid PK (this means the user removed this field from every tab and we need to delete it).
            {
                List <DisplayField> listFieldsToDelete = orphanedTab.ListDisplayFields.FindAll(x => x.DisplayFieldNum != 0);
                listFieldsToDelete.ForEach(x => DisplayFields.Delete(x.DisplayFieldNum));
            }
            OrthoChartTabLinks.Sync(listOrthoChartTabLinks, OrthoChartTabLinks.GetDeepCopy());
            DataValid.SetInvalid(InvalidType.OrthoChartTabs);
            DialogResult = DialogResult.OK;
        }