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(); } }
public ActionResult Delete(int id) { var res = _purchaseDataService.GetById(id); if (_salesShipmentsDataService.GetByInventoryDataID(res.InventoryDataID) == null) { _inventoryDataService.Delete(id); _purchaseDataService.Delete(id); SuccessNotification($"{"删除成功" + res.GoodsName}"); return(RedirectToAction("Index")); } ErrorNotification("已经存在销售出货记录" + res.GoodsName + "不允许修改"); return(RedirectToAction("Index")); }
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 { } }
private void InitFields() { this.mButtonUse = FindViewById <Button>(Resource.Id.buttonUseUse); this.mButtonDelete = FindViewById <Button>(Resource.Id.buttonUseDelete); this.mTextSelectedItem = FindViewById <TextView>(Resource.Id.textViewUseSelectedItem); this.mListViewInventory = this.FindViewById <RecyclerView>(Resource.Id.recyclerViewUse); this.mListViewInventory.SetLayoutManager(new LinearLayoutManager(this)); this.mSpinnerStorages = FindViewById <Spinner>(Resource.Id.spinnerUseStorageSelected); this.mButtonBack = FindViewById <ImageButton>(Resource.Id.btnUseBack); this.mButtonSearch = FindViewById <Button>(Resource.Id.buttonSearchUse); this.mSearchBox = FindViewById <EditText>(Resource.Id.searchBoxUse); LoadAdapterData(); LoadItemData(); mButtonUse.Click += (object sender, EventArgs args) => { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Confirm Use"); alert.SetMessage("Use your item?"); alert.SetPositiveButton("Use It", (senderAlert, eventargs) => { Consume newLoc = new Consume() { DateConsumed = System.DateTime.Now, InventoryId = mInventory.Id }; var progressDialog = ProgressDialog.Show(this, "Please wait...", "Consuming...", true); new Thread(new ThreadStart(delegate { var isAdded = mConsumeDataService.Add(newLoc); RunOnUiThread(() => progressDialog.Hide()); if (isAdded) { RunOnUiThread(() => Toast.MakeText(this, "Consumed!", ToastLength.Short).Show()); } else { RunOnUiThread(() => Toast.MakeText(this, "Failed to consume, please check your connection", ToastLength.Long).Show()); } })).Start(); }); alert.SetNegativeButton("Cancel", (senderAlert, eventargs) => { Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); }; mButtonDelete.Click += (object sender, EventArgs args) => { var progressDialog = ProgressDialog.Show(this, "Please wait...", "Consuming...", true); new Thread(new ThreadStart(delegate { var isDeleted = mInventoryDataService.Delete(mInventory.Id); RunOnUiThread(() => progressDialog.Hide()); if (isDeleted) { RunOnUiThread(() => Toast.MakeText(this, "Consumed!", ToastLength.Short).Show()); } else { RunOnUiThread(() => Toast.MakeText(this, "Failed to consume, please check your connection", ToastLength.Long).Show()); } })).Start(); }; mButtonBack.Click += (object sender, EventArgs args) => { Intent nextActivity = new Intent(this, typeof(PageMainActivity)); StartActivity(nextActivity); }; mButtonSearch.Click += (object sender, EventArgs args) => { inventoriesForSearch.Clear(); SearchItem(); }; }