private void SaveInfoToDatabase(PDFInfo pdf) { logger.Info($"Getting req info from the database for {pdf.Barcode}"); var barcode = int.Parse(pdf.Barcode); var req = RequisitionFactory.CreateRequisition(barcode, new ProlisService()); if (req != null) { var doc = new RequisitionDocument() { RequisitionId = req.RequisitionNo, Document = pdf.Pdf, markedDeleted = false }; logger.Info("Req info received. Saving info."); var db = new RequisitionService(); db.SaveRequisition(req); var docService = new LOIS.BLL.services.DocumentService(); docService.SaveDocument(doc); if (req.Patient != null) { db.SavePatient(req.Patient); } logger.Debug("Saved for " + pdf.Barcode); } }
private void dgPendingTransactions_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; this.Cursor = Cursors.WaitCursor; try { if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { var item = senderGrid.Rows[e.RowIndex].DataBoundItem as RequisitionItem; if (item == null) { return; } using (var context = SqlDataHandler.GetDataContext()) { var requisitionDoc = context.RequisitionDocumentSet.FirstOrDefault(a => a.RequisitionId == item.RequisitionId); if (e.ColumnIndex == 1) //view doc { this.axAcroPDF1.Visible = false; if (requisitionDoc != null) { DisplayPDF(requisitionDoc.FileData); } } else { ofdAttachment.Multiselect = false; if (ofdAttachment.ShowDialog() == DialogResult.OK) { for (int i = 0; i < ofdAttachment.FileNames.Count(); i++) { if (IsValidPdf(ofdAttachment.FileNames[i])) { byte[] pdfData = File.ReadAllBytes(ofdAttachment.FileNames[i]); if (requisitionDoc == null) { requisitionDoc = new RequisitionDocument() { RequisitionId = item.RequisitionId, IsInvoice = true }; context.RequisitionDocumentSet.Add(requisitionDoc); } requisitionDoc.FileData = pdfData; requisitionDoc.FileName = ofdAttachment.SafeFileNames[i]; context.SaveChanges(); DisplayPDF(pdfData); item.InvoiceCount = 1; RefreshGrid(); } else { Controller.HandleError("Invalid PDF\n" + ofdAttachment.FileNames[i] + "\n Please load a different pdf"); } break; } } } } } } finally { this.Cursor = Cursors.Default; Application.DoEvents(); } }