示例#1
0
        //private void PDF_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        //{
        //    Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();
        //    saveFileDialog.Filter = "PDF File|*.pdf";
        //    saveFileDialog.Title = "Save to a PDF file";
        //    saveFileDialog.ShowDialog();
        //    if (!string.IsNullOrEmpty(saveFileDialog.FileName))
        //    {
        //        float docWidth = (float)diagramView.Page.ActualWidth;
        //        float docHeight = (float)diagramView.Page.ActualHeight;
        //        string jpgFileName = "tempjpg.jpg";
        //        string xpsFileName = "tempXpS.xps";
        //        Syncfusion.XPS.XPSToPdfConverter xpsTopdfConverter = new Syncfusion.XPS.XPSToPdfConverter();
        //        Syncfusion.Pdf.Graphics.PdfUnitConvertor converter = new Syncfusion.Pdf.Graphics.PdfUnitConvertor();
        //        float pdfHeight = converter.ConvertUnits(docHeight, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point);
        //        float pdfWidth = converter.ConvertUnits(docWidth, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point);
        //        System.Drawing.SizeF pageSize = new System.Drawing.SizeF(pdfWidth, pdfHeight);
        //        diagramView.Save(jpgFileName, new Size(docWidth * 1.5, docHeight * 1.5), ImageStretch.Expand);
        //        Syncfusion.Pdf.PdfDocument pdfDocument = new Syncfusion.Pdf.PdfDocument();
        //        pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
        //        pdfDocument.PageSettings.Margins.All = 0;
        //        PdfImage image = new PdfBitmap(jpgFileName);
        //        pdfDocument.PageSettings.Size = image.PhysicalDimension;
        //        Syncfusion.Pdf.PdfPage page = pdfDocument.Pages.Add();
        //        page.Graphics.DrawImage(image, 0, 0);
        //        pdfDocument.Save(saveFileDialog.FileName);
        //        pdfDocument.Close(true);
        //        UpadteImageformat();
        //    }
        //}

        private void ExportToPDF_Click_1(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();
            saveFileDialog.Filter   = "PDF File|*.pdf";
            saveFileDialog.Title    = "Save to a PDF file";
            saveFileDialog.FileName = "Diagram";
            saveFileDialog.ShowDialog();
            if (!string.IsNullOrEmpty(saveFileDialog.FileName))
            {
                float  docWidth    = (float)diagramView.Page.ActualWidth;
                float  docHeight   = (float)diagramView.Page.ActualHeight;
                string jpgFileName = "tempjpg.jpg";
                string xpsFileName = "tempXpS.xps";
                Syncfusion.XPS.XPSToPdfConverter         xpsTopdfConverter = new Syncfusion.XPS.XPSToPdfConverter();
                Syncfusion.Pdf.Graphics.PdfUnitConvertor converter         = new Syncfusion.Pdf.Graphics.PdfUnitConvertor();
                float pdfHeight = converter.ConvertUnits(docHeight, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point);
                float pdfWidth  = converter.ConvertUnits(docWidth, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point);
                System.Drawing.SizeF pageSize = new System.Drawing.SizeF(pdfWidth, pdfHeight);
                diagramView.Save(jpgFileName, new Size(docWidth * 1.5, docHeight * 1.5), ImageStretch.Expand);
                Syncfusion.Pdf.PdfDocument pdfDocument = new Syncfusion.Pdf.PdfDocument();
                pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
                pdfDocument.PageSettings.Margins.All = 0;
                PdfImage image = new PdfBitmap(jpgFileName);
                pdfDocument.PageSettings.Size = image.PhysicalDimension;
                Syncfusion.Pdf.PdfPage page = pdfDocument.Pages.Add();
                page.Graphics.DrawImage(image, 0, 0);
                pdfDocument.Save(saveFileDialog.FileName);
                pdfDocument.Close(true);
                //UpadteImageformat();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string path = @"mychart.png";

            fillChart3();

            string fileName = System.Windows.Forms.Application.StartupPath + "\\chartExport";

            string exportFileName = fileName + ".pdf";

            string file = fileName + ".gif";

            this.chart3.SaveImage("mychart.png", ChartImageFormat.Png);

            //Create a PDF document

            PdfDocument pdfDoc = new PdfDocument();

            //Add a page to the empty PDF document

            pdfDoc.Pages.Add();

            //Draw chart image in the first page

            pdfDoc.Pages[0].Graphics.DrawImage(PdfImage.FromFile(path), new PointF(10, 30));

            //Save the PDF Document to disk.

            pdfDoc.Save(exportFileName);

            // Launches the file.

            System.Diagnostics.Process.Start(exportFileName);
        }
示例#3
0
        /// <summary>
        /// Get pdf stream for creating pdf dcoument
        /// </summary>
        /// <returns></returns>
        private MemoryStream GetPDFStream()
        {
            MemoryStream docIoWordMemoryStream = new MemoryStream();
            MemoryStream docIoPdfMemoryStream  = new MemoryStream();

            _documentTemplate.Save(docIoWordMemoryStream, FormatType.Doc);
            DocToPDFConverter converter = new DocToPDFConverter();

            Syncfusion.Pdf.PdfDocument pdfdoc = converter.ConvertToPDF(docIoWordMemoryStream);
            pdfdoc.Save(docIoPdfMemoryStream);
            return(docIoPdfMemoryStream);
        }
        private void BtnPK_Click(object sender, EventArgs e)
        {
            List <Sport> sport = new List <Sport>();

            sport = InfoWhole();
            //Create a new PDF document
            PdfDocument doc = new PdfDocument();
            //Add a page
            PdfPage page = doc.Pages.Add();
            // Create a PdfLightTable
            PdfLightTable pdfLightTable = new PdfLightTable();

            // Initialize DataTable to assign as DateSource to the light table
            System.Data.DataTable table = new System.Data.DataTable();
            //Include columns to the DataTable

            table.Columns.Add("Kalorije");
            table.Columns.Add("Vzpon distance");
            table.Columns.Add("Kadenca");
            table.Columns.Add("Avg kadenca");
            //Include rows to the DataTable
            int count = sport.Count;

            int stevec = 1;

            foreach (var item in sport)
            {
                table.Rows.Add(new string[] { item.Porabljene_kalorije, item.Skupen_vzpon, item.Max_kadenca, item.Povp_kadenca });
                stevec++;
            }

            //Applying cell padding to table
            pdfLightTable.Style.CellPadding = 3;
            pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable3Accent3);
            //Assign data source
            pdfLightTable.DataSource = table;
            //Setting this property to true to show the header of table
            pdfLightTable.Style.ShowHeader = true;
            //Draw PdfLightTable
            pdfLightTable.Draw(page, new PointF(0, 0));
            //Save the document

            doc.Save("PdfTable.pdf");
            //Close the document
            doc.Close(true);
            //This will open the PDF file so, the result will be seen in default PDF viewer
            Process.Start("PdfTable.pdf");
        }
        private void BtnPDF_Click(object sender, EventArgs e)
        {
            List <Sport> sport = new List <Sport>();

            sport = Info();
            //Create a new PDF document
            Syncfusion.Pdf.PdfDocument doc = new PdfDocument();
            //Add a page
            PdfPage page = doc.Pages.Add();
            // Create a PdfLightTable
            PdfLightTable pdfLightTable = new PdfLightTable();

            // Initialize DataTable to assign as DateSource to the light table
            System.Data.DataTable table = new System.Data.DataTable();
            //Include columns to the DataTable

            table.Columns.Add("Kolesar");
            table.Columns.Add("Total distance");
            table.Columns.Add("Total calories");
            table.Columns.Add("Total time");
            //Include rows to the DataTable
            int count = sport.Count;

            int stevec = 1;

            foreach (var item in sport)
            {
                table.Rows.Add(new string[] { stevec.ToString(), item.Stevilo_prevozenih_km, item.Porabljene_kalorije, item.Trajanje_aktivnosti });
                stevec++;
            }

            //Applying cell padding to table
            pdfLightTable.Style.CellPadding = 3;
            pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable3Accent3);
            //Assign data source
            pdfLightTable.DataSource = table;
            //Setting this property to true to show the header of table
            pdfLightTable.Style.ShowHeader = true;
            //Draw PdfLightTable
            pdfLightTable.Draw(page, new PointF(0, 0));
            //Save the document

            doc.Save("PdfTable.pdf");
            //Close the document
            doc.Close(true);
            //This will open the PDF file so, the result will be seen in default PDF viewer
            Process.Start("PdfTable.pdf");
        }
