Business ERP Part 46 Stock Products 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 stock products to tblStock in database, so now follow below code.
Source Code:
Action C# Code :
public ActionResult StockProducts()
{
if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"])))
{
return RedirectToAction("Login", "Home");
}
var userid = 0;
var usertypeid = 0;
var companyid = 0;
var branchid = 0;
var branchtypeid = 0;
int.TryParse(Convert.ToString(Session["UserID"]), out userid);
int.TryParse(Convert.ToString(Session["UserTypeID"]), out usertypeid);
int.TryParse(Convert.ToString(Session["CompanyID"]), out companyid);
int.TryParse(Convert.ToString(Session["BranchID"]), out branchid);
int.TryParse(Convert.ToString(Session["BranchTypeID"]), out branchtypeid);
var stock = DB.tblStocks.Where(p => p.CompanyID == companyid && p.BranchID == branchid).ToList();
var list = new List<StockMV>();
foreach (var product in stock)
{
var item = new StockMV();
item.BranchID = product.BranchID;
item.CategoryID = product.CategoryID;
item.CompanyID = product.CompanyID;
item.CreateBy = product.tblUser.UserName;
item.CurrentPurchaseUnitPrice = product.CurrentPurchaseUnitPrice;
item.Description = product.Description;
item.ExpiryDate = product.ExpiryDate;
item.ManufactureDate = product.ManufactureDate;
item.IsActive = product.IsActive;
item.ProductID = product.ProductID;
item.ProductName = product.ProductName;
item.Quantity = product.Quantity;
item.SaleUnitPrice = product.SaleUnitPrice;
item.StockTreshHoldQuantity = product.StockTreshHoldQuantity;
item.UserID = product.UserID;
item.CategoryName = product.tblCategory.categoryName;
list.Add(item);
}
return View(list);
}
View Code :
@model IEnumerable<ERP_App.Models.StockMV>
@{
ViewBag.Title = "StockProducts";
}
<div class="card">
<div class="card-header">
<div class="card-title">Stock</div>
</div>
<div class="card-body">
<div>@Html.ActionLink("New Product", "CreateProduct", 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.ProductName)
</th>
<th>
@Html.DisplayNameFor(model => model.CategoryName)
</th>
<th>
@Html.DisplayNameFor(model => model.Quantity)
</th>
<th>
@Html.DisplayNameFor(model => model.SaleUnitPrice)
</th>
<th>
@Html.DisplayNameFor(model => model.CurrentPurchaseUnitPrice)
</th>
<th>
@Html.DisplayNameFor(model => model.ExpiryDate)
</th>
<th>
@Html.DisplayNameFor(model => model.ManufactureDate)
</th>
<th>
@Html.DisplayNameFor(model => model.StockTreshHoldQuantity)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.IsActive)
</th>
<th>
@Html.DisplayNameFor(model => model.CreateBy)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ProductName)
</td>
<td>
@Html.DisplayFor(modelItem => item.CategoryName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Quantity)
</td>
<td>
@Html.DisplayFor(modelItem => item.SaleUnitPrice)
</td>
<td>
@Html.DisplayFor(modelItem => item.CurrentPurchaseUnitPrice)
</td>
<td>
@Html.DisplayFor(modelItem => item.ExpiryDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.ManufactureDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.StockTreshHoldQuantity)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.IsActive)
</td>
<td>
@Html.DisplayFor(modelItem => item.CreateBy)
</td>
<td>
@Html.ActionLink("Edit", "EditProduct", new { productID = item.ProductID }, new { @class = "btn btn-warning" })
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
good thank you
ReplyDelete