Exemplo n.º 1
0
        public ActionResult Uproduct(string psort, string id, string pname, string pidno, string pcontent, string plink, HttpPostedFileBase txt_file)
        {
            Product p = new Product();
            ProductData pd = new ProductData();
            p.Pid = Convert.ToInt32(id);
            p.PName = pname;
            p.PidnoNum = pidno;
            p.PContent = pcontent;
            p.PLink = plink;
            p.Sort = Convert.ToInt32(psort);
            //檢查是否有選擇檔案
            if (txt_file != null)
            {
                //檢查檔案大小要限制也可以在這裡做
                if (txt_file.ContentLength > 0)
                {
                    string savedName = Path.Combine(Server.MapPath("~/images/product/"), txt_file.FileName);
                    txt_file.SaveAs(savedName);
                }
                p.PbigImg = "~/images/product/" + txt_file.FileName;
            }
            //if (txt_file == null)
            //{
            //   p.PbigImg = "~/images/example_img.jpg";
            //}
            else
            {
                p.PbigImg = pd.GetProduct_Once(p);
            }
            p.PbannerImg = "";

            pd.Update(p);
            return RedirectToAction("Conter", new { tabid = "1", m = "1" });
        }
Exemplo n.º 2
0
        public ActionResult Dproduct(string id)
        {
            if (Session["Member"] == null)
            {
                return RedirectToAction("login");
            }

            Product p = new Product();
            p.Pid = Convert.ToInt32(id);
            ProductData pd = new ProductData();
            pd.Delete(p);
            return RedirectToAction("Conter", new { tabid = "1", m = "1" });
        }