Exemplo n.º 1
0
        public double GetPFdInAt(double freq)
        {
            if (PFdIn == null || Freqs == null || freq < Freqs.First() || freq > Freqs.Last())
            {
                return(Double.NaN);
            }

            int i;

            for (i = 0; i < Freqs.Length && Freqs[i] < freq; i++)
            {
                ;
            }

            if (freq == Freqs[i])
            {
                return(PFdIn[i]);
            }

            // Interpolate (linear)
            return(PFdIn[i - 1] + (PFdIn[i] - PFdIn[i - 1]) / (Freqs[i] - Freqs[i - 1]) * (freq - Freqs[i - 1]));
        }
        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;
        }