Exemplo n.º 1
0
        public ActionResult Read_Ward([DataSourceRequest] DataSourceRequest request)
        {
            log4net.Config.XmlConfigurator.Configure();
            string whereCondition = "";

            if (request.Filters.Count > 0)
            {
                whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]);
            }
            var data = new Master_Territory().GetPageWard(request.Page, request.PageSize, whereCondition);

            return(Json(data));
        }
Exemplo n.º 2
0
        public ActionResult GetWardByDistrictID(string id)
        {
            IDbConnection db = new OrmliteConnection().openConn();

            try
            {
                var data = new Master_Territory().GetWardByDistrictID(id);
                return(Json(new { success = true, data = data }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { db.Close(); }
        }
Exemplo n.º 3
0
        public FileResult Export_Region([DataSourceRequest] DataSourceRequest request)
        {
            ExcelPackage   pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/ViTriDiaLy_VungMien.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 Master_Territory().GetExportRegion(request, whereCondition);
                int           rowNum    = 2;
                foreach (var item in lstResult)
                {
                    ws.Cells["A" + rowNum].Value = item.TerritoryID;
                    ws.Cells["B" + rowNum].Value = item.TerritoryName;
                    ws.Cells["C" + rowNum].Value = item.ParentName;
                    ws.Cells["D" + rowNum].Value = item.Title;
                    ws.Cells["E" + rowNum].Value = item.Latitude;
                    ws.Cells["F" + rowNum].Value = item.Longitude;
                    //ws.Cells["G" + rowNum].Value = item.Longitude;
                    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
                        "ViTriDiaLy_VungMien" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx")); //Suggested file name in the "Save as" dialog which will be displayed to the end user
        }