示例#6
0
        public IActionResult Index()
        {
            HtmlToPdfConverter      converter = new HtmlToPdfConverter();
            WebKitConverterSettings settings  = new WebKitConverterSettings();

            settings.WebKitPath = Path.Combine(Environment.CurrentDirectory, "QtBinariesWindows");

            converter.ConverterSettings = settings;
            string      path     = "https://localhost:44347/Invoice/ShowInvoice?OrderId=2015";
            PdfDocument document = converter.Convert("https://www.google.com");

            MemoryStream ms = new MemoryStream();

            document.Save(ms);

            document.Close(true);

            ms.Position = 0;
            FileStreamResult fileStreamResult = new FileStreamResult(ms, "application/pdf");

            fileStreamResult.FileDownloadName = "CHUJ.pdf";
            return(fileStreamResult);
        }
示例#7
0
        public async Task <IActionResult> GenerateDocument(int Id, string tokenId)
        {
            var LabTest = tests.GetById(Id);

            if (LabTest == null)
            {
                return(NotFound());
            }

            //Loads or opens an existing word document through Open method of WordDocument class
            Stream fs = new FileStream("Templates/result.docx", FileMode.Open, FileAccess.Read, FileShare.Read);

            WordDocument document = new WordDocument(fs, FormatType.Docx);

            if (document.Sections.Count < 1)
            {
                throw new Exception("Result template empty. Please contact your Application support.");
            }
            IWSection section = document.Sections[0];

            IWTable table = section.Tables[0];

            WParagraph p = (WParagraph)table.Rows[0].Cells[1].ChildEntities[0];

            p.AppendText(LabTest.BioData.Fullname);

            p = (WParagraph)table.Rows[1].Cells[1].ChildEntities[0];
            string gardian = LabTest.BioData.LegalGardianName;

            gardian = string.IsNullOrEmpty(gardian) ? "-" : gardian;
            p.AppendText(gardian);

            p = (WParagraph)table.Rows[2].Cells[1].ChildEntities[0];
            p.AppendText(Utils.Utils.toShortdate(LabTest.BioData.Dateofbirth));

            //skip 3


            //Repos.GenderRepos genders = new Repos.GenderRepos();


            int g_id = 1;

            foreach (var g in genders.GetAll())
            {
                string tmp = g.Gender.Substring(0, 2).Trim().Trim('=');
                try
                {
                    p = (WParagraph)table.Rows[3].Cells[g_id].ChildEntities[0];
                    WCheckBox checkbox = p.AppendCheckBox();

                    if (LabTest.BioData.Gender == g_id)
                    {
                        checkbox.Checked = true;
                    }

                    p.AppendText(" " + tmp);

                    g_id++;
                }
                catch {
                }
            }

            p = (WParagraph)table.Rows[4].Cells[1].ChildEntities[0];
            p.AppendText(LabTest.BioData.EpidNo);

            //skip 5 for local phone number
            p = (WParagraph)table.Rows[5].Cells[1].ChildEntities[0];
            p.AppendText(LabTest.BioData.LocalPhone ?? "-");

            p = (WParagraph)table.Rows[6].Cells[1].ChildEntities[0];
            p.AppendText(LabTest.BioData.HomePhone ?? "-");

            p = (WParagraph)table.Rows[7].Cells[1].ChildEntities[0];
            p.AppendText(LabTest.BioData.ResidentialAddress);

            //next table
            table = section.Tables[1];

            p = (WParagraph)table.Rows[0].Cells[1].ChildEntities[0];
            p.AppendText(LabTest.LabTest.MethodNavigation.Methodname);

            int k = 1;

            var _indicators = indicators.GetAll();

            foreach (var i in LabTest.Indicators)
            {
                var iname = _indicators.FirstOrDefault(x => x.Id == i.Indicator).IndicatorName;

                p = (WParagraph)table.Rows[k].Cells[0].ChildEntities[0];
                p.AppendText(iname);

                p = (WParagraph)table.Rows[k].Cells[1].ChildEntities[0];
                p.AppendText(i.IndicatorValue.Value.ToString());

                k++;
            }



            /*Dictionary<int, string> _dict = new Dictionary<int, string> {
             *  { 1, "POSITIVE"},
             *  { 2, "NEGATIVE"},
             *  { 97, "NO RESULT"}
             * };*/
            var p1 = (WParagraph)table.Rows[k].Cells[0].ChildEntities[0];

            p = (WParagraph)table.Rows[k].Cells[1].ChildEntities[0];
            WCheckBox checkbox1 = p.AppendCheckBox();

            if (LabTest.LabTest.Interpretation == 2)
            {
                checkbox1.Checked = true;
                p1.AppendText("INTERPRETATION: NEGATIVE RESULT");
            }
            else if (LabTest.LabTest.Interpretation > 2)
            {
                p1.AppendText("INTERPRETATION: UNKNOWN");
            }

            p.AppendText(" NEGATIVE");

            p         = (WParagraph)table.Rows[k + 1].Cells[1].ChildEntities[0];
            checkbox1 = p.AppendCheckBox();
            if (LabTest.LabTest.Interpretation == 1)
            {
                checkbox1.Checked = true;
                p1.AppendText("INTERPRETATION: POSITIVE RESULT");
            }

            p.AppendText(" POSITIVE");

            //next table
            table = section.Tables[2];

            DateTime d1 = DateTime.Today;               // any date will do

            p = (WParagraph)table.Rows[0].Cells[1].ChildEntities[0];
            p.AppendText(LabTest.LabTest.TestingDate.Value.ToString("dd/MMM/yyyy"));

            p = (WParagraph)table.Rows[1].Cells[1].ChildEntities[0];
            TimeSpan t   = LabTest.LabTest.TestingTime.Value;
            string   chg = (d1 + t).ToString("hh:mm tt");

            p.AppendText(chg);

            p = (WParagraph)table.Rows[2].Cells[1].ChildEntities[0];
            p.AppendText(LabTest.LabTest.ReportingDate.Value.ToString("dd/MMM/yyyy"));

            p   = (WParagraph)table.Rows[3].Cells[1].ChildEntities[0];
            t   = LabTest.LabTest.ReportingTime.Value;
            chg = (d1 + t).ToString("hh:mm tt");
            p.AppendText(chg);

            //next table
            table = section.Tables[3];

            //Repos.SpecimenRepos _specimen = new Repos.SpecimenRepos();

            k = 1;
            foreach (var s in LabTest.Specimen)
            {
                bool other = s.Specimen == 99;

                var sname = specimen.GetById(s.Specimen).Type;
                p = (WParagraph)table.Rows[k].Cells[0].ChildEntities[0];

                IWTextRange textRange = p.AppendText(sname + (other?" (Specify)":""));
                textRange.CharacterFormat.FontSize = 8;


                p.ApplyStyle(Syncfusion.DocIO.DLS.BuiltinStyle.BlockText);
                p = (WParagraph)table.Rows[k].Cells[1].ChildEntities[0];
                if (other && !string.IsNullOrEmpty(s.SpecimenOther))
                {
                    textRange = p.AppendText(s.SpecimenOther);
                    textRange.CharacterFormat.FontSize = 10;
                }

                p         = (WParagraph)table.Rows[k].Cells[2].ChildEntities[0];
                checkbox1 = p.AppendCheckBox();
                if (s.Checked)
                {
                    checkbox1.Checked = true;
                }

                k++;
            }


            //
            //table = section.Tables[1];
            // p = (WParagraph)table.Rows[6].Cells[1].ChildEntities[0];
            //p.AppendText(LabTest.BioData.ResidentialAddress);


            DocIORenderer render = new DocIORenderer();

            //Converts Word document to PDF.
            Syncfusion.Pdf.PdfDocument pdfDocument = render.ConvertToPDF(document);
            //Release the resources used by the Word document and DocIO Renderer objects.

            render.Dispose();
            //render.Dispose();
            document.Dispose();

            //add barcode
            PdfQRBarcode barcode = new PdfQRBarcode();

            barcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High;
            //Set XDimension
            barcode.XDimension = 2.5f;
            //https://localhost:44353/LabTests/Details/

            barcode.Text = string.Format("{0}LabTests/Details/{1}", _api.getEnpoint(), Id);
            //Creating new PDF Document
            //PdfDocument doc = new PdfDocument();
            //Adding new page to PDF document
            PdfPage page = pdfDocument.Pages[0];

            //Printing barcode on to the Pdf.
            //barcode.Draw(page, new PointF(25, 70));
            barcode.Draw(page, new PointF(250, 650));

            if (!string.IsNullOrEmpty(tokenId))
            {
                Response.Cookies.Append("fileDownloadToken", tokenId);
            }

            MemoryStream stream = new MemoryStream();

            //document.Save(stream, FormatType.Docx);
            pdfDocument.Save(stream);
            //return File(stream, "application/msword", "Sample.docx");
            return(File(stream.ToArray(), "application/octet-stream", "Draft.pdf"));
            //return RedirectToAction(nameof(Index));
        }
