protected void btnSave_Click(object sender, EventArgs e)
    {
        #region ServerSide Validation


        #endregion ServerSide Validations

        ProductENT entProduct = new ProductENT();
        ProductBAL balProduct = new ProductBAL();

        #region Gather Data

        if (txtProductName.Text.Trim() != String.Empty)
        {
            entProduct.ProductName = txtProductName.Text.Trim();
        }

        entProduct.CreationDate = DateTime.Now;

        entProduct.UserID = Convert.ToInt32(Session["UserID"]);

        if (Request.QueryString["ProductID"] == null)
        {
            balProduct.Insert(entProduct);
            lblMessage.Text = "Data Insert SuccessFully";
            ClearControl();
        }
        else
        {
            entProduct.ProductID = Convert.ToInt32(Request.QueryString["ProductID"]);
            balProduct.Update(entProduct);
            Response.Redirect("~/AdminPanel/Product/ProductList.aspx");
        }

        #endregion Gather Data
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        #region ServerSide Validation
        String strErrorMessage = "";

        if (ddlCategoryID.SelectedIndex <= 0)
        {
            strErrorMessage += "Select Category<br/>";
        }

        if (txtProductName.Text == "")
        {
            strErrorMessage += "Enter Product Name<br/>";
        }

        if (txtDescription.Text == "")
        {
            strErrorMessage += "Enter Description<br/>";
        }

        if (txtPrice.Text == "")
        {
            strErrorMessage += "Enter Price<br/>";
        }

        if (strErrorMessage != "")
        {
            lblMessage.Text    = strErrorMessage;
            divMessage.Visible = true;
        }

        #endregion ServerSide Validation

        #region Collect FormData
        ProductENT entProduct = new ProductENT();

        if (ddlCategoryID.SelectedIndex != 0)
        {
            entProduct.CategoryID = Convert.ToInt32(ddlCategoryID.SelectedValue);
        }

        if (txtProductName.Text != "")
        {
            entProduct.ProductName = txtProductName.Text.Trim();
        }

        if (txtDescription.Text != "")
        {
            entProduct.Description = txtDescription.Text.Trim();
        }

        if (txtPrice.Text != "")
        {
            entProduct.Price = Convert.ToInt32(txtPrice.Text.Trim());
        }

        #region Upload File
        if (fuProductImage.HasFile)
        {
            string strPath = "~/ProductImage/";
            if (ddlCategoryID.SelectedItem.ToString() == "Calendar")
            {
                strPath += "Calendar/";
            }
            if (ddlCategoryID.SelectedItem.ToString() == "T-shirt")
            {
                strPath += "T-shirt/";
            }
            if (ddlCategoryID.SelectedItem.ToString() == "Canvas")
            {
                strPath += "Canvas/";
            }
            string strPhysicalPath = Server.MapPath(strPath) + fuProductImage.FileName;
            fuProductImage.SaveAs(strPhysicalPath);
            entProduct.ProductImage = strPath + fuProductImage.FileName;
        }
        else
        {
            lblMessage.Text    = "Select File";
            divMessage.Visible = true;
        }
        #endregion Upload File

        #endregion Collect FormData

        ProductBAL balProduct = new ProductBAL();

        if (Request.QueryString["ProductID"] == null)
        {
            if (balProduct.Insert(entProduct))
            {
                ClearControls();
                lblMessage.Text    = "Add Successfully";
                divMessage.Visible = true;
            }
            else
            {
                lblMessage.Text    = balProduct.Message;
                divMessage.Visible = true;
            }
        }
        else
        {
            entProduct.ProductID = Convert.ToInt32(Request.QueryString["ProductID"]);

            if (balProduct.Update(entProduct))
            {
                ClearControls();
                Response.Redirect("~/AdminPanel/Product/ProductList.aspx");
            }
            else
            {
                lblMessage.Text    = balProduct.Message;
                divMessage.Visible = true;
            }
        }
    }