public ActionResult Update(int id)
        {
            var catepro = new ProductCategoryDAO().GetProductCategoryByID(id);

            SetViewBag(catepro.parentID);
            return(View(catepro));
        }
        private void btn_insert_Click(object sender, EventArgs e)
        {
            try
            {
                ProductCategory item = new ProductCategory();
                item.Address     = txb_supplier_address.Text;
                item.Name        = txb_supplier_name.Text;
                item.PhoneNumber = txb_supplier_phone.Text;

                bool result = new ProductCategoryDAO().Insert(item);

                if (result == true)
                {
                    MessageBox.Show("Thêm nhà cung cấp thành công");
                    LoadCategory();
                }
                else
                {
                    MessageBox.Show("Có lỗi trong quá trình Thêm");
                }
            }
            catch
            {
                MessageBox.Show("Có lỗi trong quá trình Thêm");
            }
        }
        private void btn_edit_Click(object sender, EventArgs e)
        {
            try
            {
                ProductCategory item = new ProductCategory();
                item.ID          = Convert.ToInt32(txb_supplier_code.Text);
                item.Address     = txb_supplier_address.Text;
                item.Name        = txb_supplier_name.Text;
                item.PhoneNumber = txb_supplier_phone.Text;

                bool result = new ProductCategoryDAO().Update(item);

                if (result == true)
                {
                    MessageBox.Show("Sửa nhà cung cấp thành công");
                    LoadCategory();
                }
                else
                {
                    MessageBox.Show("Có lỗi trong quá trình Sửa");
                }
            }
            catch
            {
                MessageBox.Show("Có lỗi trong quá trình Sửa");
            }
        }
Esempio n. 4
0
        public ActionResult ListProductCategory()
        {
            ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();
            var listProduct = productCategoryDAO.SelectAll().ToList();

            return(PartialView(listProduct));
        }
Esempio n. 5
0
        private void SetViewBag(long?selectedID = null)
        {
            var dao = new ProductCategoryDAO();

            ViewBag.Link = new SelectList(dao.ListAll(), "CategoryID", "Name", selectedID);
            //list-gan colum value cho tung selection tuong ung- chon truong coloum tren db se hien thi- chon selected item hien thi
        }
        public ActionResult UpdateProductCategory(ProductCategory model)
        {
            if (ModelState.IsValid)
            {
                var       dao       = new ProductCategoryDAO();
                UserLogin userlogin = (UserLogin)Session["USER_SESSION"];
                model.ModifiedBy = userlogin.UserName;
                string metatitle = CastString.Cast(model.Name);
                model.MetaTitle = metatitle;
                bool result = dao.UpdateProductCategory(model);
                if (result)
                {
                    return(RedirectToAction("Index", "ProductCategory"));
                }
                else
                {
                    ModelState.AddModelError("UpdateProdCategoryError", "Chưa cập nhật được");
                }
            }
            else
            {
            }

            return(View(model));
        }
        public BaseResponse <ProductCategory> GetProductCategory()
        {
            var list = new ProductCategoryDAO().ListAll();
            BaseResponse <ProductCategory> response = new BaseResponse <ProductCategory>(StatusResponse.Success, "", list);

            return(response);
        }
 public ActionResult CapNhat(tbl_ProductCatalog model)
 {
     if (CheckType2())
     {
         if (ModelState.IsValid)
         {
             model.MetaName = ConvertToUnSign(model.CatalogProductName);
             var result = new ProductCategoryDAO().CapNhat(model);
             if (result)
             {
                 SetAlert("Cập nhật thành công", "success");
                 return(RedirectToAction("DanhSach"));
             }
             else
             {
                 SetAlert("Cập nhật không thành công.", "danger");
             }
         }
         GetTypeProduct(model.ProductTypeID);
         return(View(model));
     }
     else
     {
         SetAlert("Bạn không có quyền tru cập!", "error");
         return(RedirectToAction("TrangChu", "Index"));
     }
 }
 public ActionResult Edit(ProductCategory productCategory, string tempstatus)
 {
     if (ModelState.IsValid)
     {
         if (tempstatus == "Kích Hoạt")
         {
             productCategory.Status = true;
         }
         else
         {
             productCategory.Status = false;
         }
         productCategory.ModifiedDate = DateTime.Now.ToString();
         ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();
         var check = productCategoryDAO.Edit(productCategory);
         if (check > 0)
         {
             TempData["msg"] = MessageBox.Show("Edit thành công");
             return(RedirectToAction("Index", "ProductCategory"));
         }
         else
         {
             ModelState.AddModelError("", "Edit không thành công");
         }
     }
     SetCategoryParent();
     return(View("Index"));
 }
        public ActionResult Xoa(int ID)
        {
            var result = new ProductCategoryDAO().Delete(ID);

            SetAlert("Xóa thông tin thành công", "success");
            return(RedirectToAction("Index", "DanhMuc"));
        }
