Esempio n. 1
0
        public ActionResult Read_TransporterLocation([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().GetPage(request.Page, request.PageSize, whereCondition);

            return(Json(data));
        }
Esempio n. 2
0
        public FileResult Export_TransporterLocation([DataSourceRequest] DataSourceRequest request)
        {
            ExcelPackage   pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/DiaBanVanChuyen.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().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.IsAllMerchant? 1 : 0;
                    ws.Cells["D" + rowNum].Value = item.TransporterID;
                    ws.Cells["E" + rowNum].Value = item.TransporterName;
                    ws.Cells["F" + rowNum].Value = item.Note;
                    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
                        "DiaBanVanChuyen" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx")); //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }