/// <summary> /// /// </summary> /// <returns></returns> public static List <SelectListItem> ListOfCategories(bool allowSelectAll = true) { List <SelectListItem> listCategory = new List <SelectListItem>(); if (allowSelectAll) { listCategory.Add(new SelectListItem() { Value = "", Text = "--- All Category ---" }); } foreach (var item in CatalogBLL.Category_List("")) { listCategory.Add(new SelectListItem() { Value = Convert.ToString(item.CategoryID), Text = item.CategoryName }); } return(listCategory); }
/// <summary> /// select list cac attributes /// </summary> /// <param name="productID"></param> /// <returns></returns> public static List <ProductAttribute> Attributes(int productID) { if (productID > 0) { return(CatalogBLL.GetProductAttributes(productID)); } else { List <ProductAttribute> list = new List <ProductAttribute>(); List <DomainModels.Attribute> atts = CatalogBLL.GetAttributes(); foreach (DomainModels.Attribute att in atts) { list.Add(new ProductAttribute() { AttributeID = att.AttributeID, AttributeName = att.AttributeName, AttributeValues = "", DisplayOrder = 1, ProductID = 0 }); } return(list); } }
/// <summary> /// /// </summary> /// <returns></returns> public static List <SelectListItem> ListOfCountries(bool allowSelectAll = true) { List <SelectListItem> listCountries = new List <SelectListItem>(); if (allowSelectAll) { listCountries.Add(new SelectListItem() { Value = "", Text = "--- All Country ---" }); } foreach (var item in CatalogBLL.Country_List()) { listCountries.Add(new SelectListItem() { Value = item.Country, Text = item.Country }); } return(listCountries); }
/// <summary> /// /// </summary> /// <param name="allowSelectAll"></param> /// <returns></returns> public static List <SelectListItem> ListOfCustomer(bool allowSelectAll = true) { List <SelectListItem> listCustomer = new List <SelectListItem>(); if (allowSelectAll) { listCustomer.Add(new SelectListItem() { Value = "", Text = "--- All Customer ---" }); } foreach (var item in CatalogBLL.Customer_ListNoPagination()) { listCustomer.Add(new SelectListItem() { Value = Convert.ToString(item.CustomerID), Text = item.CompanyName }); } return(listCustomer); }
public ActionResult ajaxAttribute(string id = "") { try { Product checkProduct = CatalogBLL.Product_Get(id); if (checkProduct == null) { return(RedirectToAction("Index")); } var model = new Models.AttributeResult { Data = CatalogBLL.Product_GetAttribute(id), }; return(Json(new { model.Data }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(RedirectToAction("Index")); } }
public static List <SelectListItem> ListOfProduct(bool allowSelectAll = true) { List <SelectListItem> listProduct = new List <SelectListItem>(); if (allowSelectAll) { listProduct.Add(new SelectListItem() { Value = "", Text = "--- All Products ---" }); } foreach (var item in CatalogBLL.Product_GetAll()) { listProduct.Add(new SelectListItem() { Value = Convert.ToString(item.ProductID), Text = item.ProductName }); } return(listProduct); }
public ActionResult Input(string id = "") { if (string.IsNullOrEmpty(id)) { ViewBag.Title = "Add new category"; Category newCategory = new Category(); newCategory.CategoryID = 0; return(View(newCategory)); } else { ViewBag.Title = "Edit category"; Category editCategory = CatalogBLL.Category_Get(Convert.ToInt32(id)); if (editCategory == null) { return(RedirectToAction("Index")); } return(View(editCategory)); } }
public ActionResult Input(string id = "") { if (string.IsNullOrEmpty(id)) { ViewBag.Title = "Add New Shipper"; Shipper newShipper = new Shipper(); newShipper.ShipperID = 0; return(View(newShipper)); } else { ViewBag.Title = "Edit Shipper"; Shipper editShipper = CatalogBLL.Shipper_Get(Convert.ToInt32(id)); if (editShipper == null) { return(RedirectToAction("index")); } return(View(editShipper)); } }
/// <summary> /// View page: List of products /// </summary> /// <param name="page"></param> /// <param name="searchValue"></param> /// <param name="category"></param> /// <param name="supplier"></param> /// <returns></returns> public IActionResult Index(int page = 1, string searchValue = "", string category = "", string supplier = "") { int rowCount = 0; int pageSize = 10; List <Product> listOfProduct = CatalogBLL.ListOfProduct(page, pageSize, searchValue ?? "", out rowCount, category, supplier); var model = new Models.ProductPaginationResult() { Page = page, Data = listOfProduct, PageSize = pageSize, RowCount = rowCount, SearchValue = searchValue, SelectedCategory = category, SelectedSupplier = supplier, }; return(View(model)); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Detail(string id = "") { if (!String.IsNullOrEmpty(id)) { Order data = CatalogBLL.GetOrder(Convert.ToInt32(id)); if (data == null) { return(RedirectToAction("Index", "Order")); } else { ViewData["OrderDetail"] = CatalogBLL.OrderDetails_List(data.OrderID); return(View(data)); } } else { return(RedirectToAction("Index", "Order")); } }
public ActionResult Input(string id = "") { if (string.IsNullOrEmpty(id)) { ViewBag.Title = "Add Customer"; Customer newCustomer = new Customer(); newCustomer.CustomerID = null; return(View(newCustomer)); } else { Customer editCustomer = CatalogBLL.GetCustomer(id); if (editCustomer == null) { return(RedirectToAction("Index")); } ViewBag.Title = "Edit Customer"; return(View(editCustomer)); } }
public ActionResult Input(Product data, HttpPostedFileBase file = null) { if (data.Descriptions == null) { data.Descriptions = ""; } if (file != null) { string get = DateTime.Now.ToString("ddMMyyyhhmmss"); string fileExtension = Path.GetExtension(file.FileName); string fileName = get + fileExtension; string path = Path.Combine(Server.MapPath("~/Images"), fileName); data.PhotoPath = fileName; file.SaveAs(path); } if (data.ProductID == 0) { if (file == null) { TempData["emptyFile"] = "Vui lòng chọn file"; return(RedirectToAction("Input")); } else { int productID = CatalogBLL.Product_Add(data); //return Content( productID.ToString()); TempData["productID"] = productID; return(RedirectToAction("AddProductAttribute")); } } else { var getProduct = CatalogBLL.GetProduct(data.ProductID); if (file == null) { data.PhotoPath = getProduct.PhotoPath; } bool updateProduct = CatalogBLL.Product_Update(data); return(RedirectToAction("Index")); } }
public ActionResult InputDetail(ProductAttributes model) { try { //kiem tra tinh hop le if (string.IsNullOrEmpty(model.AttributeName)) { ModelState.AddModelError("AttributeName", "AttributeName is required"); } if (string.IsNullOrEmpty(model.AttributeValues)) { ModelState.AddModelError("AttributeValues", "AttributeValues is required"); } if (model.DisplayOrder == 0) { ModelState.AddModelError("DisplayOrder", "DisplayOrder is required"); } if (!ModelState.IsValid) { return(View(model)); } if (model.AttributeID == 0) { int attributeId = CatalogBLL.ProductAttribute_Add(model); return(RedirectToAction("Index")); } else { bool updateResult = CatalogBLL.ProductAttribute_Update(model); return(RedirectToAction("Input", "Product", new { id = model.ProductID })); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message + ":" + ex.StackTrace); return(View(model)); } }
public static List <SelectListItem> Shippers(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = " --- All Shippers---" }); } foreach (var i in CatalogBLL.ListOfShippers(1, -1, "")) { list.Add(new SelectListItem() { Value = Convert.ToString(i.ShipperID), Text = i.CompanyName }); } return(list); }
public static List <SelectListItem> Customer(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "", Text = " --- All Customer---" }); } foreach (var i in CatalogBLL.ListOfCustomers(1, -1, "", "")) { list.Add(new SelectListItem() { Value = i.CustomerID, Text = i.CompanyName }); } return(list); }
public static List <SelectListItem> Employee(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = " --- All Employees---" }); } foreach (var i in CatalogBLL.ListOfEmployees(1, -1, "")) { list.Add(new SelectListItem() { Value = Convert.ToString(i.EmployeeID), Text = i.FirstName + " " + i.LastName }); } return(list); }
/// <summary> /// Danh sách SelectListItem cho Shipper /// </summary> /// <param name="allowSelectAll"></param> /// <returns></returns> public static List <SelectListItem> Shipper(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = "-- All Shipper --" }); } foreach (var shipper in CatalogBLL.Shipper_List()) { list.Add(new SelectListItem() { Value = shipper.ShipperID.ToString(), Text = shipper.CompanyName }); } return(list); }
/// <summary> /// Danh sách SelectListItem cho Category /// </summary> /// <param name="allowSelectAll"></param> /// <returns>List SelectListItem</returns> public static List <SelectListItem> Category(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = "-- All Category --" }); } foreach (var category in CatalogBLL.Category_CategoryName()) { list.Add(new SelectListItem() { Value = category.CategoryID.ToString(), Text = category.CategoryName }); } return(list); }
public static List <SelectListItem> Product(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = "-- All Products --" }); } foreach (var product in CatalogBLL.Products_List(1, CatalogBLL.Product_Count("", 0, 0), "", 0, 0)) { list.Add(new SelectListItem() { Value = product.ProductID.ToString(), Text = product.ProductName }); } return(list); }
// GET: Category public ActionResult Index(int page = 1, string searchValue = "") { int pageSize = 5; int rowCount = 0; List <Category> listOfCategory = CatalogBLL.ListOfCategories(page, pageSize, searchValue, out rowCount); var model = new Models.CategoryPaginationResult() { Page = page, PageSize = pageSize, RowCount = rowCount, SearchValue = searchValue, Data = listOfCategory }; return(View(model)); //int pageSize = 3; //int rowCount = 0; //List<Supplier> model = CatalogBLL.ListOfSuppliers(page, pageSize, searchValue, out rowCount); //ViewBag.RowCount = rowCount; //return View(model); }
public static List <SelectListItem> Customer(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "", Text = "-- All Customers --" }); } foreach (var customer in CatalogBLL.Customers_List(1, CatalogBLL.Customer_Count(""), "")) { list.Add(new SelectListItem() { Value = customer.CustomerID, Text = customer.CompanyName }); } return(list); }
public ActionResult Attribute(string id = "") { try { Product checkProduct = CatalogBLL.Product_Get(id); if (checkProduct == null) { return(RedirectToAction("Index")); } var model = new Models.AttributeResult { Data = CatalogBLL.Product_GetAttribute(id), ProductID = Convert.ToInt32(id) }; return(View(model)); } catch (Exception e) { return(RedirectToAction("Index")); } }
public static List <SelectListItem> Supplier(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = "-- All Suppliers --" }); } foreach (var supplier in CatalogBLL.Suppliers_List(1, CatalogBLL.Supplier_Count(""), "")) { list.Add(new SelectListItem() { Value = supplier.SupplierID.ToString(), Text = supplier.CompanyName }); } return(list); }
public static List <SelectListItem> Categories(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = "All Category" }); } foreach (var item in CatalogBLL.Category_List(1, CatalogBLL.Category_Count(""), "")) { list.Add(new SelectListItem() { Value = item.CategoryID.ToString(), Text = item.CategoryName, }); } return(list); }
//public static List<SelectListItem> ListOfCountry() { // List<SelectListItem> listCountries = new List<SelectListItem>(); // listCountries.Add(new SelectListItem() { Value = "USA", Text = "United States of America" }); // listCountries.Add(new SelectListItem() { Value = "UK", Text = "England" }); // listCountries.Add(new SelectListItem() { Value = "Japan", Text = "Japan" }); // listCountries.Add(new SelectListItem() { Value = "Australia", Text = "Australia" }); // listCountries.Add(new SelectListItem() { Value = "Sweden", Text = "Sweden" }); // listCountries.Add(new SelectListItem() { Value = "Brazil", Text = "Brazil" }); // listCountries.Add(new SelectListItem() { Value = "Germany", Text = "Germany" }); // listCountries.Add(new SelectListItem() { Value = "Italy", Text = "Italy" }); // listCountries.Add(new SelectListItem() { Value = "Norway", Text = "Norway" }); // listCountries.Add(new SelectListItem() { Value = "France", Text = "France" }); // listCountries.Add(new SelectListItem() { Value = "Singapore", Text = "Singapore" }); // listCountries.Add(new SelectListItem() { Value = "Denmark", Text = "Denmark" }); // listCountries.Add(new SelectListItem() { Value = "Netherlands", Text = "Netherlands" }); // listCountries.Add(new SelectListItem() { Value = "Finland", Text = "Finland" }); // listCountries.Add(new SelectListItem() { Value = "Canada", Text = "Canada" }); // listCountries.Add(new SelectListItem() { Value = "Venezuela", Text = "Venezuela" }); // listCountries.Add(new SelectListItem() { Value = "Belgium", Text = "Belgium" }); // listCountries.Add(new SelectListItem() { Value = "Mexico", Text = "Mexico" }); // listCountries.Add(new SelectListItem() { Value = "Argentina", Text = "Argentina" }); // listCountries.Add(new SelectListItem() { Value = "Switzerland", Text = "Switzerland" }); // listCountries.Add(new SelectListItem() { Value = "Spain", Text = "Spain" }); // listCountries.Add(new SelectListItem() { Value = "Poland", Text = "Poland" }); // listCountries.Add(new SelectListItem() { Value = "Portugal", Text = "Portugal" }); // return listCountries; //} public static List <SelectListItem> Countries(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "", Text = "-- Choose Countries --" }); } foreach (var item in CatalogBLL.Countrie_List("")) { list.Add(new SelectListItem() { Value = item.Country.ToString(), Text = item.Country, }); } return(list); }
/// <summary> /// Danh sách SelectListItem cho Country /// </summary> /// <param name="allowSelectAll"></param> /// <returns>List SelectListItem</returns> public static List <SelectListItem> Country(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "", Text = "-- All Countries --" }); } foreach (var countries in CatalogBLL.Country_List()) { list.Add(new SelectListItem() { Value = countries.CountryName.ToString(), Text = countries.CountryName }); } return(list); }
/// <summary> /// Danh sách SelectListItem cho Customer /// </summary> /// <param name="allowSelectAll"></param> /// <returns></returns> public static List <SelectListItem> Customers(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { list.Add(new SelectListItem() { Value = "0", Text = "-- All Customer Company Name --" }); } foreach (var customer in CatalogBLL.Customer_List()) { list.Add(new SelectListItem() { Value = customer.CustomerID.ToString(), Text = customer.CompanyName }); } return(list); }
public ActionResult Input(Category model) { try { if (string.IsNullOrEmpty(model.Description)) { model.Description = ""; } if (!ModelState.IsValid) { if (model.CategoryID == 0) { ViewBag.Title = "Add New Shipper"; ViewBag.ConfirmButton = "Add"; } else { ViewBag.Title = "Edit New Shipper"; ViewBag.ConfirmButton = "Save"; } return(View(model)); } //Đưa dữ liệu vào CSDL if (model.CategoryID == 0) { int shipperID = CatalogBLL.Category_Add(model); return(RedirectToAction("Index")); } else { bool rs = CatalogBLL.Category_Update(model); return(RedirectToAction("Index")); } } catch (Exception e) { return(View(model)); } }
public ActionResult Input(Countrie model, string method, string country) { if (string.IsNullOrEmpty(model.CountryName)) { ModelState.AddModelError("CountryName", "CountryName Expected"); } if (!ModelState.IsValid) { ViewBag.Title = model.CountryName == "" ? "Create new Country" : "Edit a Country"; return(View(model)); } if (method == "Edit a country") { CatalogBLL.Update(model, country); } else { if (CatalogBLL.Get(model.CountryName) != null) { ModelState.AddModelError("CountryName", "CountryName Existed"); if (!ModelState.IsValid) { ViewBag.Title = model.CountryName == "" ? "Create new Country" : "Edit a Country"; return(View(model)); } } else { CatalogBLL.Add(model); } } return(RedirectToAction("Index")); }
// GET: Suppliers public ActionResult Index(int page = 1, string searchValue = "") { //int pageSize = 3; //int rowCount = 0; //List<Supplier> model = CatalogBLL.ListOfSuppliers(page,pageSize,searchValue, out rowCount); //ViewBag.rowCount = rowCount; //return View(model); int pageSize = 3; int rowCount = 0; List<Supplier> ListOfSupplier = CatalogBLL.ListOfSuppliers(page, pageSize, searchValue, out rowCount); var model = new Models.SupplierPaginationResult() { Page = page, PageSize = pageSize, RowCount = rowCount, SearchValue = searchValue, Data = ListOfSupplier }; return View(model); }