๐ Documentation: IrbyImaging/Views/GLType/Index.cshtml
File Path:
IrbyImaging/Views/GLType/Index.cshtml
Purpose: Razor view for listing and managing General Ledger (GL) records via DataTables.
๐ Table of Contents
- Overview & Purpose
- Key Functional Areas
- Dependencies & Technologies
- ViewModel & DataModel
- UI Elements & Layout
- Action Links & Routing
- Thirdโparty Integrations
- Sample Code Blocks
- Usage Examples
- UML Diagram (Simplified)
- Conclusion
๐ Overview & Purpose
This Razor view renders a paginated, searchable, and exportable table of General Ledger (GL) records (often called โGL/TAPโ in this context). It allows users to:
- View all existing GL records
- See the total count of records
- Add, Update, or Delete individual records
- Export the table to CSV, Excel, or print directly
It is intended to be a part of an ASP.NET Core MVC application under the IrbyImaging solution.
๐ ๏ธ Key Functional Areas
-
Page Setup
- Sets the title:
"General Ledger List" - Applies a shared layout:
~/Views/Shared/_ATSLayout.cshtml
- Sets the title:
-
Header & Counters
- Title
<h2>with a dynamic badge showing record count - โAdd New GL Recordโ button
- Title
-
Data Table
- Uses
<table>with idassetDatatable - Columns:
Column Purpose GL Code Unique code of the GL entry Description Textual description of the GL entry Available? Indicates if the record is active Update Link to Edit the record Delete Link to Delete (soft or hard) record
- Uses
-
DataTables Initialization
- Integrates with DataTables.js
- Exposes CSV, Excel, and Print export buttons
๐ Dependencies & Technologies
| Type | Library / Framework |
|---|---|
| Server-side | ASP.NET Core MVC |
| View Engine | Razor (.cshtml) |
| CSS Framework | Bootstrap 4 |
| Table Plugin | DataTables (v1.10.25) |
| JS Export Extensions | DataTables Buttons, JSZip, PDFMake |
| CDN & Local Assets | Mix of ~/lib/datatables/* and public CDNs |
๐๏ธ ViewModel & DataModel
- Model Declaration
@model IrbyImaging.DomainClasses.GeneralLedger - Core Properties
public class GeneralLedger { public IEnumerable<GLTypeDetail> GLTypeDetail { get; set; } } public class GLTypeDetail { public int Id { get; set; } public string Code { get; set; } public string Description { get; set; } public bool IsInactive { get; set; } }
๐จ UI Elements & Layout
-
Header Section
<h2>GL/TAP Records <span class="badge irby-red">@Model.GLTypeDetail.Count()</span> </h2> <p> <a asp-action="Create" class="btn-sm btn-success irby-green"> Add New GL Record </a> </p> -
Data Table Markup
<table id="assetDatatable" class="table table-striped ..."> <thead> ... </thead> <tbody> @foreach (var item in Model.GLTypeDetail) { <tr> <td>@item.Code</td> <td>@item.Description</td> <td>@(item.IsInactive ? "โ " : "โ")</td> <td> <a href="@Url.Action("Edit","GLType",new { id=item.Id })" class="btn-sm btn-warning">Update</a> </td> <td> <a href="@Url.Action("Delete","GLType",new { id=item.Id })" class="btn-sm btn-danger">Delete</a> </td> </tr> } </tbody> </table>
๐ Action Links & Routing
| Button / Link | Action | Controller | Route Values | CSS Classes |
|---|---|---|---|---|
| Add New GL Record | Create | GLType | None | btn-success |
| Update | Edit | GLType | id = item.Id |
btn-warning |
| Delete | Delete | GLType | id = item.Id |
btn-danger |
Note: The Delete link currently points to the
Editaction in code. Confirm if this is intentional or should be updated to aDeleteaction.
๐ Thirdโparty Integrations
- DataTables Core
- Display, pagination, sorting
- Buttons Extension
- Export to CSV, Excel, Print
- JSZip & PDFMake
- Excel file generation
- PDF font support
CDN scripts loaded under @section Scripts:
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
<!-- ... jszip, pdfmake, buttons.html5, buttons.print ... -->
๐ Sample Code Blocks
DataTable Initialization
$(document).ready(function () {
$('#assetDatatable').DataTable({
dom: 'Bfrtip',
buttons: [ 'csv', 'excel', 'print' ]
});
});
Conditional Icon Rendering
<td>
@(item.IsInactive
? "โ
" // Active
: "โ") // Inactive
</td>
๐ Usage Examples
-
Navigating to the GL List
- URL:
/GLType/Index - Displays table with all GL records.
- URL:
-
Exporting Data
- Click CSV button in top-left of table.
- File downloaded:
GLTypeDetail.csv.
-
Adding a New Record
- Click Add New GL Record.
- Redirects to
/GLType/Create.
-
Editing an Existing Record
- Click Update icon on a row.
- Redirects to
/GLType/Edit/{id}.
๐ ๏ธ UML Diagram (Simplified)
@startuml
class GeneralLedger {
+IEnumerable<GLTypeDetail> GLTypeDetail
}
class GLTypeDetail {
+int Id
+string Code
+string Description
+bool IsInactive
}
GeneralLedger "1" *-- "*" GLTypeDetail
@enduml
- Simplified class relationship.
โ Conclusion
This view delivers a rich, interactive experience for managing General Ledger records through:
- Interactive table with filtering, sorting, paging
- Action buttons for CRUD operations
- Seamless data exports (CSV, Excel, Print)
By leveraging ASP.NET Core MVC with Razor and the powerful DataTables plugin, the page ensures maintainability, scalability, and a userโfriendly interface. ๐
End of documentation.