Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            InsuranceCompanies.AddRange(insuranceCompaniesJID.Keys);
            DateBegin = DateTime.Now.Date.AddDays(DateTime.Now.Day * -1);
            DateEnd   = DateBegin;
            DateBegin = DateBegin.AddDays((DateBegin.Day - 1) * -1);
            IsCheckedLoadTypeTreatmentsDetails = true;

            DataContext = this;

            //Loaded += (s, e) => {
            //	if (Debugger.IsAttached) {
            //		SelectedFile = @"C:\Users\nn-admin\Desktop\PL шаблон.xlsx";
            //		IsCheckedLoadTypeProfitAndLoss = true;
            //		ReadSheetNames();
            //	}
            //};

            Closing += (s, e) => {
                if ((bwReadFile != null && bwReadFile.IsBusy) ||
                    (bwLoadToDb != null && bwLoadToDb.IsBusy))
                {
                    if (MessageBox.Show(
                            this,
                            "Текущие операции еще не завершены" + Environment.NewLine +
                            "Данные могут быть потеряны" + Environment.NewLine +
                            "Вы уверены, что хотите завершить работу?",
                            string.Empty,
                            MessageBoxButton.YesNo,
                            MessageBoxImage.Question) == MessageBoxResult.No)
                    {
                        e.Cancel = true;
                    }
                }
            };

            timerWorkIndicator          = new DispatcherTimer();
            timerWorkIndicator.Interval = TimeSpan.FromMilliseconds(300);
            timerWorkIndicator.Tick    += (s, e) => {
                UpdateProgress(string.Empty, true);
            };
        }
        async private Task <bool> getClaims()
        {
            if (Claims == null)
            {
                Claims = new ObservableCollection <Claim>();

                foreach (DTO_Claim claim in ServiceLayer.ClaimsList)
                {
                    Claims.Add(new Claim(claim));
                    Customer cust = Customers.Where(c => c.CustomerID == Claims.Last().CustomerID).Single();
                    Claims.Last().CustomerName         = cust.FirstName + " " + cust.LastName;
                    Address address                    = Addresses.Where(a => a.AddressID == Claims.Last().PropertyID).Single();
                    Claims.Last().Address              = address.StreetAddress + ", " + address.Zip;
                    Claims.Last().InsuranceCompanyName = InsuranceCompanies.Where(i => i.InsuranceCompanyID == Claims.Last().InsuranceCompanyID).Single().CompanyName;
                }
            }

            return(true);
        }
        async private void accountSelected(object o)
        {
            if (o is Claim)
            {
                Claim = o as Claim;
                // Retrieve the Customer, Property Address, Billing Address, previous Inspection, and Lead information.
                Customer           = Customers.Where(c => c.CustomerID == Claim.CustomerID).Single();
                IsExistingCustomer = true;

                PropertyAddress   = Addresses.Where(a => a.AddressID == Claim.PropertyID).Single();
                IsExistingAddress = true;

                // Check if the BillingID is the same as PropertyID
                if (Claim.BillingID == Claim.PropertyID)
                {
                    /// BillingSameAsProperty = true;
                    BillingAddress = PropertyAddress;
                }
                else // If it's not retrieve the BillingAddress from the server
                {
                    ///BillingSameAsProperty = false;
                    BillingAddress = Addresses.Where(a => a.AddressID == Claim.BillingID).Single();
                }

                Lead = Leads.Where(l => l.LeadID == Claim.LeadID).Single();

                if (Lead.LeadTypeID == 1)
                {
                    if ((ErrorMessage = await new ServiceLayer().GetKnockerResponseByID(new DTO_KnockerResponse {
                        KnockerResponseID = (int)Lead.KnockerResponseID
                    })) != null)
                    {
                        return;
                    }
                    else
                    {
                        KnockerResponse = new KnockerResponse(ServiceLayer.KnockerResponse);
                    }
                }
                else if (Lead.LeadTypeID == 2)
                {
                    if ((ErrorMessage = await new ServiceLayer().GetReferrerByID(new DTO_Referrer {
                        ReferrerID = (int)Lead.CreditToID
                    })) != null)
                    {
                        return;
                    }
                    else
                    {
                        Referrer = new Referrer(ServiceLayer.Referrer);
                    }
                }

                Inspection = Inspections.Where(i => i.ClaimID == Claim.ClaimID).Single();

                Claim.InsuranceCompanyName = InsuranceCompanies.Where(i => i.InsuranceCompanyID == Claim.InsuranceCompanyID).Single().CompanyName;
            }
            else if (o is Lead)
            {
                Lead = o as Lead;
                // Retrieve the Customer and Property Address Information, and Claim if there is one attached.
                Customer           = Customers.Where(c => c.CustomerID == Lead.CustomerID).Single();
                IsExistingCustomer = true;
                PropertyAddress    = Addresses.Where(a => a.AddressID == Lead.AddressID).Single();
                IsExistingAddress  = true;
                BillingAddress     = null;

                // Check if any Claims are connected to the Lead
                if (Claims.Any(c => c.LeadID == Lead.LeadID))
                {
                    Claim = Claims.Where(c => c.LeadID == Lead.LeadID).Single();

                    // Check if BillingID is the same as PropertyID
                    if (Claim.BillingID == Claim.PropertyID)
                    {
                        ///BillingSameAsProperty = true;
                        BillingAddress     = PropertyAddress;
                        IsExistingAddressB = true;
                    }
                    else // If it's not retrieve the BillingAddress from the server
                    {
                        ///BillingSameAsProperty = false;
                        BillingAddress = Addresses.Where(a => a.AddressID == Claim.BillingID).Single();
                    }

                    // Retrieve the Inspection attached to the Claim
                    if ((ErrorMessage = await new ServiceLayer().GetInspectionsByClaimID(Claim.toDTO())) != null)
                    {
                        return;
                    }

                    Inspection = new Inspection(ServiceLayer.InspectionsList.Last());
                }
                else // Instantiate the Claim object
                {
                    Claim = new Claim {
                        LeadID = Lead.LeadID
                    };
                }

                BillingAddress = new Address();
                ///LeadIsAttached = true;
            }
            else if (o is Customer)
            {
                Customer = o as Customer;
            }
            else if (o is Address && code == 4)
            {
                PropertyAddress = o as Address;
            }
            else if (o is Address && code == 5)
            {
                BillingAddress = o as Address;
            }

            else if (o is Adjuster && code == 6)
            {
                Adjuster = o as Adjuster;
            }
            else if (o is Adjustment && code == 7)
            {
                Adjustment = o as Adjustment;
            }
            else if (o == null)
            {
                //AddLead.Execute(o);
            }

            CurrentPage = new ClaimHUDView();
            //OnRequestClose(this, new EventArgs());
        }