Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public ActionResult ExportEmployeesWorkingReport(string month)
        {
            List <UsersModel> lusModel = new List <UsersModel>();

            Database db    = new Database();
            UsersDAO usDAO = new UsersDAO(db);

            lusModel = usDAO.FindByMonthYear(month);
            db.Close();

            foreach (var u in lusModel)
            {
                db = new Database();
                RepairDAO rDAO = new RepairDAO(db);
                u.REPAIR             = new WorkingEmployeesViewModel();
                u.REPAIR.SUCCESS_REP = rDAO.CountByUserIDSuccess(u.USER_NO);
                db.Close();

                db   = new Database();
                rDAO = new RepairDAO(db);
                u.REPAIR.WAIT_REP = rDAO.CountByUserIDWait(u.USER_NO);
                db.Close();

                db               = new Database();
                rDAO             = new RepairDAO(db);
                u.REPAIR.NOW_REP = rDAO.CountByUserIDNowWorking(u.USER_NO);
                db.Close();

                db   = new Database();
                rDAO = new RepairDAO(db);
                u.REPAIR.CANNOT_REP = rDAO.CountByUserIDFail(u.USER_NO);
                db.Close();
            }


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

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

            var data = lusModel.Select(d => new {
                UID     = d.USER_UID,
                NAME    = d.NAME + " " + d.LASTNAME,
                WAIT    = d.REPAIR.WAIT_REP,
                NOW     = d.REPAIR.NOW_REP,
                SUCCESS = d.REPAIR.SUCCESS_REP,
                CANNOT  = d.REPAIR.CANNOT_REP
            }).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("WorkingDataSetReport", data);

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

            lr.DisplayName = "รายงานผลงานประจำ" + cv.monthToStringMonth(Int32.Parse(x[1])) + " " + x[0];  // ชื่อรายงาน
            string reportType = type;
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfoA4 =
                "<DeviceInfo>" +
                "  <OutputFormat>" + type + "</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));
        }
Exemplo n.º 3
0
        public ActionResult RepairingExportReport(string t)
        {
            string             month  = Request.Params["month"];
            Database           db     = new Database();
            RepairDAO          rDAO   = new RepairDAO(db);
            List <RepairModel> rModel = rDAO.FindByMonthYear(month);

            db.Close();

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

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

            var data = rModel.Select(r => new
            {
                C_UID   = r.CUSTOMER.CUST_UID,
                C_NAME  = r.CUSTOMER.C_NAME + " " + r.CUSTOMER.C_LASTNAME,
                REP_DET = r.PRODUCT.TYPE.PRO_TYPE_NAME + " " + r.PRODUCT.BANRD.PRO_BAND_NAME + " " + r.MODEL,
                DAMAGE  = r.DAMAGE,
                STAFF   = r.STAFF.NAME + " " + r.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("DataSetRepairing", 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));
        }