public override string ToString() { string tokenTypeString = (Type + " ").Substring(0, 16); string location = $"{FromLine.ToString()}:{FromCol.ToString()}-{ToLine.ToString()}:{ToCol.ToString()}"; location = (location + " ").Substring(0, 10); return($"{tokenTypeString} - {location} - '{this.Text ?? ""}'"); }
/// <summary> /// Formats the location according to script preferences /// </summary> /// <param name="script">The script.</param> public string FormatLocation(Script script) { if (IsClrLocation) { return("[clr]"); } if (FromLine == ToLine) { if (FromChar == ToChar) { return($"(Line {FromLine.ToString()}, Position {FromChar.ToString()})"); } return($"(Line {FromLine.ToString()}, Position {FromChar.ToString()}-{ToChar.ToString()})"); } return($"(Line {FromLine.ToString()}, Position {FromChar.ToString()}-{ToLine.ToString()},{ToChar.ToString()})"); }
private void GenerateTrackingCodeButton_Click(object sender, RoutedEventArgs e) { CurrentPart = (Part)Line_PartComboBox.SelectedItem; using (var db = new MTSDB()) { var parts = from p in db.Parts where p.PartNo == CurrentPart.PartNo select p; Part P = parts.SingleOrDefault(); if (P == null) { MessageBox.Show("Part Not Found !! Please Verify", "Database Error", MessageBoxButton.OK, MessageBoxImage.Error); } int qty = 0; if (int.TryParse(Line_ReleaseQtyTextBox.Text, out qty) == false || (qty == 0)) { MessageBox.Show("Please Verify Quantity", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } CurrentPart = P; if (P.Quantity < qty) { MessageBox.Show("Quantity Unavailable", "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } ToLine tl = new ToLine(); foreach (FromStores fs in P.FromStoresRecords) { if (qty > 0) { if (fs.Balance <= 0) { continue; } if (fs.Balance >= qty) { var FromStoresToLines = new FromStoresToLines(); FromStoresToLines.FromStores = fs; FromStoresToLines.ToLine = tl; FromStoresToLines.FromStoresBalance = fs.Balance.Value; fs.Balance -= qty; P.Quantity -= qty; tl.Quantity += qty; tl.Timestamp = DateTime.Now; tl.Part = P; if ((tl.SMN == String.Empty) || tl.SMN == null) { DateTime ts = DateTime.Now; int offset = 0; if (ts.Hour >= 22 && ts.Hour < 6) { offset = 1; } P.ToLineReference++; tl.SMN = P.PartID.ToString("D4") + P.ToLineReference.Value.ToString("D4") + (ts.DayOfYear - offset).ToString("D3") + (ts.Year - 2000).ToString("D2"); } tl.SUN = fs.SUN; FromStoresToLines.ToLineBalance = qty; FromStoresToLines.Part = P; db.FromStoresToLines.Add(FromStoresToLines); break; } else { var FromStoresToLines = new FromStoresToLines(); FromStoresToLines.FromStores = fs; FromStoresToLines.ToLine = tl; FromStoresToLines.FromStoresBalance = fs.Balance.Value; tl.Quantity += fs.Balance; tl.Timestamp = DateTime.Now; tl.Part = P; if ((tl.SMN == String.Empty) || tl.SMN == null) { DateTime ts = DateTime.Now; int offset = 0; if (ts.Hour >= 22 && ts.Hour < 6) { offset = 1; } P.ToLineReference++; tl.SMN = P.PartID.ToString("D4") + P.ToLineReference.Value.ToString("D4") + (ts.DayOfYear - offset).ToString("D3") + (ts.Year - 2000).ToString("D2"); } tl.SUN = fs.SUN; qty -= fs.Balance.Value; FromStoresToLines.ToLineBalance = fs.Balance.Value; P.Quantity -= fs.Balance.Value; fs.Balance = 0; FromStoresToLines.Part = P; db.FromStoresToLines.Add(FromStoresToLines); } } } tl.Balance = tl.Quantity; tl.Timestamp = DateTime.Now; P.ToLineRecords.Add(tl); P.LastUpdated = DateTime.Now; P.LastActivity = "To Line Entry"; db.SaveChanges(); //Code for generation of Tracking Code // PrinterManager.PrintSMN(PrinterName, tl.SMN, templatePath); MessageBox.Show("SMN Generated - " + tl.SMN, "Information", MessageBoxButton.OK, MessageBoxImage.Information); this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { Line_PartComboBox.Text = ""; Line_PartComboBox.SelectedItem = null; Line_ReleaseQtyTextBox.Clear(); DisplayParts.Clear(); })); } }
/// <summary> /// Returns a <see cref="System.String" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String" /> that represents this instance. /// </returns> public override string ToString() { return($"{(IsStepStop ? "*" : " ")} ({FromLine.ToString()}, {FromChar.ToString()}) -> ({ToLine.ToString()}, {ToChar.ToString()})"); }