public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { if (value is EoiQuotesMarkedForConversionView) { return((value as EoiQuotesMarkedForConversionView).ShipDate.Trim()); } else if (value is EoiAllTabletProjectsView) { using var __nat02context = new NAT02Context(); if (__nat02context.EoiProjectsOnHold.Any(p => p.ProjectNumber == (value as EoiAllTabletProjectsView).ProjectNumber && p.RevisionNumber == (value as EoiAllTabletProjectsView).RevisionNumber)) { string comment = string.IsNullOrEmpty(__nat02context.EoiProjectsOnHold.FirstOrDefault(p => p.ProjectNumber == (value as EoiAllTabletProjectsView).ProjectNumber && p.RevisionNumber == (value as EoiAllTabletProjectsView).RevisionNumber).OnHoldComment.Trim()) ? "No Comment" : __nat02context.EoiProjectsOnHold.First(p => p.ProjectNumber == (value as EoiAllTabletProjectsView).ProjectNumber && p.RevisionNumber == (value as EoiAllTabletProjectsView).RevisionNumber).OnHoldComment.Trim(); __nat02context.Dispose(); return(comment); } else { __nat02context.Dispose(); return(null); } } else if (value is EoiAllToolProjectsView) { using var __nat02context = new NAT02Context(); if (__nat02context.EoiProjectsOnHold.Any(p => p.ProjectNumber == (value as EoiAllToolProjectsView).ProjectNumber && p.RevisionNumber == (value as EoiAllToolProjectsView).RevisionNumber)) { string comment = string.IsNullOrEmpty(__nat02context.EoiProjectsOnHold.FirstOrDefault(p => p.ProjectNumber == (value as EoiAllToolProjectsView).ProjectNumber && p.RevisionNumber == (value as EoiAllToolProjectsView).RevisionNumber).OnHoldComment.Trim()) ? "No Comment" : __nat02context.EoiProjectsOnHold.First(p => p.ProjectNumber == (value as EoiAllToolProjectsView).ProjectNumber && p.RevisionNumber == (value as EoiAllToolProjectsView).RevisionNumber).OnHoldComment.Trim(); __nat02context.Dispose(); return(comment); } else { __nat02context.Dispose(); return(null); } } else { return(null); } } catch (Exception ex) { IMethods.WriteToErrorLog("ToolTipConverter => Convert()", ex.Message, new User()); return(null); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { using var _ = new NAT02Context(); List <EoiNotificationsActive> active = _.EoiNotificationsActive.Where(n => n.User == user.DomainName).ToList(); foreach (EoiNotificationsActive a in active) { EoiNotificationsViewed viewed = new EoiNotificationsViewed() { NotificationId = a.Id, Type = a.Type, Number = a.Number, Message = a.Message, User = a.User, Timestamp = DateTime.Now }; _.EoiNotificationsViewed.Add(viewed); _.SaveChanges(); _.EoiNotificationsActive.Remove(a); _.SaveChanges(); } _.Dispose(); parent.SetNotificationPicture(); }
public void BuildCalendar(DateTime targetDate) { Days.Clear(); //Calculate when the first day of the month is and work out an //offset so we can fill in any boxes before that. DateTime d = new DateTime(targetDate.Year, targetDate.Month, 1); int offset = DayOfWeekNumber(d.DayOfWeek); if (offset != 0) { d = d.AddDays(-offset); } //Show 6 weeks each with 7 days = 42 for (int box = 1; box <= 42; box++) { Day day = new Day { Date = d, Enabled = true, IsTargetMonth = targetDate.Month == d.Month }; using var _nat02Context = new NAT02Context(); if (_nat02Context.EoiCalendar.Any(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day)) { day.Notes = _nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day).Notes; } _nat02Context.Dispose(); day.PropertyChanged += Day_Changed; day.IsToday = d == DateTime.Today; Days.Add(day); d = d.AddDays(1); } }
private void AddNoteToDate(DateTime dateTime, string note) { using var _nat02Context = new NAT02Context(); try { // Exists if (_nat02Context.EoiCalendar.Any(c => c.Year == dateTime.Year && c.Month == dateTime.Month && c.Day == dateTime.Day)) { EoiCalendar eoiCalendar = _nat02Context.EoiCalendar.First(c => c.Year == dateTime.Year && c.Month == dateTime.Month && c.Day == dateTime.Day); eoiCalendar.Notes += System.Environment.NewLine + note; eoiCalendar.DomainName = user.DomainName; _nat02Context.SaveChanges(); } else { EoiCalendar eoiCalendar = new EoiCalendar { Year = (Int16)dateTime.Year, Month = (byte)dateTime.Month, Day = (byte)dateTime.Day, DomainName = user.DomainName, Notes = note }; _nat02Context.EoiCalendar.Add(eoiCalendar); _nat02Context.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("There was an error processing your request. It may have been parially processed" + System.Environment.NewLine + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); IMethods.WriteToErrorLog("RecurringEventWindow => AddNoteToDate => Date: " + dateTime.ToLongDateString() + " => Note: " + note, ex.Message, user); } _nat02Context.Dispose(); }
private void QuoteConversionDataGrid_MouseUp(object sender, MouseButtonEventArgs e) { string csr = ((sender as DataGrid).SelectedCells[0].Item as VwQuoteConversion).Rep; using var _ = new NAT02Context(); List <double> pct = new List <double>(); _.Dispose(); // CreateLineGraph(csr, pct); // CreateBarGraph(csr); }
private void ArchiveNotification_Click(object sender, RoutedEventArgs e) { string orderNumber = (((sender as Image).Parent as StackPanel).Parent as Grid).Children.OfType <TextBlock>().Single(tb => tb.Name == "OrderNumberTextBlock").Text; using var _ = new NAT02Context(); if (_.EoiNotificationsActive.Count(n => n.Number == orderNumber) > 0) { List <EoiNotificationsActive> actives = _.EoiNotificationsActive.Where(n => n.Number == orderNumber).ToList(); foreach (EoiNotificationsActive active in actives) { EoiNotificationsArchived archived = new EoiNotificationsArchived() { NotificationId = active.Id, Number = active.Number, Type = active.Type, Message = active.Message, User = active.User, Timestamp = DateTime.Now }; _.EoiNotificationsActive.Remove(active); _.EoiNotificationsArchived.Add(archived); } } else if (_.EoiNotificationsViewed.Count(n => n.Number == orderNumber) > 0) { List <EoiNotificationsViewed> vieweds = _.EoiNotificationsViewed.Where(n => n.Number == orderNumber).ToList(); foreach (EoiNotificationsViewed viewed in vieweds) { EoiNotificationsArchived archived = new EoiNotificationsArchived() { NotificationId = viewed.NotificationId, Number = viewed.Number, Type = viewed.Type, Message = viewed.Message, User = viewed.User, Timestamp = DateTime.Now }; _.EoiNotificationsViewed.Remove(viewed); _.EoiNotificationsArchived.Add(archived); } } _.SaveChanges(); _.Dispose(); FillNotifications(); }
/// <summary> /// Returns ordered list of quotes. Should call ShowDialog() to get the ordered list back. /// </summary> /// <param name="quotes"></param> /// <param name="user"></param> /// <param name="mainWindow"></param> public OrderingWindow(List <Tuple <int, short> > quotes, User user) { InitializeComponent(); try { this.user = user; quotesList = quotes; Header.Text = "Confirm quote(s) to submit."; Title = "Submit Quote(s)"; // Populate the textblocks for the listbox foreach (Tuple <int, short> quote in quotesList) { using var _nat02Context = new NAT02Context(); string customer = _nat02Context.EoiQuotesNotConvertedView.First(q => q.QuoteNo == (double)quote.Item1 && q.QuoteRevNo == quote.Item2).CustomerName; _nat02Context.Dispose(); string q = quote.Item1 + "-" + quote.Item2 + " - " + customer; textBlockList.Add(new TextBlock { Text = q }); } DragAndDrop dragAndDrop = new DragAndDrop(user, ListBox1, textBlockList); ButtonGrid.Children.Clear(); ButtonGrid.ColumnDefinitions.Clear(); ButtonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100) }); ButtonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(100) }); Button submitButton = new Button { Name = "Submit", Content = "Submit", VerticalAlignment = VerticalAlignment.Center, MinHeight = 24, Style = (System.Windows.Style)Application.Current.Resources["Button"] }; Grid.SetColumn(submitButton, 0); submitButton.Click += SubmitQuotes_Click; Button cancelButton = new Button { Name = "Cancel", Content = "Cancel", VerticalAlignment = VerticalAlignment.Center, MinHeight = 24, Style = (System.Windows.Style)Application.Current.Resources["Button"] }; Grid.SetColumn(cancelButton, 1); cancelButton.Click += Cancel_Click; ButtonGrid.Children.Add(submitButton); ButtonGrid.Children.Add(cancelButton); } catch { this.Close(); } }
/// <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 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; }
private void Calendar_DayChanged(object sender, Jarloo.Calendar.DayChangedEventArgs e) { DateTime d = e.Day.Date; using var _nat02Context = new NAT02Context(); // Delete from table if (string.IsNullOrEmpty(e.Day.Notes) || string.IsNullOrWhiteSpace(e.Day.Notes)) { // Exists if (_nat02Context.EoiCalendar.Any(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day)) { if (_nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day).ActionDateTime < timeEnteredCalendar || _nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day).DomainName == user.DomainName) { // Remove EoiCalendar eoiCalendar = _nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day); _nat02Context.EoiCalendar.Remove(eoiCalendar); _nat02Context.SaveChanges(); _nat02Context.Dispose(); } else { MessageBox.Show("There appears to have been a change made by '" + _nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day).DomainName + "' to this date before you deleted the note. Please re-open the calendar to load the information.", "Prevoiusly changed", MessageBoxButton.OK, MessageBoxImage.Information); _nat02Context.Dispose(); } } } // Insert or Update else { // Exists if (_nat02Context.EoiCalendar.Any(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day)) { if (_nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day).ActionDateTime < timeEnteredCalendar || _nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day).DomainName == user.DomainName) { EoiCalendar eoiCalendar = _nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day); eoiCalendar.Notes = e.Day.Notes; eoiCalendar.DomainName = user.DomainName; _nat02Context.SaveChanges(); _nat02Context.Dispose(); } else { MessageBox.Show("There appears to have been a change made by '" + _nat02Context.EoiCalendar.First(c => c.Year == (short)d.Year && c.Month == (byte)d.Month && c.Day == (byte)d.Day).DomainName + "' to this date before you altered the note. Please re-open the calendar to load the information.", "Prevoiusly changed", MessageBoxButton.OK, MessageBoxImage.Information); _nat02Context.Dispose(); } } // New else { EoiCalendar eoiCalendar = new EoiCalendar { Day = (byte)d.Day, Month = (byte)d.Month, Year = (Int16)d.Year, DomainName = user.DomainName, Notes = e.Day.Notes }; _nat02Context.EoiCalendar.Add(eoiCalendar); _nat02Context.SaveChanges(); _nat02Context.Dispose(); } } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { // Initiate an instance of the context using var _ = new NAT02Context(); int ret = 0; try { EoiTrackedDocuments trackedDocument = new EoiTrackedDocuments(); if (ToProductionCheckBox.IsChecked.Value) { // Insert into EOI_TrackedDocuments trackedDocument.Type = documentType; // Quote or Order trackedDocument.Number = documentNumber; // Quote number or Order number trackedDocument.MovementId = 3; // Type of movement to notify for trackedDocument.User = user.DomainName; // User requesting notification // Execute the DML statement _.EoiTrackedDocuments.Add(trackedDocument); // Save the changes ret = _.SaveChanges(); } if (ShippedCheckBox.IsChecked.Value) { // Insert into EOI_TrackedDocuments trackedDocument.Type = documentType; // Quote or Order trackedDocument.Number = documentNumber; // Quote number and rev or Order number trackedDocument.MovementId = 5; // Type of movement to notify for trackedDocument.User = user.DomainName; // User requesting notification // Execute the DML statement _.EoiTrackedDocuments.Add(trackedDocument); // Save the changes ret = _.SaveChanges(); } if (ret == 1) { MessageBox.Show("Document will now be tracked."); } else if (ret == 0) { } else { throw new Microsoft.EntityFrameworkCore.DbUpdateException(); } } catch (Exception ex) { IMethods.WriteToErrorLog("SaveButton_Click -- DocumentTrackingWindow.xaml.cs", ex.Message, user); } finally { // Dispose of the context object _.Dispose(); } Close(); }
public ExpanderModule() { // Header grid // This houses the title of the module and any extra features i.e. // search boxes, filter combo boxes, etc. Grid headerLabelGrid = new Grid() { Name = SharedName + "HeaderLabelGrid", Height = 31, Background = new SolidColorBrush(SystemColors.GradientActiveCaptionColor), HorizontalAlignment = HorizontalAlignment.Stretch }; // Header label // This contains the title of the module Label headerLabel = new Label() { Name = SharedName + "Label", Content = ModuleTitle, HorizontalContentAlignment = HorizontalAlignment.Center, BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(1, 3, 1, 1), Height = 31, FontWeight = FontWeights.Bold, FontSize = 14, Padding = new Thickness(0), Background = new SolidColorBrush(SystemColors.GradientActiveCaptionColor), HorizontalAlignment = HorizontalAlignment.Stretch }; // Search box // This allows searching of the expanders inside the module if the // SearchBox bool is set to true TextBox searchBox = new TextBox() { Name = SharedName + "SearchBox", BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(1, 3, 1, 1), Padding = new Thickness(0, 5, 0, 5) }; searchBox.TextChanged += SearchBox_TextChanged; ColumnDefinition cDef; cDef = new ColumnDefinition(); cDef.Width = new GridLength(1, GridUnitType.Star); // Sets title position headerLabelGrid.ColumnDefinitions.Add(cDef); cDef = new ColumnDefinition(); cDef.Width = new GridLength(150); // Sets search box position headerLabelGrid.ColumnDefinitions.Add(cDef); Grid.SetColumn(headerLabel, 0); headerLabelGrid.Children.Add(headerLabel); Grid.SetColumn(searchBox, 1); headerLabelGrid.Children.Add(searchBox); // Scroll viewer for stack panel // This presents a scrollbar on the right side of the stack panel ScrollViewer scrollViewer = new ScrollViewer() { VerticalScrollBarVisibility = ScrollBarVisibility.Visible, CanContentScroll = true, BorderBrush = new SolidColorBrush(SystemColors.WindowFrameColor), Height = (ModuleHeight / RowCount), HorizontalAlignment = HorizontalAlignment.Stretch }; // Stack panel header for expanders // This grid is where the column headers are placed Grid headerGrid = new Grid() { Background = ColumnHeaderBackground, Height = 30, HorizontalAlignment = HorizontalAlignment.Stretch }; ColumnDefinition colDef; colDef = new ColumnDefinition(); colDef.Width = new GridLength(25); // Blank space to account for expander arrow headerGrid.ColumnDefinitions.Add(colDef); //foreach (var column in Columns) //{ // colDef = new ColumnDefinition(); // colDef.Width = column.Item2; // headerGrid.ColumnDefinitions.Add(colDef); // Label label = new Label() { Content = column.Item1 }; // Grid.SetRow(label, 0); // Grid.SetColumn(label, column.Item3 + 1); // headerGrid.Children.Add(label); //} colDef = new ColumnDefinition(); colDef.Width = new GridLength(22); // Blank space to account for scrollbar headerGrid.ColumnDefinitions.Add(colDef); // Stack panel for expanders StackPanel interiorStackPanel = new StackPanel() { Name = "InteriorStackPanel", CanVerticallyScroll = true, ScrollOwner = scrollViewer, HorizontalAlignment = HorizontalAlignment.Stretch }; using var _nat02context = new NAT02Context(); _nat02context.EoiOrdersInEngineeringUnprintedView.OrderBy(o => o.OrderNo).Load(); var binding = new Binding { Source = _nat02context.EoiOrdersInEngineeringUnprintedView.Local.ToObservableCollection(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; _nat02context.Dispose(); interiorStackPanel.SetBinding(ItemsControl.ItemsSourceProperty, binding); // Expanders //foreach (var item in binding) //{ // Grid grid = new Grid(); // grid.HorizontalAlignment = HorizontalAlignment.Stretch; // colDef = new ColumnDefinition(); // colDef.Width = new GridLength(60); // grid.ColumnDefinitions.Add(colDef); // colDef = new ColumnDefinition(); // colDef.Width = new GridLength(this.Width / 3 - 327); // colDef.Width = new GridLength(1, GridUnitType.Star); // grid.ColumnDefinitions.Add(colDef); // colDef = new ColumnDefinition(); // colDef.Width = new GridLength(80); // grid.ColumnDefinitions.Add(colDef); // colDef = new ColumnDefinition(); // colDef.Width = new GridLength(40); // grid.ColumnDefinitions.Add(colDef); // colDef = new ColumnDefinition(); // colDef.Width = new GridLength(55); // grid.ColumnDefinitions.Add(colDef); // colDef = new ColumnDefinition(); // colDef.Width = new GridLength(40); // grid.ColumnDefinitions.Add(colDef); // Label orderNoLabel = new Label(); // orderNoLabel.Content = (item.OrderNo / 100).ToString(); // Label customerLabel = new Label(); // customerLabel.Content = item.Customer.Trim(); // Label shipDateLabel = new Label(); // shipDateLabel.Content = item.ShipDate.ToShortDateString(); // Label rushLabel = new Label(); // rushLabel.Content = item.Rush.Trim(); // Label onHoldLabel = new Label(); // onHoldLabel.Content = item.OnHold; // Label repInitialsLabel = new Label(); // repInitialsLabel.Content = item.RepInitials; // Grid.SetRow(orderNoLabel, 0); // Grid.SetColumn(orderNoLabel, 0); // grid.Children.Add(orderNoLabel); // Grid.SetRow(customerLabel, 0); // Grid.SetColumn(customerLabel, 1); // grid.Children.Add(customerLabel); // Grid.SetRow(shipDateLabel, 0); // Grid.SetColumn(shipDateLabel, 2); // grid.Children.Add(shipDateLabel); // Grid.SetRow(rushLabel, 0); // Grid.SetColumn(rushLabel, 3); // grid.Children.Add(rushLabel); // Grid.SetRow(onHoldLabel, 0); // Grid.SetColumn(onHoldLabel, 4); // grid.Children.Add(onHoldLabel); // Grid.SetRow(repInitialsLabel, 0); // Grid.SetColumn(repInitialsLabel, 5); // grid.Children.Add(repInitialsLabel); // int daysToShip = (order.ShipDate.Date - DateTime.Now.Date).Days; // Expander expander = new Expander() // { // IsExpanded = false, // Header = grid, // HorizontalAlignment = HorizontalAlignment.Stretch // }; // if (daysToShip < 0) // { // expander.Background = new SolidColorBrush(Colors.Red); // expander.Foreground = new SolidColorBrush(Colors.Black); // } // else if (daysToShip == 0) // { // expander.Background = new SolidColorBrush(Colors.Orange); // expander.Foreground = new SolidColorBrush(Colors.Black); // } // else if (daysToShip > 0 && daysToShip < 4) // { // expander.Background = new SolidColorBrush(Colors.Yellow); // expander.Foreground = new SolidColorBrush(Colors.Black); // } // else // { // expander.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFFFFFFF")); // } // // expander.Expanded += Expander_Expanded; // interiorStackPanel.Children.Add(expander); //} scrollViewer.Content = interiorStackPanel; }
/// <summary> /// Open existing Customer Note. /// </summary> /// <param name="ID"></param> /// <param name="user"></param> public CustomerNoteWindow(int ID, User user) { this.user = user; this.ID = ID; InitializeComponent(); using var _nat02Context = new NAT02Context(); try { LinkType.IsEnabled = false; LinkDocumentNumber.IsEnabled = false; LinkAdd.IsEnabled = false; LinkAdd.Cursor = Cursors.Arrow; LinkRemove.IsEnabled = false; LinkRemove.Cursor = Cursors.Arrow; if (_nat02Context.EoiCustomerNotes.Any(cn => cn.ID == ID)) { EoiCustomerNotes eoiCustomerNote = _nat02Context.EoiCustomerNotes.First(cn => cn.ID == ID); EnteredBy.Text = "Entered by: " + eoiCustomerNote.User; EnteredDate.Text = "Date: " + eoiCustomerNote.Timestamp.ToLocalTime(); CustomerNumber.Text = eoiCustomerNote.CustomerNumber ?? ""; CustomerName.Text = eoiCustomerNote.CustomerName ?? ""; ShipToNumber.Text = eoiCustomerNote.ShipToNumber ?? ""; ShipToName.Text = eoiCustomerNote.ShipToName ?? ""; EndUserNumber.Text = eoiCustomerNote.EndUserNumber ?? ""; EndUserName.Text = eoiCustomerNote.EndUserName ?? ""; CategoryComboBox.Text = eoiCustomerNote.Category; CommentTextBox.Text = eoiCustomerNote.Note; if (eoiCustomerNote.QuoteNumbers != null && eoiCustomerNote.QuoteNumbers.Length > 0) { string[] quoteNumbers = eoiCustomerNote.QuoteNumbers.Split(','); foreach (string quoteNumber in quoteNumbers) { ListBoxItem listBoxItem = new ListBoxItem { Content = quoteNumber, Style = (Style)Application.Current.Resources["ListBoxItem"] }; LinkListBox.Items.Add(listBoxItem); } } if (eoiCustomerNote.OrderNumbers != null && eoiCustomerNote.OrderNumbers.Length > 0) { string[] orderNumbers = eoiCustomerNote.OrderNumbers.Split(','); foreach (string orderNumber in orderNumbers) { ListBoxItem listBoxItem = new ListBoxItem { Content = orderNumber, Style = (Style)Application.Current.Resources["ListBoxItem"] }; LinkListBox.Items.Add(listBoxItem); } } if (eoiCustomerNote.NotificationDate != null) { NotificationDate.SelectedDate = eoiCustomerNote.NotificationDate; NotificationDate.IsEnabled = false; } } CustomerNumber.IsReadOnly = true; CustomerName.IsReadOnly = true; ShipToNumber.IsReadOnly = true; ShipToName.IsReadOnly = true; EndUserNumber.IsReadOnly = true; EndUserName.IsReadOnly = true; CategoryComboBox.IsEnabled = false; CommentTextBox.IsReadOnly = true; OKButton.IsEnabled = false; } catch (Exception ex) { IMethods.WriteToErrorLog("CustomerNoteWindow.xaml.cs => Existing Note: '" + ID + "'", ex.Message, user); } _nat02Context.Dispose(); }
/// <summary> /// Submits the data to '[EOI_CustomerNotes]'. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OKButton_Click(object sender, RoutedEventArgs e) { using var _nat02Context = new NAT02Context(); string quoteNumbers = ""; string orderNumbers = ""; string userName = null; string customerNumber = null; string customerName = null; string shipToNumber = null; string shipToName = null; string endUserNumber = null; string endUserName = null; string category = null; string note = null; DateTime?notificationDate = null; try { foreach (ListBoxItem listBoxItem in LinkListBox.Items.OfType <ListBoxItem>()) { string s = listBoxItem.Content.ToString(); if (s.Contains("-")) { quoteNumbers += s + ","; } else { orderNumbers += s + ","; } } quoteNumbers = quoteNumbers.Trim(','); orderNumbers = orderNumbers.Trim(','); quoteNumbers = string.IsNullOrEmpty(quoteNumbers) ? null : quoteNumbers; orderNumbers = string.IsNullOrEmpty(orderNumbers) ? null : orderNumbers; userName = string.IsNullOrEmpty(user.DomainName) ? null : user.DomainName; customerNumber = string.IsNullOrEmpty(CustomerNumber.Text) ? null : CustomerNumber.Text; customerName = string.IsNullOrEmpty(CustomerName.Text) ? null : CustomerName.Text; shipToNumber = string.IsNullOrEmpty(ShipToNumber.Text) ? null : ShipToNumber.Text; shipToName = string.IsNullOrEmpty(ShipToName.Text) ? null : ShipToName.Text; endUserNumber = string.IsNullOrEmpty(EndUserNumber.Text) ? null : EndUserNumber.Text; endUserName = string.IsNullOrEmpty(EndUserName.Text) ? null : EndUserName.Text; category = ((ComboBoxItem)CategoryComboBox.SelectedItem).Content.ToString(); note = CommentTextBox.Text; notificationDate = NotificationDate.Text.ToString() == "" ? (DateTime?)null : NotificationDate.SelectedDate; EoiCustomerNotes customerNote = new EoiCustomerNotes { Timestamp = DateTime.UtcNow, User = userName, CustomerNumber = customerNumber, CustomerName = customerName, ShipToNumber = shipToNumber, ShipToName = shipToName, EndUserNumber = endUserNumber, EndUserName = endUserName, Category = category, Note = note, QuoteNumbers = quoteNumbers, OrderNumbers = orderNumbers, NotificationDate = notificationDate, }; if (ID > 0) { customerNote.ID = ID; _nat02Context.EoiCustomerNotes.Update(customerNote); } else { _nat02Context.EoiCustomerNotes.Add(customerNote); } _nat02Context.SaveChanges(); _nat02Context.Dispose(); Close(); } catch (Exception ex) { IMethods.WriteToErrorLog("CustomerNoteWindow.xaml.cs => OKButton_Click() => User: '******' CustomerNumber: '" + customerNumber ?? "Null" + "' CustomerName: '" + customerName ?? "Null" + "' ShipToNumber: '" + shipToNumber ?? "Null" + "' ShipToName: '" + shipToName ?? "Null" + "' EndUserNumber: '" + endUserNumber ?? "Null" + "' EndUserName: '******' Category: '" + category + "' Note: '" + note + "' QuoteNumbers: '" + quoteNumbers ?? "Null" + "' OrderNumbers: '" + orderNumbers ?? "Null" + "' NotificationDate: '" + notificationDate ?? "Null" + "'", ex.Message + " ----Inner Exception: " + ex.InnerException.Message, user); MessageBox.Show(ex.Message + "\n" + ex.InnerException.Message); } _nat02Context.Dispose(); }
private void SetOnHold() { try { using var _nat02Context = new NAT02Context(); if (!engineeringProject) { using var _projectsContext = new ProjectsContext(); using var _driveworksContext = new DriveWorksContext(); if (_projectsContext.HoldStatus.Any(p => p.ProjectNumber == projectNumber && p.RevisionNumber == revisionNumber)) { // Update data in HoldStatus HoldStatus holdStatus = _projectsContext.HoldStatus.Where(p => p.ProjectNumber == projectNumber && p.RevisionNumber == revisionNumber).First(); holdStatus.HoldStatus1 = "ON HOLD"; holdStatus.TimeSubmitted = DateTime.Now; holdStatus.OnHoldComment = CommentBox.Text; holdStatus.User = User.GetUserName() ?? Environment.UserName.ToLower(); _projectsContext.HoldStatus.Update(holdStatus); } else { // Insert into HoldStatus HoldStatus holdStatus = new HoldStatus(); holdStatus.ProjectNumber = projectNumber; holdStatus.RevisionNumber = revisionNumber; holdStatus.TimeSubmitted = DateTime.Now; holdStatus.HoldStatus1 = "ON HOLD"; holdStatus.OnHoldComment = CommentBox.Text; holdStatus.User = User.GetUserName() ?? Environment.UserName.ToLower(); _projectsContext.HoldStatus.Add(holdStatus); } // Drive specification transition name to "On Hold - " projectType string _name = projectNumber + (Convert.ToInt32(revisionNumber) > 0 ? "_" + revisionNumber : ""); Specifications spec = _driveworksContext.Specifications.Where(s => s.Name == _name).First(); spec.StateName = "On Hold - " + projectType; _driveworksContext.Specifications.Update(spec); var name = IMethods.GetDisplayNameFromDWPrincipalID(_projectsContext.ProjectSpecSheet.First(p => p.ProjectNumber.ToString() == projectNumber && p.RevisionNumber.ToString() == revisionNumber).Csr).Split(' '); EoiNotificationsActive eoiNotificationsActive = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive); if (!string.IsNullOrEmpty(_projectsContext.ProjectSpecSheet.First(p => p.ProjectNumber.ToString() == projectNumber && p.RevisionNumber.ToString() == revisionNumber).ReturnToCsr)) { name = IMethods.GetDisplayNameFromDWPrincipalID(_projectsContext.ProjectSpecSheet.First(p => p.ProjectNumber.ToString() == projectNumber && p.RevisionNumber.ToString() == revisionNumber).ReturnToCsr).Split(' '); EoiNotificationsActive eoiNotificationsActive1 = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive1); } _projectsContext.SaveChanges(); _driveworksContext.SaveChanges(); _nat02Context.SaveChanges(); _projectsContext.Dispose(); _driveworksContext.Dispose(); _nat02Context.Dispose(); parent.BoolValue = true; } else { using var _projectsContext = new ProjectsContext(); EngineeringProjects eProject = _projectsContext.EngineeringProjects.First(p => p.ProjectNumber == projectNumber.ToString() && p.RevNumber == revisionNumber.ToString()); eProject.OnHold = true; eProject.OnHoldComment = CommentBox.Text; eProject.OnHoldDateTime = DateTime.UtcNow; eProject.OnHoldUser = User.GetUserName() ?? Environment.UserName.ToLower(); var name = IMethods.GetDisplayNameFromDWPrincipalID(eProject.CSR).Split(' '); EoiNotificationsActive eoiNotificationsActive = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive); if (!string.IsNullOrEmpty(eProject.ReturnToCSR) && eProject.ReturnToCSR.Length > 0) { name = IMethods.GetDisplayNameFromDWPrincipalID(eProject.ReturnToCSR).Split(' '); EoiNotificationsActive eoiNotificationsActive1 = new EoiNotificationsActive() { Type = "Project", Number = projectNumber, Message = "Project has been put on hold.", User = (name[0].Substring(0, 1) + name[1]).ToLower(), Timestamp = DateTime.Now }; _nat02Context.EoiNotificationsActive.Add(eoiNotificationsActive1); } //string _name = projectNumber + (Convert.ToInt32(revisionNumber) > 0 ? "_" + revisionNumber : ""); //Specifications spec = _driveworksContext.Specifications.Where(s => s.Name == _name).First(); //spec.StateName = "On Hold - " + projectType; //_driveworksContext.Specifications.Update(spec); _projectsContext.SaveChanges(); _nat02Context.SaveChanges(); _projectsContext.Dispose(); _nat02Context.Dispose(); if (projectWindow != null) { projectWindow.PutOnHoldButton.Content = "Take Off Hold"; } } string path = @"R:\TOOLING AUTOMATION\Project Specifications\" + projectNumber + "\\"; if (File.Exists(path + "On_Hold_Comment.txt")) { int i = 1; while (File.Exists(path + "On_Hold_Comment_" + i + ".txt")) { i++; } path = path + "On_Hold_Comment_" + i + ".txt"; } try { // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.Write("Comment: " + Environment.NewLine + CommentBox.Text + Environment.NewLine + Environment.NewLine + "Time: " + Convert.ToString(DateTime.Now) + Environment.NewLine + "User: "******"SetOnHold", ex.Message); } }
/// <summary> /// Instance of the current user of the application to house settings and preferences /// </summary> /// <param name="domainName"></param> public User(string domainName) { try { DomainName = domainName.ToLower(); } catch (Exception ex) { IMethods.WriteToErrorLog("User.cs -> Setting domain name.", ex.Message, null); } using var _nat02context = new NAT02Context(); EoiSettings settings = _nat02context.EoiSettings.SingleOrDefault(row => row.DomainName.Trim().ToLower() == domainName.Trim().ToLower()); try { System.IO.StreamReader streamReader = new System.IO.StreamReader(@"\\nshare\VB_Apps\NatoliOrderInterface\version.json"); string version = ""; while (!streamReader.ReadLine().Contains(':')) { version = streamReader.ReadLine().Split(':')[1].Trim('"'); break; } PackageVersion = version; settings.PackageVersion = PackageVersion; _nat02context.SaveChanges(); } catch (Exception ex) { IMethods.WriteToErrorLog("User.cs -> Export applications version.", ex.Message, null); } _nat02context.Dispose(); string deptCode = DomainName.Length == 0 ? "GUEST" : SetUserName(); EmployeeCode = settings.EmployeeId; userName = settings.FullName; using var _driveworksContext = new DriveWorksContext(); dwDisplayName = userName == "Gregory Lyle" ? "Greg Lyle" : userName == "Nicholas Tarte" ? "Nick Tarte" : userName == "Floyd Smith" ? "Joe Smith" : userName == "Ronald Faltus" ? "Ron Faltus" : userName; if (_driveworksContext.SecurityUsers.Any(su => su.DisplayName == dwDisplayName)) { dwPrincipalId = _driveworksContext.SecurityUsers.First(su => su.DisplayName == dwDisplayName).PrincipalId; } else { dwDisplayName = ""; dwPrincipalId = ""; } _driveworksContext.Dispose(); Subscribed = settings.Subscribed.Split().ToList(); Width = settings.Width; Height = settings.Height; Top = settings.Top; Left = settings.Left; Maximized = settings.Maximized; QuoteDays = settings.QuoteDays; Zoom = settings.Zoom; ModuleRows = (short)settings.ModuleRows; FilterActiveProjects = settings.FilterActiveProjects; DepartmentCode = deptCode; if (deptCode == "D1153" || DomainName == "pturner" || DomainName == "rmouser") { Department = "Engineering"; } else if (deptCode == "D1102") { Department = "Hob Programming"; } else if (deptCode == "D1151") { Department = "Order Entry"; } else if (deptCode == "D1133") { Department = "Barb"; } else { Department = "Customer Service"; } VisiblePanels = settings.Panels.Split(',').ToList(); foreach (string panel in VisiblePanels) { if (panel == "TabletProjectsNotStarted" || panel == "TabletProjectsStarted" || panel == "TabletProjectsDrawn" || panel == "TabletProjectsSubmitted" || panel == "TabletProjectsOnHold" || panel == "ToolProjectsNotStarted" || panel == "ToolProjectsStarted" || panel == "ToolProjectsDrawn" || panel == "ToolProjectsOnHold") { VisiblePanels.Remove(panel); } } if (DomainName == "dkruggel") { SignatureLeft = 955; SignatureBottom = 20; } else if (DomainName == "twilliams") { SignatureLeft = 958; SignatureBottom = 20; } else if (DomainName == "dsachuk") { SignatureLeft = 958; SignatureBottom = 20; } else { SignatureLeft = 0; SignatureBottom = 0; } if (userName.ContainsAny("David Kruggel", "Tyler Williams", "Mustafa Mulaosmanovic")) { ViewReports = true; } //if (DomainName == "dkruggel" || DomainName == "twilliams") //{ // InputBox inputBox = new InputBox("Enter password", "Password"); // inputBox.ShowDialog(); // Password = inputBox.ReturnString; //} }
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); } }