Business ERP Part 30 Financial Years in ASP.NET MVC

  Business ERP Part 30 Financial Years in ASP.NET MVC

Hi, Dear's here we learn how to implement Auto Time Table Generator in Visual Studio using C# Windows Form. Ilyasoft software company provide full project step by step training on our YouTube Channel ilyasoft software company so now subscribe, share and like for more project base tutorials


In this part we are going to Show Financial Year's from tblFinancialYearTable, so now follow below code.

Source Code: 
Action C# Code :
using DatabaseLayer;
using ERP_App.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ERP_App.Controllers
{
    public class AdminConfigController : Controller
    {
        private BusinessERPDbEntities DB = new BusinessERPDbEntities();
public ActionResult AllFinanicalYears()
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
            {
                return RedirectToAction("Login", "Home");
            }
            var userid = 0;
            var usertypeid = 0;
            int.TryParse(Convert.ToString(Session["UserID"]), out userid);
            int.TryParse(Convert.ToString(Session["UserTypeID"]), out usertypeid);
            if (usertypeid != 1)
            {
                return RedirectToAction("Admin", "Dashboard");
            }
            var list = new List<FinancialYearMV>();
            var financialyears = DB.tblFinancialYears.ToList();
            foreach (var financialyear in financialyears)
            {
                var addfinancialyear = new FinancialYearMV();
                addfinancialyear.FinancialYearID = financialyear.FinancialYearID;
                addfinancialyear.FinancialYear = financialyear.FinancialYear;
                addfinancialyear.StartDate = financialyear.StartDate;
                addfinancialyear.EndDate = financialyear.EndDate;
                addfinancialyear.IsActive = financialyear.IsActive;
                addfinancialyear.UserID = financialyear.UserID;
                addfinancialyear.CreatedBy = financialyear.tblUser.UserName;
                list.Add(addfinancialyear);
            }
            return View(list);
        }
    }
}

View Code :
@model IEnumerable<ERP_App.Models.FinancialYearMV>
@{
    ViewBag.Title = "Finanical Year's";
}
<div class="card">
    <div class="card-header">
        <div class="card-title">Financial Year's</div>
    </div>
    <div class="card-body">
        <div>@Html.ActionLink("New Financial Year", "CreateFinancialYear", null, new { @class = "btn btn-primary" })</div>
        <hr />
        <table class="table table-striped my-4 w-100" id="datatable2">
            <thead>
                <tr>
                    <th>
                        @Html.DisplayNameFor(model => model.FinancialYear)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.StartDate)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.EndDate)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.IsActive)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.CreatedBy)
                    </th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.FinancialYear)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.StartDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.EndDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.IsActive)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.CreatedBy)
                    </td>
                    <td>
                        @Html.ActionLink("Edit", "EditFinancialYear", new { financialyearid = item.FinancialYearID }, new { @class = "btn btn-warning" })
                    </td>
                </tr>
                }
            </tbody>
        </table>
    </div>
</div>


Comments