This commit is contained in:
MOHD ARIFF 2024-12-30 16:32:16 +08:00
parent 5576acc67d
commit 52421e9693
13 changed files with 953 additions and 51 deletions

View File

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using PSTW_CentralSystem.Models;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace PSTW_CentralSystem.Areas.Inventory.Models
{
public class InventoryMasterModel
{
[Key]
public int StoreId { get; set; }
public int UserId { get; set; }
[ForeignKey("UserId")]
public virtual UserModel? User { get; set; }
[ForeignKey("StoreId")]
public virtual StoreModel? Store { get; set; }
}
}

View File

@ -32,7 +32,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public DateTime? InvoiceDate { get; set; } public DateTime? InvoiceDate { get; set; }
[Comment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;")] [Comment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;")]
public int ItemStatus { get; set; } = 1; public int ItemStatus { get; set; } = 1;
public string ItemLocation { get; set; } = string.Empty; public int? MovementId { get; set; }
public int CreatedByUserId { get; set; } public int CreatedByUserId { get; set; }
[ForeignKey("CreatedByUserId")] [ForeignKey("CreatedByUserId")]
public virtual UserModel? CreatedBy { get; set; } public virtual UserModel? CreatedBy { get; set; }
@ -42,5 +42,8 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public virtual DepartmentModel? Department { get; set; } public virtual DepartmentModel? Department { get; set; }
[ForeignKey("ProductId")] [ForeignKey("ProductId")]
public virtual ProductModel? Product { get; set; } public virtual ProductModel? Product { get; set; }
[ForeignKey("MovementId")]
public virtual ItemMovementModel? Movement { get; set; }
} }
} }

View File

