Beispiel #1
0
        public bool Print(Guid?id, string printOption)
        {
            try
            {
                OPDHistory      entity = new OPDHistory();
                OPDHistoryModel model  = entity.GetById(id.Value);

                string renamefileName = DateTime.Now.Ticks.ToString() + ".pdf";
                string path           = ConfigurationManager.AppSettings["SaveReport"].ToString() + DateTime.Now.ToString("dd-MM-yyyy");
                if (ErrorLog.IsFolderExist(path))
                {
                    path = path + "\\" + renamefileName;
                }


                // Create a Document object //
                var document = new iTextSharp.text.Document(PageSize.A4, 50, 50, 10, 10);

                // Create a new PdfWrite object, writing the output to a MemoryStream //
                FileStream output = new FileStream(path, FileMode.Create);
                var        writer = PdfWriter.GetInstance(document, output);

                // Method To Set Page Header And Footer //
                //setBillHeaderFooter(writer, document);

                // Open the Document for writing //
                document.Open();

                if (printOption == "Bill")
                {
                    setBillPageBody(document, model);
                    new BillHistory().Update(model.Id);
                }
                else if (printOption == "Prescription")
                {
                    setPrescriptionPageBody(document, model);
                }
                else if (printOption == "Both")
                {
                    setBillPageBody(document, model);
                    setPrescriptionPageBody(document, model);
                }

                // flush and clear the document from memory //
                document.Close();

                System.Diagnostics.Process.Start(path);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
 public OPDHistoryModel GetById(Guid id)
 {
     try
     {
         OPDHistory entity = new OPDHistory();
         return(entity.GetById(id));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }