Exemplo n.º 1
0
        public static void AddPartialQuantityRow(DataGridView dataGridViewGood, DataGridView dataGridViewBad, 
												 string dirtyBarcode, double partialQuantity, LocalRepository localRepository)
        {
            var indexGood = dataGridViewGood.FindRowForGoodProduct(dirtyBarcode);
            var indexBad = dataGridViewBad.FindRowForBadProduct(dirtyBarcode);

            if (indexGood != -1)
            {
                var quantityGood = Convert.ToDouble(dataGridViewGood.Rows[indexGood].Cells[ProductQuantityCountedRow].Value);
                dataGridViewGood.Rows[indexGood].Cells[ProductQuantityCountedRow].Value = quantityGood + partialQuantity;

                localRepository.UpdateGoodQuantity(dirtyBarcode, quantityGood + partialQuantity);

                return;
            }

            var quantityBad = Convert.ToDouble(dataGridViewBad.Rows[indexBad].Cells[NotProductQuantityCountedRow].Value);
            dataGridViewBad.Rows[indexBad].Cells[NotProductQuantityCountedRow].Value = quantityBad + partialQuantity;

            localRepository.UpdateBadQuantity(dirtyBarcode, quantityBad + partialQuantity);

            return;
        }
Exemplo n.º 2
0
        public static bool DecreaseQuantityRow(DataGridView dataGridViewGood, DataGridView dataGridViewBad, 
											   string dirtyBarcode, LocalRepository localRepository)
        {
            var indexGood = dataGridViewGood.FindRowForGoodProduct(dirtyBarcode);
            var indexBad = dataGridViewBad.FindRowForBadProduct(dirtyBarcode);

            if (indexGood != -1)
            {
                var quantityGood = Convert.ToDouble(dataGridViewGood.Rows[indexGood].Cells[ProductQuantityCountedRow].Value);
                if (quantityGood > 0)
                {
                    dataGridViewGood.Rows[indexGood].Cells[ProductQuantityCountedRow].Value = --quantityGood;

                    localRepository.UpdateGoodQuantity(dirtyBarcode, quantityGood);

                    return true;
                }
                return false;
            }

            var quantityBad = Convert.ToDouble(dataGridViewBad.Rows[indexBad].Cells[NotProductQuantityCountedRow].Value);
            if (quantityBad > 0)
            {
                dataGridViewBad.Rows[indexBad].Cells[NotProductQuantityCountedRow].Value = --quantityBad;

                localRepository.UpdateBadQuantity(dirtyBarcode, quantityBad);

                return true;
            }
            return false;
        }