Ejemplo n.º 1
0
 private void OnRemoveClicked(object sender, EventArgs e)
 {
     if (mSelectedInventoryClass.Id != null)
     {
         Inventorylog newInventoryLog = new Inventorylog()
         {
             InventoryId   = mSelectedInventoryClass.Id,
             Description   = mSelectedInventoryClass.ItemName + " Removed By " + mUser.Username,
             LogDate       = DateTime.Now,
             CreatedUserId = mUser.ID.ToString(),
             AddedUserId   = mUser.ID.ToString()
         };
         new Thread(new ThreadStart(delegate
         {
             var isAdded   = mInventoryLogDataService.Add(newInventoryLog);
             var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id);
             if (isDeleted)
             {
                 UpdateInventories();
                 UpgradeProgress();
                 this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show());
                 mProgressBar.Visibility = Android.Views.ViewStates.Invisible;
             }
             else
             {
                 this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
             }
         })).Start();
     }
 }
Ejemplo n.º 2
0
        private void InventoryOptions_OnComplete(object sender, OnHomeInventoryDialogPicked e)
        {
            var menu = e.MenuItem;

            if (menu == 1)
            {
                if (mSelectedInventoryClass.Id != null)
                {
                    Inventorylog newInventoryLog = new Inventorylog()
                    {
                        InventoryId   = mSelectedInventoryClass.Id,
                        Description   = mSelectedInventoryClass.ItemName + " Used By " + mUser.Username,
                        LogDate       = DateTime.Now,
                        CreatedUserId = mUser.ID.ToString(),
                        AddedUserId   = mUser.ID.ToString()
                    };
                    new Thread(new ThreadStart(delegate
                    {
                        var isAdded   = mInventoryLogDataService.Add(newInventoryLog);
                        var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id);
                        if (isDeleted)
                        {
                            UpdateInventories();
                            LoadInventoriesData();

                            this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show());
                            ReplaceFragment(new InventoriesFragment(), "Manage Inventories");
                        }
                        else
                        {
                            this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
                        }
                    })).Start();
                }
            }
            else if (menu == 2)
            {
                if (mSelectedInventoryClass.Id != null)
                {
                    Inventorylog newInventoryLog = new Inventorylog()
                    {
                        InventoryId   = mSelectedInventoryClass.Id,
                        Description   = mSelectedInventoryClass.ItemName + " Throwed By " + mUser.Username,
                        LogDate       = DateTime.Now,
                        CreatedUserId = mUser.ID.ToString(),
                        AddedUserId   = mUser.ID.ToString()
                    };
                    new Thread(new ThreadStart(delegate
                    {
                        var isAdded   = mInventoryLogDataService.Add(newInventoryLog);
                        var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id);
                        if (isDeleted)
                        {
                            UpdateInventories();
                            LoadInventoriesData();
                            this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show());
                            ReplaceFragment(new InventoriesFragment(), "Manage Inventories");
                        }
                        else
                        {
                            this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
                        }
                    })).Start();
                }
            }
            else if (menu == 3)
            {
                if (mSelectedInventoryClass.Id != null)
                {
                    Inventorylog newInventoryLog = new Inventorylog()
                    {
                        InventoryId   = mSelectedInventoryClass.Id,
                        Description   = mSelectedInventoryClass.ItemName + " Removed By " + mUser.Username,
                        LogDate       = DateTime.Now,
                        CreatedUserId = mUser.ID.ToString(),
                        AddedUserId   = mUser.ID.ToString()
                    };
                    new Thread(new ThreadStart(delegate
                    {
                        var isAdded   = mInventoryLogDataService.Add(newInventoryLog);
                        var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id);
                        if (isDeleted)
                        {
                            UpdateInventories();
                            LoadInventoriesData();
                            this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show());
                        }
                        else
                        {
                            this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
                        }
                    })).Start();
                }
            }
            else
            {
            }
        }