public ActionResult Read_TransporterLocation_Territory([DataSourceRequest] DataSourceRequest request) { var dbConn = new OrmliteConnection().openConn(); string whereCondition = ""; if (request.Filters.Count > 0) { whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]); } var data = new DC_LG_Transporter_Location_Territory().GetPage(request.Page, request.PageSize, whereCondition); return(Json(data)); }
public FileResult Export_TransporterLocation_Territory([DataSourceRequest] DataSourceRequest request) { ExcelPackage pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/DiaBanVanChuyenTheoVung.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_Transporter_Location_Territory().Getlist(whereCondition); int rowNum = 2; foreach (var item in lstResult) { ws.Cells["A" + rowNum].Value = item.TransporterLocationID; ws.Cells["B" + rowNum].Value = item.TransporterLocationName; 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.Note; ws.Cells["H" + rowNum].Value = item.Status ? "Đang hoạt động" : "Ngưng hoạt động"; //ws.Cells["F" + rowNum].Value = item.PickingProvinceID + "-" + item.PickingProvinceName; //ws.Cells["G" + rowNum].Value = item.CreatedBy; //ws.Cells["H" + rowNum].Value = Convert.ToDateTime(item.CreatedAt).ToString("dd/MM/yyyy"); //ws.Cells["I" + rowNum].Value = item.Status ? "Đang hoạt động" : "Ngưng hoạt động"; 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 "DiaBanVanChuyenTheoVung" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx")); //Suggested file name in the "Save as" dialog which will be displayed to the end user }