Business ERP Part 24 Account Activity 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 all accounts activities from tblAccountActivity Table, 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 AllAccountActivity()
{
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<AccountActivityMV>();
var accountactivities = DB.tblAccountActivities.ToList();
foreach (var acountactivity in accountactivities)
{
list.Add(new AccountActivityMV() { AccountActivityID = acountactivity.AccountActivityID, Name = acountactivity.Name });
}
return View(list);
}
}
}
View Code :
@model IEnumerable<ERP_App.Models.AccountActivityMV>
@{
ViewBag.Title = "Account Activities";
}
<div class="card">
<div class="card-header">
<div class="card-title">Account Activities</div>
</div>
<div class="card-body">
<div>@Html.ActionLink("New Account Activity", "CreateAccountActivity", null, new { @class = "btn btn-primary" })</div>
<hr />
<table class="table table-striped my-4 w-100" id="datatable2">
<thead>
<tr>
<th>
Account Activity
</th>
<th>
Action
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.ActionLink("Edit", "EditAccountActivity", new { accountactivityid = item.AccountActivityID }, new { @class = "btn btn-warning" })
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
Comments
Post a Comment