public void SetItemDetails()
        {
            if (currentGroupItem == null || currentGroupItem.IsSpoof)
            {
                SelectedBrand          = null;
                SelectedFreq           = null;
                SelectedDeliveryMethod = null;
                SelectedPlatform       = null;
                SelectedSpecialist     = null;
                ContractName           = null;
                if (ReportTypes != null)
                {
                    ReportTypes.ForEach((thislist, thisreport) => RemoveWeakEventListener(thisreport, ReportListener));
                    ReportTypes = new ObservableReportTypes(safeReportTypes, true);
                    ReportTypes.ForEach((thislist, thisreport) => AddWeakEventListener(thisreport, ReportListener));
                }
                ClientLocations = null;

                RaisePropertyChanged("ReportTypes");
                ReportText = "Select Report Types...";
                return;
            }

            if (/*DB.Connnected &&*/ ReportTypes == null)
            {
                ReportTypes     = new ObservableReportTypes(ReportTypesTarget.GetReportTypesAsList());
                safeReportTypes = new ObservableReportTypes(ReportTypes, true);
            }

            if (CurrentGroupItem.ContractID == null)
            {
                ContractName = "No Contract assigned.";
            }
            else
            {
                Contract contract = ContractTarget.GetByContractID((int)CurrentGroupItem.ContractID);
                if (contract == null)
                {
                    ContractName = "No contract found for this Group.";
                }
                else
                {
                    ContractName = contract.DESCR;
                }
            }
            AddWeakEventListener(CurrentGroupItem, EncryptListener);

            IgReports = InvoiceGrpReportsTarget.GetById(currentGroupItem.InvoiceGrpId);

            foreach (ReportType reportType in ReportTypes)
            {
                foreach (InvoiceGrpReport igr in IgReports)
                {
                    if (igr.REPORT_TYPE_ID == reportType.REPORT_TYPE_ID)
                    {
                        reportType.IsSelected = true;
                    }
                    else
                    {
                        reportType.IsSelected = false;
                    }
                }
            }
            RaisePropertyChanged("ReportTypes");
            base.ViewCore.UpdateCB();

            SelectedSpecialist       = (Specialists.First(ss => ss.Id == currentGroupItem.BillingSpecialistID) as BillingSpecialist);
            SelectedFreq             = (Freqs.First(f => f.FREQ == currentGroupItem.BillingFrequency) as Freq);
            SelectedPlatform         = (Platforms.First(p => p.PLATFORM == currentGroupItem.PrimaryPlatform) as Platform);
            SelectedDeliveryMethod   = (DeliveryMethods.First(dm => dm.TheDeliveryMethod == currentGroupItem.DeliveryMethod) as DeliveryMethod);
            SelectedBrand            = (Brands.FirstOrDefault(b => b.BRAND == currentGroupItem.Brand) as Brand);
            SelectedRemitTo          = (RemitTos.First(r => r.REMIT_TO_ID == currentGroupItem.RemitToID) as RemitTo);
            SelectedInvoiceStyle     = (InvoiceStyles.First(i => i.INVOICE_STYLE == currentGroupItem.InvoiceStyle) as InvoiceStyle);
            SelectedInvoiceGrpStatus = (InvoiceGrpStatuss.First(i => i.INVOICE_GRP_STATUS == currentGroupItem.InvoiceGroupStatus) as InvoiceGrpStatus);

            if (ClientLocations != null)
            {
                ClientLocations.CollectionChanged -= ClientLocCollectionChanged;
            }
            ClientLocations = ExtClientTarget.FetchLocations(CurrentGroupItem.InvoiceGrpId, true);
            ClientLocations.CollectionChanged += ClientLocCollectionChanged;

            currentGroupItem.Modified = false;
            GroupVM.EnablePicker      = true;
        }
        public InvoiceGrpDetailViewModel(IInvoiceGrpDetailView view)
            : base(view)
        {
            ThisView = view;
            BillingSpecialistTarget = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateBillingSpecialistRepository();
            FreqsTarget             = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateFreqRepository();
            PlatformsTarget         = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreatePlatformRepository();
            BrandsTarget            = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateBrandRepository();
            ReportTypesTarget       = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateReportTypeRepository();
            DeliveryMethodsTarget   = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateDeliveryMethodsRepository();
            InvoiceGrpReportsTarget = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateInvoiceGrpReportRepository();
            RemitToTarget           = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateRemitToRepository();
            ExtClientTarget         = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateExtClientRepository();
            DataTarget = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateInvoiceGroupRepository();

            ContractTarget         = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateContractRepository();
            InvoiceStyleTarget     = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateInvoiceStyleRepository();
            InvoiceGrpStatusTarget = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateInvoiceGrpStatusRepository();

            //ContractTarget.ConnectionString.Segments

            if (true /*DB.Connnected*/)
            {
                List <ReportType> lst = ReportTypesTarget.GetReportTypesAsList();
                if (lst != null)
                {
                    ReportTypes = new ObservableReportTypes(ReportTypesTarget.GetReportTypesAsList());
                    ReportTypes.ForEach((types, report) => AddWeakEventListener(report, ReportListener));
                    safeReportTypes = new ObservableReportTypes(ReportTypes, true);
                }
            }



            OnPropertyChanged(new PropertyChangedEventArgs("ItemsSource"));

            SaveCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (HasErrorVM == false && Modified == true),
                ExecuteDelegate    = x => SaveInvoice()
            };

            AddNewCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (Modified == false && PopSwitch == false),
                ExecuteDelegate    = x => AddNewInvoice()
            };

            // Restore the changes
            RestoreCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (Modified == true),
                ExecuteDelegate    = x => CancelChanges()
            };

            DeleteCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (CurrentGroupItem != null),
                ExecuteDelegate    = x => DeleteInvoice()
            };

            PopCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (CurrentGroupItem != null),
                ExecuteDelegate    = x =>
                {
                    if (notAssignedLocations == null)
                    {
                        NotAssignedLocations = this.ExtClientTarget.FetchLocations(0, false);
                    }
                    view.Pop();
                }
            };

            AddLocationsCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (HasSelections == true && CurrentGroupItem != null),
                ExecuteDelegate    = x => AddLocations()
            };

            UnassignLocationsCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (CurrentGroupItem != null && SelectedClientLocations.Count > 0),
                ExecuteDelegate    = x => UnassignLocations()
            };

            FilterByContractCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (CurrentGroupItem != null && CurrentGroupItem.ContractID != null),
                ExecuteDelegate    = x => FilterByContract()
            };

            JumpToContractCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (CurrentGroupItem != null && CurrentGroupItem.ContractID != null),
                ExecuteDelegate    = x => JumpToContract()
            };

            BrowseFolderCommand = new MedQuist.BillingAdmin.ViewModels.SimpleCommand
            {
                CanExecuteDelegate = x => (CurrentGroupItem != null && CurrentGroupItem.ContractID != null),
                ExecuteDelegate    = x => BrowseFolder()
            };

            NoSaveCommand = RestoreCommand;

            SelectedNALocations     = new ObservableCollection <ClientLocation> ();
            SelectedClientLocations = new ObservableCollection <ClientLocation>();
        }