public ActionResult itemCategoryCreate(FormCollection form, HttpPostedFileBase fileUpload) { tbl_product_type tic = new tbl_product_type(); var name = form["name"]; bool err = false; if (String.IsNullOrEmpty(name)) { err = true; ViewData["Error"] += "Vui lòng nhập tên danh mục!\n"; } tic.TenLoaiSP = name; tic.TrangChu = true; tic.Status = true; tic.alias = DataHelper.GeneralHelper.getInstance().getAliasFromProductTypeName(data, name); if (err == false) { data.tbl_product_types.InsertOnSubmit(tic); data.SubmitChanges(); return(RedirectToAction("itemCategoryView")); } else { return(View(URLHelper.URL_ADMIN_ITEM_CATEGORY_M, tic)); } }
public ActionResult ItemCategorySetTrangChuEnable(int id) { tbl_product_type tic = getOneItemCategory(id); tic.TrangChu = !tic.TrangChu; UpdateModel(tic); data.SubmitChanges(); return(RedirectToAction("itemCategoryView")); }
public ActionResult ProductType(string id, int?page, string sorting) { tbl_header hea = db.tbl_headers.SingleOrDefault(n => n.id == 1); Session["title"] = ViewBag.shoptitle; Session["icon"] = hea.shortcuticon; int pageSize = 20; int pageNum = (page ?? 1); var laysp = from g in db.tbl_Products from h in db.tbl_product_types where h.alias.Equals(id) && g.IDLoaiSP == h.ID && g.Status == true && h.Status == true select g; Session["loai"] = id; tbl_product_type loai = db.tbl_product_types.SingleOrDefault(n => n.alias.Equals(id)); Session["tenloai"] = loai.TenLoaiSP; ViewBag.TenLoai = (from l in db.tbl_product_types where l.alias.Equals(id) select l); ViewBag.TenSapXep = "Sắp xếp: A đến Z"; ViewBag.NameSortParm = "Name_desc"; ViewBag.NameSortParmasc = "Name_asc"; ViewBag.DateSortParm = "Date_desc"; ViewBag.PriceSortParm = "Price_desc"; ViewBag.PriceSortPasc = "Price"; if (sorting == "Name_desc") { ViewBag.TenSapXep = "Sắp xếp: Z đến A"; return(View(laysp.OrderByDescending(n => n.TenSP).ToPagedList(pageNum, pageSize))); } if (sorting == "Name_asc") { ViewBag.TenSapXep = "Sắp xếp: A đến Z"; return(View(laysp.OrderBy(n => n.TenSP).ToPagedList(pageNum, pageSize))); } if (sorting == "Date_desc") { ViewBag.TenSapXep = "Sản phẩm mới"; return(View(laysp.OrderByDescending(n => n.NgayCapNhat).ToPagedList(pageNum, pageSize))); } if (sorting == "Price_desc") { ViewBag.TenSapXep = "Sắp xếp Giá: Cao Đến Thấp"; return(View(laysp.OrderByDescending(n => n.GiaHienTai).ToPagedList(pageNum, pageSize))); } if (sorting == "Price") { ViewBag.TenSapXep = "Sắp xếp Giá: Thấp đến Cao"; return(View(laysp.OrderBy(n => n.GiaHienTai).ToPagedList(pageNum, pageSize))); } return(View(laysp.ToPagedList(pageNum, pageSize))); }
public ActionResult CreateNewType(tbl_product_type tbl_product_type) { if (ModelState.IsValid) { db.tbl_product_type.AddObject(tbl_product_type); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_product_type)); }
//Gọi từ View sang Controll public ActionResult header() { //Lấy ra danh sách Menu tbl_product_type dt = db.tbl_product_types.Where(n => n.TenLoaiSP.Contains("Điện thoại") && n.Status == true).Single(); ViewBag.aliasdt = dt.alias; tbl_product_type mtb = db.tbl_product_types.Where(n => n.TenLoaiSP.Contains("Tablet") && n.Status == true).Single(); ViewBag.aliasmtb = mtb.alias; ViewBag.hsxdt = (from h in db.tbl_producers from l in db.tbl_product_types where h.Idloaisp == l.ID && h.status == true && l.Status == true && l.TenLoaiSP.Contains("Điện thoại") select h).ToList(); ViewBag.hsxmtb = (from h in db.tbl_producers from l in db.tbl_product_types where h.Idloaisp == l.ID && h.status == true && l.Status == true && l.TenLoaiSP.Contains("Tablet") select h).ToList(); return(PartialView()); }
public ActionResult itemCategoryEdit(FormCollection form, HttpPostedFileBase fileUpload) { var id = form["id"]; if (id == null) { return(itemCategoryCreate(form, fileUpload)); } else { tbl_product_type tic = getOneItemCategory(Int32.Parse(id)); var name = form["name"]; bool err = false; if (String.IsNullOrEmpty(name)) { err = true; ViewData["Error"] += "Vui lòng nhập tên danh mục!\n"; } if (!tic.TenLoaiSP.Equals(name)) { tic.alias = DataHelper.GeneralHelper.getInstance().getAliasFromProductTypeName(data, name); } tic.TenLoaiSP = name; if (err == false) { UpdateModel(tic); data.SubmitChanges(); return(RedirectToAction("itemCategoryView")); } else { return(View(URLHelper.URL_ADMIN_ITEM_CATEGORY_M, tic)); } } }