Exemple #1
0
        private void insertProduct()
        {
            tblProduct          = adpProduct.GetData();
            Cache["tblProduct"] = tblProduct;

            string  name    = txtProductName.Text;
            decimal price   = decimal.Parse(txtPrice.Text);
            int     quant   = int.Parse(txtQuantity.Text);
            int     categID = int.Parse(ddlCategory.SelectedValue);

            int result = adpProduct.Insert(name, price, quant, categID);

            if (result == 1)
            {
                lblErrorMessage.Text      = "Product Inserted ";
                lblErrorMessage.ForeColor = System.Drawing.Color.Yellow;
                txtProductName.Text       = "";
                txtProductNumber.Text     = "";
                ddlCategory.SelectedIndex = -1;
                txtPrice.Text             = "";
                txtQuantity.Text          = "";
            }
            else
            {
                lblErrorMessage.Text      = "Product NOT Inserted";
                lblErrorMessage.ForeColor = System.Drawing.Color.Red;
            }
            Refresh();
        }
        //code to add product into the data base
        protected void btn_add_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (ddl_Category.SelectedIndex > 0)
                {
                    string  name  = txtname.Text;
                    string  desc  = txtdesc.Text;
                    decimal price = decimal.Parse(txtprice.Text);
                    int     qty   = Int32.Parse(txtqty.Text);
                    int     Cat   = ddl_Category.SelectedIndex;

                    adpProd.Insert(name, desc, price, qty, Cat);

                    lblMessage.Text      = "Product" + name + "Added Successfully!";
                    lblMessage.ForeColor = System.Drawing.Color.Green;
                    RefreshTable();
                }
            }
            else
            {
                lblMessage.Text      = "Validation Failed!";
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Exemple #3
0
        /// <summary>
        /// Method called when AddProduct button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddProduct_Click(object sender, EventArgs e)
        {
            string  productName  = txtProductName.Text;
            string  productDesc  = txtPtoductDesc.Text;
            int     productQty   = int.Parse(txtProductQty.Text);
            string  productType  = ddlProductType.SelectedValue;
            decimal productPrice = decimal.Parse(txtProductPrice.Text);
            string  productBrand = txtProductBrand.Text;
            string  productImage = flProductImage.FileName;
            int     userId       = user.UserId;
            int     categoryId   = int.Parse(ddlProductCategory.SelectedValue);

            bool result = false;

            if (product != null && Request.QueryString["ProductId"] != null)
            {
                if (!flProductImage.HasFile)
                {
                    productImage = product.ProductImage;
                }
                else
                {
                    productImage = flProductImage.FileName;
                }
                result = true;
            }
            else
            {
                result = uploadFile();
            }

            if (!flProductImage.HasFile || result)
            {
                int rowInserted;
                if (product != null && Request.QueryString["ProductId"] != null)
                {
                    rowInserted = adpProduct.Update(
                        productName, productDesc, productType, productPrice, productBrand, productImage, userId, categoryId, productQty, product.ProductId);
                }
                else
                {
                    if (!flProductImage.HasFile)
                    {
                        productImage = "default.jpg";
                    }
                    rowInserted = adpProduct.Insert(productName, productDesc, productType, productPrice, productBrand, productImage, userId, categoryId, productQty);
                }
                if (rowInserted > 0)
                {
                    Response.Redirect("~/MyProducts.aspx");
                }
                else
                {
                }
            }
        }
Exemple #4
0
 public int Insert(ProductInfo info)
 {
     return(db.Insert(info.pc_id, info.pcs_id, info.p_name, info.p_serial, info.p_status, info.p_show, info.p_show_hot, info.p_detail, info.p_stock, info.p_stock_unit, info.p_price1, info.p_price2, info.p_price3, info.p_price4, info.p_price5, info.p_createDate, info.p_editDate, info.p_hits, InsertSorting(info.pc_id), info.p_img, info.p_files, info.l_id));
 }
 public void Insert(Product product)
 {
     _product.Insert(product.Name, product.BrandId, product.Description, product.Price, product.Size,
                     product.Stock, product.CategoryId, product.Colour);
 }