Beispiel #1
0
        protected void gvProductDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                Label        lblProductId    = (Label)gvProductDetails.Rows[e.RowIndex].FindControl("lblProductId");
                DropDownList ddlEditCategory = (DropDownList)gvProductDetails.Rows[e.RowIndex].FindControl("ddlEditCategory");
                //DropDownList ddlEditBrand = (DropDownList)gvProductDetails.Rows[e.RowIndex].FindControl("ddlEditBrand");
                TextBox txtEditProductName = (TextBox)gvProductDetails.Rows[e.RowIndex].FindControl("txtEditProductName");
                TextBox txtEditDescription = (TextBox)gvProductDetails.Rows[e.RowIndex].FindControl("txtEditDescription");


                TextBox txtEditWeight       = (TextBox)gvProductDetails.Rows[e.RowIndex].FindControl("txtEditWeight");
                TextBox txtstockinEditPrice = (TextBox)gvProductDetails.Rows[e.RowIndex].FindControl("txtstockinEditPrice");
                TextBox txtEditPrice        = (TextBox)gvProductDetails.Rows[e.RowIndex].FindControl("txtEditPrice");
                TextBox txtEditProduct      = (TextBox)gvProductDetails.Rows[e.RowIndex].FindControl("txtEditbarcode");
                TextBox txtEditthresh       = (TextBox)gvProductDetails.Rows[e.RowIndex].FindControl("txtEditThresh");
                //if (ddlEditCategory.SelectedItem.Text != ("") && ddlEditBrand.Text != ("") && txtEditProductName.Text != (""))
                if (ddlEditCategory.SelectedItem.Text != ("") && txtEditProductName.Text != (""))
                {
                    Domain.Product existing = productRepo.GetById(Convert.ToInt32(lblProductId.Text));
                    if (existing != null)
                    {
                        existing.CategoryId = Convert.ToInt32(ddlEditCategory.SelectedValue);
                        //existing.BrandId = Convert.ToInt32(ddlEditBrand.SelectedValue);
                        existing.ProductName        = txtEditProductName.Text;
                        existing.ProductDescription = txtEditDescription.Text;
                        existing.ProductWeight      = txtEditWeight.Text;
                        existing.StockInPrice       = Convert.ToDecimal(txtstockinEditPrice.Text);
                        existing.ProductPrice       = Convert.ToDecimal(txtEditPrice.Text);
                        //existing.BarCode = Convert.ToDecimal(txtEditProduct.Text);
                        existing.ThreshHold       = Convert.ToInt32(txtEditthresh.Text);
                        existing.LastUpdatedBy    = "admin";
                        existing.LastUpdationTime = DateTime.Now;
                        existing.TenantId         = tenantId;
                    }


                    productRepo.Edit(existing);
                    productRepo.Save();
                    gvProductDetails.EditIndex = -1;
                    BindData();
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Product Sucessfully Updated');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Null Filled Not allowed');", true);
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        protected void gvProductDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.Equals("ADD"))
                {
                    Button       btnadd         = (Button)gvProductDetails.FooterRow.FindControl("lbtnAdd");
                    DropDownList ddlAddCategory = (DropDownList)gvProductDetails.FooterRow.FindControl("ddlAddCategory");
                    //DropDownList ddlAddBrand = (DropDownList)gvProductDetails.FooterRow.FindControl("ddlAddBrand");
                    TextBox txtAddProductName = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddProductName");
                    TextBox txtAddDescription = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddDescription");
                    TextBox txtAddthresh      = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddThresh");

                    TextBox txtAddWeight = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddWeight");
                    TextBox txtAddPrice  = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddPrice");
                    //TextBox txtAddbarcode = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddbarcode");
                    TextBox txtstockinprice = (TextBox)gvProductDetails.FooterRow.FindControl("txtstockinAddPrice");
                    //btn.Visible = false;
                    btnadd.Enabled = false;

                    //TextBox txtAddFeatureName = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddFeatureName");
                    //TextBox txtAddDescription = (TextBox)gvProductDetails.FooterRow.FindControl("txtAddDescription");
                    //if (ddlAddCategory.SelectedItem.Text != ("") && ddlAddBrand.Text != ("") && txtAddProductName.Text != ("")) if (ddlAddCategory.SelectedItem.Text != ("") && ddlAddBrand.Text != ("") && txtAddProductName.Text != (""))
                    if (ddlAddCategory.SelectedItem.Text != ("") && txtAddProductName.Text != (""))
                    {
                        Domain.Product product = new Domain.Product()
                        {
                            CategoryId = Convert.ToInt32(ddlAddCategory.SelectedValue),
                            //BrandId = Convert.ToInt32(ddlAddBrand.SelectedValue),
                            ProductName        = txtAddProductName.Text,
                            ProductDescription = txtAddDescription.Text,
                            ProductWeight      = txtAddWeight.Text,
                            StockInPrice       = !string.IsNullOrWhiteSpace(txtstockinprice.Text) ? Convert.ToDecimal(txtstockinprice.Text) : 0,
                            ProductPrice       = !string.IsNullOrWhiteSpace(txtAddPrice.Text) ? Convert.ToDecimal(txtAddPrice.Text) : 0,
                            ThreshHold         = !string.IsNullOrWhiteSpace(txtAddthresh.Text) ? (Convert.ToInt32(txtAddthresh.Text)) : 0,
                            CreationTime       = DateTime.Now,
                            LastUpdationTime   = DateTime.Now,
                            CreatedBy          = "admin",
                            LastUpdatedBy      = "admin",
                            TenantId           = tenantId,
                        };

                        productRepo.Add(product);
                        productRepo.Save();
                        BindData();
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Product Sucessfully Inserted');", true);
                        BindData();
                        btnadd.Enabled = true;
                    }

                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Null Filled Not allowed');", true);
                        btnadd.Enabled = true;
                    }
                }
                //BindData();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }