public ActionResult AddRam(string ram)
        {
            RamDAO dao  = new RamDAO();
            User   user = Session["User"] as User;
            var    rs   = "";

            if (user == null || user.LEVEL.Equals("10") == false)
            {
                rs = "user";
            }
            else if (ram == null)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.checkNull(ram) == false)
            {
                rs = "null";
            }

            else if (ToolsOfAdmin.checkNum(ram) == false)
            {
                rs = "number";
            }
            else if (dao.checkExit(Convert.ToInt32(ram)) == true)
            {
                rs = "exit";
            }
            else if (Convert.ToInt32(ram) <= 0)
            {
                rs = "lower";
            }
            else
            {
                var check = dao.addRam(Convert.ToInt32(ram));
                if (check == false)
                {
                    rs = "fail";
                }
                else
                {
                    rs = "success";
                }
            }
            return(Json(new { result = rs }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteMemory(string memory)
        {
            MemoryDAO dao  = new MemoryDAO();
            User      user = Session["User"] as User;
            var       rs   = "";

            if (user == null || user.LEVEL.Equals("10") == false)
            {
                rs = "user";
            }
            else if (memory == null)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.checkNull(memory) == false)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.checkNum(memory) == false)
            {
                rs = "number";
            }
            else if (dao.checkExit(Convert.ToInt32(memory)) == false)
            {
                rs = "exit";
            }
            else if (Convert.ToInt32(memory) <= 0)
            {
                rs = "lower";
            }
            else
            {
                var check = dao.delMemory(Convert.ToInt32(memory));
                if (check == false)
                {
                    rs = "fail";
                }
                else
                {
                    rs = "success";
                }
            }
            return(Json(new { result = rs }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteBrand(string brand)
        {
            string   rs   = "";
            BrandDAO dao  = new BrandDAO();
            User     user = Session["User"] as User;

            if (user == null || user.LEVEL.Equals("10") == false)
            {
                rs = "user";
            }
            else if (brand == null)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.checkNull(brand) == false)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.oneWord(brand) == false)
            {
                rs = "word";
            }
            else if (dao.checkExit(brand) == false)
            {
                rs = "exit";
            }
            else
            {
                var check = dao.delBrand(brand);
                if (check == false)
                {
                    rs = "fail";
                }
                else
                {
                    rs = "success";
                }
            }
            return(Json(new { result = rs }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public string generateNameProduct(string nameproduct, string brand)
        {
            string tembrand = ToolsOfAdmin.FirstCharToUpper(brand.ToLower());

            return(tembrand + " " + nameproduct);
        }
        public ActionResult AddProduct(FormProduct form)
        {
            string             rs              = "";
            ProductDAO         dao             = new ProductDAO();
            User               user            = Session["User"] as User;
            string             idproduct       = "";
            string             nameproduct     = form.nameproduct;
            string             hedieuhanh      = form.hedieuhanh;
            string             brand           = form.brand;
            string             memory          = form.memory;
            string             ram             = form.ram;
            string             price           = form.price;
            string             amount          = form.amount;
            string             salerate        = form.salerate;
            string             description     = form.description;
            HttpPostedFileBase image1          = form.image1;
            HttpPostedFileBase image2          = form.image2;
            HttpPostedFileBase image3          = form.image3;
            List <string>      checkNullString = new List <string>();

            checkNullString.Add(nameproduct);
            checkNullString.Add(hedieuhanh);
            checkNullString.Add(brand);
            checkNullString.Add(memory);
            checkNullString.Add(ram);
            checkNullString.Add(price);
            checkNullString.Add(amount);
            checkNullString.Add(salerate);
            checkNullString.Add(description);
            List <string> checkNum = new List <string>();

            checkNum.Add(memory);
            checkNum.Add(ram);
            checkNum.Add(price);
            checkNum.Add(amount);
            checkNum.Add(salerate);
            List <HttpPostedFileBase> listFiles = new List <HttpPostedFileBase>();

            listFiles.Add(image1);
            listFiles.Add(image2);
            listFiles.Add(image3);

            if (user == null || user.LEVEL.Equals("10") == false)
            {
                rs = "user";
            }

            else if (ToolsOfAdmin.checkNullList(checkNullString) == false)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.checkNumList(checkNum) == false)
            {
                rs = "number";
            }
            else if (image1 == null || image2 == null || image3 == null)
            {
                rs = "filenull";
            }
            else if (ToolsOfAdmin.checkFileNull(listFiles) == false)
            {
                rs = "filenull";
            }
            else if (ToolsOfAdmin.checkFileImage(listFiles) == false)
            {
                rs = "notimage";
            }
            else if (Convert.ToInt32(salerate) > 100 || Convert.ToInt32(salerate) < 0)
            {
                rs = "sale";
            }
            else if (ToolsOfAdmin.checkSaleRate(price, salerate) == false)
            {
                rs = "sale";
            }
            else if (Convert.ToInt32(amount) < 0 || Convert.ToInt32(price) <= 0)
            {
                rs = "amount";
            }

            else if (dao.checkExitNameProductForAdd(dao.generateNameProduct(form.nameproduct, form.brand)) == false)
            {
                rs = "name";
            }
            else
            {
                description = ToolsOfAdmin.DecodeUrlString(form.description);
                description = ToolsOfAdmin.ExtractText(description);

                idproduct = dao.addProduct(form, listFiles, description);
                if (idproduct == "fail")
                {
                    rs = "fail";
                }
                else
                {
                    rs = "success";
                }
            }
            return(Json(new { result = rs, idproduct = idproduct }, JsonRequestBehavior.DenyGet));
        }