public ActionResult ExportReport() { List <Purchase> allEverest = new List <Purchase>(); using (pharmEntities dc = new pharmEntities()) { allEverest = dc.Purchases.ToList(); } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Report"), "PurchaseReport.rpt")); rd.SetDataSource(allEverest); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "EverestList.pdf")); } catch (Exception ex) { throw; } }
public JsonResult SaveEvent(Event e) { var status = false; using (pharmEntities dc = new pharmEntities()) { if (e.Id > 0) { //Update the event var v = dc.Events.Where(a => a.Id == e.Id).FirstOrDefault(); if (v != null) { v.Subject = e.Subject; v.Start = e.Start; v.End = e.End; v.Description = e.Description; v.IsFullDay = e.IsFullDay; v.ThemeColor = e.ThemeColor; } } else { dc.Events.Add(e); } dc.SaveChanges(); status = true; } return(new JsonResult { Data = new { status = status } }); }
public ActionResult Report(string id) { LocalReport lr = new LocalReport(); string path = Path.Combine(Server.MapPath("~/Report"), "PurchaseReport.rpt"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } else { return(View("Index")); } List <Purchase> cm = new List <Purchase>(); using (pharmEntities dc = new pharmEntities()) { cm = dc.Purchases.ToList(); } ReportDataSource rd = new ReportDataSource("MyDataset", cm); lr.DataSources.Add(rd); string reportType = id; string mimeType; string encoding; string fileNameExtension; string deviceInfo = "<DeviceInfo>" + " <OutputFormat>" + id + "</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; renderedBytes = lr.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(File(renderedBytes, mimeType)); }
public JsonResult GetEvents() { using (pharmEntities dc = new pharmEntities()) { var events = dc.Events.ToList(); return(new JsonResult { Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
protected void Page_Load(object sender, EventArgs e) { CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None; PurchaseReport crystalReport = new PurchaseReport(); pharmEntities entities = new pharmEntities(); crystalReport.SetDataSource(from ta in entities.Purchases.Take(10) select ta); CrystalReportViewer1.ReportSource = crystalReport; CrystalReportViewer1.RefreshReport(); }
public JsonResult DeleteEvent(int eventID) { var status = false; using (pharmEntities dc = new pharmEntities()) { var v = dc.Events.Where(a => a.Id == eventID).FirstOrDefault(); if (v != null) { dc.Events.Remove(v); dc.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }