Ejemplo n.º 1
0
        public ActionResult Report(SelectReportModel model)
        {
            try
            {
                using (InhCheckupDataContext cdc = new InhCheckupDataContext())
                {
                    string rptID = model.DropdownReport[0].Value;

                    string path = cdc.mst_corp_reports.Where(x => x.mcr_id == Convert.ToInt32(rptID)).Select(x => x.mcr_report_path).FirstOrDefault();
                    if (path == null)
                    {
                        List <Stream> listStream = new List <Stream>();
                        List <string> listPath   = cdc.mst_corp_reports.Where(x => (x.mcr_is_multi_report == true) && (x.mcr_type == 'F')).OrderBy(x => x.mcr_seq).Select(x => x.mcr_report_path).ToList();
                        foreach (string rptPath in listPath)
                        {
                            listStream.Add(LoadReport(rptPath, model));
                        }
                        return(File(MergedPDF(listStream), "application/pdf", "Corporate Summary.pdf"));
                    }
                    else
                    {
                        string nameReport = cdc.mst_corp_reports.Where(x => x.mcr_report_path == path).Select(y => y.mcr_report_name).FirstOrDefault();
                        string filename   = nameReport + ".pdf";
                        return(File(LoadReport(path, model), "application/pdf", filename));
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Msg = ex.Message;
                return(View("Report", model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult SelectReport(Criterias model)
        {
            int totalservice = 0;

            using (InhCheckupDataContext cdc = new InhCheckupDataContext())
            {
                totalservice = cdc.vw_patient_corporates
                               .Where(x => (x.companyname == null ? "" : x.companyname) == (model.companyname == null ? "" : model.companyname) &&
                                      x.arrived_date.Value.Date >= model.startdate.Date &&
                                      x.arrived_date.Value.Date <= model.enddate.Date)
                               .Count();
            }
            SelectReportModel sModel = new SelectReportModel
            {
                companyname     = model.companyname,
                startdate       = model.startdate,
                enddate         = model.enddate,
                patients        = model.patients,
                totalservice    = totalservice,
                sub_companyname = model.sub_companyname
            };

            using (InhCheckupDataContext cdc = new InhCheckupDataContext())
            {
                List <mst_corp_report> mstRpt = cdc.mst_corp_reports
                                                .Where(x => (x.mcr_active == true) && (x.mcr_type == 'F')).ToList();
                sModel.DropdownReport = mstRpt.OrderBy(x => x.mcr_seq)
                                        .Select(x => new SelectListItem
                {
                    Selected = false,
                    Value    = x.mcr_id.ToString(),
                    Text     = x.mcr_report_name
                }).ToList();
                if (sModel.DropdownReport.Count > 0)
                {
                    sModel.DropdownReport.FirstOrDefault().Selected = true;
                }
                return(View("SelectReport", sModel));
            }
        }
Ejemplo n.º 3
0
        private Stream LoadReport(string path, SelectReportModel model)
        {
            try
            {
                string         reportPath = Request.MapPath(path);
                ReportDocument rptDoc     = new ReportDocument();
                rptDoc.Load(reportPath);
                SetDBLogonForReport(rptDoc);
                rptDoc.Refresh();
                rptDoc.VerifyDatabase();
                rptDoc.SetParameterValue("@companyName", string.IsNullOrEmpty(model.companyname) ? "" : model.companyname);
                rptDoc.SetParameterValue("@subcompanyName", string.IsNullOrEmpty(model.sub_companyname) ? "" : model.sub_companyname);
                rptDoc.SetParameterValue("@startDate", model.startdate);
                rptDoc.SetParameterValue("@endDate", model.enddate);

                if (CheckParamReport(rptDoc, "@totalpatient"))
                {
                    rptDoc.SetParameterValue("@totalpatient", model.patients);
                }
                if (CheckParamReport(rptDoc, "@totalservice"))
                {
                    rptDoc.SetParameterValue("@totalservice", model.totalservice);
                }
                if (CheckParamReport(rptDoc, "@totalnoservice"))
                {
                    rptDoc.SetParameterValue("@totalnoservice", model.patients - model.totalservice);
                }
                Stream pdf = rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                rptDoc.Close();
                rptDoc.Dispose();
                return(pdf);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
 public ActionResult SelectReport(SelectReportModel model)
 {
     return(Report(model));
 }