public override bool OnContextItemSelected(IMenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.MenuInfo; ListView listView = FindViewById <ListView>(Resource.Id.ArticleList); ArticleListView selectedItem = Tools.Cast <ArticleListView>(listView.Adapter.GetItem(info.Position)); switch (item.ItemId) { case 1: // Lagerbestand var storageDetails = new Intent(this, typeof(StorageItemQuantityActivity)); storageDetails.PutExtra("ArticleId", selectedItem.ArticleId); this.SaveListState(); this.StartActivityForResult(storageDetails, 20); return(true); case 2: // Auf Einkaufsliste AddToShoppingListDialog.ShowDialog( this, selectedItem.ArticleId, null, null, this.RefreshArticleList); return(true); default: return(base.OnContextItemSelected(item)); } }
private async void ButtonBarcode_Click(object sender, System.EventArgs e) { string eanCode; if (Debugger.IsAttached) { eanCode = "4006544205006"; } else { var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var scanResult = await scanner.Scan(); if (scanResult == null) { return; } eanCode = scanResult.Text; } TRACE("Scanned Barcode: {0}", eanCode); var result = Database.GetArticlesByEanCode(eanCode); if (result.Count == 0) { // Neuanlage Artikel var articleDetails = new Intent(this, typeof(ArticleDetailsActivity)); articleDetails.PutExtra("EANCode", eanCode); StartActivityForResult(articleDetails, ContinueScanMode); return; } List <string> actions; AlertDialog.Builder selectDialog = new AlertDialog.Builder(this); if (result.Count == 1) // Artikel eindeutig gefunden { int articleId = result[0].ArticleId; actions = new List <string>() { Resources.GetString(Resource.String.Main_Button_Lagerbestand), Resources.GetString(Resource.String.Main_Button_Artikelangaben), Resources.GetString(Resource.String.Main_Button_AufEinkaufsliste) }; var shoppingItemCount = Database.GetShoppingListQuantiy(articleId, -1); if (shoppingItemCount >= 0) { // Von der Einkaufsliste direkt ins Lager. actions.Add(Resources.GetString(Resource.String.Main_Button_InLagerbestand)); } selectDialog.SetTitle("Aktion wählen..."); selectDialog.SetItems(actions.ToArray(), (sender2, args) => { switch (args.Which) { case 0: // Lagerbestand bearbeiten var storageDetails = new Intent(this, typeof(StorageItemQuantityActivity)); storageDetails.PutExtra("ArticleId", articleId); storageDetails.PutExtra("EditMode", true); this.StartActivityForResult(storageDetails, ContinueScanMode); break; case 1: // Artikelstamm bearbeiten var articleDetails = new Intent(this, typeof(ArticleDetailsActivity)); articleDetails.PutExtra("ArticleId", articleId); StartActivityForResult(articleDetails, ContinueScanMode); break; case 2: // Auf die Einkaufsliste AddToShoppingListDialog.ShowDialog(this, articleId); break; case 3: if (shoppingItemCount == 0) { shoppingItemCount = 1; } // Aus Einkaufsliste ins Lager var storageDetails2 = new Intent(this, typeof(StorageItemQuantityActivity)); storageDetails2.PutExtra("ArticleId", articleId); storageDetails2.PutExtra("EditMode", true); storageDetails2.PutExtra("Quantity", (double)shoppingItemCount); this.StartActivityForResult(storageDetails2, EditStorageQuantity); break; } return; }); selectDialog.Show(); return; } actions = new List <string>() { Resources.GetString(Resource.String.Main_Button_LagerbestandListe), Resources.GetString(Resource.String.Main_Button_ArtikelListe) }; selectDialog.SetTitle("Aktion wählen..."); selectDialog.SetItems(actions.ToArray(), (sender2, args) => { switch (args.Which) { case 0: // Lagerbestand Liste var storageDetails = new Intent(this, typeof(StorageItemListActivity)); storageDetails.PutExtra("EANCode", eanCode); this.StartActivityForResult(storageDetails, ContinueScanMode); break; case 1: // Artikel Liste var articleDetails = new Intent(this, typeof(ArticleListActivity)); articleDetails.PutExtra("EANCode", eanCode); this.StartActivityForResult(articleDetails, ContinueScanMode); break; } return; }); selectDialog.Show(); return; }
private void SearchEANCode(string eanCode) { TRACE("Scanned Barcode: {0}", eanCode); var result = Database.GetArticlesByEanCode(eanCode); if (result.Count == 0) { // Neuanlage Artikel var articleDetails = new Intent(this, typeof(ArticleDetailsActivity)); articleDetails.PutExtra("EANCode", eanCode); StartActivityForResult(articleDetails, ContinueScanMode); return; } List <string> actions; AlertDialog.Builder selectDialog = new AlertDialog.Builder(this); if (result.Count == 1) // Artikel eindeutig gefunden { int articleId = result[0].ArticleId; string zusatzInfo = string.Empty; decimal quantityInStorage = Database.GetArticleQuantityInStorage(articleId); if (quantityInStorage > 0) { zusatzInfo += string.Format("- Bestand: {0:#,0.######}", quantityInStorage); } decimal shoppingListQuantiy = Database.GetShoppingListQuantiy(articleId); if (shoppingListQuantiy > 0) { if (!string.IsNullOrEmpty(zusatzInfo)) { zusatzInfo += "\n"; } zusatzInfo += string.Format("- Auf Einkaufsliste: {0:#,0.######}", shoppingListQuantiy); } actions = new List <string>() { Resources.GetString(Resource.String.Main_Button_Lagerbestand), Resources.GetString(Resource.String.Main_Button_Artikelangaben), Resources.GetString(Resource.String.Main_Button_AufEinkaufsliste) }; var shoppingItemCount = Database.GetShoppingListQuantiy(articleId, -1); if (shoppingItemCount >= 0) { // Von der Einkaufsliste direkt ins Lager. actions.Add(Resources.GetString(Resource.String.Main_Button_InLagerbestand)); } if (!string.IsNullOrEmpty(zusatzInfo)) { TextView info = new TextView(this); //info.SetBackgroundColor(Android.Graphics.Color.LightGray); info.SetTextColor(Android.Graphics.Color.Gray); info.SetPadding(25, 0, 0, 0); info.Text = zusatzInfo; selectDialog.SetView(info); } selectDialog.SetTitle("Aktion wählen..."); selectDialog.SetItems(actions.ToArray(), (sender2, args) => { switch (args.Which) { case 0: // Lagerbestand bearbeiten var storageDetails = new Intent(this, typeof(StorageItemQuantityActivity)); storageDetails.PutExtra("ArticleId", articleId); storageDetails.PutExtra("EditMode", true); this.StartActivityForResult(storageDetails, ContinueScanMode); break; case 1: // Artikelstamm bearbeiten var articleDetails = new Intent(this, typeof(ArticleDetailsActivity)); articleDetails.PutExtra("ArticleId", articleId); StartActivityForResult(articleDetails, ContinueScanMode); break; case 2: // Auf die Einkaufsliste AddToShoppingListDialog.ShowDialog(this, articleId); break; case 3: if (shoppingItemCount == 0) { shoppingItemCount = 1; } // Aus Einkaufsliste ins Lager var storageDetails2 = new Intent(this, typeof(StorageItemQuantityActivity)); storageDetails2.PutExtra("ArticleId", articleId); storageDetails2.PutExtra("EditMode", true); storageDetails2.PutExtra("Quantity", (double)shoppingItemCount); this.StartActivityForResult(storageDetails2, EditStorageQuantity); break; } return; }); selectDialog.Show(); return; } actions = new List <string>() { Resources.GetString(Resource.String.Main_Button_LagerbestandListe), Resources.GetString(Resource.String.Main_Button_ArtikelListe) }; selectDialog.SetTitle("Aktion wählen..."); selectDialog.SetItems(actions.ToArray(), (sender2, args) => { switch (args.Which) { case 0: // Lagerbestand Liste var storageDetails = new Intent(this, typeof(StorageItemListActivity)); storageDetails.PutExtra("EANCode", eanCode); this.StartActivityForResult(storageDetails, ContinueScanMode); break; case 1: // Artikel Liste var articleDetails = new Intent(this, typeof(ArticleListActivity)); articleDetails.PutExtra("EANCode", eanCode); this.StartActivityForResult(articleDetails, ContinueScanMode); break; } return; }); selectDialog.Show(); return; }