Esempio n. 1
0
        private void AddInventoryData()
        {
            //for (int i = 0; mProducts.Count > i; i++){
            //    if (mName.Text == mProducts[i].Name){
            //        mProduct.Id = mProducts[i].Id;
            //        mProduct.Name = mProducts[i].Name;
            //    }
            //}
            Inventory newInventory = new Inventory()
            {
                ExpirationDate = DateTemp,
                StorageId      = mStorage.Id,
                ItemName       = mName.Text,
                Price          = decimal.Parse(mPrice.Text),
                ProductId      = mProduct.Id,
                AddedUserId    = LoginPageActivity.StaticUserClass.ID.ToString()
            };

            new Thread(new ThreadStart(delegate {
                var isInventoryAdded = mInventoryDataService.Add(newInventory);
                if (isInventoryAdded)
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Inventory Added", ToastLength.Long).Show());
                    ReplaceFragment(new HomeFragment(), "Home");
                }
                else
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed to add, please check again form's field", ToastLength.Long).Show());
                }
            })).Start();
        }
Esempio n. 2
0
        private void AddInventoryData()
        {
            if (mBarcode.Text == "-")
            {
                AddProductData();
                tempproductid = mNewProductId;
            }
            else if (mBarcode.Text != "-")
            {
                if (mIsContainName)
                {
                    tempproductid = mProduct.Id;
                }
                else
                {
                    AddProductData();
                    tempproductid = mNewProductId;
                }
            }

            Inventory newInventory = new Inventory()
            {
                ExpirationDate = DateTemp,
                StorageId      = mStorage.Id,
                ItemName       = mName.Text,
                Stock          = int.Parse(mStock.Text),
                ProductId      = tempproductid,
                AddedUserId    = LoginPageActivity.StaticUserClass.ID.ToString()
            };

            new Thread(new ThreadStart(delegate {
                if (int.Parse(mStock.Text) != 0)
                {
                    var isInventoryAdded = mInventoryDataService.Add(newInventory);
                    if (isInventoryAdded)
                    {
                        UpdateDataAsync();
                        this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Inventory Added", ToastLength.Long).Show());
                        ReplaceFragment(new HomeFragment(), "Home");
                    }
                    else
                    {
                        this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed to add, please check again form's field", ToastLength.Long).Show());
                    }
                }
                else
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "No Item Added", ToastLength.Long).Show());
                }
            })).Start();
        }
Esempio n. 3
0
        private void AddInventoryData()
        {
            var intent = new Intent(this, typeof(PageMainActivity));

            for (int i = 0; mProducts.Count > i; i++)
            {
                if (mName.Text == mProducts[i].Name)
                {
                    mProduct.Id   = mProducts[i].Id;
                    mProduct.Name = mProducts[i].Name;
                }
            }
            Inventory newInventory = new Inventory()
            {
                ExpirationDate = DateTemp,
                StorageId      = mStorage.Id,
                ItemName       = mName.Text,
                Price          = decimal.Parse(mPrice.Text),
                ProductId      = mProduct.Id
            };

            var progressDialog = ProgressDialog.Show(this, "Please wait...", "Adding To Inventory...", true);

            new Thread(new ThreadStart(delegate
            {
                var isInventoryAdded = mInventoryDataService.Add(newInventory);
                RunOnUiThread(() => progressDialog.Hide());

                if (isInventoryAdded)
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Inventory Added", ToastLength.Long).Show());
                    this.StartActivity(intent);
                }
                else
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Failed to add, please check again form's field", ToastLength.Long).Show());
                }
            })).Start();
        }