protected void grdInventory_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        DataTable productList = (DataTable)Page.ViewState["ProductList"];
        Inventory inv = new Inventory();
        ProductManager pManager = new ProductManager(this);

        var productName = (grdInventory.Rows[e.RowIndex].FindControl("txtProduct") as TextBox).Text;
        var product = pManager.GetProductByName((int)Company.MatrixId, productName);
        if (product != null)
        {
            inv.ProductId = product.ProductId;
            inv.Quantity = Convert.ToInt16((grdInventory.Rows[e.RowIndex].FindControl("txtQuantity") as TextBox).Text);
            AddProduct(inv, productName);
            BindGrid();
            e.Cancel = true;
        }
        else
        {
            ShowError(Resources.Exception.nonexistentProduct);
            BindGrid();
        }

    }
    protected void grdInventory_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        DataTable productList = (DataTable)Page.ViewState["ProductList"];
        Inventory inv = new Inventory();
        ProductManager pManager = new ProductManager(this);

        var productName = (grdInventory.Rows[e.RowIndex].FindControl("txtProduct") as TextBox).Text;
        var product = pManager.GetProductByName(Company.CompanyId, productName);
        if (product != null)
        {
            inv.ProductId = product.ProductId;
            inv.Quantity = Convert.ToInt16((grdInventory.Rows[e.RowIndex].FindControl("txtQuantity") as TextBox).Text);
            AddProduct(inv, productName);
            BindGrid();
            e.Cancel = true;
        }
        else
        {
            ShowError("Esse produto ainda não foi cadastrado,<br />faça o cadastro na tela de produtos, e tente novamente<br /><br />");
            BindGrid();
        }

    }
Example #3
0
    /// <summary>
    /// this method add a existent product in DataTable Products
    /// </summary>
    private void AddExistentProduct()
    {

        if (Deposit == null)
        {
            ShowError("O usuário não está habilitado para gerar vendas!");
            return;
        }

        var iManager = new InventoryManager(this);
        var pManager = new ProductManager(this);
        Inventory productInInventory;

        var product = pManager.GetProductByName(Company.CompanyId, selProduct.Product.Name);

        decimal unitCost = 0;
        decimal unitPrice = 0;

        if (ucTxtUnitPrice.CurrencyValue.HasValue)
            unitPrice = ucTxtUnitPrice.CurrencyValue.Value;

        productInInventory = iManager.GetProductInventory(Company.CompanyId, product.ProductId, Deposit.DepositId);

        if (productInInventory != null)
        {
            if (unitPrice == 0)
                unitPrice = productInInventory.UnitPrice;
            unitCost = productInInventory.RealCost;
        }

        Page.ViewState["InventoryProductId"] = product.ProductId;

        if (!ucTxtUnitPrice.CurrencyValue.HasValue)
            ucTxtUnitPrice.CurrencyValue = 0;

        addProductRow(product.ProductId, ucCurrFieldQuantityData.IntValue, product.Name, product.ProductCode, unitPrice, unitCost);
    }
    protected void btnServiceOrderItemProduct_Click(object sender, ImageClickEventArgs e)
    {
        //search the Product in Inventory
        productManager = new ProductManager(this);
        inventoryManager = new InventoryManager(this);

        Product product = productManager.GetProductByName(Company.CompanyId, txtProduct.Text);

        litErrorMessage.Visible = false;

        if (product != null)
        {
            if (!String.IsNullOrEmpty(cboDeposit.SelectedValue))
                if (!IsValidProductWithDeposit(product))
                    return;

            if (ucCurrFieldQuantity.IntValue == 0)
            {
                litErrorMessage.Visible = true;
                litErrorMessage.Text = "Quantidade não pode ser zero!";
                return;
            }

            Decimal productPrice = Decimal.Zero;
            Inventory inventory = inventoryManager.GetProductInventory(Company.CompanyId, product.ProductId, Deposit.DepositId);
            if (inventory != null)
                productPrice = inventory.UnitPrice;

            ProductItem productItem = new ProductItem(product.CompanyId, product.ProductId, product.Name, ucCurrFieldQuantity.IntValue, txtDescription.Text, productPrice, Convert.ToBoolean(choProductIsApplied.Checked));
            ProductItemsList.Add(productItem);
            BindProducts();

            txtProduct.Text = String.Empty;
            txtDescription.Text = String.Empty;
            ucCurrFieldQuantity.Text = String.Empty;
        }
    }