Example #1
0
 public ActionResult Input(Shipper model)
 {
     try
     {
         //TODO :Kiểm tra tính hợp lệ của dữ liệu nhập vào
         if (string.IsNullOrEmpty(model.CompanyName))
         {
             ModelState.AddModelError("CompanyName", "CompanyName expected");
         }
         if (string.IsNullOrEmpty(model.Phone))
         {
             model.Phone = "";
         }
         //TODO :Lưu dữ liệu nhập vào
         if (model.ShipperID == 0)
         {
             CatelogBLL.AddShipper(model);
         }
         else
         {
             CatelogBLL.UpdateShipper(model);
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message + ":" + ex.StackTrace);
         return(View(model));
     }
 }
Example #2
0
 public ActionResult ChangePassword(EmployeePassword model)
 {
     try
     {
         if (string.IsNullOrEmpty(model.password))
         {
             ModelState.AddModelError("password", "Old password expected");
         }
         if (string.IsNullOrEmpty(model.nPassword))
         {
             ModelState.AddModelError("nPassword", "New password expected");
         }
         if (string.IsNullOrEmpty(model.aPassword))
         {
             ModelState.AddModelError("aPassword", "Password expected");
         }
         CatelogBLL.ChangePassword(model.Id, model.password, model.nPassword, model.aPassword);
         return(RedirectToAction("Input/" + model.Id));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message + ":" + ex.StackTrace);
         return(View(model));
     }
 }
Example #3
0
        public static void init()
        {
            string connectionsString = ConfigurationManager.ConnectionStrings["LiteCommerce"].ConnectionString;

            //TODO : Khởi tạo các dll khi cần sử dụng
            CatelogBLL.Initalize(connectionsString);
        }
 public ActionResult Input(string id = "")
 {
     try
     {
         if (string.IsNullOrEmpty(id))
         {
             ViewBag.Title = "Create new Category";
             Category newCategory = new Category()
             {
                 CategoryID = 0
             };
             return(View(newCategory));
         }
         else
         {
             ViewBag.Title = "Edit a Category";
             Category editCategory = CatelogBLL.GetCategory(Convert.ToInt32(id));
             if (editCategory == null)
             {
                 return(RedirectToAction("Index"));
             }
             return(View(editCategory));
         }
     }
     catch (Exception ex)
     {
         return(Content(ex.Message + ": " + ex.StackTrace));
     }
 }
Example #5
0
 public ActionResult Input(string id = "")
 {
     try
     {
         if (string.IsNullOrEmpty(id))
         {
             ViewBag.Title = "Create new Supplier";
             Supplier newSupplier = new Supplier()
             {
                 SupplierID = 0
             };
             return(View(newSupplier));
         }
         else
         {
             ViewBag.Title = "Edit a Supplier";
             Supplier editSupplier = CatelogBLL.GetSupplier(Convert.ToInt32(id));
             if (editSupplier == null)
             {
                 return(RedirectToAction("Index"));
             }
             return(View(editSupplier));
         }
     }
     catch (Exception ex)
     {
         return(Content(ex.Message + ": " + ex.StackTrace));
     }
 }
Example #6
0
        public ActionResult Input(string id)
        {
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    ViewBag.Title = "Create new Customer";
                    Customer newCustomer = new Customer();

                    ViewBag.Action = "_Create";
                    return(View(newCustomer));
                }
                else
                {
                    ViewBag.Title  = "Edit a Customer";
                    ViewBag.Action = "_Edit";
                    Customer editCustomer = CatelogBLL.getCustomer(id);
                    if (editCustomer == null)
                    {
                        return(RedirectToAction("Index"));
                    }
                    return(View(editCustomer));
                }
            }
            catch (Exception ex)
            {
                return(Content(ex.Message + ": " + ex.StackTrace));
            }
        }
        public ActionResult Input(Category model)
        {
            try
            {
                //TODO: Kiểm tra tính hợp lệ của dữ liệu được nhập
                if (string.IsNullOrEmpty(model.CategoryName))
                {
                    ModelState.AddModelError("CategoryName", "CategoryName expected");
                }
                if (string.IsNullOrEmpty(model.Description))
                {
                    ModelState.AddModelError("Description", "Description expected");
                }



                //TODO: Lưu dư liệu vào DB
                if (model.CategoryID == 0)
                {
                    CatelogBLL.AddCategory(model);
                }
                else
                {
                    CatelogBLL.UpdateCategory(model);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message + ": " + ex.StackTrace);
                return(View(model));
            }
        }
