public BackgroundServerWithWcf()
        {
            WorkerReportsProgress = true;
            WorkerSupportsCancellation = true;

            _host = new Host();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }