| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using System;
- using System.Linq;
- using InABox.Mobile;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace PRS.Mobile
- {
-
- public class StockTransactionSavedArgs : EventArgs
- {
- public StockTransaction Transaction { get; private set; }
- public StockTransactionSavedArgs(StockTransaction transaction)
- {
- Transaction = transaction;
- }
- }
- public delegate void StockTransactionSavedEvent(object sender, StockTransactionSavedArgs args);
-
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class TransferEdit
- {
- public event StockTransactionSavedEvent? TransactionSaved;
-
- public TransferEdit(StockTransaction transaction, StockTransactions otherTransactions)
- {
- InitializeComponent();
- ViewModel.Transaction = transaction;
- ViewModel.OtherTransactions = otherTransactions;
- }
-
- private void _tick_OnClicked(object sender, MobileMenuButtonClickedEventArgs args)
- {
- TransactionSaved?.Invoke(this, new StockTransactionSavedArgs(ViewModel.Transaction));
- Navigation.PopAsync();
- }
- private void IncreaseQty_Clicked(object sender, MobileButtonClickEventArgs args)
- {
- if ((sender as MobileButton)?.BindingContext is StockTransactionAllocation alloc)
- alloc.Quantity = Math.Min(alloc.Maximum, alloc.Quantity + 1);
- //ViewModel.Transaction.Quantity += 1.0;
- }
- private void DecreaseQty_Clicked(object sender, MobileButtonClickEventArgs args)
- {
- if ((sender as MobileButton)?.BindingContext is StockTransactionAllocation alloc)
- alloc.Quantity = Math.Max(0, alloc.Quantity - 1);
- //ViewModel.Transaction.Quantity -= 1.0;
- }
- private void SelectLocation_Clicked(object sender, MobileButtonClickEventArgs args)
- {
- ShowPopup(() =>
- SelectionView.Execute<StockLocationShell>(
- columns =>
- {
- columns.Add(new MobileGridTextColumn<StockLocationShell>()
- { Column = x => x.Code, Width = GridLength.Auto });
- columns.Add(new MobileGridTextColumn<StockLocationShell>()
- { Column = x => x.Description, Width = GridLength.Star });
- },
- refresh => App.Data.StockLocations.Refresh(false),
- locations =>
- {
- ViewModel.Transaction.Target.LocationID = locations?.FirstOrDefault()?.ID ?? Guid.Empty;
- ViewModel.Transaction.Target.LocationCode = locations?.FirstOrDefault()?.Code ?? string.Empty;
- ViewModel.Transaction.Target.LocationDescription = locations?.FirstOrDefault()?.Description ?? string.Empty;
- DismissPopup();
- })
- );
- }
- private void SelectStyle_Clicked(object sender, MobileButtonClickEventArgs args)
- {
- ShowPopup(() =>
- SelectionView.Execute<ProductStyleShell>(
- columns =>
- {
- columns.Add(new MobileGridTextColumn<ProductStyleShell>()
- { Column = x => x.Code, Width = GridLength.Auto });
- columns.Add(new MobileGridTextColumn<ProductStyleShell>()
- { Column = x => x.Description, Width = GridLength.Star });
- },
- refresh => App.Data.ProductStyles.Refresh(false),
- styles =>
- {
- ViewModel.Transaction.Target.StyleID = styles?.FirstOrDefault()?.ID ?? Guid.Empty;
- ViewModel.Transaction.Target.StyleCode = styles?.FirstOrDefault()?.Code ?? string.Empty;
- ViewModel.Transaction.Target.StyleDescription = styles?.FirstOrDefault()?.Description ?? string.Empty;
- DismissPopup();
- })
- );
- }
- private void SelectJob_Clicked(object sender, MobileButtonClickEventArgs args)
- {
- ShowPopup(() =>
- SelectionView.Execute<JobShell>(
- columns =>
- {
- columns.Add(new MobileGridTextColumn<JobShell>()
- { Column = x => x.JobNumber, Width = GridLength.Auto });
- columns.Add(new MobileGridTextColumn<JobShell>()
- { Column = x => x.Name, Width = GridLength.Star });
- },
- refresh => App.Data.Jobs.Refresh(false),
- jobs =>
- {
- ViewModel.Transaction.Target.JobID = jobs?.FirstOrDefault()?.ID ?? Guid.Empty;
- ViewModel.Transaction.Target.JobNumber = jobs?.FirstOrDefault()?.JobNumber ?? string.Empty;
- ViewModel.Transaction.Target.JobName = jobs?.FirstOrDefault()?.Name ?? string.Empty;
- DismissPopup();
- })
- );
- }
- }
- }
|