Beispiel #1
0
        public ActionResult StandardSpendingExportExcel(string filter)
        {
            DataTable dt = new DataTable("Grid");

            dt.Columns.AddRange(new DataColumn[10]
            {
                new DataColumn(AppRes.StaffLevelID),
                new DataColumn(AppRes.StandardSpending),
                new DataColumn(AppRes.Policy),
                new DataColumn(AppRes.MinSpending),
                new DataColumn(AppRes.MinPerson),
                new DataColumn(AppRes.R_StartDate),
                new DataColumn(AppRes.EndDate),
                new DataColumn(AppRes.CreatedDate),
                new DataColumn(AppRes.ModifiedDate),
                new DataColumn(AppRes.Promotion_Status),
            });
            dt.Columns[0].DataType = typeof(string);
            dt.Columns[1].DataType = typeof(double);
            dt.Columns[2].DataType = typeof(string);
            dt.Columns[3].DataType = typeof(double);
            dt.Columns[4].DataType = typeof(int);
            dt.Columns[5].DataType = typeof(DateTime);
            dt.Columns[6].DataType = typeof(DateTime);
            dt.Columns[7].DataType = typeof(string);
            dt.Columns[8].DataType = typeof(string);
            dt.Columns[9].DataType = typeof(string);


            var db           = new StandardSpending_DAL();
            int total        = 0;
            int LanguageCode = Global.CurrentUser.CurrentLanguageID;
            var lstData      = db.StandardSpending_GetList(1, 5000, filter, LanguageCode, out total);

            foreach (var item in lstData)
            {
                dt.Rows.Add(item.StaffLevelName, item.StandardSpendingAmount, item.Name, item.MinSpending, item.MinPerson, item.StartDate, item.EndDate, item.CreatedDate == null ? "" : item.CreatedDate.Value.ToString("dd/MM/yyyy"), item.ModifiedDate == null ? "" : item.ModifiedDate.Value.ToString("dd/MM/yyyy"), item.StatusName);
            }

            var wb = new XLWorkbook();

            wb.Worksheets.Add(dt);
            byte[] data = null;
            using (var stream = new MemoryStream())
            {
                wb.SaveAs(stream);
                data = stream.ToArray();
            }
            return(File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "StandardSpending.xlsx"));
        }
Beispiel #2
0
        public ActionResult TableServerSideGetData(int pageIndex, int pageSize, string filter = "")
        {
            var db           = new StandardSpending_DAL();
            int total        = 0;
            int LanguageCode = Global.CurrentLanguage;
            var result       = db.StandardSpending_GetList(pageIndex, pageSize, filter, LanguageCode, out total);
            var lstTotal     = new TableColumnsTotalModel();

            lstTotal.Total1 = "15";
            lstTotal.Total2 = "25";
            lstTotal.Total3 = "35";
            return(Content(JsonConvert.SerializeObject(new
            {
                employees = result,
                totalCount = total,
                lstTotal = lstTotal
            })));
        }