Exemple #1
0
        public ActionResult GetMonthlyDepartmentReport(DateTime FromDate, DateTime ToDate)
        {
            var data = db.BillServices.Where(p => p.Paid == true && p.PaidDate >= FromDate && p.PaidDate <= ToDate).ToList();


            var allDepartments = db.Departments.ToList();


            var CrystalReportData = new List <DepartmentReportViewModel>();


            foreach (var item in allDepartments)
            {
                var singleDept = new DepartmentReportViewModel();
                singleDept.DepartmentName = item.DepartmentName;
                singleDept.Amount         = data.Where(p => p.DepartmentId == item.Id).Sum(x => x.Quatity * x.Price);

                CrystalReportData.Add(singleDept);
            }

            BillPaymentsDataSet billPayments = new BillPaymentsDataSet();

            foreach (var item in CrystalReportData)
            {
                billPayments.BillPayments.AddBillPaymentsRow(item.DepartmentName, item.Amount);
            }



            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/CrystalReports/Finance/BillPyments.rpt")));

            rd.SetDataSource(billPayments);
            rd.Subreports["RptReportHeader.rpt"].SetDataSource(HeaderAndFooterForReports.GetAllReportHeader());
            rd.SetParameterValue("fromDate", FromDate);
            rd.SetParameterValue("toDate", ToDate);

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();

            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            string fileName = " - " + DateTime.Today + ".pdf";

            return(File(stream, "application/pdf", fileName));
        }
        public ActionResult GetDrugWiseReport(DateTime FromDate, DateTime ToDate, int?DrugId, int?insuaranceCompany)
        {
            DrugWiseReportDataSet drugWiseReportDataSet = new DrugWiseReportDataSet();

            drugWiseReportDataSet = GetDrugTWiseReportData(FromDate, ToDate, DrugId, insuaranceCompany);

            ReportDocument Rd = new ReportDocument();

            Rd.Load(Path.Combine(Server.MapPath("~/Areas/PharmacyModule/Reports/DrugWiseReport/DrugWiseReport.rpt")));
            Rd.SetDataSource(drugWiseReportDataSet);
            Rd.Subreports["RptReportHeader.rpt"].SetDataSource(HeaderAndFooterForReports.GetAllReportHeader());
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();

            Stream Stream = Rd.ExportToStream(
                CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            Stream.Seek(0, SeekOrigin.Begin);
            return(File(Stream, "application/pdf", "DrugWiseSummary.pdf"));
        }
        public ActionResult GetCurrentStockReport(string ItemName, string CurrentStockFilter, bool?IsDonor)
        {
            var items = db.ItemMaster.Where(p => p.StoreName == "MS").ToList();

            if (ItemName != null && ItemName.Length > 0)
            {
                items = items.Where(e => e.ItemName.Contains(ItemName)).ToList();
            }

            if (CurrentStockFilter != null && !CurrentStockFilter.Equals("all"))
            {
                if (CurrentStockFilter.Equals("greater"))
                {
                    items = items.Where(e => e.CurrentStock > 0).ToList();
                }

                if (CurrentStockFilter.Equals("less"))
                {
                    items = items.Where(e => e.CurrentStock == 0).ToList();
                }
            }

            if (IsDonor != null && (bool)IsDonor)
            {
            }

            DataSetCurrentStock dataSet = new DataSetCurrentStock();

            if (items.Count() > 0)
            {
                foreach (var item in items.OrderBy(E => E.ItemName))
                {
                    var date = (item.ExpiryDate ?? DateTime.Now.Date.AddYears(1));

                    dataSet.ItemMasterItem.AddItemMasterItemRow(
                        item.BatchNo.ToUpper(),
                        item.ItemName.ToUpper(),
                        item.CurrentStock,
                        //DateTime.Now,
                        date,
                        item.ReorderLevel,
                        Convert.ToDecimal(item.CostPriceUnit)
                        );
                }
            }

            ReportDocument Rd = new ReportDocument();

            Rd.Load(Path.Combine(Server.MapPath("~/Areas/PharmacyModule/Reports/CurrentStock/RptCurrentStock.rpt")));
            Rd.SetDataSource(dataSet);
            Rd.Subreports["RptReportHeader.rpt"].SetDataSource(HeaderAndFooterForReports.GetAllReportHeader());
            Rd.Subreports["RptReportFooter.rpt"].SetDataSource(HeaderAndFooterForReports.GetAllReportFooter());

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();

            Stream Stream = Rd.ExportToStream(
                CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            Stream.Seek(0, SeekOrigin.Begin);
            string FileName = "PCurrentStock " + DateTime.Now.ToString() + ".pdf";

            return(File(Stream, "application/pdf", FileName));
        }