Ejemplo n.º 1
0
        public ActionResult Violations()
        {
            ViolationTypeViewModel viewModel = SystemViewModelData.BuildUpViolationTypeViewModel(null, true);

            // Perform default search for all Violation Library Entries:
            viewModel.ViolationTypeGridView = Repository.ViolationTypes.GridSearch();

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public ActionResult SearchViolations([DataSourceRequest] DataSourceRequest request, int?violationProgramElementID = null, int?violationCategoryID = null, int?violationSourceID = null, string violationTypeNumber = "", string name = "", string description = "", string violationCitation = "", DateTime?beginDate = null, DateTime?endDate = null)
        {
            ViolationTypeViewModel viewModel = SystemViewModelData.BuildUpViolationTypeViewModel(null, true);

            // Perform search using user-entered criteria:
            var ViolationTypes = Repository.ViolationTypes.GridSearch(violationProgramElementID: violationProgramElementID,
                                                                      violationCategoryID: violationCategoryID,
                                                                      violationSourceID: violationSourceID,
                                                                      typeNumber: violationTypeNumber,
                                                                      name: name,
                                                                      description: description,
                                                                      citation: violationCitation,
                                                                      beginDate: beginDate,
                                                                      endDate: endDate);

            DataSourceResult result = ViolationTypes.ToList().ToDataSourceResult(request);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult Violations(ViolationTypeViewModel violationTypeViewModel, FormCollection formCollection)
        {
            ViolationTypeViewModel viewModel = SystemViewModelData.BuildUpViolationTypeViewModel(null, true);

            // Set Populated viewModel search parameters to user-supplied values
            viewModel.ViolationProgramElementID = violationTypeViewModel.ViolationProgramElementID;
            viewModel.ViolationCategoryID       = violationTypeViewModel.ViolationCategoryID;
            viewModel.ViolationSourceID         = violationTypeViewModel.ViolationSourceID;
            viewModel.ViolationTypeNumber       = violationTypeViewModel.ViolationTypeNumber;
            viewModel.Name              = violationTypeViewModel.Name;
            viewModel.Description       = violationTypeViewModel.Description;
            viewModel.ViolationCitation = violationTypeViewModel.ViolationCitation;
            viewModel.BeginDate         = violationTypeViewModel.BeginDate;
            viewModel.EndDate           = violationTypeViewModel.EndDate;

            // Perform search using user-entered criteria, return Grid View:
            viewModel.ViolationTypeGridView = Repository.ViolationTypes.GridSearch(violationProgramElementID: violationTypeViewModel.ViolationProgramElementID,
                                                                                   violationCategoryID: violationTypeViewModel.ViolationCategoryID,
                                                                                   violationSourceID: violationTypeViewModel.ViolationSourceID,
                                                                                   typeNumber: violationTypeViewModel.ViolationTypeNumber,
                                                                                   name: violationTypeViewModel.Name,
                                                                                   description: violationTypeViewModel.Description,
                                                                                   citation: violationTypeViewModel.ViolationCitation,
                                                                                   beginDate: violationTypeViewModel.BeginDate,
                                                                                   endDate: violationTypeViewModel.EndDate
                                                                                   );

            //Check for Export
            if (!string.IsNullOrWhiteSpace(formCollection["export"]))
            {
                string     excelTemplateFilePath = System.IO.Path.Combine(Server.MapPath("~"), ConfigurationManager.AppSettings["ViolationLibraryExcelTemplate"]);
                FileStream sourceXlsDataStream   = new System.IO.FileStream(excelTemplateFilePath, FileMode.Open, FileAccess.Read);

                ExcelWorkbook workbook = new ExcelWorkbook(sourceXlsDataStream);
                workbook.LicenseKey = Excel.GetWinnovativeExcelLicenseKey();

                // Obtain First Worksheet (this is where our Inventory will be inserted)
                ExcelWorksheet excelWorksheet = workbook.Worksheets[0];

                if (formCollection["export"] == "Export to Excel")
                {
                    if (excelWorksheet != null)
                    {
                        // Retrieve the real entities for export (not only the Grid View from above)
                        // based on the provided search criteria:
                        viewModel.Entities = Repository.ViolationTypes.Search(violationProgramElementID: violationTypeViewModel.ViolationProgramElementID,
                                                                              violationCategoryID: violationTypeViewModel.ViolationCategoryID,
                                                                              violationSourceID: violationTypeViewModel.ViolationSourceID,
                                                                              typeNumber: violationTypeViewModel.ViolationTypeNumber,
                                                                              name: violationTypeViewModel.Name,
                                                                              description: violationTypeViewModel.Description,
                                                                              citation: violationTypeViewModel.ViolationCitation);

                        DataTable table = ViolationLibraryDataTable(viewModel.Entities);
                        excelWorksheet.LoadDataTable(table, 4, 1, false);
                    }
                    SetDownloadFileHeader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "CERSViolationLibrary_SearchResults.xlsx");
                }
                else if (formCollection["export"] == "Export Entire Violation Library")
                {
                    if (excelWorksheet != null)
                    {
                        // Retrieve the entire set of Violation Types (the real entities, not Grid View)
                        viewModel.Entities = Repository.ViolationTypes.Search();

                        DataTable table = ViolationLibraryDataTable(viewModel.Entities);
                        excelWorksheet.LoadDataTable(table, 4, 1, false);
                    }
                    SetDownloadFileHeader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "CERSViolationLibrary_EntireExport.xlsx");
                }

                workbook.Save(Response.OutputStream);
                Response.End();

                return(new EmptyResult());
            }

            return(View(viewModel));
        }
Ejemplo n.º 4
0
        public ActionResult ViolationDetail(int violationTypeID)
        {
            ViolationTypeViewModel viewModel = SystemViewModelData.BuildUpViolationTypeViewModel(violationTypeID);

            return(View(viewModel));
        }