Esempio n. 11
0
        public ActionResult Category(long id, int page = 1, int pageSize = 3)
        {
            var category = new ProductCategoryDAO().ViewDetail(id);

            ViewBag.category = category;
            int totalRecord = 0;
            var model       = new ProductDAO().ListByCategoryID(id, ref totalRecord, page, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            int maxPage   = 3;
            int totalPage = 0;

            totalPage = (int)Math.Ceiling((double)((double)totalRecord / pageSize));

            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            return(View(model));
        }
        public ActionResult Delete(long id)
        {
            var  dao    = new ProductCategoryDAO();
            bool result = dao.Delete(id);

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(long id)
        {
            var dao   = new ProductCategoryDAO();
            var model = dao.ViewDetail(id);

            return(View(model));
        }
Esempio n. 14
0
        public ActionResult SearchForm()
        {
            ProductCategoryDAO db = new ProductCategoryDAO();
            var model             = db.GetAllProductcate();

            return(PartialView("_SearchForm", model));
        }
 public ActionResult CreateProductCategory(ProductCategory model)
 {
     if (ModelState.IsValid)
     {
         //Kiểm tra xem tên loại sản phẩm đã có chư
         var  dao    = new ProductCategoryDAO();
         bool exsits = dao.ProductCategoryExist(model.Name);
         if (!exsits)
         {
             UserLogin userlogin = (UserLogin)Session["USER_SESSION"];
             model.CreatedBy   = userlogin.UserName;
             model.CreatedDate = DateTime.Now;
             string metatitle = CastString.Cast(model.Name);
             model.MetaTitle = metatitle;
             bool result = dao.CreateProductCategory(model);
             if (result)
             {
                 return(RedirectToAction("Index", "ProductCategory"));
             }
             else
             {
                 ModelState.AddModelError("CreateProdCategoryError", "Tạo mới không thành công");
             }
         }
         else
         {
             //trường hợp tên đã có
             ModelState.AddModelError("CreateProdCategoryError", "Tên loại sản phẩm này đã có");
         }
     }
     else
     {
     }
     return(View(model));
 }
        public ActionResult Remove(int productCategoryID)
        {
            ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();

            productCategoryDAO.Remove(productCategoryID);
            return(RedirectToAction("Index"));
        }
        public ActionResult UpdateProductCategory(int id)
        {
            var dao   = new ProductCategoryDAO();
            var model = dao.productCategoryDetail(id);

            return(View(model));
        }
 public ActionResult Create(ProductCategory productCategory, string tempstatus)
 {
     if (ModelState.IsValid)
     {
         ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();
         productCategory.CreateBy   = BaseController.NguoiDungHienTai.UserAccount;
         productCategory.CreateDate = DateTime.Now;
         if (tempstatus == "Kích Hoạt")
         {
             productCategory.Status = true;
         }
         else
         {
             productCategory.Status = false;
         }
         var check = productCategoryDAO.Create(productCategory);
         if (check > 0)
         {
             TempData["msg"] = MessageBox.Show("Create successfully");
             return(RedirectToAction("Create", "ProductCategory"));
         }
         else
         {
             ModelState.AddModelError("", "Create fail");
         }
     }
     SetCategoryParent();
     return(View());
 }
        public BaseResponse <ProductCategory> GetProductCategory(int page, int number)
        {
            var list = new ProductCategoryDAO().GetListProduct(page, number);
            BaseResponse <ProductCategory> response = new BaseResponse <ProductCategory>(StatusResponse.Success, "", list);

            return(response);
        }
        // GET: Admin/ProductCategory
        public ActionResult Index()
        {
            var dao = new ProductCategoryDAO();
            var listProductCategory = dao.listProdCategory();

            return(View(listProductCategory));
        }
Esempio n. 21
0
        //Tạo menu các loại thực đơn
        public ActionResult menuProdCategory()
        {
            var dao   = new ProductCategoryDAO();
            var model = dao.listProdCateClient();

            return(PartialView(model));
        }
        public ActionResult HienThiSanPhamTheoDanhMuc(int categoryID, string ListSortBy, string ListPrice, int page = 1, int pagesize = 6)
        {
            var productdao         = new ProductDAO();
            var productcategorydao = new ProductCategoryDAO();


            ViewBag.CategoryDetail = productcategorydao.ViewCategoryDetail(categoryID);
            ViewBag.DanhMucCon     = productcategorydao.ListChildCategory(categoryID);
            ViewBag.XemNhieuNhat   = productdao.XemNhieuNhat();

            int totalRecord = 0;
            var list        = productdao.DanhSachSanPham(categoryID, ListSortBy, ListPrice, ref totalRecord, page, pagesize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pagesize));
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            DropdownSortBy();
            DropdownPrice();

            return(View(list));
        }
        public ActionResult Edit(int id)
        {
            var proCate = new ProductCategoryDAO().ViewDetail(id);

            SetViewBag(proCate.ParentID);
            return(View(proCate));
        }
Esempio n. 24
0
        public ActionResult Update(long id)
        {
            GetViewBag_Session();
            var model = new ProductCategoryDAO().ViewDetail(id);

            return(View(model));
        }
Esempio n. 25
0
        public ActionResult Category(int id, int pageIndex = 1, int pageSize = 1)
        {
            var category = new ProductCategoryDAO().ViewDetail(id);

            ViewBag.Category = category;
            int totalRecord = 0;
            var products    = new ProductDAO().ListAllByCategory(id, ref totalRecord, pageIndex, pageSize);

            //Phân trang
            ViewBag.Total     = totalRecord;
            ViewBag.PageIndex = pageIndex;

            int totalPage = 0, maxPage = 5;

            totalPage = (int)Math.Ceiling((float)totalRecord / pageSize);

            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = maxPage;
            ViewBag.Next      = pageIndex + 1;
            ViewBag.Prev      = pageIndex - 1;

            return(View(products));
        }
        public void GetProductCategoryName(int idselected = 1)
        {
            ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();
            var listCategory = productCategoryDAO.SelectAll();

            ViewBag.listCategory = new SelectList(listCategory, "CategoryID", "CategoryName", idselected);
        }
Esempio n. 27
0
        void Search_Hang(string text)
        {
            List <ProductCategory> list = new ProductCategoryDAO().Search(text);

            dgr_search.DataSource          = list;
            dgr_search.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
Esempio n. 28
0
        public ActionResult Category(long cateId)
        {
            var category = new ProductCategoryDAO().ViewDetail(cateId);
            var ListProductByCategoryID = new ProductDAO().ListByCategoryID(cateId);

            ViewBag.ListProductByCategoryID = ListProductByCategoryID;
            return(View(category));
        }
Esempio n. 29
0
        // GET: Admin/ProductCategory
        public ActionResult Index(string searchString, int page = 1, int pagesize = 10)
        {
            var dao   = new ProductCategoryDAO();
            var model = dao.ListAllPage(searchString, page, pagesize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
        public BaseResponse <ProductCategory> UpdateProductCategory(ProductCategory obj)
        {
            bool           result = new ProductCategoryDAO().Update(obj);
            StatusResponse status = result ? StatusResponse.Success : StatusResponse.Fail;
            BaseResponse <ProductCategory> response = new BaseResponse <ProductCategory>(status, "", null);

            return(response);
        }