Esempio n. 1
0
        public DataTable GetDepartmentReport(DepartmentReportSearch search)
        {
            var deptIDs = "";

            if (search.departmentIds != null)
            {
                search.departmentIds.ForEach(item => {
                    deptIDs += "," + item;
                });
                deptIDs = deptIDs.TrimStart(',');
            }

            DataTable dt = new DataTable();

            EnsureConnectionOpen();

            using (var command = CreateCommand("Proc_DepartmentReport", CommandType.StoredProcedure,
                                               new SqlParameter("startDate", search.startDate), new SqlParameter("endDate", search.endDate),
                                               new SqlParameter("departmentIDs", deptIDs), new SqlParameter("currentUserID", search.currentUserID)))
            {
                using (var da = new SqlDataAdapter(command)) {
                    da.Fill(dt);
                }
            }

            return(dt);
        }
Esempio n. 2
0
        public ActionResult GetDepartmentReport(DepartmentReportSearch search)
        {
            search.currentUserID = Common.CommonHelper.CurrentUser;
            DataTable dt         = _reportAppService.GetDepartmentReport(search);
            string    JSONresult = JsonConvert.SerializeObject(dt);

            return(Json(new { data = JSONresult }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public FileResult GetExcelForReport(DepartmentReportSearch search)
        {
            search.currentUserID = Common.CommonHelper.CurrentUser;
            DataTable dt        = _reportAppService.GetDepartmentReport(search);
            string    sheetName = "部门工时统计报表";
            var       book      = Common.CommonHelper.CreateHSSFromDataTable(sheetName, dt, new List <int>()
            {
                0
            }, true);
            MemoryStream ms = new MemoryStream();

            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", sheetName + ".xls"));
        }