コード例 #1
0
        public ActionResult Update(int id)
        {
            var catepro = new ProductCategoryDAO().GetProductCategoryByID(id);

            SetViewBag(catepro.parentID);
            return(View(catepro));
        }
コード例 #2
0
        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");
            }
        }
コード例 #3
0
        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");
            }
        }
コード例 #4
0
        public ActionResult ListProductCategory()
        {
            ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();
            var listProduct = productCategoryDAO.SelectAll().ToList();

            return(PartialView(listProduct));
        }
コード例 #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
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        public BaseResponse <ProductCategory> GetProductCategory()
        {
            var list = new ProductCategoryDAO().ListAll();
            BaseResponse <ProductCategory> response = new BaseResponse <ProductCategory>(StatusResponse.Success, "", list);

            return(response);
        }
コード例 #8
0
 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"));
     }
 }
コード例 #9
0
 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"));
 }
コード例 #10
0
        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"));
        }
コード例 #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));
        }
コード例 #12
0
        public ActionResult Delete(long id)
        {
            var  dao    = new ProductCategoryDAO();
            bool result = dao.Delete(id);

            return(RedirectToAction("Index"));
        }
コード例 #13
0
        public ActionResult Edit(long id)
        {
            var dao   = new ProductCategoryDAO();
            var model = dao.ViewDetail(id);

            return(View(model));
        }
コード例 #14
0
        public ActionResult SearchForm()
        {
            ProductCategoryDAO db = new ProductCategoryDAO();
            var model             = db.GetAllProductcate();

            return(PartialView("_SearchForm", model));
        }
コード例 #15
0
 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));
 }
コード例 #16
0
        public ActionResult Remove(int productCategoryID)
        {
            ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();

            productCategoryDAO.Remove(productCategoryID);
            return(RedirectToAction("Index"));
        }
コード例 #17
0
        public ActionResult UpdateProductCategory(int id)
        {
            var dao   = new ProductCategoryDAO();
            var model = dao.productCategoryDetail(id);

            return(View(model));
        }
コード例 #18
0
 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());
 }
コード例 #19
0
        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);
        }
コード例 #20
0
        // GET: Admin/ProductCategory
        public ActionResult Index()
        {
            var dao = new ProductCategoryDAO();
            var listProductCategory = dao.listProdCategory();

            return(View(listProductCategory));
        }
コード例 #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));
        }
コード例 #22
0
        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));
        }
コード例 #23
0
        public ActionResult Edit(int id)
        {
            var proCate = new ProductCategoryDAO().ViewDetail(id);

            SetViewBag(proCate.ParentID);
            return(View(proCate));
        }
コード例 #24
0
        public ActionResult Update(long id)
        {
            GetViewBag_Session();
            var model = new ProductCategoryDAO().ViewDetail(id);

            return(View(model));
        }
コード例 #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));
        }
コード例 #26
0
        public void GetProductCategoryName(int idselected = 1)
        {
            ProductCategoryDAO productCategoryDAO = new ProductCategoryDAO();
            var listCategory = productCategoryDAO.SelectAll();

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

            dgr_search.DataSource          = list;
            dgr_search.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #30
0
        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);
        }