public ActionResult Read_DeliveryFeeTerritory([DataSourceRequest] DataSourceRequest request) { string whereCondition = ""; if (request.Filters.Count > 0) { whereCondition = new KendoApplyFilter().ApplyFilter(request.Filters[0]); } var data = new DC_LG_DeliveryFee_Territory().GetPage(request.Page, request.PageSize, whereCondition); return(Json(data)); }
public FileResult Export_DeliveryTerritory([DataSourceRequest] DataSourceRequest request) { ExcelPackage pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/GoiCuocVanChuyenTheoVungMien.xlsx"))); ExcelWorksheet ws = pck.Workbook.Worksheets["Data"]; if (userAsset["Export"]) { string whereCondition = ""; if (request.Filters.Count > 0) { whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]); } IDbConnection db = new OrmliteConnection().openConn(); var lstResult = new DC_LG_DeliveryFee_Territory().GetList(request, whereCondition); int rowNum = 2; foreach (var item in lstResult) { ws.Cells["A" + rowNum].Value = item.DeliveryFeeID; ws.Cells["B" + rowNum].Value = item.DeliveryFeeName; ws.Cells["C" + rowNum].Value = item.ProvinceID; ws.Cells["D" + rowNum].Value = item.ProvinceName; ws.Cells["E" + rowNum].Value = item.DistrictID; ws.Cells["F" + rowNum].Value = item.DistrictName; ws.Cells["G" + rowNum].Value = item.PickingProvinceID; ws.Cells["H" + rowNum].Value = item.PickingProvinceName; ws.Cells["I" + rowNum].Value = item.PickingDistrictID; ws.Cells["J" + rowNum].Value = item.PickingDistrictName; rowNum++; } db.Close(); } else { ws.Cells["A2:E2"].Merge = true; ws.Cells["A2"].Value = "You don't have permission to export data."; } MemoryStream output = new MemoryStream(); pck.SaveAs(output); return(File(output.ToArray(), //The binary data of the XLS file "application/vnd.ms-excel", //MIME type of Excel files "GoiCuocVanChuyenTheoVungMien" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx")); //Suggested file name in the "Save as" dialog which will be displayed to the end user }