Exemple #1
0
        // create a row in the table using the current values
        public int CreateFromCurrent(SqlTransaction trans)
        {
            ProductData dao = new ProductData(ConnStr, trans);

            Id = dao.Create(Name, Price);
            return(Id);
        }
        public IActionResult Create(Product newProduct)
        {
            ProductData.Create(newProduct);

            ViewData["Message"] = "Congratulations, your product has been added to our database!";

            return(RedirectToAction("ProductInfo", "Product", new { id = newProduct.productId }));
        }
Exemple #3
0
        public IActionResult Create(Product e)
        {
            if (!ModelState.IsValid)
            {
                return(View(e));
            }

            using (var data = new ProductData())
                data.Create(e);

            return(RedirectToAction("Index"));
        }
        public ActionResult Create(ProductModel product)
        {
            try
            {
                using (ProductData data = new ProductData())
                {
                    data.Create(product);
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(product));
            }
        }
        private async void AddProductButton_Click(object sender, EventArgs e)
        {
            // ASINを入力させるモーダルフォームを立ち上げる
            string         ASIN   = "";
            ASIN_InputForm form   = new ASIN_InputForm();
            DialogResult   result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                ASIN = form.value.Trim();
                // 有効なASINか調べる
                if (Tools.CheckASINValidity(ASIN))
                {
                    DisableAllButtons();
                    statusLabel.Text = "商品情報を取得しています";
                    // 商品データを取得する
                    products[productNum] = await productData.Create(ASIN, cacheFolderPath);

                    // リストに追加する
                    ProductList.AddProduct(products[productNum]);
                    // 登録したので登録している商品数をインクリメントする
                    productNum++;

                    // 登録した商品にリスト中で選択する
                    ProductList.Items[productNum - 1].Selected = true;
                    ProductList.Select();
                    if (productNum == 1)
                    {
                        await DrawProductInformation(products[productNum - 1], cacheFolderPath);

                        DrawPriceHistory(products[productNum - 1]);
                    }
                    statusLabel.Text = "商品情報登録完了";
                    EnabledAllButtons();
                }
                else
                {
                    MessageBox.Show("有効なASINではありません");
                }
            }
        }
        public ActionResult Cproduct(string psort, string pname, string pidno, string pcontent, string plink, HttpPostedFileBase txt_file)
        {
            Product p = new Product();
            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);

                }
            }
            if (txt_file == null)
            {
                p.PbigImg = Server.MapPath("~/images/example_img.jpg");
            }
            else
            {
                p.PbigImg = "~/images/product/" + txt_file.FileName;

            }
            p.PbannerImg = "";

            ProductData pd = new ProductData();
            ViewData["isDbOK"] = pd.Create(p);

            return RedirectToAction("Conter", new { tabid = "1", m = "1" });
        }
Exemple #7
0
        public void Create(Product product)
        {
            var data = new ProductData();

            data.Create(product);
        }