public static void UpdateRow(this DataGridView dataGridView, Product product) { var index = dataGridView.FindRowForProduct(product); switch (product.BarcodeType) { case BarcodeTypes.Delivery: case BarcodeTypes.Ean: if (index == -1) dataGridView.AddNewProductRow(null, product); else dataGridView.ChangeExistingProductRow(index, null, product); break; case BarcodeTypes.NotExisting: if (index == -1) dataGridView.AddNewProductRow("Błąd - Nie istniejący", product); else dataGridView.ChangeExistingProductRow(index, "Błąd - Nie istniejący", product); break; case BarcodeTypes.Selled: if (index == -1) dataGridView.AddNewProductRow("Błąd - Sprzedany", product); else dataGridView.ChangeExistingProductRow(index, "Błąd - Sprzedany", product); break; } dataGridView.Sort(dataGridView.Columns[DateModifiedRow], ListSortDirection.Descending); }
private static void AddNewProductRow(this DataGridView dataGridView, string typeName, Product product) { var productName = String.IsNullOrEmpty(typeName) ? product.Name : typeName; dataGridView.Rows.Add(product.ID, product.BarcodeType, product.DirtyBarcode, product.CleanBarcode, productName, 1, DateTime.Now, DateTime.Now); }
private static void ChangeExistingProductRow(this DataGridView dataGridView, int index, string typeName, Product product) { var quantityFromRow = (int) dataGridView.Rows[index].Cells[QuantityCountRow].Value; var dateAddedFromRow = (DateTime) dataGridView.Rows[index].Cells[DateAddedRow].Value; var productName = String.IsNullOrEmpty(typeName) ? product.Name : typeName; dataGridView.Rows[index].SetValues(product.ID, product.BarcodeType, product.DirtyBarcode, product.CleanBarcode, productName, ++quantityFromRow, dateAddedFromRow, DateTime.Now); }
public Product FindProduct(string barcode) { var product = new Product(); try { //using delivery code var deliveryProduct = (from zk in _remoteDatabase.ZDST_KLAS.Include("ZDST.TOWARY") where zk.ID_KLASYFIKACJE == 6 && zk.WARTOSC == barcode && zk.ID_APTEKI == PharmacyId select new {zk.ZDST.CZYNNY, zk.ZDST.TOWARY.ID_TOWARY, zk.ZDST.TOWARY.NAZWA}).Single(); product.ID = deliveryProduct.ID_TOWARY; product.Name = deliveryProduct.NAZWA; product.CleanBarcode = barcode; product.BarcodeType = deliveryProduct.CZYNNY == "T" ? BarcodeTypes.Delivery : BarcodeTypes.Selled; } catch (InvalidOperationException) { //using EAN try { var tempProduct = (from tw in _remoteDatabase.TOWARY where tw.EAN_REF == barcode && tw.ID_APTEKI == PharmacyId select new {tw.ID_TOWARY, tw.NAZWA}).Single(); product.ID = tempProduct.ID_TOWARY; product.Name = tempProduct.NAZWA; product.CleanBarcode = barcode; product.BarcodeType = BarcodeTypes.Ean; } catch (InvalidOperationException) { product.ID = 0; product.Name = null; product.CleanBarcode = barcode; product.BarcodeType = BarcodeTypes.NotExisting; } } return product; }
private static int FindRowForGoodProduct(this DataGridView dataGridView, Product product) { var index = -1; try { if (dataGridView.Rows.Count > 0) { foreach (DataGridViewRow row in dataGridView.Rows) { if (row.Cells[ProductIdRow].Value.ToString() == product.ID.ToString() && row.Cells[ProductDirtyBarcode].Value.ToString() == product.DirtyBarcode) { index = row.Index; } } } } catch (InvalidOperationException) { index = -1; } return index; }
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); }
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); }
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); }
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, ""); }
public static void UpdateLog(this ListBox listBox, string clientName, string clientGuid, string eventMessage, Product product, string firstEvent) { if (product != null) { if (string.IsNullOrEmpty(product.Name)) { listBox.Items.Add(string.Format("({0}) {1} ({2}), wykonał operację: {3}, na: {4} ({5})", DateTime.Now.ToShortTimeString(), clientName, clientGuid, eventMessage, "Nie istniejący/sprzedany", product.CleanBarcode)); } else { listBox.Items.Add(string.Format("({0}) {1} ({2}), wykonał operację: {3}, na: {4} ", DateTime.Now.ToShortTimeString(), clientName, clientGuid, eventMessage, product.Name)); } } else { listBox.Items.Add(string.Format("({0}) {1} ({2}), wykonał operację: {3}, na: {4} ", DateTime.Now.ToShortTimeString(), clientName, clientGuid, eventMessage, firstEvent)); } listBox.SelectedIndex = listBox.Items.Count - 1; listBox.SelectedIndex = -1; }
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); }
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); }
private void EnqueueBackgroundServerEventStack(BackgroundServerEventCommands eventCommand, Product product, string firstEvent, string secondEvent, string prefix, string clientName, string clientGuid) { _backgroundServerMessageStack.Enqueue(new BackgroundServerEventStack { Product = product, EventCommand = eventCommand, FirstEvent = firstEvent, SecondEvent = secondEvent, Prefix = prefix, ClientGuid = clientGuid, ClientName = clientName }); }
private void EnqueueBackgroundEventStack(Product product, BackgroundEventCommands eventCommand, string eventText) { BackgroundMessageStacks.Enqueue(new BackgroundEventStack { Product = product, EventCommand = eventCommand, Event = eventText }); ReportProgress(0); }