public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string customerNumber = value.ToString().Trim();

            if (customerNumber.Length > 2)
            {
                using var _necContext = new NECContext();
                if (_necContext.Rm00101.Any(c => c.Custnmbr != null && c.Custnmbr.Trim() == customerNumber))
                {
                    string customerName = _necContext.Rm00101.First(c => c.Custnmbr != null && c.Custnmbr.Trim() == customerNumber).Custname.Trim();
                    _necContext.Dispose();
                    return(customerName);
                }
                else
                {
                    _necContext.Dispose();
                    return(DependencyProperty.UnsetValue);
                }
            }
            else
            {
                return(DependencyProperty.UnsetValue);
            }

            throw new NotImplementedException();
        }
        private void FillQuoteList()
        {
            using var _ = new NAT01Context();
            List <QuoteHeader> quoteHeader = _.QuoteHeader.Where(q => (q.UserAcctNo.Trim() == CustomerNumber || q.ShipToAccountNo.Trim() == CustomerNumber || q.CustomerNo.Trim() == CustomerNumber) && q.OrderNo == 0 &&
                                                                 !_.OrderHeader.Where(o => o.UserAcctNo == CustomerNumber).Select(o => o.QuoteNumber).Contains((double)q.QuoteNo))
                                             .OrderByDescending(q => q.QuoteNo).ToList();

            _.Dispose();

            foreach (QuoteHeader quote in quoteHeader)
            {
                ContentControl contentControl = new ContentControl()
                {
                    Style = FindResource("QuoteGrid") as Style
                };

                using var __ = new NECContext();
                string customerName = __.Rm00101.First(r => r.Custnmbr == quote.UserAcctNo.Trim() || r.Custnmbr == quote.ShipToAccountNo.Trim() || r.Custnmbr == quote.CustomerNo.Trim()).Custname.Trim();
                __.Dispose();

                contentControl.ApplyTemplate();
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "QuoteNumberTextBlock").Text    = quote.QuoteNo.ToString();
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "QuoteRevNumberTextBlock").Text = quote.QuoteRevNo.ToString();
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "CustomerNameTextBlock").Text   = customerName;

                // QuoteDockPanel.Children.Add(contentControl);
            }
        }
        public CustomerInfoWindow(User _user, MainWindow _parent, string _customerNumber)
        {
            CustomerNumber = _customerNumber;
            user           = _user;
            parent         = _parent;

            using var _  = new NECContext();
            CustomerName = _.Rm00101.First(r => r.Custnmbr.Trim().ToLower() == CustomerNumber.Trim().ToLower()).Custname.Trim();
            _.Dispose();

            InitializeComponent();

            // FillQuoteList();
            FillOrderList();
            FillProjectList();
        }
