πŸ“˜ PncLookup.cshtml Documentation


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Model & Data Models
  4. Layout & ViewData
  5. UI Components & Search Form
    5.1 Employee Dropdown
    5.2 Date Pickers
    5.3 Text Inputs
    5.4 Action Buttons
  6. Result Grid πŸ“Š
  7. JavaScript Functions & Logic
    7.1 performSearch()
    7.2 clearForm()
    7.3 toolbarClick()
    7.4 getComponentValue()
    7.5 Filter Functions
  8. AJAX Endpoint Overview
  9. Third-Party Integrations πŸ”Œ
  10. Styling & CSS 🎨
  11. Usage Examples & Code Snippets πŸ’‘
  12. UML Diagram πŸ“ˆ
  13. Conclusion 🏁

1. Overview & Purpose 🎯

PncLookup.cshtml is an ASP.NET Razor view that enables users in the accounting imaging module to:

  • πŸ” Search PNC (Purchasing Card) statements based on multiple criteria.
  • πŸ“Š View results in an interactive grid with paging, sorting, filtering, and export capabilities.
  • πŸ“₯ Export the search results to Excel with custom formatting.

This page is part of IrbyImaging's AccountingImaging module and uses Syncfusion EJ2 controls for rich UI functionality.


2. Dependencies & Technologies πŸ› οΈ

Category Technology / Library
UI Framework ASP.NET Core MVC (Razor views)
JS Component Library Syncfusion EJ2 (ejs-grid, ejs-datepicker, ejs-dropdownlist, etc.)
Data Binding ViewBag, Model (PncData)
AJAX & JSON Fetch API, Newtonsoft.Json
Anti‑Forgery @Html.AntiForgeryToken()
Styling Bootstrap 4 / Custom CSS
Utilities Syncfusion.JavaScript.Models
Date Handling System.Globalization

3. View Model & Data Models 🏷️

@model IrbyImaging.UI.Models.PncData
  • PncData (C# Model)
    • Contains properties used for rendering and filtering PNC statements.
    • Typical fields: PostingDate, TransactionId, DepartmentOrJobNumber, Subsidiary, etc.
@using Newtonsoft.Json
@using System.Linq
  • ViewBag
    • ViewBag.Employees & ViewBag.Jobs: Collections used as data sources for dropdown filters.

4. Layout & ViewData πŸ–ΌοΈ

@{
  ViewData["Title"] = "Search Statements";
  Layout = "~/Views/Shared/_AccountingLayout.cshtml";
}
  • ViewData["Title"] sets the page title.
  • Layout references a shared layout to provide consistent header, footer, and navigation.

5. UI Components & Search Form πŸ”

The search form is organized into rows (.uniform-row) with multiple input controls:

5.1 Employee Dropdown

<ejs-dropdownlist id="employeeSearch"
                  dataSource="@ViewBag.Employees"
                  showClearButton="true"
                  allowFiltering="true"
                  filtering="employeeFilter"
                  placeholder="Select an Employee"
                  popupHeight="300px"
                  popupWidth="400px">
  <e-dropdownlist-fields text="Text" value="Value"></e-dropdownlist-fields>
</ejs-dropdownlist>
  • Features:
    • Live filtering (allowFiltering)
    • Clear button
    • Custom popup size

5.2 Date Pickers

<ejs-datepicker id="DatePick"
                placeholder="Select Date"
                format="MM/dd/yyyy">
</ejs-datepicker>

<ejs-datepicker id="monthYear"
                format="MMMM y"
                placeholder="Select Month/Year"
                start="Year"
                depth="Year">
</ejs-datepicker>
  • DatePick: Single date selection.
  • monthYear: Month-year only (no day granularity).

5.3 Text Inputs

<ejs-textbox id="merchant" placeholder="Enter Merchant"></ejs-textbox>
<ejs-textbox id="CCNumber" placeholder="XXXX"></ejs-textbox>
<ejs-textbox id="subsidiary" placeholder="Enter Subsidiary"></ejs-textbox>
<ejs-textbox id="workOrder" placeholder="Enter Work Order #"></ejs-textbox>
<ejs-textbox id="unitNumber" placeholder="Enter Unit #"></ejs-textbox>
  • For free-text filters (merchant name, card last 4 digits, etc.).

5.4 Action Buttons

<ejs-button id="searchBtn" content="Search" isPrimary="true" cssClass="e-flat"></ejs-button>
<ejs-button id="clearBtn" content="Clear" cssClass="e-flat"></ejs-button>
<ejs-button id="exportBtn" content="Export to Excel" cssClass="e-flat"></ejs-button>
  • Search: Triggers AJAX search.
  • Clear: Resets form & hides grid.
  • Export: Exports grid data to Excel.

6. Result Grid πŸ“Š

<ejs-grid id="ResultGrid"
          allowPaging="true"
          allowSorting="true"
          allowFiltering="true"
          allowResizing="true"
          allowExcelExport="true"
          toolbar="@(new List<string>() { "ExcelExport" })"
          toolbarClick="toolbarClick"
          gridLines="Both"
          height="450">
  <!-- Column definitions -->
  <e-grid-columns>
    <e-grid-column field="PostingDate" headerText="Posting Date" type="date" format="yMd" width="130"></e-grid-column>
    <!-- More columns... -->
  </e-grid-columns>
</ejs-grid>
  • Key Features:
    • Paging (15 rows/page)
    • Excel-style filtering
    • Export to Excel (via toolbar or separate button)
    • Custom column formats (dates, currency)

7. JavaScript Functions & Logic 🧩

All scripts run on DOMContentLoaded:

7.1 performSearch()

function performSearch() {
  const formData = {
    EmployeeJdeAB: getComponentValue('employeeSearch'),
    TransactionDate: getComponentValue('DatePick'),
    // ...
  };
  grid.showSpinner();
  fetch('/AccountingImaging/SearchPnc', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'RequestVerificationToken': token
    },
    body: JSON.stringify(formData)
  })
  .then(res => res.json())
  .then(data => {
    grid.dataSource = data;
    grid.refresh();
    document.getElementById('resultContainer').style.display = '';
    grid.hideSpinner();
  })
  .catch(err => {
    console.error(err);
    grid.hideSpinner();
    alert('An error occurred while searching.');
  });
}
  • Flow:
    1. Gather form values
    2. Show loading spinner
    3. AJAX POST to /AccountingImaging/SearchPnc
    4. Populate grid & show results
    5. Error handling with alert