Example #8
0
 public ActionResult Delete(int[] employeeIDs)
 {
     if (employeeIDs != null)
     {
         CatelogBLL.DeleteEmployees(employeeIDs);
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Delete(int[] categoryIDs = null)
 {
     if (categoryIDs != null)
     {
         CatelogBLL.DeleteCategories(categoryIDs);
     }
     return(RedirectToAction("Index"));
 }
Example #10
0
 public ActionResult Delete(int[] supplierIDs = null)
 {
     if (supplierIDs != null)
     {
         CatelogBLL.DeleteSuppliers(supplierIDs);
     }
     return(RedirectToAction("Index"));
 }
Example #11
0
 public ActionResult Delete(int[] ShipperIDs)
 {
     if (ShipperIDs != null)
     {
         CatelogBLL.DeleteShippers(ShipperIDs);
     }
     return(RedirectToAction("Index"));
 }
Example #12
0
 public ActionResult Delete(string[] customerIDs)
 {
     if (customerIDs != null)
     {
         CatelogBLL.DeleteCustomer(customerIDs);
     }
     return(RedirectToAction("Index"));
 }
Example #13
0
        // GET: Customer
        public ActionResult Index(int page = 1, string searchValue = "")
        {
            int             pageSize       = 10;
            int             rowCount       = 0;
            List <Customer> listOfCustomer = CatelogBLL.ListOfCustomers(page, pageSize, searchValue, out rowCount);
            var             model          = new Models.CustomerPaginationResult()
            {
                Page        = page,
                PageSize    = pageSize,
                RowCount    = rowCount,
                SearchValue = searchValue,
                Data        = listOfCustomer
            };

            return(View(model));
        }
Example #14
0
        // GET: Supplier
        public ActionResult Index(int page = 1, string searchValue = "")
        {
            //int pageSize = 5;
            //int rowCount = 0;
            //List<Supplier> model = CatelogBLL.ListOfSuppliers(page, pageSize, searchValue, out rowCount);
            //ViewBag.RowCount = rowCount;
            //return View(model);
            int             pageSize       = 5;
            int             rowCount       = 0;
            List <Supplier> listOfSupplier = CatelogBLL.ListOfSuppliers(page, pageSize, searchValue, out rowCount);
            var             model          = new Models.SupplierPaginationResult()
            {
                Page        = page,
                PageSize    = pageSize,
                RowCount    = rowCount,
                SearchValue = searchValue,
                Data        = listOfSupplier
            };

            return(View(model));
        }
Example #15
0
 public ActionResult Input(string id = "")
 {
     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 = CatelogBLL.GetEmployee(Convert.ToInt32(id));
         if (editEmployee == null)
         {
             return(RedirectToAction("Index"));
         }
         return(View(editEmployee));
     }
 }
Example #16
0
 public ActionResult Input(string id)
 {
     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 = CatelogBLL.GetShipper(Convert.ToInt32(id));
         if (editShipper == null)
         {
             return(RedirectToAction("Index"));
         }
         return(View(editShipper));
     }
 }
Example #17
0
        public ActionResult Input(Supplier model)
        {
            try
            {
                //TODO: Kiểm tra tính hợp lệ của dữ liệu được nhập
                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 = "";
                }



                //TODO: Lưu dư liệu vào DB
                if (model.SupplierID == 0)
                {
                    CatelogBLL.AddSupplier(model);
                }
                else
                {
                    CatelogBLL.UpdateSupplier(model);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message + ": " + ex.StackTrace);
                return(View(model));
            }
        }
