コード例 #1
0
        public FileContentResult pdf()
        {
            string html      = string.Empty;
            var    RS        = new ResidencySurveyModel();
            var    CL        = new commonLogic();
            var    htmlToPdf = new HtmlToPdfConverter();

            try
            {
                string uniqueId = (string)Request.QueryString["a"];
                string page     = (string)Request.QueryString["page"];
                RS.where     = " WHERE unique_id = '" + uniqueId + "'";
                CL.dataTable = RS.select();
                CL.pageType  = page;
                html         = CL.ViewHtml();
                string htmlContent = "<!DOCTYPE html><html lang='en'><head><style><style>body{font-family: 'Poppins', sans-serif;}.h5, h5 {font-size: 1rem; }hr{width: 100%;}hr {margin-top: 1rem;margin-bottom: 1rem;border: 0; border-top: 1px solid rgba(0, 0, 0, 0.1);}.col-md-12{width:100%;}.col-sm-8{width:60%; float:left;}.col-sm-4{width:40%;float:right;}</style></style></head><body>" + html + "</body></html>";

                //var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
                htmlToPdf.PageFooterHtml = $@"page <span class=""page""></span> of <span class=""topage""></span>";
                var    pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
                string fileName = CL.getFileName();
                return(File(pdfBytes, "application/pdf", fileName + ".pdf"));
            }
            catch (Exception e)
            {
                CL.getLog("Fail to generate PDF." + e);
                return(new FileContentResult(new byte[] { }, "PDF"));
            }
        }
コード例 #2
0
 public ActionResult list()
 {
     try
     {
         var RS = new ResidencySurveyModel();
         var CL = new commonLogic();
         CL.dataTable     = RS.select();
         CL.tableId       = "residencySurveyList";
         ViewBag.htmldata = CL.residenceSurveyGridView();
     }
     catch (Exception e)
     {
         return(View());
     }
     return(View());
 }
コード例 #3
0
        public string view(string uniqueID)
        {
            string html = string.Empty;

            try
            {
                var RS = new ResidencySurveyModel();
                var CL = new commonLogic();
                RS.where     = " WHERE unique_id = '" + uniqueID + "'";
                CL.dataTable = RS.select();
                CL.pageType  = "summary";
                html         = CL.ViewHtml();
            }
            catch (Exception e)
            {
                return(html);
            }
            return(html);
        }
コード例 #4
0
        public ActionResult index(ResidencySurveyModel RS)
        {
            Boolean status;

            try
            {
                status = RS.insert();
            }
            catch (Exception e)
            {
                status = false;
            }
            if (status)
            {
                return(RedirectToAction("list", "ResidenceSurvey", new { msg = 8 }));
            }
            else
            {
                return(RedirectToAction("list", "ResidenceSurvey", new { msg = 9 }));
            }
        }