@ -0,0 +1,43 @@
using PSTW_CentralSystem.Models;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace PSTW_CentralSystem.Areas.Inventory.Models
{
public class ItemMovementModel
{
[Key]
public int Id { get; set; }
public int ItemId { get; set; }
public int? ToStation { get; set; }
public int? ToStore { get; set; }
public int? ToUser { get; set; }
[Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")]
public string? ToOther { get; set; }
[Comment("StockIn, Stock Out")]
public string? Action { get; set; }
public int? Quantity { get; set; }
public string? Remark { get; set; }
public string? ConsignmentNote { get; set; }
public DateTime? Date { get; set; }
public int? LastUser { get; set; }
public int? LastStore{ get; set; }
public int? LastStation{ get; set; }
[Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")]
public string? LatestStatus { get; set; }
public bool MovementComplete { get; set; } = false;
public virtual ItemModel? Item { get; set; }
[ForeignKey("ToStore")]
public virtual StoreModel? NextStore { get; set; }
[ForeignKey("ToStation")]
public virtual StationModel? NextStation { get; set; }
[ForeignKey("ToUser")]
public virtual UserModel? NextUser { get; set; }
[ForeignKey("LastStore")]
public virtual StoreModel? FromStore { get; set; }
[ForeignKey("LastStation")]
public virtual StationModel? FromStation { get; set; }
[ForeignKey("LastUser")]
public virtual UserModel? FromUser { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using PSTW_CentralSystem.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PSTW_CentralSystem.Areas.Inventory.Models
{
public class StationModel
{
[Key]
public int StationId { get; set; }
public int StationPicID { get; set; }
public string? StationName { get; set; }
public int DepartmentId { get; set; }
[ForeignKey("DepartmentId")]
public virtual DepartmentModel? Department { get; set; }
[ForeignKey("StationPicID")]
public virtual UserModel? StationPic { get; set; }
}
}

View File

@ -1,6 +1,16 @@
namespace PSTW_CentralSystem.Areas.Inventory.Models using PSTW_CentralSystem.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PSTW_CentralSystem.Areas.Inventory.Models
{ {
public class StoreModel public class StoreModel
{ {
[Key]
public int Id { get; set; }
public int CompanyId { get; set; }
public string StoreName { get; set; } = string.Empty;
[ForeignKey("CompanyId")]
public virtual CompanyModel? Company { get; set; }
} }
} }

View File

@ -543,6 +543,10 @@
$(td).attr('id', `qr${cellData}`); $(td).attr('id', `qr${cellData}`);
}, },
}, },
{
"title": "Category",
"data": "category",
},
{ {
"title": "Serial Number", "title": "Serial Number",
"data": "serialNumber", "data": "serialNumber",
@ -560,7 +564,7 @@
"data": "purchaseDate", "data": "purchaseDate",
}, },
{ {
"title": "Price After Convert(RM)", "title": "Price(RM)",
"data": "convertPrice", "data": "convertPrice",
}, },
{ {
@ -575,6 +579,18 @@
else { return data } else { return data }
} }
}, },
{
"title": "Location",
"data": "currentUser",
"render": function (data, type, full, meta) {
currentUser = data ?? null;
currentStore = full.currentStore ?? 'N/A';
currentStation = full.currentStation ?? 'N/A';
return `User: ${currentUser}<br>
Store: ${currentStore}<br>
Station: ${currentStation}`
}
},
{ {
"title": "Print", "title": "Print",
"data": "uniqueID", "data": "uniqueID",
@ -601,7 +617,7 @@
const containerId = `qr${data.uniqueID}`; const containerId = `qr${data.uniqueID}`;
const container = $(`#${containerId}`); const container = $(`#${containerId}`);
container.empty(); container.empty();
container.append(`${data.uniqueID}`); container.append(`${data.uniqueID}<a href="#" target="_blank">`);
// console.log(container[0]); // console.log(container[0]);
if (container) { if (container) {
// Generate QR code only if not already generated // Generate QR code only if not already generated
@ -939,9 +955,9 @@
const imgData = canvas.toDataURL('image/png'); const imgData = canvas.toDataURL('image/png');
// Open the image in a new tab for preview (optional) // Open the image in a new tab for preview (optional)
const newWindow = window.open(); // const newWindow = window.open();
newWindow.location.href = imgData; // newWindow.location.href = imgData;
console.log(imgData) // console.log(imgData)
// Use printJS to print the image // Use printJS to print the image
printJS({ printJS({
printable: imgData, printable: imgData,

View File

@ -9,6 +9,8 @@ using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using PSTW_CentralSystem.Areas.Inventory.Models;
using System.Security.Cryptography.X509Certificates;
namespace PSTW_CentralSystem.Controllers.API namespace PSTW_CentralSystem.Controllers.API
{ {
@ -18,7 +20,7 @@ namespace PSTW_CentralSystem.Controllers.API
public class AdminAPI : Controller public class AdminAPI : Controller
{ {
private readonly ILogger<AdminAPI> _logger; private readonly ILogger<AdminAPI> _logger;
private readonly CentralSystemContext _identityDbContext; private readonly CentralSystemContext _centralDbContext;
private readonly UserManager<UserModel> _userManager; private readonly UserManager<UserModel> _userManager;
private readonly SignInManager<UserModel> _signInManager; private readonly SignInManager<UserModel> _signInManager;
private readonly RoleManager<RoleModel> _roleManager; private readonly RoleManager<RoleModel> _roleManager;
@ -26,7 +28,7 @@ namespace PSTW_CentralSystem.Controllers.API
public AdminAPI(ILogger<AdminAPI> logger, CentralSystemContext authDbContext, UserManager<UserModel> userManager, SignInManager<UserModel> signInManager, RoleManager<RoleModel> roleManager) public AdminAPI(ILogger<AdminAPI> logger, CentralSystemContext authDbContext, UserManager<UserModel> userManager, SignInManager<UserModel> signInManager, RoleManager<RoleModel> roleManager)
{ {
_logger = logger; _logger = logger;
_identityDbContext = authDbContext; _centralDbContext = authDbContext;
_userManager = userManager; _userManager = userManager;
_signInManager = signInManager; _signInManager = signInManager;
_roleManager = roleManager; _roleManager = roleManager;
@ -100,7 +102,7 @@ namespace PSTW_CentralSystem.Controllers.API
List<UserModel> userInfo = new List<UserModel>(); List<UserModel> userInfo = new List<UserModel>();
// Fetch all users excluding those with roles SuperAdmin or SystemAdmin // Fetch all users excluding those with roles SuperAdmin or SystemAdmin
var allUsers = await _identityDbContext.Users var allUsers = await _centralDbContext.Users
.Include(u => u.Department.Company) .Include(u => u.Department.Company)
.ToListAsync(); .ToListAsync();
@ -141,7 +143,7 @@ namespace PSTW_CentralSystem.Controllers.API
{ {
try try
{ {
var user = await _identityDbContext.Users.FindAsync(id); var user = await _centralDbContext.Users.Include("Department").FirstOrDefaultAsync(u => u.Id == id);
if (user == null) if (user == null)
{ {
@ -156,7 +158,31 @@ namespace PSTW_CentralSystem.Controllers.API
await _userManager.AddToRoleAsync(user, role); await _userManager.AddToRoleAsync(user, role);
user.UserInfoStatus = 1; user.UserInfoStatus = 1;
await _identityDbContext.SaveChangesAsync(); if (role == "Inventory Master") {
var StoreName = user.Department!.DepartmentName + " (" + user.Department!.DepartmentCode + ")";
var existingStore = await _centralDbContext.Stores.FirstOrDefaultAsync(s => s.StoreName == StoreName);
if (existingStore == null)
{
existingStore = new StoreModel
{
StoreName = StoreName,
CompanyId = user.Department.CompanyId,
};
await _centralDbContext.Stores.AddAsync(existingStore);
await _centralDbContext.SaveChangesAsync();
}
var masterStore = await _centralDbContext.Stores.FirstOrDefaultAsync(s => s.Id == existingStore.Id);
var newInventoryMaster = new InventoryMasterModel
{
UserId = user.Id,
StoreId = existingStore.Id,
};
await _centralDbContext.InventoryMasters.AddAsync(newInventoryMaster);
}
await _centralDbContext.SaveChangesAsync();
return Ok(new { message = "User updated successfully" }); return Ok(new { message = "User updated successfully" });
} }
@ -169,7 +195,7 @@ namespace PSTW_CentralSystem.Controllers.API
[HttpPost("GetDepartmentWithCompanyList")] [HttpPost("GetDepartmentWithCompanyList")]
public async Task<IActionResult> GetDepartmentWithCompanyList() public async Task<IActionResult> GetDepartmentWithCompanyList()
{ {
var companyList = await _identityDbContext.Companies var companyList = await _centralDbContext.Companies
.Include(c => c.Departments) .Include(c => c.Departments)
.Select(c => new { .Select(c => new {
c.CompanyId, c.CompanyId,
@ -185,8 +211,8 @@ namespace PSTW_CentralSystem.Controllers.API
[HttpPost("GetDepartmentWithCompany")] [HttpPost("GetDepartmentWithCompany")]
public async Task<DepartmentCompany> GetDepartmentWithCompany(int companyId, int departmentId) public async Task<DepartmentCompany> GetDepartmentWithCompany(int companyId, int departmentId)
{ {
var departmentList = await _identityDbContext.Departments.FirstOrDefaultAsync(d => d.DepartmentId == departmentId); var departmentList = await _centralDbContext.Departments.FirstOrDefaultAsync(d => d.DepartmentId == departmentId);
var companyList = await _identityDbContext.Companies.FirstOrDefaultAsync(c => c.CompanyId == companyId); var companyList = await _centralDbContext.Companies.FirstOrDefaultAsync(c => c.CompanyId == companyId);
// Create a new list to store departments with their company name // Create a new list to store departments with their company name
var departmentWithCompany = new DepartmentCompany var departmentWithCompany = new DepartmentCompany
@ -211,8 +237,8 @@ namespace PSTW_CentralSystem.Controllers.API
CompanyName = departmentCompanyDetails.Company! CompanyName = departmentCompanyDetails.Company!
}; };
_identityDbContext.Companies.Add(companyModel); _centralDbContext.Companies.Add(companyModel);
await _identityDbContext.SaveChangesAsync(); await _centralDbContext.SaveChangesAsync();
foreach (var department in departmentCompanyDetails.Department!) foreach (var department in departmentCompanyDetails.Department!)
{ {
@ -223,8 +249,8 @@ namespace PSTW_CentralSystem.Controllers.API
DepartmentCode = department.DepartmentCode ?? string.Empty DepartmentCode = department.DepartmentCode ?? string.Empty
}; };
_identityDbContext.Departments.Add(departmentModel); _centralDbContext.Departments.Add(departmentModel);
await _identityDbContext.SaveChangesAsync(); await _centralDbContext.SaveChangesAsync();
} }
return Ok( new { message = "Company and department added successfully" }); return Ok( new { message = "Company and department added successfully" });

View File

@ -265,11 +265,34 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
// Get the item list // Get the item list
if (isAdmin) if (isAdmin)
{ {
itemList = await _centralDbContext.Items.Include("CreatedBy").Include("Department").Include("Product").ToListAsync(); itemList = await _centralDbContext.Items
.AsNoTracking()
.Include("CreatedBy")
.Include("Department")
.Include("Product")
.Include(i => i.Movement)
.ThenInclude(m => m!.FromStore)
.Include(i => i.Movement)
.ThenInclude(m => m!.FromStation)
.Include(i => i.Movement)
.ThenInclude(m => m!.FromUser)
.ToListAsync();
} }
else else
{ {
itemList = await _centralDbContext.Items.Include("CreatedBy").Include("Department").Include("Product").Where(i => i.DepartmentId == user.departmentId).ToListAsync(); itemList = await _centralDbContext.Items
.AsNoTracking()
.Include("CreatedBy")
.Include("Department")
.Include("Product")
.Include(i => i.Movement)
.ThenInclude(m => m!.FromStore)
.Include(i => i.Movement)
.ThenInclude(m => m!.FromStation)
.Include(i => i.Movement)
.ThenInclude(m => m!.FromUser)
.Where(i => i.DepartmentId == user.departmentId)
.ToListAsync();
} }
// Get the departments list (DepartmentId references Departments) // Get the departments list (DepartmentId references Departments)
@ -295,10 +318,16 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.DODate, item.DODate,
item.Warranty, item.Warranty,
EndWDate = item.EndWDate.ToString("dd/MM/yyyy"), EndWDate = item.EndWDate.ToString("dd/MM/yyyy"),
item.InvoiceDate, InvoiceDate = item.InvoiceDate?.ToString("dd/MM/yyyy"),
item.Department?.DepartmentName, item.Department?.DepartmentName,
item.CreatedBy!.UserName, CreatedBy=item.CreatedBy!.UserName,
item.Product!.ProductName, item.Product!.ProductName,
item.Product!.Category,
//CurrentUser = item.Movement?.FromUser?.UserName,
CurrentUser = item.Movement?.FromUser?.UserName,
CurrentStore = item.Movement?.FromStore?.StoreName,
CurrentStation = item.Movement?.FromStation?.StationName,
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
}).ToList(); }).ToList();
@ -333,7 +362,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
try try
{ {
var product = await _centralDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found"); var product = await _centralDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found");
var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == item.CreatedByUserId) ?? new InventoryMasterModel{ UserId = item.CreatedByUserId };
var addToProduct = item.Quantity; var addToProduct = item.Quantity;
product.QuantityProduct += addToProduct; product.QuantityProduct += addToProduct;
@ -347,8 +376,27 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
await _centralDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID await _centralDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID
ItemMovementModel itemMovement = new ItemMovementModel
{
ItemId = item.ItemID,
ToUser = inventoryMaster.UserId,
ToStore = inventoryMaster.StoreId,
LastStore = inventoryMaster.StoreId,
LastUser = inventoryMaster.UserId,
LatestStatus = "Ready To Deploy",
Action= "Stock In",
Date = DateTime.Now,
MovementComplete = true,
};
_centralDbContext.ItemMovements.Add(itemMovement);
await _centralDbContext.SaveChangesAsync();
// Fetch the generated ItemID // Fetch the generated ItemID
var savedItem = await _centralDbContext.Items.FirstOrDefaultAsync(i => i.ItemID == item.ItemID); var savedItem = await _centralDbContext.Items.FirstOrDefaultAsync(i => i.ItemID == item.ItemID);
// Fetch the generated itemMovement
var savedMovement = await _centralDbContext.ItemMovements.FirstOrDefaultAsync(i => i.Id == itemMovement.Id);
if (savedItem != null) if (savedItem != null)
{ {
@ -363,10 +411,12 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
string? itemId = item.ItemID.ToString("D5"); string? itemId = item.ItemID.ToString("D5");
var uniqueId = $"{deptCode}{initialCategory}{productId}{itemId}".ToUpper(); var uniqueId = $"{deptCode}{initialCategory}{productId}{itemId}".ToUpper();
savedItem.UniqueID = uniqueId; savedItem.UniqueID = uniqueId;
savedItem.MovementId = savedMovement?.Id;
_centralDbContext.Items.Update(savedItem); _centralDbContext.Items.Update(savedItem);
await _centralDbContext.SaveChangesAsync(); await _centralDbContext.SaveChangesAsync();
} }
var updatedItem = new var updatedItem = new
{ {
savedItem!.ItemID, savedItem!.ItemID,
@ -437,7 +487,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.DODate, item.DODate,
item.Warranty, item.Warranty,
EndWDate = item.EndWDate.ToString("dd/MM/yyyy"), EndWDate = item.EndWDate.ToString("dd/MM/yyyy"),
item.InvoiceDate, InvoiceDate = item.InvoiceDate?.ToString("dd/MM/yyyy"),
item.Department?.DepartmentName, item.Department?.DepartmentName,
item.CreatedBy!.UserName, item.CreatedBy!.UserName,
item.Product!.ProductName, item.Product!.ProductName,

View File

@ -38,7 +38,8 @@ namespace PSTW_CentralSystem.DBContext
new RoleModel { Id = 1, Name = "SuperAdmin", NormalizedName = "SuperAdmin".ToUpper(), Description = "Can access all pages" }, new RoleModel { Id = 1, Name = "SuperAdmin", NormalizedName = "SuperAdmin".ToUpper(), Description = "Can access all pages" },
new RoleModel { Id = 2, Name = "SystemAdmin", NormalizedName = "SystemAdmin".ToUpper(), Description = "Can access some admin pages" }, new RoleModel { Id = 2, Name = "SystemAdmin", NormalizedName = "SystemAdmin".ToUpper(), Description = "Can access some admin pages" },
new RoleModel { Id = 3, Name = "Engineer", NormalizedName = "Engineer".ToUpper(), Description = "Can access operation pages" }, new RoleModel { Id = 3, Name = "Engineer", NormalizedName = "Engineer".ToUpper(), Description = "Can access operation pages" },
new RoleModel { Id = 4, Name = "Observer", NormalizedName = "Observer".ToUpper(), Description = "Can access data viewer pages" }); new RoleModel { Id = 4, Name = "Observer", NormalizedName = "Observer".ToUpper(), Description = "Can access data viewer pages" },
new RoleModel { Id = 5, Name = "Inventory Master", NormalizedName = "Inventory Master".ToUpper(), Description = "Handle inventory module" });
var passwordHasher = new PasswordHasher<UserModel>(); var passwordHasher = new PasswordHasher<UserModel>();
@ -91,6 +92,10 @@ namespace PSTW_CentralSystem.DBContext
public DbSet<ItemModel> Items { get; set; } public DbSet<ItemModel> Items { get; set; }
public DbSet<ProductModel> Products { get; set; } public DbSet<ProductModel> Products { get; set; }
public DbSet<SupplierModel> Suppliers { get; set; } public DbSet<SupplierModel> Suppliers { get; set; }
public DbSet<InventoryMasterModel> InventoryMasters { get; set; }
public DbSet<ItemMovementModel> ItemMovements { get; set; }
public DbSet<StationModel> Stations { get; set; }
public DbSet<StoreModel> Stores { get; set; }
} }
} }

View File

@ -12,7 +12,7 @@ using PSTW_CentralSystem.DBContext;
namespace PSTW_CentralSystem.Migrations namespace PSTW_CentralSystem.Migrations
{ {
[DbContext(typeof(CentralSystemContext))] [DbContext(typeof(CentralSystemContext))]
[Migration("20241223071002_Initiate")] [Migration("20241230074733_Initiate")]
partial class Initiate partial class Initiate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -140,6 +140,21 @@ namespace PSTW_CentralSystem.Migrations
b.ToTable("AspNetUserTokens", (string)null); b.ToTable("AspNetUserTokens", (string)null);
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.InventoryMasterModel", b =>
{
b.Property<int>("StoreId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("StoreId");
b.HasIndex("UserId");
b.ToTable("InventoryMasters");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{ {
b.Property<int>("ItemID") b.Property<int>("ItemID")
@ -170,6 +185,9 @@ namespace PSTW_CentralSystem.Migrations
b.Property<string>("DONo") b.Property<string>("DONo")
.HasColumnType("longtext"); .HasColumnType("longtext");
b.Property<float>("DefaultPrice")
.HasColumnType("float");
b.Property<int>("DepartmentId") b.Property<int>("DepartmentId")
.HasColumnType("int"); .HasColumnType("int");
@ -190,13 +208,13 @@ namespace PSTW_CentralSystem.Migrations
.HasColumnType("int") .HasColumnType("int")
.HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;"); .HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;");
b.Property<int?>("MovementId")
.HasColumnType("int");
b.Property<string>("PONo") b.Property<string>("PONo")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("longtext");
b.Property<float>("DefaultPrice")
.HasColumnType("float");
b.Property<int>("ProductId") b.Property<int>("ProductId")
.HasColumnType("int"); .HasColumnType("int");
@ -231,11 +249,87 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("DepartmentId"); b.HasIndex("DepartmentId");
b.HasIndex("MovementId")
.IsUnique();
b.HasIndex("ProductId"); b.HasIndex("ProductId");
b.ToTable("Items"); b.ToTable("Items");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Action")
.HasColumnType("longtext")
.HasComment("StockIn, Stock Out");
b.Property<string>("ConsignmentNote")
.HasColumnType("longtext");
b.Property<DateTime?>("Date")
.HasColumnType("datetime(6)");
b.Property<int>("ItemId")
.HasColumnType("int");
b.Property<int?>("LastStation")
.HasColumnType("int");
b.Property<int?>("LastStore")
.HasColumnType("int");
b.Property<int?>("LastUser")
.HasColumnType("int");
b.Property<string>("LatestStatus")
.HasColumnType("longtext")
.HasComment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery");
b.Property<bool>("MovementComplete")
.HasColumnType("tinyint(1)");
b.Property<int?>("Quantity")
.HasColumnType("int");
b.Property<string>("Remark")
.HasColumnType("longtext");
b.Property<string>("ToOther")
.HasColumnType("longtext")
.HasComment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery");
b.Property<int?>("ToStation")
.HasColumnType("int");
b.Property<int?>("ToStore")
.HasColumnType("int");
b.Property<int?>("ToUser")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LastStation");
b.HasIndex("LastStore");
b.HasIndex("LastUser");
b.HasIndex("ToStation");
b.HasIndex("ToStore");
b.HasIndex("ToUser");
b.ToTable("ItemMovements");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
{ {
b.Property<int>("ManufacturerId") b.Property<int>("ManufacturerId")
@ -290,6 +384,54 @@ namespace PSTW_CentralSystem.Migrations
b.ToTable("Products"); b.ToTable("Products");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", b =>
{
b.Property<int>("StationId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("StationId"));
b.Property<int>("DepartmentId")
.HasColumnType("int");
b.Property<string>("StationName")
.HasColumnType("longtext");
b.Property<int>("StationPicID")
.HasColumnType("int");
b.HasKey("StationId");
b.HasIndex("DepartmentId");
b.HasIndex("StationPicID");
b.ToTable("Stations");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<string>("StoreName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("CompanyId");
b.ToTable("Stores");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
{ {
b.Property<int>("SupplierId") b.Property<int>("SupplierId")
@ -451,6 +593,13 @@ namespace PSTW_CentralSystem.Migrations
Description = "Can access data viewer pages", Description = "Can access data viewer pages",
Name = "Observer", Name = "Observer",
NormalizedName = "OBSERVER" NormalizedName = "OBSERVER"
},
new
{
Id = 5,
Description = "Handle inventory module",
Name = "Inventory Master",
NormalizedName = "INVENTORY MASTER"
}); });
}); });
@ -536,16 +685,16 @@ namespace PSTW_CentralSystem.Migrations
{ {
Id = 1, Id = 1,
AccessFailedCount = 0, AccessFailedCount = 0,
ConcurrencyStamp = "7a7ee381-cecc-4268-9fc4-1f04eebfcb2c", ConcurrencyStamp = "cedbd3af-4aa6-41cc-a71f-f85ac3a7c6ac",
Email = "admin@pstw.com.my", Email = "admin@pstw.com.my",
EmailConfirmed = true, EmailConfirmed = true,
FullName = "MAAdmin", FullName = "MAAdmin",
LockoutEnabled = false, LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY", NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY", NormalizedUserName = "ADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEKL4x2bfz8vXmcqMKqRsdQPdP9FVEhj4IR3FVvfFdeMdJb1Z7vekx6E3Qzycgpj3WA==", PasswordHash = "AQAAAAIAAYagAAAAEEsEPaF/WtRT6js4zpE9wiOXZXn+Vq29o4nc8esBsMmSE3Sm5q636DZeu7ECQlQ0RA==",
PhoneNumberConfirmed = false, PhoneNumberConfirmed = false,
SecurityStamp = "5f7b5fe6-fb4d-4350-93aa-f3103c6e9a4d", SecurityStamp = "a7be7fa2-a275-4646-a387-2d1d1042878d",
TwoFactorEnabled = false, TwoFactorEnabled = false,
UserInfoStatus = 1, UserInfoStatus = 1,
UserName = "admin@pstw.com.my" UserName = "admin@pstw.com.my"
@ -554,16 +703,16 @@ namespace PSTW_CentralSystem.Migrations
{ {
Id = 2, Id = 2,
AccessFailedCount = 0, AccessFailedCount = 0,
ConcurrencyStamp = "fd4022cd-e08a-43c1-823c-573a86e86a9d", ConcurrencyStamp = "948106ca-aeaa-49fa-87c9-018445595c12",
Email = "sysadmin@pstw.com.my", Email = "sysadmin@pstw.com.my",
EmailConfirmed = true, EmailConfirmed = true,
FullName = "SysAdmin", FullName = "SysAdmin",
LockoutEnabled = false, LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY", NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY", NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAENI+MWqt+OwSLiTBhOC5LBV7nWb8hnfcGEnUOLpadTdCHa6rV0ukUo6Hd5nGRL5rTw==", PasswordHash = "AQAAAAIAAYagAAAAEL/iXkcbIqa5+OnqaBOBuG2KiSvkxA2shZYl0XQVtmadQnaO2eARuKwyGQqlWu9NqQ==",
PhoneNumberConfirmed = false, PhoneNumberConfirmed = false,
SecurityStamp = "0b4291c9-d818-4485-bd96-adde7e14286d", SecurityStamp = "04aeb405-81f6-4ca0-9ed8-ce10c2e5dd6e",
TwoFactorEnabled = false, TwoFactorEnabled = false,
UserInfoStatus = 1, UserInfoStatus = 1,
UserName = "sysadmin@pstw.com.my" UserName = "sysadmin@pstw.com.my"
@ -621,6 +770,25 @@ namespace PSTW_CentralSystem.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.InventoryMasterModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", "Store")
.WithMany()
.HasForeignKey("StoreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Models.UserModel", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Store");
b.Navigation("User");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{ {
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company") b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
@ -641,6 +809,10 @@ namespace PSTW_CentralSystem.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", "Movement")
.WithOne("Item")
.HasForeignKey("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", "MovementId");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product") b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product")
.WithMany("Items") .WithMany("Items")
.HasForeignKey("ProductId") .HasForeignKey("ProductId")
@ -653,9 +825,50 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Department"); b.Navigation("Department");
b.Navigation("Movement");
b.Navigation("Product"); b.Navigation("Product");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", "FromStation")
.WithMany()
.HasForeignKey("LastStation");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", "FromStore")
.WithMany()
.HasForeignKey("LastStore");
b.HasOne("PSTW_CentralSystem.Models.UserModel", "FromUser")
.WithMany()
.HasForeignKey("LastUser");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", "NextStation")
.WithMany()
.HasForeignKey("ToStation");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", "NextStore")
.WithMany()
.HasForeignKey("ToStore");
b.HasOne("PSTW_CentralSystem.Models.UserModel", "NextUser")
.WithMany()
.HasForeignKey("ToUser");
b.Navigation("FromStation");
b.Navigation("FromStore");
b.Navigation("FromUser");
b.Navigation("NextStation");
b.Navigation("NextStore");
b.Navigation("NextUser");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{ {
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer") b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer")
@ -667,6 +880,36 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Manufacturer"); b.Navigation("Manufacturer");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", b =>
{
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
.WithMany()
.HasForeignKey("DepartmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Models.UserModel", "StationPic")
.WithMany()
.HasForeignKey("StationPicID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Department");
b.Navigation("StationPic");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", b =>
{
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b => modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
{ {
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company") b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
@ -687,6 +930,11 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Department"); b.Navigation("Department");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
{
b.Navigation("Item");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{ {
b.Navigation("Items"); b.Navigation("Items");

View File

@ -159,6 +159,28 @@ namespace PSTW_CentralSystem.Migrations
}) })
.Annotation("MySql:CharSet", "utf8mb4"); .Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Stores",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(type: "int", nullable: false),
StoreName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Stores", x => x.Id);
table.ForeignKey(
name: "FK_Stores_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "CompanyId",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Products", name: "Products",
columns: table => new columns: table => new
@ -329,6 +351,123 @@ namespace PSTW_CentralSystem.Migrations
}) })
.Annotation("MySql:CharSet", "utf8mb4"); .Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "InventoryMasters",
columns: table => new
{
StoreId = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InventoryMasters", x => x.StoreId);
table.ForeignKey(
name: "FK_InventoryMasters_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InventoryMasters_Stores_StoreId",
column: x => x.StoreId,
principalTable: "Stores",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Stations",
columns: table => new
{
StationId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
StationPicID = table.Column<int>(type: "int", nullable: false),
StationName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DepartmentId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Stations", x => x.StationId);
table.ForeignKey(
name: "FK_Stations_AspNetUsers_StationPicID",
column: x => x.StationPicID,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Stations_Departments_DepartmentId",
column: x => x.DepartmentId,
principalTable: "Departments",
principalColumn: "DepartmentId",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ItemMovements",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ItemId = table.Column<int>(type: "int", nullable: false),
ToStation = table.Column<int>(type: "int", nullable: true),
ToStore = table.Column<int>(type: "int", nullable: true),
ToUser = table.Column<int>(type: "int", nullable: true),
ToOther = table.Column<string>(type: "longtext", nullable: true, comment: "Repair, Calibration, Faulty, Ready To Deploy, On Delivery")
.Annotation("MySql:CharSet", "utf8mb4"),
Action = table.Column<string>(type: "longtext", nullable: true, comment: "StockIn, Stock Out")
.Annotation("MySql:CharSet", "utf8mb4"),
Quantity = table.Column<int>(type: "int", nullable: true),
Remark = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConsignmentNote = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true),
LastUser = table.Column<int>(type: "int", nullable: true),
LastStore = table.Column<int>(type: "int", nullable: true),
LastStation = table.Column<int>(type: "int", nullable: true),
LatestStatus = table.Column<string>(type: "longtext", nullable: true, comment: "Repair, Calibration, Faulty, Ready To Deploy, On Delivery")
.Annotation("MySql:CharSet", "utf8mb4"),
MovementComplete = table.Column<bool>(type: "tinyint(1)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ItemMovements", x => x.Id);
table.ForeignKey(
name: "FK_ItemMovements_AspNetUsers_LastUser",
column: x => x.LastUser,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_ItemMovements_AspNetUsers_ToUser",
column: x => x.ToUser,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_ItemMovements_Stations_LastStation",
column: x => x.LastStation,
principalTable: "Stations",
principalColumn: "StationId");
table.ForeignKey(
name: "FK_ItemMovements_Stations_ToStation",
column: x => x.ToStation,
principalTable: "Stations",
principalColumn: "StationId");
table.ForeignKey(
name: "FK_ItemMovements_Stores_LastStore",
column: x => x.LastStore,
principalTable: "Stores",
principalColumn: "Id");
table.ForeignKey(
name: "FK_ItemMovements_Stores_ToStore",
column: x => x.ToStore,
principalTable: "Stores",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Items", name: "Items",
columns: table => new columns: table => new
@ -352,7 +491,7 @@ namespace PSTW_CentralSystem.Migrations
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
Currency = table.Column<string>(type: "longtext", nullable: false) Currency = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
PriceInRM = table.Column<float>(type: "float", nullable: false), DefaultPrice = table.Column<float>(type: "float", nullable: false),
CurrencyRate = table.Column<float>(type: "float", nullable: false), CurrencyRate = table.Column<float>(type: "float", nullable: false),
ConvertPrice = table.Column<float>(type: "float", nullable: false), ConvertPrice = table.Column<float>(type: "float", nullable: false),
DONo = table.Column<string>(type: "longtext", nullable: true) DONo = table.Column<string>(type: "longtext", nullable: true)
@ -366,6 +505,7 @@ namespace PSTW_CentralSystem.Migrations
ItemStatus = table.Column<int>(type: "int", nullable: false, comment: "1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;"), ItemStatus = table.Column<int>(type: "int", nullable: false, comment: "1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;"),
ItemLocation = table.Column<string>(type: "longtext", nullable: false) ItemLocation = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"), .Annotation("MySql:CharSet", "utf8mb4"),
MovementId = table.Column<int>(type: "int", nullable: true),
CreatedByUserId = table.Column<int>(type: "int", nullable: false) CreatedByUserId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
@ -389,6 +529,11 @@ namespace PSTW_CentralSystem.Migrations
principalTable: "Departments", principalTable: "Departments",
principalColumn: "DepartmentId", principalColumn: "DepartmentId",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Items_ItemMovements_MovementId",
column: x => x.MovementId,
principalTable: "ItemMovements",
principalColumn: "Id");
table.ForeignKey( table.ForeignKey(
name: "FK_Items_Products_ProductId", name: "FK_Items_Products_ProductId",
column: x => x.ProductId, column: x => x.ProductId,
@ -406,7 +551,8 @@ namespace PSTW_CentralSystem.Migrations
{ 1, null, "Can access all pages", "SuperAdmin", "SUPERADMIN" }, { 1, null, "Can access all pages", "SuperAdmin", "SUPERADMIN" },
{ 2, null, "Can access some admin pages", "SystemAdmin", "SYSTEMADMIN" }, { 2, null, "Can access some admin pages", "SystemAdmin", "SYSTEMADMIN" },
{ 3, null, "Can access operation pages", "Engineer", "ENGINEER" }, { 3, null, "Can access operation pages", "Engineer", "ENGINEER" },
{ 4, null, "Can access data viewer pages", "Observer", "OBSERVER" } { 4, null, "Can access data viewer pages", "Observer", "OBSERVER" },
{ 5, null, "Handle inventory module", "Inventory Master", "INVENTORY MASTER" }
}); });
migrationBuilder.InsertData( migrationBuilder.InsertData(
@ -414,8 +560,8 @@ namespace PSTW_CentralSystem.Migrations
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FullName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserInfoStatus", "UserName", "departmentId" }, columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FullName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserInfoStatus", "UserName", "departmentId" },
values: new object[,] values: new object[,]
{ {
{ 1, 0, "7a7ee381-cecc-4268-9fc4-1f04eebfcb2c", "admin@pstw.com.my", true, "MAAdmin", false, null, "ADMIN@PSTW.COM.MY", "ADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEKL4x2bfz8vXmcqMKqRsdQPdP9FVEhj4IR3FVvfFdeMdJb1Z7vekx6E3Qzycgpj3WA==", null, false, "5f7b5fe6-fb4d-4350-93aa-f3103c6e9a4d", false, 1, "admin@pstw.com.my", null }, { 1, 0, "cedbd3af-4aa6-41cc-a71f-f85ac3a7c6ac", "admin@pstw.com.my", true, "MAAdmin", false, null, "ADMIN@PSTW.COM.MY", "ADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEEsEPaF/WtRT6js4zpE9wiOXZXn+Vq29o4nc8esBsMmSE3Sm5q636DZeu7ECQlQ0RA==", null, false, "a7be7fa2-a275-4646-a387-2d1d1042878d", false, 1, "admin@pstw.com.my", null },
{ 2, 0, "fd4022cd-e08a-43c1-823c-573a86e86a9d", "sysadmin@pstw.com.my", true, "SysAdmin", false, null, "SYSADMIN@PSTW.COM.MY", "SYSADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAENI+MWqt+OwSLiTBhOC5LBV7nWb8hnfcGEnUOLpadTdCHa6rV0ukUo6Hd5nGRL5rTw==", null, false, "0b4291c9-d818-4485-bd96-adde7e14286d", false, 1, "sysadmin@pstw.com.my", null } { 2, 0, "948106ca-aeaa-49fa-87c9-018445595c12", "sysadmin@pstw.com.my", true, "SysAdmin", false, null, "SYSADMIN@PSTW.COM.MY", "SYSADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEL/iXkcbIqa5+OnqaBOBuG2KiSvkxA2shZYl0XQVtmadQnaO2eARuKwyGQqlWu9NqQ==", null, false, "04aeb405-81f6-4ca0-9ed8-ce10c2e5dd6e", false, 1, "sysadmin@pstw.com.my", null }
}); });
migrationBuilder.InsertData( migrationBuilder.InsertData(
@ -474,6 +620,41 @@ namespace PSTW_CentralSystem.Migrations
table: "Departments", table: "Departments",
column: "CompanyId"); column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_InventoryMasters_UserId",
table: "InventoryMasters",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_ItemMovements_LastStation",
table: "ItemMovements",
column: "LastStation");
migrationBuilder.CreateIndex(
name: "IX_ItemMovements_LastStore",
table: "ItemMovements",
column: "LastStore");
migrationBuilder.CreateIndex(
name: "IX_ItemMovements_LastUser",
table: "ItemMovements",
column: "LastUser");
migrationBuilder.CreateIndex(
name: "IX_ItemMovements_ToStation",
table: "ItemMovements",
column: "ToStation");
migrationBuilder.CreateIndex(
name: "IX_ItemMovements_ToStore",
table: "ItemMovements",
column: "ToStore");
migrationBuilder.CreateIndex(
name: "IX_ItemMovements_ToUser",
table: "ItemMovements",
column: "ToUser");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Items_CompanyId", name: "IX_Items_CompanyId",
table: "Items", table: "Items",
@ -489,6 +670,12 @@ namespace PSTW_CentralSystem.Migrations
table: "Items", table: "Items",
column: "DepartmentId"); column: "DepartmentId");
migrationBuilder.CreateIndex(
name: "IX_Items_MovementId",
table: "Items",
column: "MovementId",
unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Items_ProductId", name: "IX_Items_ProductId",
table: "Items", table: "Items",
@ -498,6 +685,21 @@ namespace PSTW_CentralSystem.Migrations
name: "IX_Products_ManufacturerId", name: "IX_Products_ManufacturerId",
table: "Products", table: "Products",
column: "ManufacturerId"); column: "ManufacturerId");
migrationBuilder.CreateIndex(
name: "IX_Stations_DepartmentId",
table: "Stations",
column: "DepartmentId");
migrationBuilder.CreateIndex(
name: "IX_Stations_StationPicID",
table: "Stations",
column: "StationPicID");
migrationBuilder.CreateIndex(
name: "IX_Stores_CompanyId",
table: "Stores",
column: "CompanyId");
} }
/// <inheritdoc /> /// <inheritdoc />
@ -518,6 +720,9 @@ namespace PSTW_CentralSystem.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AspNetUserTokens"); name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "InventoryMasters");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Items"); name: "Items");
@ -531,17 +736,26 @@ namespace PSTW_CentralSystem.Migrations
name: "AspNetRoles"); name: "AspNetRoles");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "AspNetUsers"); name: "ItemMovements");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Products"); name: "Products");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Departments"); name: "Stations");
migrationBuilder.DropTable(
name: "Stores");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Manufacturers"); name: "Manufacturers");
migrationBuilder.DropTable(
name: "AspNetUsers");
migrationBuilder.DropTable(
name: "Departments");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Companies"); name: "Companies");
} }

View File

@ -137,6 +137,21 @@ namespace PSTW_CentralSystem.Migrations
b.ToTable("AspNetUserTokens", (string)null); b.ToTable("AspNetUserTokens", (string)null);
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.InventoryMasterModel", b =>
{
b.Property<int>("StoreId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("StoreId");
b.HasIndex("UserId");
b.ToTable("InventoryMasters");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{ {
b.Property<int>("ItemID") b.Property<int>("ItemID")
@ -167,6 +182,9 @@ namespace PSTW_CentralSystem.Migrations
b.Property<string>("DONo") b.Property<string>("DONo")
.HasColumnType("longtext"); .HasColumnType("longtext");
b.Property<float>("DefaultPrice")
.HasColumnType("float");
b.Property<int>("DepartmentId") b.Property<int>("DepartmentId")
.HasColumnType("int"); .HasColumnType("int");
@ -187,13 +205,13 @@ namespace PSTW_CentralSystem.Migrations
.HasColumnType("int") .HasColumnType("int")
.HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;"); .HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;");
b.Property<int?>("MovementId")
.HasColumnType("int");
b.Property<string>("PONo") b.Property<string>("PONo")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("longtext");
b.Property<float>("DefaultPrice")
.HasColumnType("float");
b.Property<int>("ProductId") b.Property<int>("ProductId")
.HasColumnType("int"); .HasColumnType("int");
@ -228,11 +246,87 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("DepartmentId"); b.HasIndex("DepartmentId");
b.HasIndex("MovementId")
.IsUnique();
b.HasIndex("ProductId"); b.HasIndex("ProductId");
b.ToTable("Items"); b.ToTable("Items");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Action")
.HasColumnType("longtext")
.HasComment("StockIn, Stock Out");
b.Property<string>("ConsignmentNote")
.HasColumnType("longtext");
b.Property<DateTime?>("Date")
.HasColumnType("datetime(6)");
b.Property<int>("ItemId")
.HasColumnType("int");
b.Property<int?>("LastStation")
.HasColumnType("int");
b.Property<int?>("LastStore")
.HasColumnType("int");
b.Property<int?>("LastUser")
.HasColumnType("int");
b.Property<string>("LatestStatus")
.HasColumnType("longtext")
.HasComment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery");
b.Property<bool>("MovementComplete")
.HasColumnType("tinyint(1)");
b.Property<int?>("Quantity")
.HasColumnType("int");
b.Property<string>("Remark")
.HasColumnType("longtext");
b.Property<string>("ToOther")
.HasColumnType("longtext")
.HasComment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery");
b.Property<int?>("ToStation")
.HasColumnType("int");
b.Property<int?>("ToStore")
.HasColumnType("int");
b.Property<int?>("ToUser")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LastStation");
b.HasIndex("LastStore");
b.HasIndex("LastUser");
b.HasIndex("ToStation");
b.HasIndex("ToStore");
b.HasIndex("ToUser");
b.ToTable("ItemMovements");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
{ {
b.Property<int>("ManufacturerId") b.Property<int>("ManufacturerId")
@ -287,6 +381,54 @@ namespace PSTW_CentralSystem.Migrations
b.ToTable("Products"); b.ToTable("Products");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", b =>
{
b.Property<int>("StationId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("StationId"));
b.Property<int>("DepartmentId")
.HasColumnType("int");
b.Property<string>("StationName")
.HasColumnType("longtext");
b.Property<int>("StationPicID")
.HasColumnType("int");
b.HasKey("StationId");
b.HasIndex("DepartmentId");
b.HasIndex("StationPicID");
b.ToTable("Stations");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<string>("StoreName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("CompanyId");
b.ToTable("Stores");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
{ {
b.Property<int>("SupplierId") b.Property<int>("SupplierId")
@ -448,6 +590,13 @@ namespace PSTW_CentralSystem.Migrations
Description = "Can access data viewer pages", Description = "Can access data viewer pages",
Name = "Observer", Name = "Observer",
NormalizedName = "OBSERVER" NormalizedName = "OBSERVER"
},
new
{
Id = 5,
Description = "Handle inventory module",
Name = "Inventory Master",
NormalizedName = "INVENTORY MASTER"
}); });
}); });
@ -533,16 +682,16 @@ namespace PSTW_CentralSystem.Migrations
{ {
Id = 1, Id = 1,
AccessFailedCount = 0, AccessFailedCount = 0,
ConcurrencyStamp = "7a7ee381-cecc-4268-9fc4-1f04eebfcb2c", ConcurrencyStamp = "cedbd3af-4aa6-41cc-a71f-f85ac3a7c6ac",
Email = "admin@pstw.com.my", Email = "admin@pstw.com.my",
EmailConfirmed = true, EmailConfirmed = true,
FullName = "MAAdmin", FullName = "MAAdmin",
LockoutEnabled = false, LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY", NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY", NormalizedUserName = "ADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEKL4x2bfz8vXmcqMKqRsdQPdP9FVEhj4IR3FVvfFdeMdJb1Z7vekx6E3Qzycgpj3WA==", PasswordHash = "AQAAAAIAAYagAAAAEEsEPaF/WtRT6js4zpE9wiOXZXn+Vq29o4nc8esBsMmSE3Sm5q636DZeu7ECQlQ0RA==",
PhoneNumberConfirmed = false, PhoneNumberConfirmed = false,
SecurityStamp = "5f7b5fe6-fb4d-4350-93aa-f3103c6e9a4d", SecurityStamp = "a7be7fa2-a275-4646-a387-2d1d1042878d",
TwoFactorEnabled = false, TwoFactorEnabled = false,
UserInfoStatus = 1, UserInfoStatus = 1,
UserName = "admin@pstw.com.my" UserName = "admin@pstw.com.my"
@ -551,16 +700,16 @@ namespace PSTW_CentralSystem.Migrations
{ {
Id = 2, Id = 2,
AccessFailedCount = 0, AccessFailedCount = 0,
ConcurrencyStamp = "fd4022cd-e08a-43c1-823c-573a86e86a9d", ConcurrencyStamp = "948106ca-aeaa-49fa-87c9-018445595c12",
Email = "sysadmin@pstw.com.my", Email = "sysadmin@pstw.com.my",
EmailConfirmed = true, EmailConfirmed = true,
FullName = "SysAdmin", FullName = "SysAdmin",
LockoutEnabled = false, LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY", NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY", NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAENI+MWqt+OwSLiTBhOC5LBV7nWb8hnfcGEnUOLpadTdCHa6rV0ukUo6Hd5nGRL5rTw==", PasswordHash = "AQAAAAIAAYagAAAAEL/iXkcbIqa5+OnqaBOBuG2KiSvkxA2shZYl0XQVtmadQnaO2eARuKwyGQqlWu9NqQ==",
PhoneNumberConfirmed = false, PhoneNumberConfirmed = false,
SecurityStamp = "0b4291c9-d818-4485-bd96-adde7e14286d", SecurityStamp = "04aeb405-81f6-4ca0-9ed8-ce10c2e5dd6e",
TwoFactorEnabled = false, TwoFactorEnabled = false,
UserInfoStatus = 1, UserInfoStatus = 1,
UserName = "sysadmin@pstw.com.my" UserName = "sysadmin@pstw.com.my"
@ -618,6 +767,25 @@ namespace PSTW_CentralSystem.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.InventoryMasterModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", "Store")
.WithMany()
.HasForeignKey("StoreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Models.UserModel", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Store");
b.Navigation("User");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{ {
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company") b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
@ -638,6 +806,10 @@ namespace PSTW_CentralSystem.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", "Movement")
.WithOne("Item")
.HasForeignKey("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", "MovementId");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product") b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product")
.WithMany("Items") .WithMany("Items")
.HasForeignKey("ProductId") .HasForeignKey("ProductId")
@ -650,9 +822,50 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Department"); b.Navigation("Department");
b.Navigation("Movement");
b.Navigation("Product"); b.Navigation("Product");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", "FromStation")
.WithMany()
.HasForeignKey("LastStation");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", "FromStore")
.WithMany()
.HasForeignKey("LastStore");
b.HasOne("PSTW_CentralSystem.Models.UserModel", "FromUser")
.WithMany()
.HasForeignKey("LastUser");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", "NextStation")
.WithMany()
.HasForeignKey("ToStation");
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", "NextStore")
.WithMany()
.HasForeignKey("ToStore");
b.HasOne("PSTW_CentralSystem.Models.UserModel", "NextUser")
.WithMany()
.HasForeignKey("ToUser");
b.Navigation("FromStation");
b.Navigation("FromStore");
b.Navigation("FromUser");
b.Navigation("NextStation");
b.Navigation("NextStore");
b.Navigation("NextUser");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{ {
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer") b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer")
@ -664,6 +877,36 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Manufacturer"); b.Navigation("Manufacturer");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", b =>
{
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
.WithMany()
.HasForeignKey("DepartmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Models.UserModel", "StationPic")
.WithMany()
.HasForeignKey("StationPicID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Department");
b.Navigation("StationPic");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", b =>
{
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b => modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
{ {
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company") b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
@ -684,6 +927,11 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Department"); b.Navigation("Department");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
{
b.Navigation("Item");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{ {
b.Navigation("Items"); b.Navigation("Items");

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB