Exemplo n.º 1
0
    private void BindProduct()
    {
        try
        {
            if (txtSearch.Text.Trim() != "Search")
            {
                objPI.SearchText = txtSearch.Text.Trim();
            }
            else
            {
                objPI.SearchText = "";
            }

            if (objPI.SortDirection == null && objPI.SortColumnName == null)
            {
                objPI.SortDirection = Convert.ToString(ViewState[Constants.SORTDERECTION]);
                objPI.SortColumnName = Convert.ToString(ViewState[Constants.SORTCOLUMNNAME]);
            }
            //List<Manufacturer> objData = new ManufacturerBLL().GetAll(objPI);

            BLL.Component.ProductBLL objprod = new BLL.Component.ProductBLL();
            gvGrid.DataSource = objprod.GetStockByDate(objPI, toDate.Value);
            gvGrid.DataBind();
        }
        catch (Exception ex)
        {
            SendMail.MailMessage("CSWeb > Error > " + (new System.Diagnostics.StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
        }
    }
Exemplo n.º 2
0
    protected void gvGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            Product objProd = new Product();
            TextBox txtControl;

            txtControl = ((TextBox)gvGrid.Rows[e.RowIndex].FindControl("txtProductIDE"));
            if (txtControl.Text != null)
            {
                objProd.ProductID = Convert.ToInt32(txtControl.Text.Trim());
            }

            txtControl = ((TextBox)gvGrid.Rows[e.RowIndex].FindControl("txtProductNameE"));
            if (txtControl != null)
            {
                objProd.ProductName = txtControl.Text.Trim();

            }

            txtControl = ((TextBox)gvGrid.Rows[e.RowIndex].FindControl("txtDescriptionE"));
            if (txtControl != null)
            {
                objProd.Description = txtControl.Text.Trim();

            }

            txtControl = ((TextBox)gvGrid.Rows[e.RowIndex].FindControl("txtMarginE"));
            if (txtControl != null)
            {
                objProd.Margin = Convert.ToDecimal(txtControl.Text.Trim());

            }
            objProd.UpdatedBy = 1;
            int mintReturn = new BLL.Component.ProductBLL().EditProduct(objProd);
            if (mintReturn == -1)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Brand with same name already exists.');", true);
            }
        }
        catch (Exception ex)
        {
        }

        //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Updated successfully');", true);
        gvGrid.EditIndex = -1;
        BindProduct();

    }