public void Dispose() { if (systemHandler != null) { systemHandler.Dispose(); systemHandler = null; } if (customerHandler != null) { customerHandler.Dispose(); customerHandler = null; } if (supplierHandler != null) { supplierHandler.Dispose(); supplierHandler = null; } if (salesmanHandler != null) { salesmanHandler.Dispose(); salesmanHandler = null; } if (otherContactHandler != null) { otherContactHandler.Dispose(); otherContactHandler = null; } }
public IHttpActionResult GetSuppliers() { Dictionary <int, Supplier> Suppliers = SupplierHandler.GetAllSupplier(db); if (Suppliers.Count == 0) { return(NotFound()); } return(Ok(Suppliers)); }
public AddPurchaseDialog() { // Set up variables and properties prior to initialization _purchaseHandler = new PurchaseHandler(); Purchase = new Purchase(); SupplierSource = new SupplierHandler().GetSuppliers(); ItemSource = new ProductHandler().GetItems(); InitializeComponent(); Logger.Info("AddPurchaseDialog Loaded successfully"); }
public SupplierDuePurchasesWindow(Supplier supplier) { _purchaseHandler = new PurchaseHandler(); var supplierHandler = new SupplierHandler(); if (string.IsNullOrEmpty(supplier.Name)) { supplier = supplierHandler.GetSuppliers(supplier.Id).SingleOrDefault(); } if (supplier == null) { throw new ArgumentNullException(nameof(supplier), @"Supplier Id is null"); } DuePurchases = _purchaseHandler.GetPurchases(supplier.Id, false); InitializeComponent(); SupplierIdTextBox.Text = supplier.Id.ToString(); NameTextBox.Text = supplier.Name; }
/// <summary> /// Event handlers SETUP /// </summary> /// <param name="EntityID"></param> /// <param name="EventHandler"></param> public void SetExtenderEventHandler(string EntityID, ExtenderEvents EventHandler) { switch (EntityID.ToLower()) { case "customer": //Clientes if (customerHandler == null) { customerHandler = new CustomerHandler(); customerHandler.SetEventHandler(EventHandler); } break; case "supplier": //Fornecedores if (supplierHandler == null) { supplierHandler = new SupplierHandler(); } supplierHandler.SetEventHandler(EventHandler); break; case "salesman": //Vendedores if (salesmanHandler == null) { salesmanHandler = new SalesmanHandler(); } salesmanHandler.SetEventHandler(EventHandler); break; case "othercontact": //Vendedores if (otherContactHandler == null) { otherContactHandler = new OtherContactHandler(); } otherContactHandler.SetEventHandler(EventHandler); break; } }
public ActionResult Edit(int productId) { #region Prep Utilities AddNewBookViewModel model = new AddNewBookViewModel(); model.model_ID = new Guid("11111111-1111-1111-1111-111111111111").ToString(); #endregion myHandler = new BusinessLogicHandler(); Book book = myHandler.GetBook(productId); IEnumerable<BookAuthor> bookAuthorList = myHandler.GetBookAuthors(book.BookID); model.books = new Book(); model.books = book; #region Create SupplierHandler supHandler = new SupplierHandler(); /*TEMP LIST*/ //List<Supplier> nameList = new List<Supplier>(); IEnumerable<Supplier> nameList = (IEnumerable<Supplier>)supHandler.GetBookSupplierList(); var disp = from nameAndId in nameList select new { Value = nameAndId.SupplierID, Text = nameAndId.Name }; ViewBag.SupplierList = new SelectList(disp.ToList()); BookCategoryHandler typeHandler = new BookCategoryHandler(); IEnumerable<BookCategory> typeList = (IEnumerable<BookCategory>)typeHandler.GetBookCategoryList(); var dispBC = from name in typeList select new { Value = name.BookCategoryID, Text = name.CategoryName }; ViewBag.BookCategoryList = new SelectList(dispBC.ToList()); AuthorHandler authHandler = new AuthorHandler(); IEnumerable<Author> authList = (IEnumerable<Author>)authHandler.GetAuthorList(); var dispAuth = from nameAndSurname in authList select new { Value = nameAndSurname.AuthorID, Text = nameAndSurname.Name, nameAndSurname.Surname }; ViewBag.authList = new SelectList(dispAuth.ToList()); PublisherHandler publHandler = new PublisherHandler(); IEnumerable<Publisher> pubList = (IEnumerable<Publisher>)publHandler.GetPublisherList(); var dispPublisher = from pubName in pubList select new { Value = pubName.PublisherID, Text = pubName.Name }; ViewBag.pubList = new SelectList(dispPublisher.ToList()); #endregion Supplier sp = new Supplier(); Author ath = new Author(); BookCategory bkc = new BookCategory(); Publisher pb = new Publisher(); foreach (var item in nameList) { if (item.SupplierID == model.books.SupplierID) { sp.SupplierID = item.SupplierID; sp.Name = item.Name; } } int[] authors = new int[bookAuthorList.Count()]; int x = 0; foreach (var item in bookAuthorList) { if (item.BookID == model.books.BookID) { authors[x] = item.AuthorID; x++; } } foreach (var item in pubList) { if (item.PublisherID == model.books.PublisherID) { pb.PublisherID = item.PublisherID; pb.Name = item.Name; } } foreach (var item in typeList) { if (item.BookCategoryID == model.books.BookCategoryID) { bkc.BookCategoryID = item.BookCategoryID; bkc.CategoryName = item.CategoryName; } } #region Display List<SelectListItem> publisher = new List<SelectListItem>(); publisher.Add(new SelectListItem { Value = pb.PublisherID.ToString(), Text = pb.Name, Selected = true }); foreach (var item in pubList) { if (item.PublisherID != pb.PublisherID) publisher.Add(new SelectListItem { Text = item.Name, Value = item.PublisherID.ToString() }); } model.publishers = new List<SelectListItem>(); model.publishers = publisher; ViewData["publishers"] = publisher; List<SelectListItem> bookCategory = new List<SelectListItem>(); bookCategory.Add(new SelectListItem { Value = bkc.BookCategoryID.ToString(), Text = bkc.CategoryName, Selected = true }); foreach (var item in typeList) { if (item.BookCategoryID != bkc.BookCategoryID) bookCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.BookCategoryID.ToString() }); } model.bookCategories = new List<SelectListItem>(); model.bookCategories = bookCategory; ViewData["bookCategories"] = bookCategory; List<SelectListItem> supplier = new List<SelectListItem>(); supplier.Add(new SelectListItem { Value = sp.SupplierID.ToString(), Text = sp.Name, Selected = true }); foreach (var item in nameList) { if (item.SupplierID != sp.SupplierID) supplier.Add(new SelectListItem { Text = item.Name, Value = item.SupplierID.ToString() }); } model.suppliers = new List<SelectListItem>(); model.suppliers = supplier; ViewData["suppliers"] = supplier; List<SelectListItem> author = new List<SelectListItem>(); foreach (var item in authList) { if (authors.Contains(item.AuthorID)) { author.Add(new SelectListItem { Text = item.Name, Value = item.AuthorID.ToString(), Selected = true }); } else { author.Add(new SelectListItem { Text = item.Name, Value = item.AuthorID.ToString() }); } } model.authors = new List<SelectListItem>(); model.authors = author; ViewData["authors"] = author; #endregion return View(model); }
public ActionResult Create(FormCollection collection, HttpPostedFileBase file) { try { myHandler = new BusinessLogicHandler(); book = new Book(); book.BookTitle = collection.GetValue("books.BookTitle").AttemptedValue.ToString(); book.Synopsis = collection.GetValue("books.Synopsis").AttemptedValue.ToString(); book.ISBN = collection.GetValue("books.ISBN").AttemptedValue.ToString(); book.BookCategoryID = Convert.ToInt32(collection.GetValue("CategoryName").AttemptedValue); book.PublisherID = Convert.ToInt32(collection.GetValue("PublisherName").AttemptedValue); book.SupplierID = Convert.ToInt32(collection.GetValue("Name").AttemptedValue); //book.AuthorID = Convert.ToInt32(collection.GetValue("FullName").AttemptedValue); string[] Authors = (string[])collection.GetValue("FullName").RawValue; book.CostPrice = Convert.ToDouble(collection.GetValue("books.CostPrice").AttemptedValue); book.SellingPrice = Convert.ToDouble(collection.GetValue("books.SellingPrice").AttemptedValue); book.DateAdded = DateTime.Now; //TryUpdateModel(book); //CONSIDER REMOVING THIS..! if (ModelState.IsValid) { if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Uploads/Books/") + file.FileName); book.CoverImage = file.FileName; } Book ba = new Book(); BookAuthor bookAuthors = new BookAuthor(); ba = myHandler.AddExperimentBook(book); ba.BookTitle = book.BookTitle; ba.Synopsis = book.Synopsis; ba.ISBN = book.ISBN; ba.BookCategoryID = book.BookCategoryID; ba.PublisherID = book.PublisherID; ba.SupplierID = book.SupplierID; ba.CoverImage = book.CoverImage; //myHandler.AddBook(ba); bookAuthors = myHandler.TrialInsertBook(ba); foreach (var item in Authors) //INSERTING BOOK AUTHORS { bookAuthors.AuthorID = Convert.ToInt32(item); myHandler.InsertBookAuthor(bookAuthors); } TempData["AlertMessage"] = "Book Successfully Entered"; } //return RedirectToAction("Index", "Book", book); return RedirectToAction("Create", "Book", null); //REDIRECT TO GET ACTION METHOD #INCASE THEY WANT TO INSERT ANOTHER BOOK :) } catch { AddNewBookViewModel model = new AddNewBookViewModel(); #region Create SupplierHandler supHandler = new SupplierHandler(); /*TEMP LIST*/ //List<Supplier> nameList = new List<Supplier>(); IEnumerable<Supplier> nameList = (IEnumerable<Supplier>)supHandler.GetBookSupplierList(); var disp = from nameAndId in nameList select new { Value = nameAndId.SupplierID, Text = nameAndId.Name }; ViewBag.SupplierList = new SelectList(disp.ToList()); BookCategoryHandler typeHandler = new BookCategoryHandler(); IEnumerable<BookCategory> typeList = (IEnumerable<BookCategory>)typeHandler.GetBookCategoryList(); var dispBC = from name in typeList select new { Value = name.BookCategoryID, Text = name.CategoryName }; ViewBag.BookCategoryList = new SelectList(dispBC.ToList()); AuthorHandler authHandler = new AuthorHandler(); IEnumerable<Author> authList = (IEnumerable<Author>)authHandler.GetAuthorList(); var dispAuth = from nameAndSurname in authList select new { Value = nameAndSurname.AuthorID, Text = nameAndSurname.Name, nameAndSurname.Surname }; ViewBag.authList = new SelectList(dispAuth.ToList()); PublisherHandler publHandler = new PublisherHandler(); IEnumerable<Publisher> pubList = (IEnumerable<Publisher>)publHandler.GetPublisherList(); var dispPublisher = from pubName in pubList select new { Value = pubName.PublisherID, Text = pubName.Name }; ViewBag.pubList = new SelectList(dispPublisher.ToList()); #endregion #region Display List<SelectListItem> bookCategory = new List<SelectListItem>(); //bookCategory.Add(new SelectListItem { Text = "Select Category", Value = "", Selected = true }); foreach (var item in typeList) { bookCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.BookCategoryID.ToString() }); } model.bookCategories = new List<SelectListItem>(); model.bookCategories = bookCategory; ViewData["bookCategories"] = bookCategory; List<SelectListItem> supplier = new List<SelectListItem>(); //supplier.Add(new SelectListItem { Text = "Select Supplier", Value = "", Selected = true }); foreach (var item in nameList) { supplier.Add(new SelectListItem { Text = item.Name, Value = item.SupplierID.ToString() }); } model.suppliers = new List<SelectListItem>(); model.suppliers = supplier; ViewData["suppliers"] = supplier; List<SelectListItem> author = new List<SelectListItem>(); //author.Add(new SelectListItem { Text = "Select Author", Value = "", Selected = true }); foreach (var item in authList) { author.Add(new SelectListItem { Text = item.Name, Value = item.AuthorID.ToString() }); } model.authors = new List<SelectListItem>(); model.authors = author; ViewData["authors"] = author; List<SelectListItem> publisher = new List<SelectListItem>(); //publisher.Add(new SelectListItem { Text = "Select Publisher", Value = "", Selected = true }); foreach (var item in pubList) { publisher.Add(new SelectListItem { Text = item.Name, Value = item.PublisherID.ToString() }); } model.publishers = new List<SelectListItem>(); model.publishers = publisher; ViewData["publishers"] = publisher; #endregion return View(model); } }
public ActionResult Create() { #region Create AddNewBookViewModel bookM = new AddNewBookViewModel(); SupplierHandler supHandler = new SupplierHandler(); /*TEMP LIST*/ //List<Supplier> nameList = new List<Supplier>(); IEnumerable<Supplier> nameList = (IEnumerable<Supplier>)supHandler.GetBookSupplierList(); var disp = from nameAndId in nameList select new { Value = nameAndId.SupplierID, Text = nameAndId.Name }; ViewBag.SupplierList = new SelectList(disp.ToList()); BookCategoryHandler typeHandler = new BookCategoryHandler(); IEnumerable<BookCategory> typeList = (IEnumerable<BookCategory>)typeHandler.GetBookCategoryList(); var dispBC = from name in typeList select new { Value = name.BookCategoryID, Text = name.CategoryName }; ViewBag.BookCategoryList = new SelectList(dispBC.ToList()); AuthorHandler authHandler = new AuthorHandler(); IEnumerable<Author> authList = (IEnumerable<Author>)authHandler.GetAuthorList(); var dispAuth = from nameAndSurname in authList select new { Value = nameAndSurname.AuthorID, Text = nameAndSurname.Name, nameAndSurname.Surname }; ViewBag.authList = new SelectList(dispAuth.ToList()); PublisherHandler publHandler = new PublisherHandler(); IEnumerable<Publisher> pubList = (IEnumerable<Publisher>)publHandler.GetPublisherList(); var dispPublisher = from pubName in pubList select new { Value = pubName.PublisherID, Text = pubName.Name }; ViewBag.pubList = new SelectList(dispPublisher.ToList()); #endregion #region Display List<SelectListItem> bookCategory = new List<SelectListItem>(); //bookCategory.Add(new SelectListItem { Text = "Select Category", Value = "", Selected = true }); foreach (var item in typeList) { bookCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.BookCategoryID.ToString() }); } bookM.bookCategories = new List<SelectListItem>(); bookM.bookCategories = bookCategory; ViewData["bookCategories"] = bookCategory; List<SelectListItem> supplier = new List<SelectListItem>(); //supplier.Add(new SelectListItem { Text = "Select Supplier", Value = "", Selected = true }); foreach (var item in nameList) { supplier.Add(new SelectListItem { Text = item.Name, Value = item.SupplierID.ToString() }); } bookM.suppliers = new List<SelectListItem>(); bookM.suppliers = supplier; ViewData["suppliers"] = supplier; List<SelectListItem> author = new List<SelectListItem>(); //author.Add(new SelectListItem { Text = "Select Author", Value = "", Selected = true }); foreach (var item in authList) { author.Add(new SelectListItem { Text = item.Name, Value = item.AuthorID.ToString() }); } bookM.authors = new List<SelectListItem>(); bookM.authors = author; ViewData["authors"] = author; List<SelectListItem> publisher = new List<SelectListItem>(); //publisher.Add(new SelectListItem { Text = "Select Publisher", Value = "", Selected = true }); foreach (var item in pubList) { publisher.Add(new SelectListItem { Text = item.Name, Value = item.PublisherID.ToString() }); } bookM.publishers = new List<SelectListItem>(); bookM.publishers = publisher; ViewData["publishers"] = publisher; #endregion return View(bookM); }
public GetSuppliersCommand(HashSet <Order> orders) { this.orders = orders; supplierHandler = new SupplierHandler(); }
public ActionResult Edit(int ProductID) { AddNewTechViewModel model = new AddNewTechViewModel(); myHandler = new BusinessLogicHandler(); gadget = new Technology(); gadget = myHandler.GetTechnologyDetails(ProductID); model.techs = new Technology(); model.techs = gadget; SupplierHandler supHandler = new SupplierHandler(); /*TEMP LIST*/ //List<Supplier> nameList = new List<Supplier>(); IEnumerable<Supplier> nameList = (IEnumerable<Supplier>)supHandler.GetTechSupplierList(); var disp = from nameAndId in nameList select new { Value = nameAndId.SupplierID, Text = nameAndId.Name }; ViewBag.SupplierList = new SelectList(disp.ToList()); TechCategoryHandler typeHandler = new TechCategoryHandler(); IEnumerable<TechCategory> typeList = (IEnumerable<TechCategory>)typeHandler.GetTechCategoryList(); var dispTC = from name in typeList select new { Value = name.TechCategoryID, Text = name.CategoryName }; ViewBag.TechCategoryList = new SelectList(dispTC.ToList()); ManufacturerHandler manHandler = new ManufacturerHandler(); IEnumerable<Manufacturer> manList = (IEnumerable<Manufacturer>)manHandler.GetManufacturerList(); var dispM = from mName in manList select new { Value = mName.ManufacturerID, Text = mName.Name }; ViewBag.ManufacturerList = new SelectList(dispM.ToList()); model.techs = myHandler.GetTechnologyDetails(ProductID); Supplier sp = new Supplier(); TechCategory tck = new TechCategory(); Manufacturer mna = new Manufacturer(); foreach (var item in manList) { if (item.ManufacturerID == model.techs.ManufacturerID) { mna.ManufacturerID = item.ManufacturerID; mna.Name = item.Name; } } foreach (var item in nameList) { if (item.SupplierID == model.techs.SupplierID) { sp.SupplierID = item.SupplierID; sp.Name = item.Name; } } foreach (var item in typeList) { if (item.TechCategoryID == model.techs.TechCategoryID) { tck.TechCategoryID = item.TechCategoryID; tck.CategoryName = item.CategoryName; } } List<SelectListItem> supplier = new List<SelectListItem>(); supplier.Add(new SelectListItem { Value = sp.SupplierID.ToString(), Text = sp.Name, Selected = true }); foreach (var item in nameList) { if (item.SupplierID != sp.SupplierID) supplier.Add(new SelectListItem { Text = item.Name, Value = item.SupplierID.ToString() }); } model.suppliers = new List<SelectListItem>(); model.suppliers = supplier; ViewData["suppliers"] = supplier; List<SelectListItem> techCategory = new List<SelectListItem>(); techCategory.Add(new SelectListItem { Value = tck.TechCategoryID.ToString(), Text = tck.CategoryName, Selected = true }); foreach (var item in typeList) { if (item.TechCategoryID != tck.TechCategoryID) techCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.TechCategoryID.ToString() }); } model.techCategories = new List<SelectListItem>(); model.techCategories = techCategory; ViewData["techCategories"] = techCategory; List<SelectListItem> manufacturer = new List<SelectListItem>(); manufacturer.Add(new SelectListItem { Value = mna.ManufacturerID.ToString(), Text = mna.Name, Selected = true }); foreach (var item in manList) { if (item.ManufacturerID != mna.ManufacturerID) manufacturer.Add(new SelectListItem { Text = item.Name, Value = item.ManufacturerID.ToString() }); } model.manufacturers = new List<SelectListItem>(); model.manufacturers = manufacturer; ViewData["manufacturers"] = manufacturer; return View(model); }
public ActionResult Create(FormCollection collection, HttpPostedFileBase file1, HttpPostedFileBase file2, HttpPostedFileBase file3) { try { myHandler = new BusinessLogicHandler(); gadget = new Technology(); Company c = new Company(); gadget.DateAdded = DateTime.Now; gadget.ModelName = collection.GetValue("techs.ModelName").AttemptedValue.ToString(); gadget.Specs = collection.GetValue("techs.Specs").AttemptedValue.ToString(); gadget.ModelNumber = collection.GetValue("techs.ModelNumber").AttemptedValue.ToString(); gadget.ManufacturerID = Convert.ToInt32(collection.GetValue("Manufacturer").AttemptedValue); gadget.TechCategoryID = Convert.ToInt32(collection.GetValue("CategoryName").AttemptedValue); gadget.SupplierID = Convert.ToInt32(collection.GetValue("Name").AttemptedValue); gadget.CostPrice = Convert.ToDouble(collection.GetValue("techs.CostPrice").AttemptedValue); gadget.SellingPrice = Convert.ToDouble(collection.GetValue("techs.SellingPrice").AttemptedValue); gadget.IsBook = false; if (ModelState.IsValid) { if (file1 != null) { file1.SaveAs(HttpContext.Server.MapPath("~/Uploads/Tech/") + file1.FileName); gadget.ImageFront = file1.FileName; } if (file2 != null) { file2.SaveAs(HttpContext.Server.MapPath("~/Uploads/Tech/") + file2.FileName); gadget.ImageTop = file2.FileName; } if (file3 != null) { file3.SaveAs(HttpContext.Server.MapPath("~/Uploads/Tech/") + file3.FileName); gadget.ImageSide = file3.FileName; } Technology ta = new Technology(); ta = myHandler.AddExperimentTech(gadget); ta.ModelName = gadget.ModelName; ta.ModelNumber = gadget.ModelNumber; ta.Specs = gadget.Specs; ta.ManufacturerID = gadget.ManufacturerID; ta.TechCategoryID = gadget.TechCategoryID; ta.SupplierID = gadget.SupplierID; //ta.CostPrice = gadget.CostPrice; //ta.SellingPrice = gadget.SellingPrice; //ta.IsBook = gadget.IsBook; ta.ImageFront = gadget.ImageFront; ta.ImageTop = gadget.ImageTop; ta.ImageSide = gadget.ImageSide; myHandler.AddTechnology(ta); TempData["AlertMessage"] = "Device Successfully Added"; } return RedirectToAction("Create", "Technology", gadget); } catch { AddNewTechViewModel techM = new AddNewTechViewModel(); /*TEMP LIST*/ //List<Supplier> nameList = new List<Supplier>(); SupplierHandler supHandler = new SupplierHandler(); IEnumerable<Supplier> nameList = (IEnumerable<Supplier>)supHandler.GetTechSupplierList(); var disp = from nameAndId in nameList select new { Value = nameAndId.SupplierID, Text = nameAndId.Name }; ViewBag.SupplierList = new SelectList(disp.ToList()); TechCategoryHandler typeHandler = new TechCategoryHandler(); IEnumerable<TechCategory> typeList = (IEnumerable<TechCategory>)typeHandler.GetTechCategoryList(); var dispTC = from name in typeList select new { Value = name.TechCategoryID, Text = name.CategoryName }; ViewBag.TechCategoryList = new SelectList(dispTC.ToList()); ManufacturerHandler manHandler = new ManufacturerHandler(); IEnumerable<Manufacturer> manList = (IEnumerable<Manufacturer>)manHandler.GetManufacturerList(); var dispM = from mName in manList select new { Value = mName.ManufacturerID, Text = mName.Name }; ViewBag.ManufacturerList = new SelectList(dispM.ToList()); List<SelectListItem> supplier = new List<SelectListItem>(); //supplier.Add(new SelectListItem { Text = "Select Supplier", Value = "", Selected = true }); foreach (var item in nameList) { supplier.Add(new SelectListItem { Text = item.Name, Value = item.SupplierID.ToString() }); } techM.suppliers = new List<SelectListItem>(); techM.suppliers = supplier; ViewData["suppliers"] = supplier; List<SelectListItem> techCategory = new List<SelectListItem>(); //techCategory.Add(new SelectListItem { Text = "Select Category", Value = "", Selected = true }); foreach (var item in typeList) { techCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.TechCategoryID.ToString(), Selected = true }); } techM.techCategories = new List<SelectListItem>(); techM.techCategories = techCategory; ViewData["techCategories"] = techCategory; List<SelectListItem> manufacturer = new List<SelectListItem>(); //manufacturer.Add(new SelectListItem { Text = "Select Manufacturer", Value = "", Selected = true }); foreach (var item in manList) { manufacturer.Add(new SelectListItem { Text = item.Name, Value = item.ManufacturerID.ToString() }); } techM.manufacturers = new List<SelectListItem>(); techM.manufacturers = manufacturer; ViewData["manufacturers"] = manufacturer; return View(techM); } }
public ActionResult Create() { AddNewTechViewModel techM = new AddNewTechViewModel(); /*TEMP LIST*/ //List<Supplier> nameList = new List<Supplier>(); SupplierHandler supHandler = new SupplierHandler(); IEnumerable<Supplier> nameList = (IEnumerable<Supplier>)supHandler.GetTechSupplierList(); var disp = from nameAndId in nameList select new { Value = nameAndId.SupplierID, Text = nameAndId.Name }; ViewBag.SupplierList = new SelectList(disp.ToList()); TechCategoryHandler typeHandler = new TechCategoryHandler(); IEnumerable<TechCategory> typeList = (IEnumerable<TechCategory>)typeHandler.GetTechCategoryList(); var dispTC = from name in typeList select new { Value = name.TechCategoryID, Text = name.CategoryName }; ViewBag.TechCategoryList = new SelectList(dispTC.ToList()); ManufacturerHandler manHandler = new ManufacturerHandler(); IEnumerable<Manufacturer> manList = (IEnumerable<Manufacturer>)manHandler.GetManufacturerList(); var dispM = from mName in manList select new { Value = mName.ManufacturerID, Text = mName.Name }; ViewBag.ManufacturerList = new SelectList(dispM.ToList()); List<SelectListItem> supplier = new List<SelectListItem>(); //supplier.Add(new SelectListItem { Text = "Select Supplier", Value = "", Selected = true }); foreach (var item in nameList) { supplier.Add(new SelectListItem { Text = item.Name, Value = item.SupplierID.ToString() }); } techM.suppliers = new List<SelectListItem>(); techM.suppliers = supplier; ViewData["suppliers"] = supplier; List<SelectListItem> techCategory = new List<SelectListItem>(); //techCategory.Add(new SelectListItem { Text = "Select Category", Value = "", Selected = true }); foreach (var item in typeList) { techCategory.Add(new SelectListItem { Text = item.CategoryName, Value = item.TechCategoryID.ToString(), Selected = true }); } techM.techCategories = new List<SelectListItem>(); techM.techCategories = techCategory; ViewData["techCategories"] = techCategory; List<SelectListItem> manufacturer = new List<SelectListItem>(); //manufacturer.Add(new SelectListItem { Text = "Select Manufacturer", Value = "", Selected = true }); foreach (var item in manList) { manufacturer.Add(new SelectListItem { Text = item.Name, Value = item.ManufacturerID.ToString() }); } techM.manufacturers = new List<SelectListItem>(); techM.manufacturers = manufacturer; ViewData["manufacturers"] = manufacturer; return View(techM); }
public SupplierWindow() { _supplierHandler = new SupplierHandler(); SupplierSource = _supplierHandler.GetSuppliers(); InitializeComponent(); }