public bool GeneratePDF(string fileName) { try { if (string.IsNullOrEmpty(fileName)) { fileName = System.IO.Path.Combine( System.IO.Path.GetTempPath(), "GRN_" + grnNumberBox.Text + ".pdf"); } if (System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName); } if (grnReportControl == null) grnReportControl = new GrnReportControl(); var firstGrnReceipt = (from grnReceipt in DBResources.Instance.Context.GRNReciepts where grnReceipt.GRNIndex == firstGrnIndex select grnReceipt).FirstOrDefault(); if (firstGrnReceipt != null) { GRNReciept grnReceipt = firstGrnReceipt as GRNReciept; GrnReportParameters parameters = new GrnReportParameters(); if (grnIndexes.Count == 1) { parameters.Supplier = Constants.GetSupplierInformation(grnReceipt.OrderedItem.PurchaseOrder.Supplier); parameters.GrnDate = grnReceipt.RecievedDate.Value.ToString(); } else { parameters.Supplier = "Multiple Suppliers"; parameters.GrnDate = "Multiple Dates"; } parameters.GrnNo = grnNumberBox.Text; parameters.StyleInfo = Constants.GetStyleInfo(grnReceipt.OrderedItem.PurchaseOrder.Order); grnReportControl.SetParameters(parameters); grnReportControl.CreateReportAsPDF(grnString, fileName); System.Diagnostics.Process.Start(fileName); return true; } } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); } return false; }
private bool GenerateGrnReport(string filePath, long? grnIndex) { try { if (grnReportControl == null) grnReportControl = new GrnReportControl(); GRNReciept grnReceipt = grnReportGrid.Items[0] as GRNReciept; GrnReportParameters parameters = new GrnReportParameters(); parameters.Supplier = Constants.GetSupplierInformation(ViewModel.PurchaseOrder.Supplier); parameters.GrnNo = grnIndex.Value.ToString(); parameters.GrnDate = grnReceipt.RecievedDate.Value.ToString(); parameters.StyleInfo = Constants.GetStyleInfo(ViewModel.PurchaseOrder.Order); grnReportControl.SetParameters(parameters); grnReportControl.CreateReportAsPDF(grnIndex.Value.ToString(), filePath); } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); return false; } return true; }