public override string ToString() { StringBuilder details = new StringBuilder(); details.AppendLine(Caption); details.Append('\t').Append("Availability: ").Append(Decode.Availability(Availability)).AppendLine(); details.Append('\t').Append("BytesPerSector: ").Append(BytesPerSector).AppendLine(); details.Append('\t').Append("Capabilities: ").Append(Capabilities).AppendLine(); details.Append('\t').Append("CapabilityDescriptions: ").Append(string.Join(", ", CapabilityDescriptions)).AppendLine(); details.Append('\t').Append("CompressionMethod: ").Append(CompressionMethod).AppendLine(); details.Append('\t').Append("ConfigManagerErrorCode: ").Append(Decode.ConfigManagerErrorCode(ConfigManagerErrorCode)).AppendLine(); details.Append('\t').Append("ConfigManagerUserConfig: ").Append(ConfigManagerUserConfig).AppendLine(); details.Append('\t').Append("CreationClassName: ").Append(CreationClassName).AppendLine(); details.Append('\t').Append("DefaultBlockSize: ").Append(DefaultBlockSize).AppendLine(); details.Append('\t').Append("Description: ").Append(Description).AppendLine(); details.Append('\t').Append("DeviceId: ").Append(DeviceId).AppendLine(); details.Append('\t').Append("ErrorCleared: ").Append(ErrorCleared).AppendLine(); details.Append('\t').Append("ErrorDescription: ").Append(ErrorDescription).AppendLine(); details.Append('\t').Append("ErrorMethodology: ").Append(ErrorMethodology).AppendLine(); details.Append('\t').Append("FirmwareRevision: ").Append(FirmwareRevision).AppendLine(); details.Append('\t').Append("Index: ").Append(Index).AppendLine(); details.Append('\t').Append("InterfaceType: ").Append(InterfaceType).AppendLine(); details.Append('\t').Append("InstallDate: ").Append(InstallDate.ToString("u")).AppendLine(); details.Append('\t').Append("LastErrorCode: ").Append(LastErrorCode).AppendLine(); details.Append('\t').Append("Manufacturer: ").Append(Manufacturer).AppendLine(); details.Append('\t').Append("MaxBlockSize: ").Append(MaxBlockSize).AppendLine(); details.Append('\t').Append("MaxMediaSize: ").Append(MaxMediaSize).AppendLine(); details.Append('\t').Append("MediaLoaded: ").Append(MediaLoaded).AppendLine(); details.Append('\t').Append("MediaType: ").Append(MediaType).AppendLine(); details.Append('\t').Append("MinBlockSize: ").Append(MinBlockSize).AppendLine(); details.Append('\t').Append("Model: ").Append(Model).AppendLine(); details.Append('\t').Append("Name: ").Append(Name).AppendLine(); details.Append('\t').Append("NeedsCleaning: ").Append(NeedsCleaning).AppendLine(); details.Append('\t').Append("NumberOfMediaSupported: ").Append(NumberOfMediaSupported).AppendLine(); details.Append('\t').Append("Partitions: ").Append(Partitions).AppendLine(); details.Append('\t').Append("PNPDeviceID: ").Append(PnpDeviceId).AppendLine(); details.Append('\t').Append("PowerManagementCapabilities: ").Append(Decode.PowerManagementCapabilities(PowerManagementCapabilities)).AppendLine(); details.Append('\t').Append("PowerManagementSupported: ").Append(PowerManagementSupported).AppendLine(); details.Append('\t').Append("SCSIBus: ").Append(ScsiBus).AppendLine(); details.Append('\t').Append("SCSILogicalUnit: ").Append(ScsiLogicalUnit).AppendLine(); details.Append('\t').Append("SCSIPort: ").Append(ScsiPort).AppendLine(); details.Append('\t').Append("SCSITargetId: ").Append(ScsiTargetId).AppendLine(); details.Append('\t').Append("SectorsPerTrack: ").Append(SectorsPerTrack).AppendLine(); details.Append('\t').Append("SerialNumber: ").Append(SerialNumber).AppendLine(); details.Append('\t').Append("Signature: ").Append(Signature).AppendLine(); details.Append('\t').Append("Size: ").Append(Size).AppendLine(); details.Append('\t').Append("Status: ").Append(Status).AppendLine(); details.Append('\t').Append("StatusInfo: ").Append(Decode.StatusInfo(StatusInfo)).AppendLine(); details.Append('\t').Append("SystemCreationClassName: ").Append(SystemCreationClassName).AppendLine(); details.Append('\t').Append("SystemName: ").Append(SystemName).AppendLine(); details.Append('\t').Append("TotalCylinders: ").Append(TotalCylinders).AppendLine(); details.Append('\t').Append("TotalHeads: ").Append(TotalHeads).AppendLine(); details.Append('\t').Append("TotalSectors: ").Append(TotalSectors).AppendLine(); details.Append('\t').Append("TotalTracks: ").Append(TotalTracks).AppendLine(); details.Append('\t').Append("TracksPerCylinder: ").Append(TracksPerCylinder).AppendLine(); return(details.ToString()); }
private string GenerateReport() { // Get information about the truck, trailer, driver string truck = tb_truck.Text; string trailer = tb_trailer.Text; string driver = tb_driver.Text; string filename = String.Empty; // Test for null or empty strings if (String.IsNullOrEmpty(truck)) { truck = "not assigned"; } if (String.IsNullOrEmpty(trailer)) { trailer = "not assigned"; } if (String.IsNullOrEmpty(driver)) { driver = "_______________"; } // Get today's date string date = InstallDate.ToString("yyyy-MM-dd"); // Get the My Documents path string MyDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // Check if output folder already exists string OutputPath = @MyDocumentsPath + @"\Truck Loads\" + @"\" + date.Substring(0, 7) + @"\"; Console.WriteLine(OutputPath); if (!File.Exists(OutputPath)) { Directory.CreateDirectory(OutputPath); } // Get the final count of items ItemCounts counts = UpdateList(); // If the counts list is null, show a warning to the user and do not generate a PDF if (counts.Covers != null) { // Get items from accessory list List <Accessory> AccList = new List <Accessory>(); int qty = 0; string item = ""; // Call default constructor Createpdf pdf = new Createpdf(); if (accDGV.Rows.Count != 0) { foreach (DataGridViewRow row in accDGV.Rows) { item = row.Cells[0].Value.ToString(); qty = Convert.ToInt32(row.Cells[1].Value); Accessory acc = new Accessory(item, qty); AccList.Add(acc); } // Generate the PDF pdf = new Createpdf(truck, trailer, driver, counts, AccList, date); } else { // Generate the PDF pdf = new Createpdf(truck, trailer, driver, counts, date); } // Create a MigraDoc document Document document = pdf.CreateDocument(); document.UseCmykColor = true; // Create a renderer for PDF that uses Unicode font encoding PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true) { // Set the MigraDoc document Document = document }; // Create the PDF document pdfRenderer.RenderDocument(); // Save the PDF document... // TODO: Check if file already exists filename = string.Format(@"{0}MaterialList_{2}_truck{1}.pdf", OutputPath, truck, date); pdfRenderer.Save(filename); // ...and start a viewer if desired if (ShowPDF == true) { Process.Start(filename); } } else { MessageBox.Show("You can not generate a list at this point, because you have no tents listed. Please add tents to this load.", "Empty List", MessageBoxButtons.OK, MessageBoxIcon.Error); filename = string.Empty; } return(filename); }