Esempio n. 1
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;
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        private static void ChangeExistingBadProductRow(this DataGridView dataGridView, Product product, 
														string typeName, int index, LocalRepository localRepository)
        {
            var qCountedFromRow = Convert.ToDouble(dataGridView.Rows[index].Cells[NotProductQuantityCountedRow].Value);
            var connectedWithProduct = dataGridView.Rows[index].Cells[NotProductConnectedWithProduct].Value;
            var clientAdded = dataGridView.Rows[index].Cells[NotProductClientAdded].Value;
            var clientConnected = dataGridView.Rows[index].Cells[NotProductClientConnected].Value;
            var dateAdded = dataGridView.Rows[index].Cells[NotProductDateAdded].Value;
            var dateConnected = dataGridView.Rows[index].Cells[NotProductDateConnected].Value;

            dataGridView.Rows[index].SetValues(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                               typeName, ++qCountedFromRow, connectedWithProduct,
                                               clientAdded, clientConnected, dateAdded,
                                               dateConnected);

            localRepository.ChangeBadProduct(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                             typeName, ++qCountedFromRow, connectedWithProduct,
                                             clientAdded, clientConnected, dateAdded,
                                             dateConnected);
        }
Esempio n. 4
0
        private static void ChangeExistingGoodProductRow(this DataGridView dataGridView, Product product, 
														 Host host, int index, string typeName, string clientName, 
														 string clientGuid, LocalRepository localRepository)
        {
            var qCountedFromRow = Convert.ToDouble(dataGridView.Rows[index].Cells[ProductQuantityCountedRow].Value);
            var qBegginingFromRow = dataGridView.Rows[index].Cells[ProductQuantityFromBeginning].Value;
            var clientAdded = dataGridView.Rows[index].Cells[ProductAddedClient].Value;
            var dateAdded = dataGridView.Rows[index].Cells[ProductDateAdded].Value;

            double qFromDatabase = 0;
            switch (product.BarcodeType)
            {
                case BarcodeTypes.Ean:
                    qFromDatabase = host.ProductService.GetEanQuantity(product.ID);
                    break;

                case BarcodeTypes.Delivery:
                    qFromDatabase = host.ProductService.GetDeliveryQuantity(product.CleanBarcode);
                    break;
            }

            dataGridView.Rows[index].SetValues(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                               product.Name, typeName, ++qCountedFromRow,
                                               qFromDatabase, qBegginingFromRow, clientAdded,
                                               string.Format("{0} ({1})", clientName, clientGuid), dateAdded, DateTime.Now);

            localRepository.ChangeGoodProduct(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                              product.Name, typeName, qCountedFromRow,
                                              qFromDatabase, qBegginingFromRow, clientAdded,
                                              string.Format("{0} ({1})", clientName, clientGuid), dateAdded, DateTime.Now);
        }
Esempio n. 5
0
        private static void AddNewGoodProductRow(this DataGridView dataGridView, Product product, Host host, 
												 string typeName, string clientName, string clientGuid, 
												 LocalRepository localRepository)
        {
            double quantity = 0;
            switch (product.BarcodeType)
            {
                case BarcodeTypes.Ean:
                    quantity = host.ProductService.GetEanQuantity(product.ID);
                    break;

                case BarcodeTypes.Delivery:
                    quantity = host.ProductService.GetDeliveryQuantity(product.CleanBarcode);
                    break;
            }

            dataGridView.Rows.Add(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                  product.Name, typeName, 1,
                                  quantity, quantity, string.Format("{0} ({1})", clientName, clientGuid),
                                  string.Format("{0} ({1})", clientName, clientGuid), DateTime.Now, DateTime.Now);

            localRepository.AddGoodProduct(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                                    product.Name, typeName, 1,
                                                    quantity, quantity, string.Format("{0} ({1})", clientName, clientGuid),
                                                    string.Format("{0} ({1})", clientName, clientGuid), DateTime.Now, DateTime.Now);
        }
Esempio n. 6
0
        private static void AddNewBadProductRow(this DataGridView dataGridView, Product product, string typeName, 
												string clientName, string clientGuid, LocalRepository localRepository)
        {
            dataGridView.Rows.Add(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                  typeName, 1, "",
                                  string.Format("{0} ({1})", clientName, clientGuid), "", DateTime.Now,
                                  "");

            localRepository.AddBadProduct(product.ID, product.DirtyBarcode, product.CleanBarcode,
                                                   typeName, 1, "",
                                                   string.Format("{0} ({1})", clientName, clientGuid), "", DateTime.Now,
                                                   "");
        }
Esempio n. 7
0
        public static void UpdateGoodRow(this DataGridView dataGridView, Product product, Host host, 
										 string clientName, string clientGuid, LocalRepository localRepository)
        {
            var index = dataGridView.FindRowForGoodProduct(product);
            switch (product.BarcodeType)
            {
                case BarcodeTypes.Delivery:
                    if (index == -1) dataGridView.AddNewGoodProductRow(product, host, "Dostawy", clientName,
                                                                       clientGuid, localRepository);
                    else dataGridView.ChangeExistingGoodProductRow(product, host, index, "Dostawy", clientName,
                                                                   clientGuid, localRepository);
                    break;

                case BarcodeTypes.Ean:
                    if (index == -1) dataGridView.AddNewGoodProductRow(product, host, "Produkt", clientName,
                                                                       clientGuid, localRepository);
                    else dataGridView.ChangeExistingGoodProductRow(product, host, index, "Produkt", clientName,
                                                                   clientGuid, localRepository);
                    break;
            }

            dataGridView.Sort(dataGridView.Columns[ProductDateModified], ListSortDirection.Descending);
        }
Esempio n. 8
0
        public static void UpdateBadRow(this DataGridView dataGridView, Product product, string clientName, 
										string clientGuid, LocalRepository localRepository)
        {
            var index = dataGridView.FindRowForBadProduct(product);
            switch (product.BarcodeType)
            {
                case BarcodeTypes.NotExisting:
                    if (index == -1) dataGridView.AddNewBadProductRow(product, "Nie istniejący", clientName,
                                                                      clientGuid, localRepository);
                    else dataGridView.ChangeExistingBadProductRow(product, "Nie istniejący", index, localRepository);
                    break;

                case BarcodeTypes.Selled:
                    if (index == -1) dataGridView.AddNewBadProductRow(product, "Sprzedany", clientName, clientGuid, localRepository);
                    else dataGridView.ChangeExistingBadProductRow(product, "Sprzedany", index, localRepository);
                    break;
            }

            dataGridView.Sort(dataGridView.Columns[NotProductDateConnected], ListSortDirection.Descending);
        }
Esempio n. 9
0
        private void MainFormShown(object sender, EventArgs e)
        {
            Text += @" - ver.: " + Version;

            _localRepository = new LocalRepository();
            _localRepository.CreateSession(DateTime.Now);

            foreach (var session in _localRepository.GetAllSessions())
            {
                listBoxSessionHistory.Items.Add(string.Format("({0}) - {1}", session.ID, session.DateAdded));
            }

            if (listBoxSessionHistory.Items.Count > 0)
            {
                listBoxSessionHistory.SelectedIndex = 0;
            }
        }