Business ERP Part 21 Branch Type 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 Branch Types in list, so now follow below code.
Source Code:
Action C# 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 AllBranchTypes()
{
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<BranchTypeMV>();
var branchtypes = DB.tblBranchTypes.ToList();
foreach (var branchtype in branchtypes)
{
list.Add(new BranchTypeMV() { BranchTypeID = branchtype.BranchTypeID, BranchType = branchtype.BranchType });
}
return View(list);
}
}
}
View Code :
@model IEnumerable<ERP_App.Models.BranchTypeMV>
@{
ViewBag.Title = "Branch Types";
}
<div class="card">
<div class="card-header">
<div class="card-title">Branch Types</div>
</div>
<div class="card-body">
<div>@Html.ActionLink("New Branch Type", "CreateBranchType", 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.BranchType)
</th>
<th>
Action
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.BranchType)
</td>
<td>
@Html.ActionLink("Edit", "EditBranchType", new { branchtypeid = item.BranchTypeID }, new { @class = "btn btn-warning" })
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
Comments
Post a Comment