Exemplo n.º 1
0
        public bool ValidateQuantity(int productId, decimal enterdQuantity, int batchId)
        {
            bool isfail = false;

            try
            {
                decimal availableQuantity = context.GetBatchwiseQuantity(batchId, productId).FirstOrDefault().Value;
                if (!btnUpdate.Visible)
                {
                    for (int i = 0; i <= gvSalesdetails.Rows.Count - 1; i++)
                    {
                        int     pId = Convert.ToInt32(gvSalesdetails.Rows[i].Cells[3].Text);
                        decimal qty = Convert.ToDecimal(gvSalesdetails.Rows[i].Cells[6].Text);
                        int     bId = Convert.ToInt32(gvSalesdetails.Rows[i].Cells[11].Text);
                        if (pId == productId && batchId == bId)
                        {
                            isfail = true;
                            lblcheckDoubleError.Visible = true;
                            lblcheckDoubleError.Text    = "Already product and batch added, Please select different product and batch or update existing product.";
                            return(isfail);
                        }
                    }
                }
                if (enterdQuantity > availableQuantity)
                {
                    isfail = true;
                    lblcheckDoubleError.Visible = true;
                    lblcheckDoubleError.Text    = "Out of stock";
                    return(isfail);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.saveerror(ex);
            }
            return(isfail);
        }