コード例 #1
0
        protected void btnCrPro_Click(object sender, EventArgs e)
        {
            var product = new UDI.CORE.Entities.Product();
            product.ProductName = ProductNameTextBox.Text;
            product.CategoryID = int.Parse(CategoriesDDL2.SelectedItem.Value);
            product.QuantityPerUnit = QuantityPerUnitTextBox.Text;
            product.UnitPrice = (int)float.Parse(UnitPriceTextBox.Text);
            product.UnitsInStock = int.Parse(UnitsInStockTextBox.Text);
            product.UnitsOnOrder = int.Parse(UnitsOnOrderTextBox.Text);
            product.ReorderLevel = int.Parse(ReorderLevelTextBox.Text);
            product.Quantity = int.Parse(QuantityTextBox.Text);
            product.Discontinued = DiscontinueCheckBox.Checked;
            if(ModelState.IsValid)
            {
                var prodID = ProductIDHidenField.Value;
                if (prodID.Trim().Length == 0)
                {
                    Prod.Add(product);                    
                }
                else
                {
                    product.ProductID = int.Parse(prodID);
                    Prod.Edit(product);
                }
            }

            ClearControl();
            LoadProduct();
            ScriptManager.RegisterStartupScript(this, GetType(), "CloseAlert", "CloseAlert();", true);
        }
コード例 #2
0
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         _prod.Edit(product);     
         return RedirectToAction("Index");
     }
     ViewBag.CategoryID = new SelectList(_cate.GetAll(), "CategoryID", "CategoryName", product.CategoryID);
     return View(product);
 }
コード例 #3
0
 public ActionResult AddListPro(Product pro)
 {
     if(ModelState.IsValid)
     {
         var ss = Session["Order_" + User.Identity.Name];
         if (ss == null)
         {
             List<Product> prolist = new List<Product>();
             prolist.Add(pro);
             Session["Order_" + User.Identity.Name] = prolist;
         }
         else
         {
             List<Product> prolist = (List<Product>)ss;
             prolist.Add(pro);
             Session["Order_" + User.Identity.Name] = prolist;
         }
     }
     return RedirectToAction("Index");
 }
コード例 #4
0
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                _prod.Add(product);
                return RedirectToAction("Create");
            }

            ViewBag.CategoryID = new SelectList(_cate.GetAll(), "CategoryID", "CategoryName", product.CategoryID);
            return Create();
            //return View(product);
        }