Esempio n. 1
0
        public ActionResult RequisitionReportView(int?page)
        {
            string       month = Request.Params["month"];
            ConvertClass cv    = new ConvertClass();

            if (String.IsNullOrEmpty(month))
            {
                month = "0-0";
            }
            List <RequisitionModel> rqModel = new List <RequisitionModel>();

            Database       db    = new Database();
            RequisitionDAO rqDAO = new RequisitionDAO(db);

            rqModel = rqDAO.FindByMonthYear(month);
            db.Close();
            ViewBag.TOTAL = rqModel.Count;
            var pageNum = page ?? 1;

            ViewBag.DATA = rqModel.ToPagedList(pageNum, 20);
            return(View());
        }
Esempio n. 2
0
        public ActionResult RequisitionExportReport(string t)
        {
            string month = Request.Params["month"];
            List <RequisitionModel> rqModel = new List <RequisitionModel>();

            Database       db    = new Database();
            RequisitionDAO rqDAO = new RequisitionDAO(db);

            rqModel = rqDAO.FindByMonthYear(month);
            db.Close();

            LocalReport lr   = new LocalReport();
            string      path = Server.MapPath("~/Reportor/RequisitionReport.rdlc");

            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }

            var data = rqModel.Select(d => new
            {
                DAMAGE     = d.REPAIR_NO.DAMAGE,
                SPARE      = d.STOCK_NO.PART.TYPE.PART_TYPE_NAME + " " + d.STOCK_NO.PART.BRAND.PART_BRAND_NAME + " " + d.STOCK_NO.STOCK_INFO,
                UNIT       = d.REQ_UNIT,
                PRICE      = d.STOCK_NO.PRICE,
                WITHDRAWAL = d.STAFF.NAME + " " + d.STAFF.LASTNAME
            }).ToList();

            ConvertClass cv = new ConvertClass();

            string[] x = month.Split('-');

            ReportParameter rpm = new ReportParameter()
            {
                Name   = "MONTH",
                Values = { cv.monthToStringMonth(Int32.Parse(x[1])) + " " + x[0] }  // ชื่อรายงาน
            };
            ReportDataSource rds = new ReportDataSource("DataSetRQ", data);

            lr.SetParameters(rpm);
            lr.DataSources.Add(rds);

            lr.DisplayName = "รายงานประจำ" + cv.monthToStringMonth(Int32.Parse(x[1])) + " " + x[0];  // ชื่อรายงาน
            string reportType = t;
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfoA4 =
                "<DeviceInfo>" +
                "  <OutputFormat>" + t + "</OutputFormat>" +
                "  <PageWidth>21cm</PageWidth>" +
                "  <PageHeight>29.7cm</PageHeight>" +
                "  <MarginTop>1cm</MarginTop>" +
                "  <MarginLeft>0.5in</MarginLeft>" +
                "  <MarginRight>0.5in</MarginRight>" +
                "  <MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;

            renderedBytes = lr.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            return(File(renderedBytes, mimeType));
        }