Example #18
0
        public ActionResult Input(Customer model, String Action)
        {
            try
            {
                //TODO: Kiểm tra tính hợp lệ của dữ liệu được nhập
                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.Phone))
                {
                    model.Phone = "";
                }
                if (string.IsNullOrEmpty(model.CustomerID))
                {
                    ModelState.AddModelError("CustomerID", "CustomerID expected");
                }



                //TODO: Lưu dư liệu vào DB
                if (Action.Equals("_Create"))
                {
                    ViewBag.Action = "_Create";
                    CatelogBLL.AddCusstomer(model);
                }
                else if (Action.Equals("_Edit"))
                {
                    ViewBag.Action = "_Edit";
                    CatelogBLL.UpdateCustomer(model);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message + ": " + ex.StackTrace);
                return(View(model));
            }
        }
Example #19
0
        public ActionResult Input(Employee model, HttpPostedFileBase PhotoPath)
        {
            try
            {
                //TODO :Kiểm tra tính hợp lệ của dữ liệu nhập vào
                if (string.IsNullOrEmpty(model.FirstName))
                {
                    ModelState.AddModelError("FirstName", "FirstName expected");
                }
                if (string.IsNullOrEmpty(model.LastName))
                {
                    ModelState.AddModelError("LastName", "LastName expected");
                }
                if (string.IsNullOrEmpty(model.Title))
                {
                    ModelState.AddModelError("Title", "Title expected");
                }
                if (string.IsNullOrEmpty(model.Password))
                {
                    ModelState.AddModelError("Password", "Password expected");
                }
                if (model.BirthDate == DateTime.MinValue)
                {
                    ModelState.AddModelError("BirthDate", "BirthDate expected");
                }
                if (model.HireDate == DateTime.MinValue)
                {
                    ModelState.AddModelError("HireDate", "HireDate expected");
                }
                if (model.HireDate.CompareTo(model.BirthDate) < 0)
                {
                    ModelState.AddModelError("HideDate", "HireDate expected");
                }
                if (string.IsNullOrEmpty(model.Email))
                {
                    model.Email = "";
                }
                if (string.IsNullOrEmpty(model.Address))
                {
                    model.Address = "";
                }
                if (string.IsNullOrEmpty(model.Country))
                {
                    model.Country = "";
                }
                if (string.IsNullOrEmpty(model.City))
                {
                    model.City = "";
                }
                if (string.IsNullOrEmpty(model.HomePhone))
                {
                    model.HomePhone = "";
                }
                if (string.IsNullOrEmpty(model.Notes))
                {
                    model.Notes = "";
                }
                if (string.IsNullOrEmpty(model.PhotoPath))
                {
                    model.PhotoPath = "";
                }
                //TODO :Lưu dữ liệu nhập vào
                if (model.EmployeeID == 0)
                {
                    if (PhotoPath != null && PhotoPath.ContentLength > 0)
                    {
                        var    ResumeName = Path.GetFileName(PhotoPath.FileName);
                        string path       = System.IO.Path.Combine(Server.MapPath("~/Uploads/"), ResumeName);
                        PhotoPath.SaveAs(path);
                        model.PhotoPath = "/Uploads/" + PhotoPath.FileName;
                    }
                    CatelogBLL.AddEmployee(model);
                }
                else
                {
                    if (model.PhotoPath != "")
                    {
                        if (PhotoPath != null && PhotoPath.ContentLength > 0)
                        {
                            var    ResumeName = Path.GetFileName(PhotoPath.FileName);
                            string path       = System.IO.Path.Combine(Server.MapPath("~/Uploads/"), ResumeName);
                            PhotoPath.SaveAs(path);
                            model.PhotoPath = "/Uploads/" + PhotoPath.FileName;
                        }
                    }
                    else
                    {
                        Employee editEmployee = CatelogBLL.GetEmployee(model.EmployeeID);
                        model.PhotoPath = editEmployee.PhotoPath;
                    }

                    CatelogBLL.UpdateEmployee(model);
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message + ":" + ex.StackTrace);
                return(View(model));
            }
        }