示例#8
0
        protected void btnGenerateReport_Click(object sender, EventArgs e)
        {
            //Syncfusion PDF
            Syncfusion.Pdf.PdfDocument[] documents = new Syncfusion.Pdf.PdfDocument[10];
            string[] allPDFDocument = new string[10];

            List <string>     listPDF   = new List <string>();
            DocToPDFConverter converter = new DocToPDFConverter();

            dsShowAllDocData = dbFamilyDetailsData.getSOOfficeDocument(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString());
            if (dsShowAllDocData.Tables[0].Rows.Count > 0)
            {
                int i = 0;
                foreach (DataRow rows in dsShowAllDocData.Tables[0].Rows)
                {
                    string DocFileName = rows["docfile"].ToString();
                    if (DocFileName != "" && !string.IsNullOrEmpty(DocFileName))
                    {
                        string FileExist = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName);
                        if (File.Exists(FileExist))
                        {
                            string fileextension = Path.GetExtension(FileExist.ToString());
                            switch (fileextension)
                            {
                            case ".docx":
                                WordDocument wordDocumentdocx = new WordDocument(FileExist, FormatType.Docx);
                                string       FolderNameDocx   = Server.MapPath(@"~/TempFile/" + cmbVillage.SelectedValue.ToString() + "/");
                                if (!Directory.Exists(FolderNameDocx))
                                {
                                    Directory.CreateDirectory(FolderNameDocx);
                                }
                                documents[i] = converter.ConvertToPDF(wordDocumentdocx);
                                string genfilenameDocx = wordDocumentdocx + "_" + i;
                                //Response.WriteFile(Server.MapPath(@"~/Documents/" + lblVillageCodeHidden.Text + "/" + lbllinkRegisrationSearch.Text));
                                documents[i].Save(FolderNameDocx + genfilenameDocx + ".pdf");
                                allPDFDocument[i] = FolderNameDocx + genfilenameDocx + ".pdf";
                                //documents[i].Save(@"F:\\DocToPDF1.pdf");
                                listPDF.Add(FolderNameDocx + genfilenameDocx + ".pdf");
                                break;

                            //RSD
                            case ".doc":
                                WordDocument wordDocumentDoc = new WordDocument(FileExist, FormatType.Doc);
                                string       FolderNameDoc   = Server.MapPath(@"~/TempFile/" + cmbVillage.SelectedValue.ToString() + "/");
                                if (!Directory.Exists(FolderNameDoc))
                                {
                                    Directory.CreateDirectory(FolderNameDoc);
                                }
                                documents[i] = converter.ConvertToPDF(wordDocumentDoc);
                                string genfilenameDoc = wordDocumentDoc + "_" + i;
                                //Response.WriteFile(Server.MapPath(@"~/Documents/" + lblVillageCodeHidden.Text + "/" + lbllinkRegisrationSearch.Text));
                                documents[i].Save(FolderNameDoc + genfilenameDoc + ".pdf");
                                allPDFDocument[i] = FolderNameDoc + genfilenameDoc + ".pdf";
                                //documents[i].Save(@"F:\\DocToPDF1.pdf");
                                listPDF.Add(FolderNameDoc + genfilenameDoc + ".pdf");
                                break;

                            case ".pdf":

                                string FolderNamePDF = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName);
                                if (!File.Exists(FolderNamePDF))
                                {
                                    //Directory.CreateDirectory(FolderNameDoc);
                                }
                                else
                                {
                                    //listPDF.Add(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + FileExist + ".pdg");
                                    listPDF.Add(Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName));
                                }


                                break;
                            }
                        }
                    }
                    i = i + 1;
                }//FOr End

                //Get All 7/12 File
                DataSet       dsGet712Files  = new DataSet();
                List <string> listPDF712File = new List <string>();
                dsGet712Files = dbFamilyDetailsData.Get712files(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString());
                if (dsGet712Files.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow rows in dsGet712Files.Tables[0].Rows)
                    {
                        string PDFFileName712 = rows["pdffilename"].ToString();
                        if (PDFFileName712 != "" && !string.IsNullOrEmpty(PDFFileName712))
                        {
                            string FileExist = Server.MapPath(@"~/7-12PDF/" + PDFFileName712 + ".pdf");
                            if (File.Exists(FileExist))
                            {
                                listPDF712File.Add(FileExist);
                            }
                        }
                    }
                    //Create 712 PDF FIle One
                    Syncfusion.Pdf.PdfDocument PDFFile712 = new Syncfusion.Pdf.PdfDocument();

                    //Syncfusion.Pdf.PdfDocumentBase.Merge(PDFFile712, listPDFArray712);

                    //listPDF.Add(Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName));
                }


                //End 712file

                Syncfusion.Pdf.PdfDocument newPdf1 = new Syncfusion.Pdf.PdfDocument();
                //DocToPDFConverter converter2 = new DocToPDFConverter();

                string[] listPDFArray    = listPDF.ToArray();
                string[] listPDFArray712 = listPDF712File.ToArray();
                Syncfusion.Pdf.PdfDocumentBase.Merge(newPdf1, listPDFArray);
                Syncfusion.Pdf.PdfDocumentBase.Merge(newPdf1, listPDFArray712);
                //newPdf1.Save(@"F:\\newPDFRSD.pdf");
                //newPdf1.Close(true);

                try
                {
                    string registerFileNo = dbFileNoData.getFileNo("PTS");
                    //string filename = Path.GetFileName(FControlName.FileName);
                    string fileExtension = ".pdf";
                    string VillageCode   = cmbVillage.SelectedValue.ToString();
                    string DocumentNo    = cmbDocumentNo.SelectedValue.ToString();
                    string NewFileName   = "PTS" + "_" + VillageCode + "_" + DocumentNo + "_" + registerFileNo + fileExtension;
                    string folderName    = Server.MapPath("~/Documents/" + VillageCode + "/");
                    if (!Directory.Exists(folderName))
                    {
                        Directory.CreateDirectory(folderName);
                    }
                    newPdf1.Save(folderName + NewFileName);
                    newPdf1.Close(true);
                    //  FControlName.SaveAs(folderName + NewFileName);

                    dbFileNoData.registername = "PTS";
                    dbFileNoData.currentno    = Convert.ToInt32(registerFileNo) + 1;
                    dbFileNoData.UpdateFileNo();
                    lbllnkTS.Text = NewFileName;
                    string FinalPath = folderName + NewFileName;
                    ViewState["filepath"] = FinalPath;

                    //Insert in to Document Status
                    string DocumentID = dbDocumentStatusData.getDocumentSeqNo();
                    dbDocumentStatusData.documentid   = Convert.ToInt32(DocumentID);
                    dbDocumentStatusData.villagecode  = cmbVillage.SelectedValue.ToString();
                    dbDocumentStatusData.documentcode = "PTS";
                    dbDocumentStatusData.documentname = NewFileName;
                    dbDocumentStatusData.documentpath = ViewState["filepath"].ToString();
                    dbDocumentStatusData.createdby    = Session["UserName"].ToString();
                    dbDocumentStatusData.createddate  = DateTime.Today;
                    dbDocumentStatusData.docno        = cmbDocumentNo.SelectedValue.ToString();
                    //Check For Record Exist
                    dsDocumenteExists = dbDocumentStatusData.DocumentExistRO(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString(), "PTS");
                    if (dsDocumenteExists.Tables[0].Rows.Count == 0)
                    {
                        //string ModifiedSurveyNo = dbDocumentStatusData.surveyno;
                        //dbDocumentStatusData.surveyno = ModifiedSurveyNo.Replace("'", "");
                        dbDocumentStatusData.surveyno      = "";
                        dbDocumentStatusData.familyno      = "";
                        dbDocumentStatusData.titlesearchno = "";
                        dbDocumentStatusData.officename    = "SO1";
                        bool DocInsert = dbDocumentStatusData.AddDocumentStatus();
                        if (DocInsert)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Not Uploaded');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Uploaded');", true);
                            SendSMS("5");
                        }
                    }
                    else
                    {
                        bool DocumentFileUpdate = dbDocumentStatusData.UpdateDocumentStatusFile();
                        if (DocumentFileUpdate)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report Not Uploaded');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Update');", true);
                            SendSMS("5");
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }