private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                var selectedGroups = listGroups.Items.Cast <ListViewItem>()
                                     .Select(x => x.Tag)
                                     .OfType <int>()
                                     .ToList();

                var formAddGroup = new FormAddGroup(_views, selectedGroups);
                if (formAddGroup.ShowDialog() == DialogResult.OK)
                {
                    foreach (var groupID in formAddGroup.SelectedGroups)
                    {
                        var hasDuplicates = _views.MainForm.datasetBilling.RegexpToGroups.Any(x => !x.IsIDNull() && x.ID == _regExpID && !x.IsGroupIDNull() && x.GroupID == groupID);
                        if (!hasDuplicates)
                        {
                            _views.MainForm.datasetBilling.RegexpToGroups.AddRegexpToGroupsRow(_regExpID, groupID);
                        }
                    }

                    ///////////////////////////////////////////////////////////////////////////////

                    _views.MainForm.adapterRegexpToGroupsBilling.Update(_views.MainForm.datasetBilling.RegexpToGroups);
                    _views.MainForm.adapterRegexpToGroupsBilling.Fill(_views.MainForm.datasetBilling.RegexpToGroups);

                    ///////////////////////////////////////////////////////////////////////////////

                    FillGroups();
                }
            }
            catch (Exception ex)
            {
                MainForm.ShowExceptionMessage(ex);
            }
        }
Example #2
0
        private void btnGroupAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (listFilters.SelectedItems.Count > 0)
                {
                    var selectedGroups = listGroups.Items.Cast <ListViewItem>()
                                         .Select(x => x.Tag)
                                         .OfType <int>()
                                         .ToList();

                    var formAddGroup = new FormAddGroup(_views, selectedGroups);
                    if (formAddGroup.ShowDialog() == DialogResult.OK)
                    {
                        var selectedFilterID = (int)listFilters.SelectedItems[0].Tag;

                        ///////////////////////////////////////////////////////////////////////////////

                        var filterRow = _views.MainForm.datasetBilling.ICDFilters.FirstOrDefault(x => x.FilterID == selectedFilterID);
                        if (filterRow == null)
                        {
                            filterRow = _views.MainForm.datasetBilling.ICDFilters.NewICDFiltersRow();
                        }

                        ///////////////////////////////////////////////////////////////////////////////

                        List <int> groupIDs;

                        if (!filterRow.IsGroupIDsNull())
                        {
                            groupIDs = filterRow.GroupIDs.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                                       .Select(x => Convert.ToInt32(x))
                                       .ToList();
                        }
                        else
                        {
                            groupIDs = new List <int>();
                        }

                        ///////////////////////////////////////////////////////////////////////////////

                        foreach (var groupID in formAddGroup.SelectedGroups)
                        {
                            if (groupIDs.Contains(groupID))
                            {
                                continue;
                            }

                            groupIDs.Add(groupID);

                            ///////////////////////////////////////////////////////////////////////////////

                            var listItem = new ListViewItem
                            {
                                Text = _views.MainForm.datasetBilling.ICD9Groups.Single(x => x.GroupID == groupID)
                                       .Name,
                                Tag = groupID
                            };

                            listGroups.Items.Add(listItem);
                        }

                        ///////////////////////////////////////////////////////////////////////////////

                        filterRow.GroupIDs = String.Join(",", groupIDs);

                        if (filterRow.RowState == DataRowState.Detached)
                        {
                            _views.MainForm.datasetBilling.ICDFilters.AddICDFiltersRow(filterRow);
                        }

                        ///////////////////////////////////////////////////////////////////////////////

                        _views.MainForm.adapterRegexpToGroupsBilling.Update(_views.MainForm.datasetBilling.RegexpToGroups);
                        _views.MainForm.adapterRegexpToGroupsBilling.Fill(_views.MainForm.datasetBilling.RegexpToGroups);

                        _views.MainForm.adapterICDFiltersBilling.Update(_views.MainForm.datasetBilling.ICDFilters);
                        _views.MainForm.adapterICDFiltersBilling.Fill(_views.MainForm.datasetBilling.ICDFilters);

                        FillGroupsList();
                    }
                }
            }
            catch (Exception ex)
            {
                MainForm.ShowExceptionMessage(ex);
            }
        }