Beispiel #4
0
        /// <summary>
        /// Instance of a work order, complete with all details about the work order
        /// </summary>
        /// <param name="orderNumber"></param>
        public WorkOrder(int orderNumber, Window parent)
        {
            try
            {
                OrderNumber      = orderNumber;
                Finished         = false;
                CanRunOnAutocell = false;
                this.parent      = parent;

                // nat01context.OrderDetails.Where(o => o.OrderNo == OrderNumber).Load();
                using (var context = new NAT02Context())
                {
                    Finished = context.EoiOrdersMarkedForChecking.Any(o => o.OrderNo == OrderNumber);
                    context.Dispose();
                }
                using (var nat01context = new NAT01Context())
                {
                    LineItemCount = nat01context.OrderDetails.Where(o => o.OrderNo == OrderNumber * 100).Count();
                    lineItems     = nat01context.OrderDetails.Where(o => o.OrderNo == OrderNumber * 100).ToDictionary(kvp => (int)kvp.LineNumber, kvp => kvp.DetailTypeId.Trim());
                    OrderHeader         orderHeader  = nat01context.OrderHeader.Where(o => o.OrderNo == OrderNumber * 100).FirstOrDefault();
                    List <OrderDetails> orderDetails = nat01context.OrderDetails.Where(o => o.OrderNo == OrderNumber * 100).ToList();
                    string repId = "";
                    string csr   = "*NO CSR*";
                    if (nat01context.QuoteHeader.Any(q => q.QuoteNo == orderHeader.QuoteNumber && q.QuoteRevNo == orderHeader.QuoteRevNo))
                    {
                        repId = string.IsNullOrEmpty(nat01context.QuoteHeader.Where(q => q.QuoteNo == orderHeader.QuoteNumber && q.QuoteRevNo == orderHeader.QuoteRevNo).First().QuoteRepId) ? "" : nat01context.QuoteHeader.Where(q => q.QuoteNo == orderHeader.QuoteNumber && q.QuoteRevNo == orderHeader.QuoteRevNo).First().QuoteRepId.Trim();
                        if (nat01context.QuoteRepresentative.Any(qr => qr.RepId == repId))
                        {
                            csr = string.IsNullOrEmpty(nat01context.QuoteRepresentative.Where(qr => qr.RepId == repId).First().Name) ? "*NO CSR*" : nat01context.QuoteRepresentative.Where(qr => qr.RepId == repId).First().Name.Trim();
                        }
                    }
                    string customerName; string endUserName;
                    using (var ctx = new NECContext())
                    {
                        customerName = ctx.Rm00101.Where(c => c.Custnmbr == orderHeader.CustomerNo).FirstOrDefault().Custname;
                        endUserName  = ctx.Rm00101.Where(c => c.Custnmbr == orderHeader.UserAcctNo).FirstOrDefault().Custname;
                        ctx.Dispose();
                    }
                    nat01context.Dispose();
                    SetInfo(orderHeader, csr, customerName, endUserName);
                }
            }
            catch (Exception ex)
            {
                IMethods.WriteToErrorLog("WorkOrder.cs -> OrderNumber: " + OrderNumber, ex.Message, null);
            }
        }
        private void FillOrderList()
        {
            using var _ = new NAT01Context();
            List <OrderHeader> orderHeader = _.OrderHeader.Where(o => o.UserAcctNo.Trim() == CustomerNumber || o.CustomerNo.Trim() == CustomerNumber || o.ShipToAccountNo == CustomerNumber)
                                             .OrderByDescending(o => o.OrderNo).ToList();

            _.Dispose();

            foreach (OrderHeader order in orderHeader)
            {
                ContentControl contentControl = new ContentControl()
                {
                    Style = FindResource("OrderGrid") as Style
                };

                bool notShipped = order.ShippedYn.Trim() == "N";
                bool rush       = order.RushYorN == "Y" || order.PaidRushFee == "Y";

                using var __ = new NECContext();
                string customerName = __.Rm00101.First(r => r.Custnmbr == order.UserAcctNo || r.Custnmbr == order.CustomerNo || r.Custnmbr == order.ShipToAccountNo).Custname.Trim();
                __.Dispose();

                contentControl.ApplyTemplate();

                foreach (TextBlock tb in (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>())
                {
                    if (notShipped)
                    {
                        tb.FontStyle = FontStyles.Oblique;
                    }
                    if (rush)
                    {
                        tb.Foreground = new SolidColorBrush(Colors.DarkRed);
                    }
                }

                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "OrderNumberTextBlock").Text    = (order.OrderNo / 100).ToString();
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "QuoteNumberTextBlock").Text    = order.QuoteNumber.ToString();
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "QuoteRevNumberTextBlock").Text = order.QuoteRevNo.ToString();
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "CustomerNameTextBlock").Text   = customerName;

                OrderDockPanel.Children.Add(contentControl);
            }
        }
        private void FillNotifications()
        {
            NM_DockPanel.Children.Clear();

            using var _ = new NAT02Context();
            List <EoiNotificationsActive> active = _.EoiNotificationsActive.Where(n => n.User == user.DomainName).OrderBy(a => a.Timestamp).ToList();
            List <EoiNotificationsViewed> viewed = _.EoiNotificationsViewed.Where(n => n.User == user.DomainName).OrderBy(a => a.Timestamp).ToList();

            List <(int Id, string Number, string CustomerName, string Message, bool Bl, string Type)> notifications = new List <(int, string, string, string, bool, string)>();

            foreach (EoiNotificationsActive a in active)
            {
                using var __  = new NAT01Context();
                using var ___ = new NECContext();
                using var _projectsContext = new ProjectsContext();
                string acctNo   = "";
                string custName = "";
                if (a.Type == "Project")
                {
                    if (_projectsContext.EngineeringProjects.Any(ep => ep.ProjectNumber == a.Number))
                    {
                        string endUserName  = _projectsContext.EngineeringProjects.First(ep => ep.ProjectNumber == a.Number).EndUserName;
                        string customerName = _projectsContext.EngineeringProjects.First(ep => ep.ProjectNumber == a.Number).CustomerName;
                        string shipToName   = _projectsContext.EngineeringProjects.First(ep => ep.ProjectNumber == a.Number).ShipToName;
                        custName =
                            !string.IsNullOrEmpty(endUserName) && !string.IsNullOrWhiteSpace(endUserName) ? endUserName :
                            !string.IsNullOrEmpty(customerName) && !string.IsNullOrWhiteSpace(customerName) ? customerName :
                            !string.IsNullOrEmpty(shipToName) && !string.IsNullOrWhiteSpace(shipToName) ? shipToName : "";
                    }
                    else if (_projectsContext.EngineeringArchivedProjects.Any(eap => eap.ProjectNumber == a.Number))
                    {
                        string rev = _projectsContext.EngineeringArchivedProjects.Where(eap => eap.ProjectNumber == a.Number).Max(p => p.RevNumber);

                        string endUserName  = _projectsContext.EngineeringArchivedProjects.First(eap => eap.ProjectNumber == a.Number && eap.RevNumber == rev).EndUserName;
                        string customerName = _projectsContext.EngineeringArchivedProjects.First(eap => eap.ProjectNumber == a.Number && eap.RevNumber == rev).CustomerName;
                        string shipToName   = _projectsContext.EngineeringArchivedProjects.First(eap => eap.ProjectNumber == a.Number && eap.RevNumber == rev).ShipToName;
                        custName =
                            !string.IsNullOrEmpty(endUserName) && !string.IsNullOrWhiteSpace(endUserName) ? endUserName :
                            !string.IsNullOrEmpty(customerName) && !string.IsNullOrWhiteSpace(customerName) ? customerName :
                            !string.IsNullOrEmpty(shipToName) && !string.IsNullOrWhiteSpace(shipToName) ? shipToName : "";
                    }
                }
                else
                {
                    acctNo   = __.OrderHeader.Single(o => o.OrderNo / 100 == double.Parse(a.Number)).UserAcctNo;
                    custName = ___.Rm00101.Single(r => r.Custnmbr.Trim() == acctNo.Trim()).Custname;
                }

                notifications.Add((a.Id, a.Number, custName, a.Message, true, a.Type));
                __.Dispose();
                ___.Dispose();
                _projectsContext.Dispose();
            }
            foreach (EoiNotificationsViewed v in viewed)
            {
                using var __  = new NAT01Context();
                using var ___ = new NECContext();
                using var _projectsContext = new ProjectsContext();
                string acctNo   = "";
                string custName = "";
                if (v.Type == "Project")
                {
                    if (_projectsContext.EngineeringProjects.Any(ep => ep.ProjectNumber == v.Number))
                    {
                        string endUserName  = _projectsContext.EngineeringProjects.First(ep => ep.ProjectNumber == v.Number).EndUserName;
                        string customerName = _projectsContext.EngineeringProjects.First(ep => ep.ProjectNumber == v.Number).CustomerName;
                        string shipToName   = _projectsContext.EngineeringProjects.First(ep => ep.ProjectNumber == v.Number).ShipToName;
                        custName =
                            !string.IsNullOrEmpty(endUserName) && !string.IsNullOrWhiteSpace(endUserName) ? endUserName :
                            !string.IsNullOrEmpty(customerName) && !string.IsNullOrWhiteSpace(customerName) ? customerName :
                            !string.IsNullOrEmpty(shipToName) && !string.IsNullOrWhiteSpace(shipToName) ? shipToName : "";
                    }
                    else if (_projectsContext.EngineeringArchivedProjects.Any(eap => eap.ProjectNumber == v.Number))
                    {
                        string rev = _projectsContext.EngineeringArchivedProjects.Where(eap => eap.ProjectNumber == v.Number).Max(p => p.RevNumber);

                        string endUserName  = _projectsContext.EngineeringArchivedProjects.First(eap => eap.ProjectNumber == v.Number && eap.RevNumber == rev).EndUserName;
                        string customerName = _projectsContext.EngineeringArchivedProjects.First(eap => eap.ProjectNumber == v.Number && eap.RevNumber == rev).CustomerName;
                        string shipToName   = _projectsContext.EngineeringArchivedProjects.First(eap => eap.ProjectNumber == v.Number && eap.RevNumber == rev).ShipToName;
                        custName =
                            !string.IsNullOrEmpty(endUserName) && !string.IsNullOrWhiteSpace(endUserName) ? endUserName :
                            !string.IsNullOrEmpty(customerName) && !string.IsNullOrWhiteSpace(customerName) ? customerName :
                            !string.IsNullOrEmpty(shipToName) && !string.IsNullOrWhiteSpace(shipToName) ? shipToName : "";
                    }
                }
                else
                {
                    acctNo   = __.OrderHeader.Single(o => o.OrderNo / 100 == double.Parse(v.Number)).UserAcctNo;
                    custName = ___.Rm00101.Single(r => r.Custnmbr.Trim() == acctNo.Trim()).Custname;
                }
                notifications.Add((v.NotificationId, v.Number, custName, v.Message, false, v.Type));
                __.Dispose();
                ___.Dispose();
                _projectsContext.Dispose();
            }

            if (notifications.Count > 0)
            {
                notifications.OrderBy(n => n.Item1);

                foreach ((int Id, string Number, string CustomerName, string Message, bool Bl, string Type)notification in notifications)
                {
                    ContentControl contentControl = new ContentControl()
                    {
                        Style = notification.Bl ? FindResource("ActiveNotificationGrid") as Style :
                                FindResource("InactiveNotificationGrid") as Style
                    };

                    contentControl.ApplyTemplate();
                    (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "OrderNumberTextBlock").Text         = notification.Number;
                    (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "CustomerNameTextBlock").Text        = notification.CustomerName;
                    (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "NotificationMessageTextBlock").Text =
                        notification.Message.Replace("Document", notification.Type);

                    NM_DockPanel.Children.Add(contentControl);
                }
            }
            else
            {
                TextBlock textBlock = new TextBlock
                {
                    Text                = "No new notifications." + Environment.NewLine + "Check back later.",
                    Style               = Application.Current.Resources["BoldTextBlock"] as Style,
                    FontSize            = 20,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    TextAlignment       = TextAlignment.Center,
                    Opacity             = .5,
                    Cursor              = Cursors.Arrow
                };
                NotificationWindowGrid.Children.Add(textBlock);
            }

            //List<EoiAllOrdersView> orders = _.EoiAllOrdersView.OrderBy(o => o.OrderNumber).ToList();

            //foreach (EoiAllOrdersView order in orders)
            //{
            //    ContentControl contentControl = new ContentControl()
            //    {
            //        Style = FindResource("OrderGrid") as Style
            //    };

            //    contentControl.ApplyTemplate();
            //    Grid grid = (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType<Grid>().First();

            //    string location = "";
            //    string state = "";

            //    if (order.BeingEntered == 1)
            //    {
            //        location = "Order Entry";
            //        state = "Being Converted to Order";
            //    }
            //    else if (order.EnteredUnscanned == 1)
            //    {
            //        location = "Order Entry/Eng.";
            //        state = "Ready for Engineering";
            //    }
            //    else if (order.InEngineering == 1)
            //    {
            //        location = "Engineering";
            //        if (order.BeingChecked == 1)
            //        {
            //            state = "Being Checked";
            //        }
            //        else if (order.MarkedForChecking == 1)
            //        {
            //            state = "Ready to be Checked";
            //        }
            //        else
            //        {
            //            state = "Being Drawn";
            //        }
            //    }
            //    else if (order.ReadyToPrint == 1)
            //    {
            //        location = "Engineering";
            //        state = "Ready to Print";
            //    }
            //    else if (order.Printed == 1)
            //    {
            //        location = "Engineering";
            //        state = "Printed/Ready for Production";
            //    }
            //    else if (order.InTheOffice == 1)
            //    {
            //        location = "Office";
            //        state = "Sent to Office";
            //    }

            //    if (order.DoNotProcess == 1)
            //    {
            //        grid.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#55FFC0CB"));
            //    }
            //    else if (order.DoNotProcess == 1)
            //    {
            //        grid.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#55FFC0CB"));
            //    }

            //    if (order.RushYorN == "Y" || order.PaidRushFee == "Y")
            //    {
            //        foreach (TextBlock textBlock in grid.Children.OfType<TextBlock>()) { textBlock.Foreground = FindResource("Tertiary.Dark") as SolidColorBrush; }
            //    }

            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "OrderNumberTextBlock").Text = order.OrderNumber.ToString();
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "QuoteNumberTextBlock").Text = order.QuoteNumber.ToString();
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "QuoteRevNumberTextBlock").Text = order.QuoteRev.ToString();
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "CustomerNameTextBlock").Text = order.CustomerName.Trim();
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "NumDaysToShipTextBlock").Text = order.NumDaysToShip.ToString();
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "NumDaysInDeptTextBlock").Text = order.DaysInDept.ToString();
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "EmployeeTextBlock").Text = order.EmployeeName;
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "LocationTextBlock").Text = location;
            //    grid.Children.OfType<TextBlock>().Single(tb => tb.Name == "StateTextBlock").Text = state;

            //    NM_DockPanel.Children.Add(contentControl);
            //}

            //for (int i = 0; i < 10; i++)
            //{
            //    ContentControl contentControl = new ContentControl()
            //    {
            //        Style = FindResource("ActiveNotificationGrid") as Style
            //    };
            //    NM_DockPanel.Children.Add(contentControl);
            //}

            _.Dispose();
        }
        private void FillProjectList()
        {
            using var _ = new ProjectsContext();
            List <ProjectSpecSheet> projectSpecSheet = _.ProjectSpecSheet.Where(p => (p.InternationalId != "N/A" ? p.InternationalId == CustomerNumber : p.CustomerNumber == CustomerNumber) &&
                                                                                // ((!(bool)p.Tools && string.IsNullOrEmpty(p.TabletCheckedBy)) || ((bool)p.Tools && string.IsNullOrEmpty(p.ToolCheckedBy))) &&
                                                                                p.HoldStatus != "CANCELED" && p.HoldStatus != "CANCELLED" && p.HoldStatus != "ON HOLD")
                                                       .OrderByDescending(p => p.ProjectNumber).ToList();

            _.Dispose();

            foreach (ProjectSpecSheet project in projectSpecSheet)
            {
                ContentControl contentControl = new ContentControl()
                {
                    Style = FindResource("ProjectGrid") as Style
                };

                SolidColorBrush back;
                SolidColorBrush fore;
                FontWeight      fontWeight;
                FontStyle       fontStyle;
                bool            priority = project.MarkedPriority is null ? false : project.MarkedPriority == "PRIORITY";
                using var nat02context = new NAT02Context();
                bool finished = nat02context.EoiProjectsFinished.Where(p => p.ProjectNumber == project.ProjectNumber && p.RevisionNumber == project.RevisionNumber).Any() ||
                                ((bool)project.Tools && project.ToolCheckedBy.Length > 0) ||
                                ((bool)project.Tablet && !(bool)project.Tools && project.TabletCheckedBy.Length > 0);
                nat02context.Dispose();
                bool   onHold = project.HoldStatus == "On Hold";
                string stage  = "";

                // Tablet
                //       Entered:   tablet=true, tabletstartedby=""
                //       Started:   tablet=true, tabletdrawnby=""
                //       Drawn:     tablet=true, tabletsubmittedby=""
                //       Submitted: tablet=true, tabletcheckedby=""
                //       Finished:  tablet=true, tool=false, projectfinished=true
                // Tool
                //       Entered:   tools=true, toolstartedby=""
                //       Started:   tools=true, tooldrawnby=""
                //       Drawn:     tools=true, toolcheckedby=""
                //       Finished:  tools=true, projectfinished=true

                bool tablet          = (bool)project.Tablet;
                bool tool            = (bool)project.Tools;
                bool tabletEntered   = false;
                bool tabletStarted   = false;
                bool tabletDrawn     = false;
                bool tabletSubmitted = false;
                bool tabletFinished  = false;
                bool toolEntered     = false;
                bool toolStarted     = false;
                bool toolDrawn       = false;
                bool toolFinished    = false;

                if (tablet && !tool)
                {
                    tabletFinished = finished;
                    if (tabletFinished)
                    {
                        stage = "Tablet Finished";
                        goto JumpPoint;
                    }
                    tabletSubmitted = project.TabletSubmittedBy is null ? false : project.TabletSubmittedBy.Length > 0;
                    if (tabletSubmitted)
                    {
                        stage = "Tablet Being Checked";
                        goto JumpPoint;
                    }
                    tabletDrawn = project.TabletDrawnBy.Length > 0;
                    if (tabletDrawn)
                    {
                        stage = "Tablet Drawn";
                        goto JumpPoint;
                    }
                    tabletStarted = project.ProjectStartedTablet.Length > 0;
                    if (tabletStarted)
                    {
                        stage = "Tablet Started";
                        goto JumpPoint;
                    }
                    tabletEntered = !tabletSubmitted && !tabletDrawn && !tabletStarted && !tabletFinished;
                    if (tabletEntered)
                    {
                        stage = "Tablet Entered";
                        goto JumpPoint;
                    }
                }
                else if (tablet && tool)
                {
                    toolFinished = finished;
                    if (toolFinished)
                    {
                        stage = "Tool Finished";
                        goto JumpPoint;
                    }
                    toolDrawn = project.ToolDrawnBy.Length > 0;
                    if (toolDrawn)
                    {
                        stage = "Tool Drawn";
                        goto JumpPoint;
                    }
                    toolStarted = project.ProjectStartedTool.Length > 0;
                    if (toolStarted)
                    {
                        stage = "Tool Started";
                        goto JumpPoint;
                    }
                    toolEntered = !toolDrawn && !toolStarted && !toolFinished;
                    if (tabletFinished)
                    {
                        stage = "Tablet Finished";
                        goto JumpPoint;
                    }
                    tabletSubmitted = project.TabletSubmittedBy is null ? false : project.TabletSubmittedBy.Length > 0;
                    if (tabletSubmitted)
                    {
                        stage = "Tablet Being Checked";
                        goto JumpPoint;
                    }
                    tabletDrawn = project.TabletDrawnBy.Length > 0;
                    if (tabletDrawn)
                    {
                        stage = "Tablet Drawn";
                        goto JumpPoint;
                    }
                    tabletStarted = project.ProjectStartedTablet.Length > 0;
                    if (tabletStarted)
                    {
                        stage = "Tablet Started";
                        goto JumpPoint;
                    }
                    tabletEntered = !tabletSubmitted && !tabletDrawn && !tabletStarted && !tabletFinished;
                    if (tabletEntered)
                    {
                        stage = "Tablet Entered";
                        goto JumpPoint;
                    }
                }
                else
                {
                    toolFinished = finished;
                    if (toolFinished)
                    {
                        stage = "Tool Finished";
                        goto JumpPoint;
                    }
                    toolDrawn = project.ToolDrawnBy.Length > 0;
                    if (toolDrawn)
                    {
                        stage = "Tool Drawn";
                        goto JumpPoint;
                    }
                    toolStarted = project.ProjectStartedTool.Length > 0;
                    if (toolStarted)
                    {
                        stage = "Tool Started";
                        goto JumpPoint;
                    }
                    toolEntered = !toolDrawn && !toolStarted && !toolFinished;
                    if (toolEntered)
                    {
                        stage = "Tool Entered";
                        goto JumpPoint;
                    }
                }

JumpPoint:
                if (tool)
                {
                    fontStyle = FontStyles.Oblique;
                }
                else
                {
                    fontStyle = FontStyles.Normal;
                }

                if (priority)
                {
                    fore       = new SolidColorBrush(Colors.DarkRed);
                    fontWeight = FontWeights.Bold;
                }
                else
                {
                    fore       = new SolidColorBrush(Colors.Black);
                    fontWeight = FontWeights.Normal;
                }

                if (onHold)
                {
                    // back = new SolidColorBrush(Colors.MediumPurple);
                }
                else if (finished)
                {
                    // back = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFADFF2F"));
                }
                else if (tabletSubmitted)
                {
                    // back = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF0A7DFF"));
                }
                else if (tabletDrawn || toolDrawn)
                {
                    // back = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF52A3FF"));
                }
                else if (tabletStarted || toolStarted)
                {
                    // back = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFB2D6FF"));
                }
                else
                {
                    // back = (SolidColorBrush)(new BrushConverter().ConvertFrom("#00FFFFFF"));
                }

                back = (SolidColorBrush)(new BrushConverter().ConvertFrom("#00FFFFFF"));

                using var __ = new NECContext();
                string customerName = __.Rm00101.Single(r => r.Custnmbr == (project.InternationalId == "N/A" ? project.CustomerNumber : project.InternationalId)).Custname.Trim();
                __.Dispose();

                contentControl.ApplyTemplate();

                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Background = back;

                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "ProjectNumberTextBlock").Text = project.ProjectNumber.ToString();
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "ProjectStageTextBlock").Text  = stage;
                (VisualTreeHelper.GetChild(contentControl as DependencyObject, 0) as Grid).Children.OfType <Grid>().First().Children.OfType <TextBlock>().Single(tb => tb.Name == "CustomerNameTextBlock").Text  = customerName;

                ProjectDockPanel.Children.Add(contentControl);
            }
        }