protected void btnaddproduct_Click(object sender, EventArgs e)
    {
        ProductModel productmodel = new ProductModel();
        Product      product      = CreateProduct();

        LblResult.Text = productmodel.AddProduct(product);
    }
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         try
         {
             ProductModel model   = new ProductModel();
             Product      product = CreateProduct();
             if (int.TryParse(Request.QueryString["id"], out int id))
             {
                 if (id > 0)
                 {
                     Response.Write("<script>alert('" + model.UpdateProduct(id, product) +
                                    "'); window.location='Management.aspx';</script>");
                 }
             }
             else
             {
                 Response.Write("<script>alert('" + model.AddProduct(product) +
                                "'); window.location='Management.aspx';</script>");
             }
         }
         catch (Exception ex)
         {
             LabelResult.Text = ex.Source + "\n" + ex.Message;
         }
     }
 }
Beispiel #3
0
        public ActionResult AddPrdctAndDoc(String productname, String productdesc, String docdtls)
        {
            Int32 prdctid = 0;
            if (productname != null && productdesc != null)
            {
                prdctid = prdctmdl.AddProduct(productname, productdesc);
                if (prdctmdl.error == null)
                {
                    if (prdctid != 0)
                    {
                        if (Convert.ToString(docdtls) != null)
                        {
                            String msg = prdctmdl.AddDocument(docdtls);
                            if (prdctmdl.error == null)
                            {
                                return Json("Records Inserted successfully. Mail sent to Main Authors.");

                            }
                        }
                    }
                    return Json(prdctmdl.Message);
                }
                {
                    return Json(prdctmdl.error);
                }
            }
            return Json("Fileds Empty.");
        }
 public void Add()
 {
     TestServiceReference.Product newProduct = new TestServiceReference.Product();
     newProduct.Count      = this.Count;
     newProduct.Name       = this.Name;
     newProduct.Price      = this.Price;
     newProduct.CustomerId = this.Customer.Id;
     model.AddProduct(newProduct);
     RefreshList();
 }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "Name,Description,Category,Producer,Supplier,Price")] Product product)
        {
            if (ModelState.IsValid)
            {
                model.AddProduct(product);
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
 private void SaveExecute()
 {
     try
     {
         productModel.AddProduct(Product);
         apv.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception " + ex.Message.ToString());
     }
 }
        public bool AddProduct()
        {
            string   ProductID   = View.ProductID;
            string   ProductName = View.ProductName1;
            string   CategoryID  = View.CategoryID;
            string   SupplierID  = View.SupplierID;
            float    Price       = View.Price;
            int      Quantity    = View.Quantity;
            DateTime CreateDate  = DateTime.Now;
            Product  p           = new Product(ProductID, ProductName, CategoryID, SupplierID, Price, Quantity, CreateDate, true);

            return(ProductModel.AddProduct(p));
        }
Beispiel #8
0
 public void AddProduct()
 {
     try
     {
         ProductModel.AddProduct(AddedProduct);
         Products        = new ObservableCollection <Product>(ProductModel.Products);
         AddedProduct    = new Product();
         SelectedProduct = Products.Last();
     }
     catch (System.Data.SqlClient.SqlException e)
     {
         MessageBox.Show("Dodanie nowego produktu nie powiodło się: " + e.Message, "Błąd dodawania");
     }
 }
 public IActionResult Create(ProductModel model)
 {
     model.AddProduct();
     return RedirectToAction("GetAll");
 }