Codes
Codes
LAB-TERMINAL
SUBMITTED TO: SIR JAMAL AHMED
SUBMITTED BY: ZUNAIRA FATIMA
REGISTRATION NO: FA20-BSE-014
COURSE TITLE: VISUAL PROGRAMMING
BS (SE)-5B
15 January 2023
CONTROLLERS
INVENTORY CONTROLLERS
DRUG NAME CONTROLLER
using PharmAssistent.Models;
using PharmAssistent.Models.InventoryModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PharmAssistent.Repository;
namespace PharmAssistent.Controllers.Inventory
{
public class DrugGenericNameController : Controller
{
CheckDuplicatecs Duplicates = new CheckDuplicatecs();
PharmContext db = new PharmContext();
// GET: DrugGenericName
public ActionResult Index()
{
return View(db.DrugGenericNames.ToList());
}
[ActionName("CreateGeneric")]
[HttpGet]
public ActionResult Create()
{
return View();
}
[ActionName("CreateGeneric")]
[HttpPost]
public ActionResult Create_Generic()
{
DrugGenericName drugGenericName = new DrugGenericName();
TryUpdateModel(drugGenericName);
{
bool count =
Duplicates.CheckDuplicatecDrugGenericName(drugGenericName);
if (count == false)
{
try
{
db.DrugGenericNames.Add(drugGenericName);
db.SaveChanges();
ViewBag.msg = "Generic Save"; // SET IT TO VIEW
}
catch
{
ViewBag.msg = "Unable to save";
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
}
return RedirectToAction("Index", "DrugGenericName");
}
BS (SE)-5B
15 January 2023
}
public ActionResult Detail(int ID)
{
}
catch
{
ViewBag.err = "Invalid Id Selected";
return View(output);
}
return View(output);
}
}
catch
{
ViewBag.msg = "ID Not Found"; // Item not Found
}
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(int ID)
{
PharmContext db = new PharmContext();
DrugGenericName drugGenericName= new DrugGenericName();
try
{
drugGenericName= db.DrugGenericNames.Single(m => m.ID == ID);
}
catch
{
ViewBag.err = "ID not Found";
return RedirectToAction("Index", "DrugGenericName");
BS (SE)-5B
15 January 2023
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
return View(drugGenericName);
}
[ActionName("Edit")]
[HttpPost]
public ActionResult Edit_Generic()
{
DrugGenericName DrugGenericNames = new DrugGenericName();
PharmContext db = new PharmContext();
TryUpdateModel(DrugGenericNames);
{
DrugGenericName original = new DrugGenericName();
bool count =
Duplicates.CheckDuplicatecDrugGenericName(DrugGenericNames);
if (count == false)
{
try
{
original = db.DrugGenericNames.Single(m => m.ID ==
DrugGenericNames.ID);
original.ID = DrugGenericNames.ID;
original.GenericName = DrugGenericNames.GenericName;
original.Description = DrugGenericNames.Description;
db.SaveChanges();
ViewBag.msg = "Generic Updated"; // SET IT TO VIEW
}
catch
{
ViewBag.msg = "Unable to Update";
}
}
}
return RedirectToAction("Index", "DrugGenericName");
}
}
}
ITEM CONTROLLER
using PharmAssistent.Models;
using PharmAssistent.Models.InventoryModel;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace PharmAssistent.Controllers.Inventory
{
public class ItemController : Controller
{
// GET: Item
public ActionResult Index()
BS (SE)-5B
15 January 2023
{
PharmContext db = new PharmContext();
// List<Item> item = new List<Item>();
var items = db.items.ToList();
//return View(item);
// var items = db.items.Include(i => i.DrugGenericName).Include(i =>
i.Manufacturer).OrderByDescending(i => i.ID);
return View(items.ToList());
}
public JsonResult PopulateDrugGenericName()
{
//holds list of suppliers
PharmContext context = new PharmContext();
List<DrugGenericName> _supplierList = new List<DrugGenericName>();
BS (SE)-5B
15 January 2023
[ActionName("NewItem")]
[HttpPost]
public ActionResult Create_New_Item()
{
if(ModelState.IsValid)
{
}
else
{
ViewBag.err = "Invalid Entry";
}
return View();
[ActionName("NewItem")]
[HttpGet]
public ActionResult CreateItem()
{
return View();
}
}
}
MANUFACTURER CONTROLLER
using PharmAssistent.Models;
using PharmAssistent.Models.InventoryModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PharmAssistent.Repository;
namespace PharmAssistent.Controllers.Inventory
{
public class ManufacturerController : Controller
{
CheckDuplicatecs Duplicates = new CheckDuplicatecs();
PharmContext db = new PharmContext();
// GET: Manufacturer
public ActionResult Index()
{
BS (SE)-5B
15 January 2023
}
public ActionResult Create()
{
return View();
}
[ActionName("Create")]
[HttpPost]
public ActionResult Create_Manufacturer()
{
TryUpdateModel(manufacturer);
{
bool count = Duplicates.CheckDuplicatecManufacturer(manufacturer);
if (count == false)
{
try
{
db.Manufacturers.Add(manufacturer);
db.SaveChanges();
ViewBag.msg = "Manufacturer Saved !"; // SET IT TO VIEW
}
catch
{
ViewBag.msg = "Unable to Create";
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
}
else
{
ViewBag.err = "Manufacturer Already Exist";
return View();
}
}
return RedirectToAction("Index", "manufacturer");
}
public ActionResult Detail(int ID)
{
}
catch
{
BS (SE)-5B
15 January 2023
return View(output);
}
return View(output);
}
}
catch
{
ViewBag.msg = "ID Not Found"; // Item not Found
}
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(int ID)
{
PharmContext db = new PharmContext();
Manufacturer manufacturer = new Manufacturer();
try
{
manufacturer = db.Manufacturers.Single(m => m.ID == ID);
}
catch
{
ViewBag.err = "ID not Found";
return RedirectToAction("Index", "Manufacturer");
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
return View(manufacturer);
}
[ActionName("Edit")]
[HttpPost]
public ActionResult Edit_Manufacturer()
{
Manufacturer manufacturer = new Manufacturer();
TryUpdateModel(manufacturer);
{
Manufacturer original = new Manufacturer();
bool count = Duplicates.CheckDuplicatecManufacturer(manufacturer);
BS (SE)-5B
15 January 2023
if (count == false)
{
try
{
original = db.Manufacturers.Single(m => m.ID ==
manufacturer.ID);
original.ID = manufacturer.ID;
original.ManufacturerName = manufacturer.ManufacturerName;
original.Description = manufacturer.Description;
db.SaveChanges();
ViewBag.msg = "Manufacturer Updated"; // SET IT TO VIEW
}
catch
{
ViewBag.msg = "Unable to Update";
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
}
return RedirectToAction("Index", "manufacturer");
}
}
}
}
using PharmAssistent.Models.PurchaseModel;
using PharmAssistent.Models;
using PharmAssistent.Models.InventoryModel;
using PharmAssistent.ViewModel;
namespace PharmAssistent.Controllers
{
BS (SE)-5B
15 January 2023
// }
public JsonResult PopulateSupplier()
{
//holds list of suppliers
List<Supplier> _supplierList = new List<Supplier>();
[HttpPost]
public JsonResult SavePurchase(PurchaseEntryVM p)
{
BS (SE)-5B
15 January 2023
if (p != null)
{
//new purchase object using the data from the viewmodel :
PurchaseEntryVM
Purchase purchase = new Purchase
{
ID = p.ID,
PurchaseID = p.PurchaseID,
Date = p.Date,
SupplierID = p.SupplierID,
Amount = p.Amount,
Discount = p.Discount,
Tax = p.Tax,
GrandTotal = p.GrandTotal,
IsPaid = p.IsPaid,
Description = p.Description,
LastUpdated = DateTime.Now
};
Purchase_Copy purchase_copy = new Purchase_Copy();
purchase_copy.PurchaseItem = new List<PurchaseItem>();
// populating the PurchaseItems from the PurchaseItems within
ViewModel : PurchaseEntryVM
foreach (var i in p.PurchaseItems)
{
purchase_copy.PurchaseItem.Add(i);
}
Service.PurchaseEntryService service = new
Service.PurchaseEntryService();
service.AddPurchaseAndPurchseItems(purchase);
service.InsertOrUpdateInventory(p.PurchaseItems);
/////<if everything is sucessful, set status to true.>
status = true;
}
// return the status in form of Json
return new JsonResult { Data = new { status = status } };
}
}
STOCK CONTROLLER
using PharmAssistent.Models;
using PharmAssistent.Models.InventoryModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace PharmAssistent.Controllers.Inventory
{
public class StockController : Controller
{
// GET: Stock
public ActionResult Index()
BS (SE)-5B
15 January 2023
ViewBag.count = stock.Count;
// var stocks = db.Stocks.Where(s => s.Qty > 0).Include(s =>
s.Item).OrderByDescending(x => x.ID);
return View(stock);
}
public ActionResult Detail(int ID)
{
}
catch
{
ViewBag.err = "Invalid Id Selected";
return View(output);
}
return View(output);
}
}
catch
{
ViewBag.msg = "ID Not Found"; // Item not Found
}
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(int ID)
{
PharmContext db = new PharmContext();
BS (SE)-5B
15 January 2023
original.ID = stocks.ID;
original.Batch = stocks.Batch;
original.CostPrice = stocks.CostPrice;
original.Expiry = stocks.Expiry;
// original.Item = stocks.Item;
// original.ItemExpired = stocks.ItemExpired;
original.ItemID = stocks.ItemID;
original.ManufactureDate = stocks.ManufactureDate;
original.PurchaseID = stocks.PurchaseID;
original.Qty = stocks.Qty;
original.SellingPrice = stocks.SellingPrice;
db.SaveChanges();
ViewBag.msg = "Supplier Deleted"; // SET IT TO VIEW
}
catch
{
ViewBag.msg = "Unable to Update";
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
return RedirectToAction("Index", "Stock");
}
}
}
BS (SE)-5B
15 January 2023
PURCHASE CONTROLLER
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PharmAssistent.Models;
using PharmAssistent.Models.PurchaseModel;
namespace PharmAssistent.Controllers
{
return View(purchase);
// return View();
}
[HttpGet]
public ActionResult Edit(string PurchaseID)
{
PharmContext db = new PharmContext();
Purchase purchase = new Purchase();
try
{
purchase = db.PurchaseContext.Single(m => m.PurchaseID ==
PurchaseID);
}
catch
{
ViewBag.err = "ID not Found";
return RedirectToAction("Index","Purchase");
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
return View(purchase);
// return View();
BS (SE)-5B
15 January 2023
}
[ActionName("Edit")]
[HttpPost]
public ActionResult Edit_Purchase()
{
Purchase purchaseView = new Purchase();
PharmContext db = new PharmContext();
TryUpdateModel(purchaseView);
{
Purchase original = new Purchase();
try
{
original.PurchaseID = purchaseView.PurchaseID;
original.Amount = purchaseView.Amount;
original.Date = purchaseView.Date;
original.Description = purchaseView.Description;
original.Discount = purchaseView.Discount;
original.Tax = purchaseView.Tax;
original.GrandTotal = purchaseView.GrandTotal;
original.IsPaid = purchaseView.IsPaid;
original.LastUpdated = DateTime.Now;
db.SaveChanges();
}
catch
{
ViewBag.msg = "Unable to Update";
//return new
HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
}
return RedirectToAction("Index", "Purchase");
}
public ActionResult Delete(string PurchaseID)
{
PharmContext db = new PharmContext();
List<PurchaseItem> purchaseitem = new List<PurchaseItem>();
Purchase purchase = new Purchase();
try
{
purchase = db.PurchaseContext.Single(m => m.PurchaseID ==
PurchaseID); ;
purchaseitem = db.PurchaseItemContext.Where(m => m.PurchaseID ==
PurchaseID).ToList();
if (purchaseitem != null)
{
foreach (var i in purchaseitem)
{
db.PurchaseItemContext.Remove(i);
}
BS (SE)-5B
15 January 2023
}
else
{
ViewBag.msg = "Item Not Deleted";
}
}
catch
{
ViewBag.err = "Unable to Delete ";
}
return RedirectToAction("Index");
}
}
}
SELL CONTROLLERS
SALES CONTROLLER
using PharmAssistent.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace PharmAssistent.Controllers.Sell
{
public class SalesController : Controller
{
PharmContext context = new PharmContext();
// GET:Sales
[HttpGet]
public ActionResult Index()
{
return View();
}
}
}
namespace PharmAssistent.Controllers.Sell
BS (SE)-5B
15 January 2023
{
public class SalesEntryController : Controller
{
PharmContext context = new PharmContext();
// GET: SalesEntry
public ActionResult Index()
{
List<Stock> stock = new List<Stock>();
stock = context.Stocks.ToList();
return View(stock);
}
}
}
ACCOUNT CONTROLLER
using System;
using System.Globalization;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using PharmAssistent.Models;
namespace PharmAssistent.Controllers
[Authorize]
public AccountController()
BS (SE)-5B
15 January 2023
UserManager = userManager;
SignInManager = signInManager;
get
private set
_signInManager = value;
get
return _userManager ??
HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
BS (SE)-5B
15 January 2023
private set
_userManager = value;
//
// GET: /Account/Login
[AllowAnonymous]
ViewBag.ReturnUrl = returnUrl;
return View();
//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
if (!ModelState.IsValid)
return View(model);
BS (SE)-5B
15 January 2023
switch (result)
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
case SignInStatus.Failure:
default:
return View(model);
//
// GET: /Account/VerifyCode
[AllowAnonymous]
// Require that the user has already logged in via username/password or external login
if (!await SignInManager.HasBeenVerifiedAsync())
return View("Error");
BS (SE)-5B
15 January 2023
//
// POST: /Account/VerifyCode
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
if (!ModelState.IsValid)
return View(model);
// The following code protects for brute force attacks against the two factor codes.
// If a user enters incorrect codes for a specified amount of time then the user account
switch (result)
case SignInStatus.Success:
return RedirectToLocal(model.ReturnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.Failure:
default:
BS (SE)-5B
15 January 2023
return View(model);
//
// GET: /Account/Register
[AllowAnonymous]
return View();
//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
if (ModelState.IsValid)
if (result.Succeeded)
// For more information on how to enable account confirmation and password reset please
visit http://go.microsoft.com/fwlink/?LinkID=320771
BS (SE)-5B
15 January 2023
AddErrors(result);
return View(model);
//
// GET: /Account/ConfirmEmail
[AllowAnonymous]
return View("Error");
BS (SE)-5B
15 January 2023
//
// GET: /Account/ForgotPassword
[AllowAnonymous]
return View();
//
// POST: /Account/ForgotPassword
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
if (ModelState.IsValid)
// Don't reveal that the user does not exist or is not confirmed
return View("ForgotPasswordConfirmation");
// For more information on how to enable account confirmation and password reset please
visit http://go.microsoft.com/fwlink/?LinkID=320771
BS (SE)-5B
15 January 2023
return View(model);
//
// GET: /Account/ForgotPasswordConfirmation
[AllowAnonymous]
return View();
//
// GET: /Account/ResetPassword
[AllowAnonymous]
//
// POST: /Account/ResetPassword
BS (SE)-5B
15 January 2023
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
if (!ModelState.IsValid)
return View(model);
if (user == null)
if (result.Succeeded)
AddErrors(result);
return View();
//
// GET: /Account/ResetPasswordConfirmation
[AllowAnonymous]
BS (SE)-5B
15 January 2023
return View();
//
// POST: /Account/ExternalLogin
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
//
// GET: /Account/SendCode
[AllowAnonymous]
if (userId == null)
return View("Error");
BS (SE)-5B
15 January 2023
//
// POST: /Account/SendCode
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
if (!ModelState.IsValid)
return View();
if (!await SignInManager.SendTwoFactorCodeAsync(model.SelectedProvider))
return View("Error");
//
// GET: /Account/ExternalLoginCallback
[AllowAnonymous]
BS (SE)-5B
15 January 2023
if (loginInfo == null)
return RedirectToAction("Login");
// Sign in the user with this external login provider if the user already has a login
switch (result)
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
case SignInStatus.Failure:
default:
// If the user does not have an account, then prompt the user to create an account
ViewBag.ReturnUrl = returnUrl;
ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
//
// POST: /Account/ExternalLoginConfirmation
[HttpPost]
[AllowAnonymous]
BS (SE)-5B
15 January 2023
[ValidateAntiForgeryToken]
if (User.Identity.IsAuthenticated)
if (ModelState.IsValid)
// Get the information about the user from the external login provider
if (info == null)
return View("ExternalLoginFailure");
if (result.Succeeded)
if (result.Succeeded)
return RedirectToLocal(returnUrl);
AddErrors(result);
BS (SE)-5B
15 January 2023
ViewBag.ReturnUrl = returnUrl;
return View(model);
//
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
//
// GET: /Account/ExternalLoginFailure
[AllowAnonymous]
return View();
if (disposing)
if (_userManager != null)
BS (SE)-5B
15 January 2023
_userManager.Dispose();
_userManager = null;
if (_signInManager != null)
_signInManager.Dispose();
_signInManager = null;
base.Dispose(disposing);
#region Helpers
get
return HttpContext.GetOwinContext().Authentication;
BS (SE)-5B
15 January 2023
ModelState.AddModelError("", error);
if (Url.IsLocalUrl(returnUrl))
return Redirect(returnUrl);
LoginProvider = provider;
RedirectUri = redirectUri;
UserId = userId;
BS (SE)-5B
15 January 2023
if (UserId != null)
properties.Dictionary[XsrfKey] = UserId;
context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
#endregion
EMPLOYEE CONTROLER
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PharmAssistent.Models;
namespace MVCDEMO.Controllers
{
public class EmployeeController : Controller
{
// GET: Employee
public ActionResult Index(int departmentId)
{
EmployeeContext employeContext = new EmployeeContext();
List<Employee> employees = employeContext.Employees.Where(emp =>
emp.DepartmentId == departmentId).ToList();
return View(employees);
BS (SE)-5B
15 January 2023
return View(employee);
}
[HttpGet]
[ActionName("Create")]
public ActionResult Create_Get()
{
return View();
}
[HttpPost]
[ActionName("Create")]
public ActionResult Create_Post()
{
Employee employee = new Employee();
TryUpdateModel(employee);
//if (ModelState.iIsValid)
//{
EmployeeBusinessLayer employeeBusinessLayer = new
EmployeeBusinessLayer();
employeeBusinessLayer.AddEmployee(employee); //
@Html.ActionLink("Back to List", "Index", new { departmentId = Model.DepartmentId })
//return View();
BS (SE)-5B
15 January 2023
return View(emp);
return View(employee);
}
[HttpPost]
[ActionName("Edit")]
public ActionResult Edit_Post(Employee employee)
{
}
}
HOME CONTROLLER
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace PharmAssistent.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
BS (SE)-5B
15 January 2023
return View();
}
return View();
}
}
}
MANAGE CONTROLLER
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using PharmAssistent.Models;
namespace PharmAssistent.Controllers
[Authorize]
public ManageController()
BS (SE)-5B
15 January 2023
UserManager = userManager;
SignInManager = signInManager;
get
private set
_signInManager = value;
get
return _userManager ??
HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
BS (SE)-5B
15 January 2023
private set
_userManager = value;
//
// GET: /Manage/Index
ViewBag.StatusMessage =
: "";
HasPassword = HasPassword(),
BrowserRemembered = await
AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
BS (SE)-5B
15 January 2023
};
return View(model);
//
// POST: /Manage/RemoveLogin
[HttpPost]
[ValidateAntiForgeryToken]
ManageMessageId? message;
if (result.Succeeded)
if (user != null)
message = ManageMessageId.RemoveLoginSuccess;
else
message = ManageMessageId.Error;
BS (SE)-5B
15 January 2023
//
// GET: /Manage/AddPhoneNumber
return View();
//
// POST: /Manage/AddPhoneNumber
[HttpPost]
[ValidateAntiForgeryToken]
if (!ModelState.IsValid)
return View(model);
if (UserManager.SmsService != null)
Destination = model.Number,
};
await UserManager.SmsService.SendAsync(message);
BS (SE)-5B
15 January 2023
//
// POST: /Manage/EnableTwoFactorAuthentication
[HttpPost]
[ValidateAntiForgeryToken]
if (user != null)
//
// POST: /Manage/DisableTwoFactorAuthentication
[HttpPost]
[ValidateAntiForgeryToken]
if (user != null)
BS (SE)-5B
15 January 2023
//
// GET: /Manage/VerifyPhoneNumber
// Send an SMS through the SMS provider to verify the phone number
//
// POST: /Manage/VerifyPhoneNumber
[HttpPost]
[ValidateAntiForgeryToken]
if (!ModelState.IsValid)
return View(model);
if (result.Succeeded)
BS (SE)-5B
15 January 2023
if (user != null)
return View(model);
//
// POST: /Manage/RemovePhoneNumber
[HttpPost]
[ValidateAntiForgeryToken]
if (!result.Succeeded)
if (user != null)
BS (SE)-5B
15 January 2023
//
// GET: /Manage/ChangePassword
return View();
//
// POST: /Manage/ChangePassword
[HttpPost]
[ValidateAntiForgeryToken]
if (!ModelState.IsValid)
return View(model);
if (result.Succeeded)
if (user != null)
BS (SE)-5B
15 January 2023
AddErrors(result);
return View(model);
//
// GET: /Manage/SetPassword
return View();
//
// POST: /Manage/SetPassword
[HttpPost]
[ValidateAntiForgeryToken]
if (ModelState.IsValid)
if (result.Succeeded)
if (user != null)
BS (SE)-5B
15 January 2023
AddErrors(result);
return View(model);
//
// GET: /Manage/ManageLogins
ViewBag.StatusMessage =
: "";
if (user == null)
return View("Error");
CurrentLogins = userLogins,
BS (SE)-5B
15 January 2023
OtherLogins = otherLogins
});
//
// POST: /Manage/LinkLogin
[HttpPost]
[ValidateAntiForgeryToken]
// Request a redirect to the external login provider to link a login for the current user
//
// GET: /Manage/LinkLoginCallback
if (loginInfo == null)
BS (SE)-5B
15 January 2023
_userManager.Dispose();
_userManager = null;
base.Dispose(disposing);
#region Helpers
get
return HttpContext.GetOwinContext().Authentication;
ModelState.AddModelError("", error);
BS (SE)-5B
15 January 2023
if (user != null)
return false;
if (user != null)
return false;
AddPhoneSuccess,
ChangePasswordSuccess,
SetTwoFactorSuccess,
SetPasswordSuccess,
RemoveLoginSuccess,
BS (SE)-5B
15 January 2023
RemovePhoneSuccess,
Error
#endregion
MODELS
INVENTRY MODEL
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PharmAssistent.Models.PurchaseModel;
using PharmAssistent.Models.InventoryModel;
namespace PharmAssistent.Models.InventoryModel
{
[Table("DrugGenericName")]
public class DrugGenericName
{
public int ID { get; set; }
[Required]
[StringLength(50, ErrorMessage="Maximum limit exceeded")]
public string GenericName { get; set; }
public string Description { get; set; }
}
}
ITEM MODEL
using PharmAssistent.Models.PurchaseModel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace PharmAssistent.Models.InventoryModel
{
BS (SE)-5B
15 January 2023
[Table("Item")]
public class Item
{
[Key]
[Display(Name = "Item No")]
public int ID { get; set; }
[Required]
[Display(Name="Item")]
public string Name { get; set; }
[Required]
[Display(Name="Generic Name")]
public int? DrugGenericNameID { get; set; }
[Required]
[Display(Name = "Manufacturer")]
public int? ManufacturerID { get; set; }
[Required]
[Display(Name = "Categeory")]
public string Categeory { get; set; }
//reference entity
public virtual DrugGenericName DrugGenericName { get; set; }
public virtual Manufacturer Manufacturer { get; set; }
//public virtual ICollection<Stock> Stocks { get; set; }
// COMENT public virtual ICollection<PurchaseItem> PurchaseItems { get; set;
}
}
public enum Categeory
{
Drug,
Supplies,
other
}
BS (SE)-5B
15 January 2023
MANUFACTURE MODEL
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PharmAssistent.Models.PurchaseModel;
namespace PharmAssistent.Models.InventoryModel
{
[Table("Manufacturer")]
public class Manufacturer
{
public int ID { get; set; }
[Required]
[StringLength(50, ErrorMessage="Too lengthy")]
public String ManufacturerName { get; set; }
public string Description { get; set; }
}
}
STOCK MODEL
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using PharmAssistent.Models.PurchaseModel;
using System.ComponentModel.DataAnnotations.Schema;
namespace PharmAssistent.Models.InventoryModel
{
[Table("Stock")]
public class Stock
{
public Stock()
{
Stop_Notification = true;
//ItemExpired = false;
}
[Key]
public int ID { get; set; }
[Required]
public int ItemID { get; set; }
BS (SE)-5B
15 January 2023
[Range(0, 9999999)]
public int Qty { get; set; }
//[Required]
//[Range(0, 100000)]
//public int Qty { get; set; }
[Required]
[Range(0, 1000000, ErrorMessage = "Out of range!")]
public decimal CostPrice { get; set; }
[Required]
[Range(0, 1000000, ErrorMessage = "Out of range!")]
public decimal SellingPrice { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode =
true)]
public DateTime? ManufactureDate { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode =
true)]
public DateTime? Expiry { get; set; }
[NotMapped]
public bool ItemExpired { get; set; }
[NotMapped]
public bool Stop_Notification { get; set; }
//references
public virtual Item Item { get; set; }
}
}
VIEWS
PURCHASE ENTRY VIEW MODEL
using PharmAssistent.Models;
using PharmAssistent.Models.PurchaseModel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace PharmAssistent.ViewModel
{
BS (SE)-5B
15 January 2023
// [Table("Purchase")]
public class PurchaseEntryVM
{
// PharmContext db = new PharmContext();
[Key]
public int ID { get; set; }
public string PurchaseID { get; set; }
public DateTime Date { get; set; }
public int SupplierID { get; set; }
public decimal Amount { get; set; }
public decimal? Discount { get; set; }
public decimal? Tax { get; set; }
public decimal GrandTotal { get; set; }
public bool IsPaid { get; set; }
public string Description { get; set; }
public DateTime LastUpdated { get; set; }
}
}
BS (SE)-5B