7.2 clearForm()

function clearForm() {
  ['employeeSearch','DatePick','monthYear','merchant','CCNumber','subsidiary','jobNameSearch','workOrder','unitNumber']
  .forEach(id => {
    const cmp = document.getElementById(id)?.ej2_instances?.[0];
    if (cmp) cmp.value = cmp.value ? null : '';
  });
  document.getElementById('resultContainer').style.display = 'none';
  grid.dataSource = [];
}
  • Resets all controls and hides the grid.

7.3 toolbarClick()

Handles grid toolbar Excel export:

function toolbarClick(args) {
  if (args.item.id === 'ResultGrid_excelexport') {
    // Build excelExportProperties with custom widths & date formatting
    grid.excelExport(excelExportProperties);
  }
}

7.4 getComponentValue()

Generic helper to retrieve EJ2 component values:

function getComponentValue(id) {
  const cmp = document.getElementById(id)?.ej2_instances?.[0];
  return cmp ? cmp.value : null;
}

7.5 Filter Functions

function jobFilter(e) {
  var query = new ej.data.Query();
  if (e.text !== '') query = query.where('Text','contains',e.text,true);
  e.updateData(@Html.Raw(JsonConvert.SerializeObject(ViewBag.Jobs)), query);
}
  • Used by dropdowns for live filtering of large lists.

8. AJAX Endpoint Overview πŸ“‘

Endpoint HTTP Method Payload Description
/AccountingImaging/SearchPnc POST JSON formData (see above) Returns filtered PncData[]
  • Anti‑Forgery Token is included in headers (RequestVerificationToken).

9. Third-Party Integrations πŸ”Œ

  • Syncfusion EJ2
    • Grid, DropdownList, DatePicker, TextBox, Button controls
    • Excel export with custom styling
  • Newtonsoft.Json for serializing ViewBag data into filter functions

10. Styling & CSS 🎨

Custom styles ensure a clean and uniform look:

.uniform-row { margin-bottom: 15px; }
.form-group label { font-weight: 500; color: #495057; }
/* Grid theming */
.e-gridheader { background-color: #f8f9fa; }
.e-grid .e-rowcell { border-color: #e9e9ef; }
/* Responsive */
@media (max-width: 768px) {
  .button-group { margin-top: 15px; }
}
  • Responsive adjustments for mobile.

11. Usage Examples & Code Snippets πŸ’‘

// User clicks "Search" β†’ performSearch() runs
performSearch();
// Results appear in the grid.

Clearing the Form

// User clicks "Clear"
clearForm();
// All inputs reset, grid hidden.

Export to Excel

// Click "Export to Excel" button
exportBtn.element.addEventListener('click', () => {
  grid.excelExport({ autoFit: true, fileName: 'PNC_Search_Results.xlsx' });
});

12. UML Diagram πŸ“ˆ

@startuml
title PncLookup.cshtml - Component Interaction

actor User
participant "PncLookup View" as View
participant "Syncfusion Grid" as Grid
participant "Controller" as Ctrl
participant "PncData Model" as Model

User -> View : Fill form & click Search
View -> Ctrl : POST /AccountingImaging/SearchPnc (formData)
Ctrl -> Model : Query DB & return List<PncData>
Model --> Ctrl : JSON data
Ctrl --> View : JSON response
View -> Grid : grid.dataSource = data
User -> Grid : Sort, Filter, Export
@enduml

13. Conclusion 🏁

The PncLookup.cshtml page provides a rich, interactive interface for searching and exporting purchasing card transactions within the AccountingImaging module. Leveraging Syncfusion EJ2 controls and AJAX patterns, it delivers:

  • Robust filtering across multiple dimensions
  • Seamless Excel export with custom formatting
  • Responsive, user-friendly UI

This documentation should empower developers to extend, maintain, and integrate the PNC lookup functionality confidently.