Exemplo n.º 1
0
        public VehicleOverallReportModel Initial(VehicleOverallReportModel model)
        {
            var settingData = _settingBLL.GetSetting();
            var listStatus  = new Dictionary <bool, string> {
                { true, "Active" }, { false, "InActive" }
            };
            var listVehType   = settingData.Where(x => x.SettingGroup == EnumHelper.GetDescription(Enums.SettingGroup.VehicleType) && x.IsActive).Select(x => new { x.SettingValue }).ToList();
            var listSupMethod = settingData.Where(x => x.SettingGroup == EnumHelper.GetDescription(Enums.SettingGroup.SupplyMethod) && x.IsActive).Select(x => new { x.SettingValue }).ToList();
            var listRegional  = _locationMappingBLL.GetLocationMapping().Where(x => x.IsActive).Select(x => new { x.Region }).Distinct().ToList();
            var listBodyType  = settingData.Where(x => x.SettingGroup == EnumHelper.GetDescription(Enums.SettingGroup.BodyType) && x.IsActive).Select(x => new { x.SettingValue }).ToList();
            var listVendor    = _vendorBLL.GetVendor().Where(x => x.IsActive).Select(x => new { x.VendorName }).Distinct().ToList();
            var listCity      = _locationMappingBLL.GetLocationMapping().Where(x => x.IsActive).Select(x => new { x.Location }).Distinct().ToList();

            model.SearchView.StatusList       = new SelectList(listStatus, "Key", "Value");
            model.SearchView.VehicleTypeList  = new SelectList(listVehType, "SettingValue", "SettingValue");
            model.SearchView.SupplyMethodList = new SelectList(listSupMethod, "SettingValue", "SettingValue");
            model.SearchView.RegionalList     = new SelectList(listRegional, "Region", "Region");
            model.SearchView.BodyTypeList     = new SelectList(listBodyType, "SettingValue", "SettingValue");;
            model.SearchView.VendorList       = new SelectList(listVendor, "VendorName", "VendorName");
            model.SearchView.CityList         = new SelectList(listCity, "Location", "Location");
            model.SearchView.FromDate         = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            model.SearchView.ToDate           = DateTime.Today;
            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;

            return(model);
        }
Exemplo n.º 2
0
        private string CreateXlsVehicleReport(VehicleOverallReportModel model)
        {
            //get data
            var data = GetVehicleData(model.SearchView);

            var slDocument = new SLDocument();

            //title
            slDocument.SetCellValue(1, 1, "VEHICLE REPORT");
            slDocument.MergeWorksheetCells(1, 1, 1, 32);
            //create style
            SLStyle valueStyle = slDocument.CreateStyle();

            valueStyle.SetHorizontalAlignment(HorizontalAlignmentValues.Center);
            valueStyle.Font.Bold     = true;
            valueStyle.Font.FontSize = 18;
            slDocument.SetCellStyle(1, 1, valueStyle);

            //create header
            slDocument = CreateHeaderVehicleReport(slDocument);

            //create data
            slDocument = CreateDataExcelVehicleReport(slDocument, data);

            var fileName = "Vehicle_report" + DateTime.Now.ToString("_yyyyMMddHHmmss") + ".xlsx";
            var path     = Path.Combine(Server.MapPath(Constans.UploadPath), fileName);

            slDocument.SaveAs(path);

            return(path);
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            var model = new VehicleOverallReportModel();

            model = Initial(model);

            var filter = new VehicleOverallReportGetByParamInput();

            filter.FromDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            filter.ToDate   = DateTime.Today;

            var data     = _vehicleOverallReportBLL.GetVehicle(filter);
            var ListData = Mapper.Map <List <VehicleOverallItem> >(data);

            model.ListVehicle = ListData;
            return(View(model));
        }
Exemplo n.º 4
0
        public void ExportVehicleReport(VehicleOverallReportModel model)
        {
            string pathFile = "";

            pathFile = CreateXlsVehicleReport(model);

            var newFile = new FileInfo(pathFile);

            var fileName = Path.GetFileName(pathFile);

            string attachment = string.Format("attachment; filename={0}", fileName);

            Response.Clear();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.WriteFile(newFile.FullName);
            Response.Flush();
            newFile.Delete();
            Response.End();
        }
Exemplo n.º 5
0
 public PartialViewResult ListVehicle(VehicleOverallReportModel model)
 {
     model.ListVehicle = GetVehicleData(model.SearchView);
     return(PartialView("_ListVehicleOverall", model));
 }