/// <summary> /// trang chủ của nhân viên /// </summary> /// <returns></returns> public ActionResult Index() { WebUserData userData = User.GetUserData(); Employee employee = CataLogBLL.GetEmployee(Convert.ToInt32(userData.UserID)); return(View(employee)); }
public ActionResult Input(string id = "") { try { if (string.IsNullOrEmpty(id)) { ViewBag.Title = "Create new Country"; Country newCountry = new Country() { CountryID = 0 }; return(View(newCountry)); } else { ViewBag.Title = "Edit a Country"; Country editCountry = CataLogBLL.GetCountry(Convert.ToInt32(id)); if (editCountry == null) { return(RedirectToAction("Index")); } return(View(editCountry)); } } catch (Exception ex) { return(Content(ex.Message + "" + ex.StackTrace)); } }
public ActionResult Input(Supplier model) { try { if (string.IsNullOrEmpty(model.CompanyName)) { ModelState.AddModelError("CompanyName", "CompanyName expected"); } if (string.IsNullOrEmpty(model.ContactName)) { ModelState.AddModelError("ContactName", "ContactName expected"); } if (string.IsNullOrEmpty(model.ContactTitle)) { ModelState.AddModelError("ContactTitle", "ContactTitle expected"); } if (string.IsNullOrEmpty(model.Address)) { model.Address = ""; } if (string.IsNullOrEmpty(model.City)) { model.City = ""; } if (string.IsNullOrEmpty(model.Country)) { model.Country = ""; } if (string.IsNullOrEmpty(model.Fax)) { model.Fax = ""; } if (string.IsNullOrEmpty(model.HomePage)) { model.HomePage = ""; } if (string.IsNullOrEmpty(model.Phone)) { model.Phone = ""; } if (!ModelState.IsValid) { ViewBag.Title = model.SupplierID == 0 ? "Create new Supplier" : "Edit a Supplier"; return(View(model)); } if (model.SupplierID == 0) { CataLogBLL.AddSupplier(model); } else { CataLogBLL.UpdateSupplier(model); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("Loi", ex.StackTrace); return(View(model)); } }
/// <summary> /// trang chủ của các thuộc tính /// </summary> /// <param name="id"></param> /// <returns></returns> // GET: Attribute public ActionResult Index(string id = "") { int productID = Convert.ToInt32(id); List <Attributes> model = CataLogBLL.GetListAttribute(productID); return(View(model)); }
public ActionResult Input(string id = "") { try { if (string.IsNullOrEmpty(id)) { ViewBag.Title = " Create new Employee"; Employee newEmployee = new Employee() { EmployeeID = 0 }; return(View(newEmployee)); } else { ViewBag.Title = "Edit a Employee"; Employee editEmployee = CataLogBLL.GetEmployee(Convert.ToInt32(id)); if (editEmployee == null) { return(RedirectToAction("Index")); } return(View(editEmployee)); } // return View(); }catch (Exception ex) { return(Content(ex.Message + "" + ex.StackTrace)); } }
public ActionResult Input(string id = "") { try { if (string.IsNullOrEmpty(id)) { ViewBag.Title = " Create new Shipper"; Shipper newShipper = new Shipper() { ShipperID = 0 }; return(View(newShipper)); } else { ViewBag.Title = "Edit a Shipper"; Shipper editShipper = CataLogBLL.GetShipper(Convert.ToInt32(id)); if (editShipper == null) { return(RedirectToAction("Index")); } return(View(editShipper)); } }catch (Exception ex) { return(Content(ex.Message + "" + ex.StackTrace)); } }
public ActionResult Input(Shipper model) { try { if (string.IsNullOrEmpty(model.CompanyName)) { ModelState.AddModelError("CompanyName", "CompanyName expected"); } if (string.IsNullOrEmpty(model.Phone)) { model.Phone = ""; } if (!ModelState.IsValid) { ViewBag.Title = model.ShipperID == 0 ? "Create new Shipper" : "Edit a Shipper"; return(View(model)); } if (model.ShipperID == 0) { CataLogBLL.AddShipper(model); } else { CataLogBLL.UpdateShipper(model); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("Loi", ex.StackTrace); return(View(model)); } }
public ActionResult Input(Category model) { try { //TODO: kiem tra tinh hop le cua du lieu if (string.IsNullOrEmpty(model.CategoryName)) { ModelState.AddModelError("CategoryName", "CategoryName expected"); } if (string.IsNullOrEmpty(model.Description)) { model.Description = ""; } if (!ModelState.IsValid) { ViewBag.Title = model.CategoryID == 0 ? "Create new Category" : "Edit a Category"; return(View(model)); } //TODO: Luu if (model.CategoryID == 0) { CataLogBLL.AddCategory(model); } else { CataLogBLL.UpdateCategory(model); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("Loi", ex.StackTrace); return(View(model)); } }
public ActionResult Input(Country model) { try { if (string.IsNullOrEmpty(model.CountryName)) { ModelState.AddModelError("CountryName", "CountryName expected"); } if (!ModelState.IsValid) { ViewBag.Title = model.CountryID == 0 ? "Create new Country" : "Edit a Country"; return(View(model)); } if (model.CountryID == 0) { CataLogBLL.AddCountry(model); } else { CataLogBLL.UpdateCountry(model); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("Loi", ex.StackTrace); return(View(model)); } }
public ActionResult Delete(int[] productIDs = null) { if (productIDs != null) { CataLogBLL.DeleteProduct(productIDs); } return(RedirectToAction("Index")); }
public ActionResult Delete(int[] employeeIDs = null) { if (employeeIDs != null) { CataLogBLL.DeleteEmployee(employeeIDs); } return(RedirectToAction("Index")); }
public ActionResult Delete(int[] shipperIDs = null) { if (shipperIDs != null) { CataLogBLL.DeleteShippers(shipperIDs); } return(RedirectToAction("Index")); }
public ActionResult Delete(int[] countryIDs = null) { if (countryIDs != null) { CataLogBLL.DeleteCountries(countryIDs); } return(RedirectToAction("Index")); }
/// <summary> /// Xóa nhiều thuộc tính /// </summary> /// <param name="attributeID"></param> /// <returns></returns> public ActionResult Delete(int[] attributeIDs, int ProductID) { if (attributeIDs != null) { CataLogBLL.DeleteCategories(attributeIDs); } return(RedirectToAction("Index", new { id = ProductID })); }
public ActionResult Delete(string[] customerIDs = null) { if (customerIDs != null) { CataLogBLL.DeleteCustomers(customerIDs); } return(RedirectToAction("Index")); }
public static void Init() { string connectionString = ConfigurationManager.ConnectionStrings["LiteCommerce"].ConnectionString; //TODO khởi tạo các BLL khi sử dụng đến CataLogBLL.Initialize(connectionString); UserAccountBLL.Initialize(connectionString); DashboardBLL.Initialize(connectionString); }
public ActionResult Input(Product model, HttpPostedFileBase uploadFile) { // Up anh if (uploadFile != null) { string fileName = $"{DateTime.Now.Ticks}{Path.GetExtension(uploadFile.FileName)}"; // string _fileName = string.Format{"{0}{1}"} $"{DateTime.Now.Ticks}{Path.GetExtension(uploadFile.FileName)}"; // string _FileName = Path.GetFileName(uploadFile.FileName); string filePath = Path.Combine(Server.MapPath("~/Images"), fileName); uploadFile.SaveAs(filePath); model.PhotoPath = fileName; } try { if (string.IsNullOrEmpty(model.ProductName)) { ModelState.AddModelError("ProductName", "ProductName expected"); } if (string.IsNullOrEmpty(model.QuantityPerUnit)) { ModelState.AddModelError("QuantityPerUnit", "QuantityPerUnit expected"); } if (string.IsNullOrEmpty(model.Descriptions)) { model.Descriptions = ""; } if (string.IsNullOrEmpty(model.PhotoPath)) { model.PhotoPath = ""; } if (!ModelState.IsValid) { ViewBag.Title = model.SupplierID == 0 ? "Create new Product" : "Edit a Product"; return(View(model)); } if (model.ProductID == 0) { CataLogBLL.AddProduct(model); } else { CataLogBLL.UpdateProduct(model); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("Loi", ex.StackTrace); return(View(model)); } }
/// <summary> /// ds các nhà cung cấp /// </summary> /// <param name="allowSelectAll"></param> /// <returns></returns> public static List <SelectListItem> Suppliers(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { foreach (Supplier supplier in CataLogBLL.ListOfSupplier()) { list.Add(new SelectListItem() { Value = supplier.SupplierID.ToString(), Text = supplier.CompanyName.ToString() }); } } return(list); }
/// <summary> /// danh sách các product /// </summary> /// <param name="allowSelectAll"></param> /// <returns></returns> public static List <SelectListItem> ProductID(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { foreach (Product product in CataLogBLL.ListOfProduct()) { list.Add(new SelectListItem() { Value = product.ProductID.ToString(), Text = product.ProductName.ToString() }); } } return(list); }
/// <summary> /// hiển thị trang chủ của khách hàng /// </summary> /// <param name="page"></param> /// <param name="searchValue"></param> /// <returns></returns> // GET: Country public ActionResult Index(int page = 1, string searchValue = "") { int pageSize = 3; int rowCount = 0; List <Country> listOfCountry = CataLogBLL.ListOfCountries(page, pageSize, searchValue, out rowCount); var model = new Models.CountryPaginationResult() { Page = page, PageSize = pageSize, RowCount = rowCount, Data = listOfCountry, SearchValue = searchValue }; return(View(model)); }
/// <summary> /// ds các thể loại /// </summary> /// <param name="allowSelectAll"></param> /// <returns></returns> public static List <SelectListItem> Categories(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); if (allowSelectAll) { foreach (Category category in CataLogBLL.ListOfCategory()) { list.Add(new SelectListItem() { Value = category.CategoryID.ToString(), Text = category.CategoryName.ToString() }); } } return(list); }
/// <summary> /// trang chủ shipper /// </summary> /// <returns></returns> // GET: Shipper public ActionResult Index(int page = 1, string searchValue = "") { int pageSize = 3; int rowCount = 0; List <Shipper> listOfShipper = CataLogBLL.ListOfShipper(page, pageSize, searchValue, out rowCount); var model = new Models.ShipperPaginationResult() { Page = page, PageSize = pageSize, RowCount = rowCount, Data = listOfShipper, SearchValue = searchValue }; // int pagesize = 3; // int rowcount = 0; // list<supplier> model = catalogbll.listofsupplier(page, pagesize, searchvalue, out rowcount); // viewbag.rowcount = rowcount; return(View(model)); }
/// <summary> /// SelectList cac quoc gia /// </summary> /// <returns></returns> public static List <SelectListItem> Countries(bool allowSelectAll = true) { List <SelectListItem> list = new List <SelectListItem>(); list.Add(new SelectListItem() { Value = "", Text = "---- All Country -----" }); if (allowSelectAll) { foreach (Country country in CataLogBLL.ListOfCountries()) { list.Add(new SelectListItem() { Value = country.CountryName, Text = country.CountryName }); } } return(list); }
public ActionResult Update(Attributes model) { if (string.IsNullOrEmpty(model.AttributeName)) { ModelState.AddModelError("AttributeName", "AttributeName expected"); } if (string.IsNullOrEmpty(model.Color)) { ModelState.AddModelError("QuantityPerUnit", "QuantityPerUnit expected"); } if (string.IsNullOrEmpty(model.Size)) { ModelState.AddModelError("Size", "Size expected"); } if (!ModelState.IsValid) { ViewBag.Title = "Edit Attribute"; } CataLogBLL.UpdateAttribute(model); return(RedirectToAction("Index", new{ id = model.ProductID })); }
public ActionResult ForgotPassword(string email = "", string pwn = "", string confirmpw = "") { ViewBag.Email = email; if (pwn.Equals(confirmpw)) { if (CataLogBLL.CheckEmail(email) != 0) { UserAccountBLL.ChangePassword(MaHoaMD5Hepler.EncodeMD5(pwn), email); return(RedirectToAction("SignIn", "Account")); } else { ModelState.AddModelError("Messege", "Email không tồn tại!"); return(View()); } } else { ModelState.AddModelError("Messege", "Mật Khẩu không khớp!"); return(View()); } }
public ActionResult Input(string id = "") { if (string.IsNullOrEmpty(id)) { ViewBag.Title = " Create new Product"; Product newProduct = new Product() { ProductID = 0 }; return(View(newProduct)); } else { ViewBag.Title = "Edit a Product"; Product editProduct = CataLogBLL.GetProduct(Convert.ToInt32(id)); if (editProduct == null) { return(RedirectToAction("Index")); } return(View(editProduct)); } }
public ActionResult Input(string id = "") { if (string.IsNullOrEmpty(id)) { ViewBag.Title = " Create new Attribute"; Attributes newAttrribute = new Attributes() { AttributeID = 0 }; return(View(newAttrribute)); } else { ViewBag.Title = "Edit a Attribute"; Attributes editAttrribute = CataLogBLL.GetAttribute(Convert.ToInt32(id)); if (editAttrribute == null) { return(RedirectToAction("Index")); } return(View(editAttrribute)); } }
// GET: Product /// <summary> /// trang chủ của sản phẩm /// </summary> /// <returns></returns> public ActionResult Index(int page = 1, string searchValue = "", int category = 1, int supplier = 1) { int pageSize = 3; int rowCount = 0; List <Product> listOfProduct = CataLogBLL.ListOfProduct(page, pageSize, searchValue, out rowCount, supplier, category); var model = new Models.ProductPaginationResult() { Page = page, PageSize = pageSize, RowCount = rowCount, Data = listOfProduct, SearchValue = searchValue, Supplier = CataLogBLL.GetSupplier(supplier), Category = CataLogBLL.GetCategory(category) // Attribute = CataLogBLL.GetAttribute() }; // int pagesize = 3; // int rowcount = 0; // list<supplier> model = catalogbll.listofsupplier(page, pagesize, searchvalue, out rowcount); // viewbag.rowcount = rowcount; return(View(model)); }
public ActionResult Input(string id = "") { try { if (string.IsNullOrEmpty(id)) { ViewBag.Title = " Create new Customer"; Customer newCustomer = new Customer() { CustomerID = "" }; return(View(newCustomer)); } else { ViewBag.Title = "Edit a Customer"; Customer editCustomer = CataLogBLL.GetCustomer(id); return(View(editCustomer)); } }catch (Exception ex) { return(Content(ex.Message + "" + ex.StackTrace)); } }
public ActionResult ChangePassword(string pw = "", string pwn = "", string confirmpw = "") { WebUserData userData = User.GetUserData(); Employee employee = CataLogBLL.GetEmployee(Convert.ToInt32(userData.UserID)); if (employee.Password.Equals(MaHoaMD5Hepler.EncodeMD5(pw))) { if (pwn.Equals(confirmpw)) { UserAccountBLL.ChangePassword(MaHoaMD5Hepler.EncodeMD5(pwn), employee.Email); return(RedirectToAction("Index")); } else { ModelState.AddModelError("MatKhau", "Mật khẩu không khớp!"); return(View()); } } else { ModelState.AddModelError("MatKhauMoi", "Mật Khẩu không đúng!"); return(View()); } }