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); } }
private void LoadData_Click(object sender, RoutedEventArgs e) { TabletModelInformation tmi = HobNumber.Text.Length > 0 ? new TabletModelInformation(HobNumber.Text) : new TabletModelInformation(); DieNumber.Text = tmi.DieNumber; HobNumber.Text = tmi.HobNumber; // Check if hob or die exists var _ = new NAT01Context(); bool hobExists = _.HobList.Any(h => h.HobNo == tmi.HobNumber && h.TipQty == short.Parse(TipQuantity.Text) && h.BoreCircle == float.Parse(BoreCircle.Text)); bool dieExists = _.DieList.Any(d => d.DieId == tmi.DieNumber); _.Dispose(); // Change Add Hob button to Update Hob if hob exists AddHobButton.Content = hobExists ? "Update Hob" : "Add Hob"; // Change Add Die button to Update Die if die exists AddDieButton.Content = dieExists ? "Update Die" : "Add Die"; TipQuantity.Text = "1"; bool dieInfoFilled = FillDieInfo(); // If die does not exist, pull in info from model if (!dieInfoFilled) { // Load die info from model Width.Text = tmi.Width.ToString("#.0000"); WidthMetric.Text = (tmi.Width * 25.4).ToString("#.00"); Length.Text = tmi.Length.ToString("#.0000"); LengthMetric.Text = (tmi.Length * 25.4).ToString("#.00"); EndRadius.Text = tmi.EndRadius.ToString("#.0000"); EndRadiusMetric.Text = (tmi.EndRadius * 25.4).ToString("#.00"); SideRadius.Text = tmi.SideRadius.ToString("#.0000"); SideRadiusMetric.Text = (tmi.SideRadius * 25.4).ToString("#.00"); } BoreCircle.Text = "0.0000"; HobStatus.Text = "D"; Size.Text = ""; // TODO: Build size string Shape.Text = ""; // TODO: Build shape string CupDepth.Text = tmi.CupDepth.ToString("#.0000"); CupDepthMetric.Text = (tmi.CupDepth * 25.4).ToString("#.00"); CupRadius.Text = tmi.CupRadius.ToString("#.0000"); CupRadiusMetric.Text = (tmi.CupRadius * 25.4).ToString("#.00"); Land.Text = tmi.Land.ToString("#.0000"); LandMetric.Text = (tmi.Land * 25.4).ToString("#.00"); LandRange.Text = "0.0000"; LandRangeMetric.Text = "0.00"; // Measurable Cup Depth // Cup Code // Bisect Code Owner.Text = ""; // TODO: Get owner customer number DateDesigned.Text = DateTime.Now.ToShortDateString(); // Hob Class DrawingYN.Text = "Y"; DrawingType.Text = "SW"; // Program/Project Number NNumber.Text = "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 OpenQuote_Click(object sender, MouseButtonEventArgs e) { using var nat01context = new NAT01Context(); Image image = sender as Image; Grid grid = (image.Parent as StackPanel).Parent as Grid; Quote quote = null; Cursor = Cursors.AppStarting; try { int quoteNumber = int.Parse((grid.Children.OfType <TextBlock>().Single(tb => tb.Name == "QuoteNumberTextBlock") as TextBlock).Text); short revNumber = short.Parse((grid.Children.OfType <TextBlock>().Single(tb => tb.Name == "QuoteRevNumberTextBlock") as TextBlock).Text); WindowCollection collection = App.Current.Windows; foreach (Window w in collection) { if (w.Title.Contains(quoteNumber.ToString())) { nat01context.Dispose(); w.WindowState = WindowState.Normal; w.Show(); goto AlreadyOpen; } } quote = new Quote(quoteNumber, revNumber); } catch (Exception ex) { MessageBox.Show(ex.Message); } try { QuoteInfoWindow quoteInfoWindow = new QuoteInfoWindow(quote, parent, user) { Owner = this, Left = Left, Top = Top }; quoteInfoWindow.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } AlreadyOpen: nat01context.Dispose(); Cursor = Cursors.Arrow; }
private void GetLineItemsToScan(Window owner) { Window LineItemChoices = new Window(); LineItemChoices.WindowStartupLocation = WindowStartupLocation.CenterScreen; LineItemChoices.Width = 250; //LineItemChoices.Height = 200; Grid grid = new Grid(); StackPanel stackPanel = new StackPanel(); stackPanel.Width = 225; stackPanel.Margin = new Thickness(0, 15, 0, 0); Label label = new Label(); label.Content = "Check the items you want to send back."; label.Width = 225; label.HorizontalContentAlignment = HorizontalAlignment.Center; stackPanelTemp = stackPanel; stackPanel.Children.Add(label); grid.Children.Add(stackPanel); LineItemChoices.Content = grid; LineItemChoices.SizeToContent = SizeToContent.Height; foreach (KeyValuePair <int, string> kvp in lineItems) { string lineType = kvp.Value.Trim(); if (lineType != "E" && lineType != "H" && lineType != "MC" && lineType != "RET" && lineType != "T" && lineType != "TM" && lineType != "Z") { using var context = new NAT01Context(); string lineDesc = context.OedetailType.Where(x => lineType == x.TypeId.Trim()).FirstOrDefault().ShortDesc.Trim(); CheckBox checkBox = new CheckBox { Name = lineType + "CheckBox", Content = lineDesc, IsChecked = true, Tag = kvp.Key, Margin = new Thickness(0, 0, 0, 15) }; stackPanel.Children.Add(checkBox); context.Dispose(); } } LineItemChoices.Closed += LineItemChoices_Closed; LineItemChoices.ShowDialog(); }
private bool FillDieInfo() { var _ = new NAT01Context(); try { DieList die = _.DieList.FirstOrDefault(d => d.DieId == DieNumber.Text.PadLeft(6)); if (!(die is null)) { Width.Text = String.Format(die.WidthMinorAxis.ToString(), "#.0000"); WidthMetric.Text = String.Format(die.WidthMinorAxisM.ToString(), "#.000"); Length.Text = String.Format(die.LengthMajorAxis.ToString(), "#.0000"); LengthMetric.Text = String.Format(die.LengthMajorAxisM.ToString(), "#.000"); EndRadius.Text = String.Format(die.EndRadius.ToString(), "#.0000"); EndRadiusMetric.Text = String.Format(die.EndRadiusM.ToString(), "#.000"); SideRadius.Text = String.Format(die.SideRadius.ToString(), "#.0000"); SideRadiusMetric.Text = String.Format(die.SideRadiusM.ToString(), "#.000"); CornerRadius.Text = String.Format(die.CornerRadius.ToString(), "#.0000"); CornerRadiusMetric.Text = String.Format(die.CornerRadiusM.ToString(), "#.000"); BlendRadius.Text = String.Format(die.BlendingRadius.ToString(), "#.0000"); BlendRadiusMetric.Text = String.Format(die.BlendingRadiusM.ToString(), "#.000"); OD.Text = String.Format(die.OutsideDiameter.ToString(), "#.0000"); ODMetric.Text = String.Format(die.OutsideDiameterM.ToString(), "#.000"); ReferenceOD.Text = String.Format(die.RefOutsideDiameter.ToString(), "#.0000"); ReferenceODMetric.Text = String.Format(die.RefOutsideDiameterM.ToString(), "#.000"); ShapeID.Text = die.ShapeId.ToString(); // ShapeText.Text = _.ShapeFields.FirstOrDefault(sf => sf.ShapeID == die.ShapeId).ShapeDescription.Trim(); PlugGauge.Text = die.PlugGaugeStatus; MasterDie.Text = die.MasterDieStatus; } else { foreach (Grid grid in DieDockPanel.Children) { foreach (TextBox tb in grid.Children.OfType <TextBox>()) { if (!(tb.Tag is null) && tb.Tag.ToString() == "Die") { tb.Text = ""; } } } } }
public SMI(string custName, string custNumber) { try { InitializeComponent(); customerName = custName; customerNumber = custNumber; SMIUserSpecificHeader.Text = customerName + " SMI's"; NAT01Context nat01Context = new NAT01Context(); SMIs = nat01Context.CustomerInstructionTable.Where(i => i.CustomerId == customerNumber).OrderBy(i => i.Inactive).ThenBy(i => i.Sequence).ToList(); nat01Context.Dispose(); FillInfo(); } catch (Exception ex) { IMethods.WriteToErrorLog("SMI.cs -> CustomerName: " + custName + " CustomerNumber: " + custNumber, 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); } }
public HobInformation() { InitializeComponent(); typingTimer.Elapsed += TypingTimer_Elapsed; var _ = new NAT01Context(); ShapeID.ItemsSource = _.ShapeFields.OrderBy(s => s.ShapeID).Select(s => s.ShapeID.ToString() + " - " + s.ShapeDescription.Trim()).ToList(); HobStatus.ItemsSource = new List <string> { "D", "N", "Y", "R", "M" }; CupCode.ItemsSource = _.CupConfig.OrderBy(c => c.CupID).Select(c => c.CupID.ToString() + " - " + c.Description.Trim()).ToList(); BisectCode.ItemsSource = _.BisectCodes.OrderBy(b => b.ID).Select(b => b.ID.Trim() + " - " + b.Description.Trim()).ToList(); HobClass.ItemsSource = _.ProductClass.OrderBy(p => p.ProductId).Select(p => p.ProductId.Trim() + " - " + p.Description.Trim()).ToList(); DrawingYN.ItemsSource = new List <string> { "Y", "N" }; DrawingType.ItemsSource = _.DrawingType.OrderBy(d => d.DrawingTypeId).Select(d => d.DrawingTypeId.Trim() + " - " + d.Description.Trim()).ToList(); _.Dispose(); }
public void GenerateTravellerNumbers() { using var _nat01context = new NAT01Context(); IQueryable <OrderDetails> orderDetails = _nat01context.OrderDetails.Where(o => o.OrderNo == OrderNumber * 100); try { foreach (OrderDetails lineItem in orderDetails) { lineItem.TravellerNo = "1" + lineItem.LineNumber.ToString("00") + OrderNumber + "00"; _nat01context.OrderDetails.Update(lineItem); } _nat01context.SaveChanges(); } catch (Exception ex) { } finally { _nat01context.Dispose(); } }
/// <summary> /// Create new Customer Note. Prefilled with quote information and prelinked to that quote. /// </summary> /// <param name="user"></param> /// <param name="quoteNo"></param> /// <param name="quoteRevNo"></param> public CustomerNoteWindow(User user, int quoteNo, short quoteRevNo) { this.user = user; InitializeComponent(); try { using var _nat01Context = new NAT01Context(); if (quoteNo != null && quoteRevNo != null) { Quote quote = new Quote(Convert.ToInt32(quoteNo), Convert.ToInt16(quoteRevNo)); LinkListBox.Items.Add(quoteNo.ToString() + "-" + quoteRevNo.ToString()); CustomerNumber.Text = quote.CustomerNo.Trim(); CustomerName.Text = quote.BillToName.Trim(); ShipToNumber.Text = quote.ShipToAccountNo.Trim(); ShipToName.Text = quote.ShiptoName.Trim(); EndUserNumber.Text = quote.UserAcctNo.Trim(); quote.Dispose(); } } catch (Exception ex) { IMethods.WriteToErrorLog("CustomerNoteWindow.xaml.cs => New Note => DocumentNo: '" + quoteNo ?? "null" + "' QuoteRevNumber: '" + quoteRevNo ?? "null" + "'", ex.Message, user); } }
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 OpenOrder_Click(object sender, RoutedEventArgs e) { using var _context = new NAT02Context(); using var _nat01context = new NAT01Context(); Image image = sender as Image; Grid grid = (image.Parent as StackPanel).Parent as Grid; Cursor = Cursors.AppStarting; WorkOrder workOrder = null; try { TextBlock textBlock = grid.Children.OfType <TextBlock>().First() as TextBlock; string orderNumber = textBlock.Text; workOrder = new WorkOrder(int.Parse(orderNumber), this); WindowCollection collection = App.Current.Windows; foreach (Window w in collection) { if (w.Title.Contains(workOrder.OrderNumber.ToString())) { _context.Dispose(); _nat01context.Dispose(); w.WindowState = WindowState.Normal; w.Show(); goto AlreadyOpen2; } } if (_context.EoiOrdersBeingChecked.Any(o => o.OrderNo == workOrder.OrderNumber && o.User != user.GetUserName())) { MessageBox.Show("BEWARE!!\n" + _context.EoiOrdersBeingChecked.Where(o => o.OrderNo == workOrder.OrderNumber && o.User != user.GetUserName()).FirstOrDefault().User + " is in this order at the moment."); } else if (_context.EoiOrdersBeingChecked.Any(o => o.OrderNo == workOrder.OrderNumber && o.User == user.GetUserName())) { MessageBox.Show("You already have this order open."); _context.Dispose(); _nat01context.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } try { OrderInfoWindow orderInfoWindow = new OrderInfoWindow(workOrder, parent, null, user) { Left = parent.Left, Top = parent.Top }; orderInfoWindow.Show(); orderInfoWindow.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } AlreadyOpen2: _context.Dispose(); _nat01context.Dispose(); Cursor = Cursors.Arrow; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { DateTime start = DateTime.Now; var backgroundColor = SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Transparent); try { if (value is EoiAllTabletProjectsView) { try { EoiAllTabletProjectsView project = value as EoiAllTabletProjectsView; bool priority = project.MarkedPriority is null ? false : project.MarkedPriority == "PRIORITY"; bool inactive = project.Complete == -1; bool finished = project.Complete == 4; bool onHold = project.HoldStatus == "On Hold"; bool submitted = project.Complete == 3; bool drawn = project.Complete == 2; bool started = project.Complete == 1; bool sentBack = System.IO.File.Exists(@"\\engserver\workstations\TOOLING AUTOMATION\Project Specifications\" + project.ProjectNumber + "\\NEED_TO_FIX.txt"); if (inactive) { if (priority) { return(SetLinearGradientBrushTablets(Colors.BlanchedAlmond, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.BlanchedAlmond, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (onHold) { if (priority) { return(SetLinearGradientBrushTablets(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (finished) { if (priority) { return(SetLinearGradientBrushTablets(Colors.GreenYellow, Colors.GreenYellow, Colors.GreenYellow, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.GreenYellow, Colors.GreenYellow, Colors.GreenYellow, Colors.GreenYellow)); } if (sentBack) { if (priority) { return(SetLinearGradientBrushTablets(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (submitted) { if (priority) { return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.DodgerBlue, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.DodgerBlue, Colors.Transparent)); } if (drawn) { if (priority) { return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.Transparent, Colors.Transparent)); } if (started) { if (priority) { return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (priority) { return(SetLinearGradientBrushTablets(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } } catch (Exception ex) { } } else if (value is EoiAllToolProjectsView) { try { EoiAllToolProjectsView project = value as EoiAllToolProjectsView; bool priority = project.MarkedPriority is null ? false : project.MarkedPriority == "PRIORITY"; bool inactive = project.Complete == -1; bool finished = project.Complete == 5; bool tablets = project.Complete == 1; bool multitip = project.MultiTipSketch; bool onHold = project.HoldStatus == "On Hold"; bool submitted = project.Complete == 4; bool drawn = project.Complete == 3; bool started = project.Complete == 2; bool sentBack = System.IO.File.Exists(@"\\engserver\workstations\TOOLING AUTOMATION\Project Specifications\" + project.ProjectNumber + "\\NEED_TO_FIX.txt"); if (inactive) { if (priority) { return(SetLinearGradientBrushTablets(Colors.BlanchedAlmond, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.BlanchedAlmond, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (onHold) { if (priority) { return(SetLinearGradientBrushTablets(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (finished) { if (priority) { return(SetLinearGradientBrushTablets(Colors.GreenYellow, Colors.GreenYellow, Colors.GreenYellow, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.GreenYellow, Colors.GreenYellow, Colors.GreenYellow, Colors.GreenYellow)); } if (sentBack) { if (priority) { return(SetLinearGradientBrushTablets(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (submitted) { if (priority) { return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.DodgerBlue, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.DodgerBlue, Colors.Transparent)); } if (drawn) { if (priority) { return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.DodgerBlue, Colors.Transparent, Colors.Transparent)); } if (started) { if (priority) { return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.DodgerBlue, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (tablets) { if (priority) { return(SetLinearGradientBrushTablets(Colors.Yellow, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.Yellow, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (multitip) { if (priority) { return(SetLinearGradientBrushTablets(Colors.Gray, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrushTablets(Colors.Gray, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (priority) { return(SetLinearGradientBrushTablets(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } } catch (Exception ex) { } } else if (value is EoiQuotesMarkedForConversionView) { EoiQuotesMarkedForConversionView quote = value as EoiQuotesMarkedForConversionView; if (quote.Rush == "Y") { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } else if (value is EoiQuotesNotConvertedView) { EoiQuotesNotConvertedView quote = value as EoiQuotesNotConvertedView; if (quote.NeedsFollowUp == 1) { if ((value as EoiQuotesNotConvertedView).RushYorN == "Y") { return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } else if (quote.NeedsFollowUp == 2) { if ((value as EoiQuotesNotConvertedView).RushYorN == "Y") { return(SetLinearGradientBrush(Colors.OrangeRed, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.OrangeRed, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if ((value as EoiQuotesNotConvertedView).RushYorN == "Y") { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } else if (value is AllProjectsView) { return(backgroundColor); } else if (parameter.ToString() == "NatoliOrderList") { int daysToShip = ((value as NatoliOrderListFinal).ShipDate - DateTime.Now.Date).Days; if (daysToShip < 0) { return(SetLinearGradientBrush(Colors.Red, Colors.Red, Colors.Red, Colors.Transparent)); } else if (daysToShip == 0) { return(SetLinearGradientBrush(Colors.Orange, Colors.Orange, Colors.Orange, Colors.Transparent)); } else if (daysToShip > 0 && daysToShip < 4) { return(SetLinearGradientBrush(Colors.Yellow, Colors.Yellow, Colors.Yellow, Colors.Transparent)); } else { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } } else { EoiAllOrdersView order = value as EoiAllOrdersView; bool rush = order.RushYorN == "Y" || order.PaidRushFee == "Y"; if (order.BeingEntered == 1) { return(backgroundColor); } if (order.InTheOffice == 1) { if (order.DoNotProcess == 1) { if (rush) { return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (rush) { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } } if (order.EnteredUnscanned == 1) { bool running = order.Generating; bool ran = !order.Generating && order.Generated; if (order.DoNotProcess == 1) { if (rush) { return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (running) { if (rush) { return(SetLinearGradientBrush(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (((order.ProcessState == "Failed" && order.ProcessState != "Complete") || order.TransitionName == "NeedInfo") && !ran) { if (rush) { return(SetLinearGradientBrush(Colors.DarkGray, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.DarkGray, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (rush) { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } } if (order.InEngineering == 1) { if (order.DoNotProcess == 1) { if (rush) { return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (order.BeingChecked == 1) { if (rush) { return(SetLinearGradientBrush(Colors.DodgerBlue, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.DodgerBlue, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (order.VariablesExist == 0) { if (rush) { return(SetLinearGradientBrush(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (order.MarkedForChecking == 1) { if (rush) { return(SetLinearGradientBrush(Colors.GreenYellow, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.GreenYellow, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (rush) { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } } if (order.ReadyToPrint == 1) { if (order.DoNotProcess == 1) { if (rush) { return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (order.VariablesExist == 0) { if (rush) { return(SetLinearGradientBrush(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } else if (order.Tablet == 1 || order.Tool == 1 || order.Tm2 == 1) { bool tm2 = System.Convert.ToBoolean(order.Tm2); bool tabletPrints = System.Convert.ToBoolean(order.Tablet); bool toolPrints = System.Convert.ToBoolean(order.Tool); List <string> hobNumbers = null; hobNumbers = !string.IsNullOrEmpty(order.HobNumbers) && !string.IsNullOrEmpty(order.HobNumbers) ? order.HobNumbers.Split(",").ToList() : null; if (tm2 || tabletPrints) { if (hobNumbers != null) { foreach (string hobNumber in hobNumbers) { string path = @"\\engserver\workstations\tool_drawings\" + order.OrderNumber + @"\" + hobNumber + ".pdf"; if (!System.IO.File.Exists(path)) { goto Missing; } } } } if (tm2 || toolPrints) { List <string> detailTypes = null; detailTypes = !string.IsNullOrEmpty(order.DetailTypes) ? order.DetailTypes.Split(",").ToList() : null; foreach (string detailTypeID in detailTypes) { if (detailTypeID == "U" || detailTypeID == "L" || detailTypeID == "D" || detailTypeID == "DS" || detailTypeID == "R") { string detailType = oeDetailTypes[detailTypeID]; detailType = detailType == "MISC" ? "REJECT" : detailType; string international = order.UnitOfMeasure; string path = @"\\engserver\workstations\tool_drawings\" + order.OrderNumber + @"\" + detailType + ".pdf"; if (!System.IO.File.Exists(path)) { goto Missing; } if (international == "M" && !System.IO.File.Exists(path.Replace(detailType, detailType + "_M"))) { goto Missing; } } } } goto NotMissing; Missing :; if (rush) { return(SetLinearGradientBrush(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Transparent)); goto Finished; NotMissing :; if (rush) { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } Finished :; } if (rush) { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } } if (order.Printed == 1) { if (order.DoNotProcess == 1) { if (rush) { return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Pink, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } if (order.VariablesExist == 0) { if (rush) { return(SetLinearGradientBrush(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.Orange, Colors.Transparent, Colors.Transparent, Colors.Transparent)); } else if (order.Tablet == 1 || order.Tool == 1 || order.Tm2 == 1) { bool tm2 = System.Convert.ToBoolean(order.Tm2); bool tabletPrints = System.Convert.ToBoolean(order.Tablet); bool toolPrints = System.Convert.ToBoolean(order.Tool); List <OrderDetails> orderDetails; OrderHeader orderHeader; using var nat01context = new NAT01Context(); orderDetails = nat01context.OrderDetails.Where(o => o.OrderNo == order.OrderNumber * 100).ToList(); orderHeader = nat01context.OrderHeader.Single(o => o.OrderNo == order.OrderNumber * 100); nat01context.Dispose(); if (tm2 || tabletPrints) { foreach (OrderDetails od in orderDetails) { if (od.DetailTypeId.Trim() == "U" || od.DetailTypeId.Trim() == "L" || od.DetailTypeId.Trim() == "R") { string path = @"\\engserver\workstations\tool_drawings\" + order.OrderNumber + @"\" + od.HobNoShapeId.Trim() + ".pdf"; if (!System.IO.File.Exists(path)) { goto Missing; } } } } if (tm2 || toolPrints) { foreach (OrderDetails od in orderDetails) { if (od.DetailTypeId.Trim() == "U" || od.DetailTypeId.Trim() == "L" || od.DetailTypeId.Trim() == "D" || od.DetailTypeId.Trim() == "DS" || od.DetailTypeId.Trim() == "R") { string detailType = oeDetailTypes[od.DetailTypeId.Trim()]; detailType = detailType == "MISC" ? "REJECT" : detailType; string international = orderHeader.UnitOfMeasure; string path = @"\\engserver\workstations\tool_drawings\" + order.OrderNumber + @"\" + detailType + ".pdf"; if (!System.IO.File.Exists(path)) { goto Missing; } if (international == "M" && !System.IO.File.Exists(path.Replace(detailType, detailType + "_M"))) { goto Missing; } } } } goto NotMissing; Missing :; if (rush) { return(SetLinearGradientBrush(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Red)); } return(SetLinearGradientBrush(Colors.MediumPurple, Colors.Transparent, Colors.Transparent, Colors.Transparent)); goto Finished; NotMissing :; if (rush) { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } Finished :; } if (rush) { return(SetLinearGradientBrush(Colors.Transparent, Colors.Transparent, Colors.Transparent, Colors.Red)); } } } } catch (Exception ex) { // System.Windows.MessageBox.Show(ex.Message); } return(backgroundColor); }
/// <summary> /// Adds document from the LinkListBox. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LinkAdd_MouseUp(object sender, MouseButtonEventArgs e) { using var _nat01Context = new NAT01Context(); string documentNumber = ""; bool isQuoteType = false; try { documentNumber = LinkDocumentNumber.Text.Trim(); switch (((ComboBoxItem)LinkType.SelectedItem).Content.ToString()) { case "Quote": isQuoteType = true; if (documentNumber.Contains("-")) { string[] quote = documentNumber.Split('-'); if (double.TryParse(quote[0], out double quoteNo) && short.TryParse(quote[1], out short quoteRevNo)) { if (_nat01Context.QuoteHeader.Any(q => q.QuoteNo == quoteNo && q.QuoteRevNo == quoteRevNo)) { ListBoxItem listBoxItem = new ListBoxItem { Content = documentNumber, Style = (Style)Application.Current.Resources["ListBoxItem"] }; //LinkListBox.Items.Add(documentNumber); LinkListBox.Items.Add(listBoxItem); LinkDocumentNumber.Clear(); } } else { MessageBox.Show("Could not find an existing quote from " + documentNumber + "."); } } break; case "Order": if (double.TryParse(documentNumber, out double orderNo)) { if (_nat01Context.OrderHeader.Any(o => o.OrderNo == Convert.ToDouble(orderNo + "00"))) { ListBoxItem listBoxItem = new ListBoxItem { Content = documentNumber, Style = (Style)Application.Current.Resources["ListBoxItem"] }; //LinkListBox.Items.Add(documentNumber); LinkListBox.Items.Add(listBoxItem); LinkDocumentNumber.Clear(); } else { MessageBox.Show("Could not find an existing order from " + documentNumber + "."); } } break; default: break; } } catch (Exception ex) { IMethods.WriteToErrorLog("CustomerNoteWindow.xaml.cs => LinkAdd_MouseUp() => Document Number: '" + documentNumber + "'", ex.Message, user); MessageBox.Show("Error converting " + documentNumber + " to " + (isQuoteType ? "a QuoteNumber-RevNumber." : "an Order Number.")); } _nat01Context.Dispose(); }