| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using Xamarin.Forms;
- using XF.Material.Forms.UI;
- using XF.Material.Forms.UI.Dialogs;
- using comal.timesheets.Products;
- using System.Threading.Tasks;
- using Xamarin.Forms.Xaml;
- namespace comal.timesheets
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class RelocatePage : BasePage
- {
- Guid _warehouseid = Guid.Empty;
- String _warehousename = "Select Warehouse";
- Guid _areaid = Guid.Empty;
- String _areaname = "Select Area / Rack";
- Guid _locationid = Guid.Empty;
- String _locationname = "Select Location / Pack";
- Job job = new Job();
- public RelocatePage()
- {
- InitializeComponent();
- }
- protected override void OnAppearing()
- {
- base.OnAppearing();
- UpdateScreen();
- }
- private void Relocate_Clicked(object sender, EventArgs e)
- {
- if (_locationid == Guid.Empty)
- return;
- Filter<StockArea> areafilter = new Filter<StockArea>(X => X.Active).IsEqualTo(true);
- GenericSelectionPage page = new GenericSelectionPage(
- "Move Stock Location to:",
- new SelectionViewModel<StockArea>(
- areafilter,
- new Expression<Func<StockArea, object>>[] { X => X.Description },
- new Expression<Func<StockArea, object>>[] { x => x.Warehouse.ID, x => x.Warehouse.Description },
- new SortOrder<StockArea>(x => x.Description)
- )
- );
- page.OnItemSelected += async (row) =>
- {
- var area = row.ToObject<StockArea>();
- if (_areaid != area.ID)
- {
- string chosenOption = await DisplayActionSheet("Change this Location's Area?", "Cancel", null, "Yes", "No");
- switch (chosenOption)
- {
- case "No":
- break;
- case "Cancel":
- break;
- case "Yes":
- StockLocation location = new StockLocation();
- location.ID = _locationid;
- location.Area.ID = area.ID;
- location.Warehouse.ID = area.Warehouse.ID;
- new Client<StockLocation>().Save(location, "Updated Stock Area", (o, err) => { });
- _warehouseid = area.Warehouse.ID;
- _warehousename = area.Warehouse.Description;
- _areaid = area.ID;
- _areaname = area.Description;
- UpdateScreen();
- await warehouseBtn.TranslateTo(0, -15, 150);
- await warehouseBtn.TranslateTo(0, 0, 150);
- await areaBtn.TranslateTo(0, -15, 150);
- await areaBtn.TranslateTo(0, 0, 150);
- await locationBtn.TranslateTo(0, -15, 150);
- await locationBtn.TranslateTo(0, 0, 150);
- break;
- default:
- break;
- }
- }
- };
- Navigation.PushAsync(page);
- }
- #region Warehouse/Area/Location buttons clicked
- void Warehouse_Clicked(System.Object sender, System.EventArgs e)
- {
- GenericSelectionPage page = new GenericSelectionPage(
- "Select Warehouse",
- new SelectionViewModel<StockWarehouse>(
- new Filter<StockWarehouse>(X => X.Active).IsEqualTo(true),
- new Expression<Func<StockWarehouse, object>>[] { X => X.Description },
- new Expression<Func<StockWarehouse, object>>[] { },
- new SortOrder<StockWarehouse>(x => x.Description)
- )
- );
- page.OnItemSelected += (row) =>
- {
- var warehouse = row.ToObject<StockWarehouse>();
- if (_warehouseid != warehouse.ID)
- {
- _warehouseid = warehouse.ID;
- _warehousename = warehouse.Description;
- _areaid = Guid.Empty;
- _areaname = "Select Area";
- _locationid = Guid.Empty;
- _locationname = "Select Location";
- }
- };
- Navigation.PushAsync(page);
- }
- void Area_Clicked(System.Object sender, System.EventArgs e)
- {
- Filter<StockArea> areafilter = new Filter<StockArea>(X => X.Active).IsEqualTo(true);
- if (_warehouseid != Guid.Empty)
- areafilter = areafilter.And(x => x.Warehouse.ID).IsEqualTo(_warehouseid);
- GenericSelectionPage page = new GenericSelectionPage(
- "Select Area",
- new SelectionViewModel<StockArea>(
- areafilter,
- new Expression<Func<StockArea, object>>[] { X => X.Description },
- new Expression<Func<StockArea, object>>[] { x => x.Warehouse.ID, x => x.Warehouse.Description },
- new SortOrder<StockArea>(x => x.Description)
- )
- );
- page.OnItemSelected += (row) =>
- {
- var area = row.ToObject<StockArea>();
- if (_areaid != area.ID)
- {
- _warehouseid = area.Warehouse.ID;
- _warehousename = area.Warehouse.Description;
- _areaid = area.ID;
- _areaname = area.Description;
- _locationid = Guid.Empty;
- _locationname = "Select Location";
- }
- };
- Navigation.PushAsync(page);
- }
- void Location_Clicked(System.Object sender, System.EventArgs e)
- {
- Filter<StockLocation> filter = new Filter<StockLocation>(X => X.Active).IsEqualTo(true);
- if (_warehouseid != Guid.Empty)
- filter = filter.And(x => x.Warehouse.ID).IsEqualTo(_warehouseid);
- if (_areaid != Guid.Empty)
- filter = filter.And(x => x.Area.ID).IsEqualTo(_areaid);
- GenericSelectionPage page = new GenericSelectionPage(
- "Select Location",
- new SelectionViewModel<StockLocation>(
- filter,
- new Expression<Func<StockLocation, object>>[] { x => x.Code, X => X.Description },
- new Expression<Func<StockLocation, object>>[] { x => x.Area.Warehouse.ID, x => x.Area.Warehouse.Description, x => x.Area.ID, x => x.Area.Description,
- x => x.Job.ID, x => x.Job.JobNumber, x => x.Job.Name},
- new SortOrder<StockLocation>(x => x.Description)
- )
- );
- page.OnItemSelected += (row) =>
- {
- var location = row.ToObject<StockLocation>();
- if (_locationid != location.ID)
- {
- _warehouseid = location.Area.Warehouse.ID;
- _warehousename = location.Area.Warehouse.Description;
- _areaid = location.Area.ID;
- _areaname = location.Area.Description;
- _locationid = location.ID;
- _locationname = location.Description;
- job.ID = location.Job.ID;
- job.JobNumber = location.Job.JobNumber;
- job.Name = location.Job.Name;
- }
- };
- Navigation.PushAsync(page);
- }
- #endregion
- #region Warehouse/Area/Location Clear buttons
- void Warehouse_Clear_Clicked(System.Object sender, System.EventArgs e)
- {
- _warehouseid = Guid.Empty;
- _warehousename = "Select Warehouse";
- _areaid = Guid.Empty;
- _areaname = "Select Area";
- _locationid = Guid.Empty;
- _locationname = "Select Location";
- UpdateScreen();
- }
- void Area_Clear_Clicked(System.Object sender, System.EventArgs e)
- {
- _areaid = Guid.Empty;
- _areaname = "Select Area";
- _locationid = Guid.Empty;
- _locationname = "Select Location";
- UpdateScreen();
- }
- void Location_Clear_Clicked(System.Object sender, System.EventArgs e)
- {
- _locationid = Guid.Empty;
- _locationname = "Select Location";
- UpdateScreen();
- }
- #endregion
- private void UpdateScreen()
- {
- warehouseBtn.Text = _warehousename;
- warehouseBtn.SetValue(Grid.ColumnSpanProperty, _warehouseid == Guid.Empty ? 3 : 2);
- warehouseBtn.Margin = new Thickness(10, 10, _warehouseid == Guid.Empty ? 5 : 0, 0);
- warehouse_ClearBtn.IsVisible = _warehouseid != Guid.Empty;
- warehouse_ClearBtn.Margin = new Thickness(0, 10, 5, 0);
- areaBtn.Text = _areaname;
- areaBtn.SetValue(Grid.ColumnSpanProperty, _areaid == Guid.Empty ? 3 : 2);
- areaBtn.Margin = new Thickness(10, 0, _areaid == Guid.Empty ? 5 : 0, 0);
- area_ClearBtn.IsVisible = _areaid != Guid.Empty;
- area_ClearBtn.Margin = new Thickness(0, 0, 5, 0);
- locationBtn.Text = _locationname;
- locationBtn.SetValue(Grid.ColumnSpanProperty, _locationid != Guid.Empty ? 2 : 3);
- locationBtn.Margin = new Thickness(10, 0, _locationid == Guid.Empty ? 5 : 0, 0);
- location_ClearBtn.IsVisible = _locationid != Guid.Empty;
- location_ClearBtn.Margin = new Thickness(0, 0, 5, 0);
- }
- }
- }
|