123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822 |
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using InABox.Mobile;
- using Xamarin.CommunityToolkit.Extensions;
- using Xamarin.CommunityToolkit.UI.Views;
- using Xamarin.Essentials;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- using LogType = InABox.Core.LogType;
- namespace PRS.Mobile
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class StocktakeModule : MobilePage
- {
- #region Fields, Constructor and OnAppearing
- List<StockLocationShell> stockLocationShells = new List<StockLocationShell>();
- List<StockHoldingShell> stockHoldingShells = new List<StockHoldingShell>();
- string DeviceType = "";
- StockLocationShell_Old openLocation = new StockLocationShell_Old();
- bool bOpening = false;
- Color stockHoldingCheckedColor = Color.FromHex("#3eb489");
- List<StockMovement> movementsToUpdate = new List<StockMovement>();
- public StocktakeModule(Guid locationid)
- {
- InitializeComponent();
- var idiom = DeviceInfo.Idiom;
- if (idiom.Equals(DeviceIdiom.Tablet))
- {
- DeviceType = "Tablet";
- }
- NavigationPage.SetHasBackButton(this, false);
- if (locationid != Guid.Empty)
- LoadLocation(locationid);
- }
- protected override void OnAppearing()
- {
- base.OnAppearing();
- bOpening = false;
- }
- #endregion
- #region Button Presses
- // private async void ExitWithoutSaving(object sender, EventArgs e)
- // {
- // if (openLocation.ID != Guid.Empty)
- // {
- // string chosenOption = await DisplayActionSheet("Leave without saving?", "Cancel", null, "Yes", "No");
- // switch (chosenOption)
- // {
- // case "Cancel":
- // return;
- // case "Yes":
- // Navigation.PopAsync();
- // break;
- // case "No":
- // return;
- // default:
- // return;
- // }
- // }
- // else
- // Navigation.PopAsync();
- // }
- // private void AddLocation_Clicked(object sender, EventArgs e)
- // {
- // if (bOpening)
- // return;
- // bOpening = true;
- // StockLocationSelectionPage stockLocationSelectionPage = new StockLocationSelectionPage( new Guid[] { }, true);
- // stockLocationSelectionPage.OnLocationSelected += (s, e) =>
- // {
- // foreach (StockLocationShell shell in e.Locations)
- // {
- // if (!stockLocationShells.Any(x => x.ID == shell.ID))
- // {
- // //shell.Color = Color.Default;
- // stockLocationShells.Add(shell);
- // //if (string.IsNullOrWhiteSpace(shell.NumberOfHoldings))
- // // FindHoldingNumber(shell);
- // }
- // }
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // leftListView.ItemsSource = null;
- // leftListView.ItemsSource = stockLocationShells;
- // });
- // };
- //
- // Navigation.PushAsync(stockLocationSelectionPage);
- // }
- private void AddItem_Clicked(object sender, EventArgs e)
- {
- if (openLocation.ID != Guid.Empty)
- {
- // var selectionpage = new ProductSelectionPage((product) =>
- // {
- // StockHoldingShell shell = new StockHoldingShell();
- // shell.ProductCode = product.Code;
- // shell.Name = product.Name;
- // shell.ImageID = product.ImageID;
- // shell.ProductID = product.ID;
- // shell.DisplayJob = openLocation.JobNumber;
- // if (!string.IsNullOrWhiteSpace(openLocation.JobNumber))
- // {
- // shell.JobNumber = openLocation.JobNumber.Substring(6);
- // }
- // shell.JobID = openLocation.JobID;
- // shell.Units = 0;
- // shell.DisplayUnits = "Units: 0";
- // shell.StyleName = "Finish: Select";
- //
- // shell.DimensionsUnitID = product.DimensionsUnitID;
- // shell.DimensionsUnitCode = product.DimensionsUnit.Code;
- // shell.DimensionsUnitDescription = product.DimensionsUnit.Description;
- // shell.DimensionsQuantity = product.DimensionsQuantity;
- // shell.DimensionsLength = product.DimensionsLength;
- // shell.DimensionsWidth = product.DimensionsWidth;
- // shell.DimensionsHeight = product.DimensionsHeight;
- // shell.DimensionsWeight = product.DimensionsWeight;
- // shell.DimensionsValue = product.DimensionsValue;
- // shell.DimensionsUnitSize = product.DimensionsUnitSize;
- // shell.DimensionsHasHeight = product.DimensionsUnit.HasHeight;
- // shell.DimensionsHasLength = product.DimensionsUnit.HasLength;
- // shell.DimensionsHasWidth = product.DimensionsUnit.HasWidth;
- // shell.DimensionsHasWeight = product.DimensionsUnit.HasWeight;
- // shell.DimensionsHasQuantity = product.DimensionsUnit.HasQuantity;
- // shell.DimensionsUnitFormula = product.DimensionsUnit.Formula;
- // shell.DimensionsUnitFormat = product.DimensionsUnit.Format;
- //
- // stockHoldingShells.Add(shell);
- // rightListView.ItemsSource = null;
- // rightListView.ItemsSource = stockHoldingShells;
- // if (shell.ImageID != Guid.Empty)
- // LoadImage(shell);
- // });
- // Navigation.PushAsync(selectionpage);
- }
- else
- {
- string alert = "";
- if (stockLocationShells.Count == 0)
- {
- alert = "Add a location first";
- }
- else
- {
- alert = "Open a location first";
- }
- DisplayAlert("Alert", alert, "OK");
- }
- }
- #endregion
- #region Lists Tapped
- private async void LeftListView_Tapped(object sender, EventArgs e)// open/close a location
- {
- // StockLocationShell_Old stockLocationShell = leftListView.SelectedItem as StockLocationShell_Old;
- // if (openLocation.ID == stockLocationShell.ID) //close location and save movements
- // {
- // bool allComplete = true;
- // bool allIncomplete = true;
- // foreach (StockHoldingShell_Old shell in stockHoldingShells)
- // {
- // if (shell.Color != stockHoldingCheckedColor)
- // allComplete = false;
- // else
- // allIncomplete = false;
- // }
- // if (!allComplete && !allIncomplete)
- // {
- // DisplayAlert("Alert", "Not all holdings have been checked for this location / pack", "OK");
- // return;
- // }
- // if (allIncomplete)
- // {
- // openLocation.ID = Guid.Empty;
- // openLocation.Code = "";
- // openLocation.Description = "";
- // stockLocationShell.Color = Color.Default;
- // stockLocationShell.OpenCloseLocation = "Open";
- // int index = stockLocationShells.FindIndex(x => x.ID.Equals(stockLocationShell.ID));
- // stockLocationShells.RemoveAt(index);
- // stockLocationShells.Insert(index, stockLocationShell);
- //
- // leftListView.ItemsSource = null;
- // leftListView.ItemsSource = stockLocationShells;
- //
- // rightListView.ItemsSource = null;
- // stockHoldingShells.Clear();
- // rightCountLbl.Text = "Items: " + stockHoldingShells.Count();
- // movementsToUpdate.Clear();
- //
- // return;
- // }
- //
- // StockTakeCompletionPage stockTakeCompletionPage = new StockTakeCompletionPage(movementsToUpdate);
- // stockTakeCompletionPage.OnStockTakeCompleted += () =>
- // {
- // openLocation.ID = Guid.Empty;
- // openLocation.Code = "";
- // openLocation.Description = "";
- // stockLocationShell.Color = stockHoldingCheckedColor;
- // stockLocationShell.OpenCloseLocation = "Completed";
- //
- // int index = stockLocationShells.FindIndex(x => x.ID.Equals(stockLocationShell.ID));
- // stockLocationShells.RemoveAt(index);
- // stockLocationShells.Insert(index, stockLocationShell);
- //
- // leftListView.ItemsSource = null;
- // leftListView.ItemsSource = stockLocationShells;
- //
- // rightListView.ItemsSource = null;
- // stockHoldingShells.Clear();
- // rightCountLbl.Text = "Items: " + stockHoldingShells.Count();
- // movementsToUpdate.Clear();
- // };
- // Navigation.PushAsync(stockTakeCompletionPage);
- // }
- // else if (openLocation.ID == Guid.Empty) //open the location and load holdings
- // {
- // Filter<StockHolding> filter = new Filter<StockHolding>(x => x.Location.ID).IsEqualTo(stockLocationShell.ID);
- // openLocation.ID = stockLocationShell.ID;
- // openLocation.Code = stockLocationShell.Code;
- // openLocation.Description = stockLocationShell.Description;
- // stockLocationShell.Color = Color.Orange;
- // stockLocationShell.OpenCloseLocation = "Close";
- //
- // LoadHoldings(filter);
- //
- // int index = stockLocationShells.FindIndex(x => x.ID.Equals(stockLocationShell.ID));
- // stockLocationShells.RemoveAt(index);
- // stockLocationShells.Insert(index, stockLocationShell);
- //
- // leftListView.ItemsSource = null;
- // leftListView.ItemsSource = stockLocationShells;
- // }
- // else if (openLocation.ID != Guid.Empty)
- // {
- // DisplayAlert("Alert", "Currently Open Location must be closed first", "OK");
- // }
- }
- private void RightListView_Tapped(object sender, EventArgs e) //open popup to confirm, on closing turns green
- {
- // if (bOpening)
- // return;
- // bOpening = true;
- // var shell = rightListView.SelectedItem as StockHoldingShell_Old;
- // var originalShell = DuplicateShell(shell);
- //
- // var style = new ProductStyle { ID = shell.StyleID, Code = shell.StyleCode, Description = shell.Finish };
- // var job = new Job { ID = shell.JobID, JobNumber = shell.JobNumber };
- //
- // var popup = new RecTransferPopup(shell, job, job, true);
- //
- // var additionalmovement = new StockMovement();
- //
- // popup.OnRecTransferItemAccepted += () =>
- // {
- // var movement = new StockMovement();
- // movement.Dimensions.Unit.ID = shell.DimensionsUnitID;
- // movement.Dimensions.Quantity = shell.DimensionsQuantity;
- // movement.Dimensions.Length = shell.DimensionsLength;
- // movement.Dimensions.Width = shell.DimensionsWidth;
- // movement.Dimensions.Height = shell.DimensionsHeight;
- // movement.Dimensions.Weight = shell.DimensionsWeight;
- // movement.Dimensions.Unit.HasHeight = shell.DimensionsHasHeight;
- // movement.Dimensions.Unit.HasLength = shell.DimensionsHasLength;
- // movement.Dimensions.Unit.HasWidth = shell.DimensionsHasWidth;
- // movement.Dimensions.Unit.HasWeight = shell.DimensionsHasWeight;
- // movement.Dimensions.Unit.HasQuantity = shell.DimensionsHasQuantity;
- // movement.Dimensions.Unit.Code = shell.DimensionsUnitCode;
- // movement.Dimensions.Unit.Description = shell.DimensionsUnitDescription;
- // movement.Dimensions.Value = shell.DimensionsValue;
- // movement.Dimensions.Unit.Formula = shell.DimensionsUnitFormula;
- // movement.Dimensions.Unit.Format = shell.DimensionsUnitFormat;
- // movement.Dimensions.UnitSize = shell.DimensionsUnitSize;
- // movement.Product.ID = shell.ProductID;
- // movement.Product.Code = shell.Code;
- // movement.Product.Name = shell.Name;
- // movement.Employee.ID = App.Data.Me.ID;
- // movement.Employee.Name = App.Data.Me.Name;
- // movement.Location.ID = openLocation.ID;
- // movement.Location.Description = openLocation.Description;
- // movement.Location.Code = openLocation.Code;
- // movement.Job.ID = shell.JobID;
- // movement.Job.JobNumber = shell.JobNumber;
- // movement.Style.ID = shell.StyleID;
- // movement.Style.Code = shell.StyleCode;
- // movement.Style.Description = shell.Finish;
- // movement.Type = StockMovementType.StockTake;
- // movement.Balance = popup.Shell.Units;
- //
- // if (popup.Shell.Units < originalShell.Units)
- // {
- // movement.Issued = originalShell.Units - popup.Shell.Units;
- // movement.Notes = "Updated incorrect Qty during stocktake. Less Qty than expected.";
- // }
- // else if (popup.Shell.Units > originalShell.Units)
- // {
- // movement.Received = popup.Shell.Units - originalShell.Units;
- // movement.Notes = "Updated incorrect Qty during stocktake. More Qty than expected.";
- // }
- // else if (popup.Shell.Units == originalShell.Units)
- // {
- // movement.Received = 0;
- // movement.Issued = 0;
- // movement.Notes = "Confirmed correct Qty during stocktake.";
- // }
- //
- // //if style is changed, create a movement that issues everything from the original style
- // //in addition to the first movement created being changed to a receive of the entered qty in the new style
- // //no need to find the difference in Qty from the original. First movement qty issued should be 0
- // if (popup.Shell.StyleID != originalShell.StyleID)
- // {
- // additionalmovement.Dimensions.Unit.ID = shell.DimensionsUnitID;
- // additionalmovement.Dimensions.Quantity = shell.DimensionsQuantity;
- // additionalmovement.Dimensions.Length = shell.DimensionsLength;
- // additionalmovement.Dimensions.Width = shell.DimensionsWidth;
- // additionalmovement.Dimensions.Height = shell.DimensionsHeight;
- // additionalmovement.Dimensions.Weight = shell.DimensionsWeight;
- // additionalmovement.Dimensions.Unit.HasHeight = shell.DimensionsHasHeight;
- // additionalmovement.Dimensions.Unit.HasLength = shell.DimensionsHasLength;
- // additionalmovement.Dimensions.Unit.HasWidth = shell.DimensionsHasWidth;
- // additionalmovement.Dimensions.Unit.HasWeight = shell.DimensionsHasWeight;
- // additionalmovement.Dimensions.Unit.HasQuantity = shell.DimensionsHasQuantity;
- // additionalmovement.Dimensions.Unit.Code = shell.DimensionsUnitCode;
- // additionalmovement.Dimensions.Unit.Description = shell.DimensionsUnitDescription;
- // additionalmovement.Dimensions.Value = shell.DimensionsValue;
- // additionalmovement.Dimensions.Unit.Formula = shell.DimensionsUnitFormula;
- // additionalmovement.Dimensions.Unit.Format = shell.DimensionsUnitFormat;
- // additionalmovement.Dimensions.UnitSize = shell.DimensionsUnitSize;
- // additionalmovement.Product.ID = shell.ProductID;
- // additionalmovement.Product.Code = shell.Code;
- // additionalmovement.Product.Name = shell.Name;
- // additionalmovement.Employee.ID = App.Data.Me.ID;
- // additionalmovement.Employee.Name = App.Data.Me.Name;
- // additionalmovement.Location.ID = openLocation.ID;
- // additionalmovement.Location.Description = openLocation.Description;
- // additionalmovement.Location.Code = openLocation.Code;
- // additionalmovement.Job.ID = shell.JobID;
- // additionalmovement.Job.JobNumber = shell.JobNumber;
- // additionalmovement.Style.ID = originalShell.StyleID;
- // additionalmovement.Style.Code = originalShell.StyleCode;
- // additionalmovement.Style.Description = originalShell.Finish;
- // additionalmovement.Notes = movement.Notes + " Also changed finish during stocktake";
- //
- // additionalmovement.Transaction = movement.Transaction;
- //
- // additionalmovement.Issued = originalShell.Units;
- // additionalmovement.Type = StockMovementType.TransferOut;
- //
- // movementsToUpdate.Add(additionalmovement);
- //
- // movement.Issued = 0;
- // movement.Received = popup.Shell.Units;
- // movement.Type = StockMovementType.TransferIn;
- // movement.Notes += " Also changed finish during stocktake";
- // }
- //
- // movementsToUpdate.Add(movement);
- //
- // shell.Color = stockHoldingCheckedColor;
- // int index = stockHoldingShells.FindIndex(x => x.ID.Equals(shell.ID));
- // stockHoldingShells.RemoveAt(index);
- // stockHoldingShells.Insert(index, shell);
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // rightListView.ItemsSource = null;
- // rightListView.ItemsSource = stockHoldingShells;
- // });
- // };
- //
- // Navigation.PushAsync(popup);
- }
- #endregion
- #region Utilities
- private async void FindHoldingNumber(StockLocationShell_Old shell)
- {
- //TODO replace code that showed number of holdings
- //Task.Run(() =>
- //{
- // CoreTable table = new Client<StockLocation>().Query(new Filter<StockLocation>(x => x.ID).IsEqualTo(shell.ID),
- // new Columns<StockLocation>(x => x.Holdings));
- // if (table.Rows.Any())
- // {
- // List<object> list = table.Rows.First().Values;
- // shell.NumberOfHoldings = "Holdings: " + list[0].ToString();
- // int index = stockLocationShells.FindIndex(x => x.ID.Equals(shell.ID));
- // stockLocationShells.RemoveAt(index);
- // stockLocationShells.Insert(index, shell);
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // leftListView.ItemsSource = null;
- // leftListView.ItemsSource = stockLocationShells;
- // });
- // }
- //});
- }
- private async void LoadLocation(Guid locationid)
- {
- // using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading"))
- // {
- // CoreTable table = QueryLocation(locationid);
- // while (table == null)
- // table = QueryLocation(locationid);
- // if (table.Rows.Any())
- // {
- // StockLocation location = table.Rows.First().ToObject<StockLocation>();
- //
- // StockLocationShell_Old shell = new StockLocationShell_Old()
- // {
- // ID = locationid,
- // Description = location.Description,
- // Warehouse = "Warehouse: " + location.Warehouse.Description,
- // Area = "Area: " + location.Area.Description,
- // JobNumber = "Job: " + location.Job.JobNumber,
- // Code = location.Code,
- // NumberOfHoldings = "Holdings: LOADING...",
- // JobID = location.Job.ID,
- // JobName = location.Job.Name
- // };
- //
- // stockLocationShells.Add(shell);
- //
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // leftListView.ItemsSource = null;
- // leftListView.ItemsSource = stockLocationShells;
- // });
- // FindHoldingNumber(shell);
- // }
- // }
- }
- private CoreTable QueryLocation(Guid locationid)
- {
- try
- {
- return new Client<StockLocation>().Query(new Filter<StockLocation>(x => x.ID).IsEqualTo(locationid),
- new Columns<StockLocation>(x => x.Description, x => x.Code, x => x.Warehouse.Description,
- x => x.Area.Description, x => x.Job.JobNumber)
- );
- }
- catch (Exception ex)
- {
- InABox.Mobile.MobileLogging.Log(ex);
- return null;
- }
- }
- private StockHoldingShell_Old DuplicateShell(StockHoldingShell_Old shell)
- {
- StockHoldingShell_Old NewShell = new StockHoldingShell_Old()
- {
- ID = shell.ID,
- Code = shell.Code,
- Name = shell.Name,
- DimensionsUnitID = shell.DimensionsUnitID,
- DimensionsQuantity = shell.DimensionsQuantity,
- DimensionsLength = shell.DimensionsLength,
- DimensionsWidth = shell.DimensionsWidth,
- DimensionsHeight = shell.DimensionsHeight,
- DimensionsWeight = shell.DimensionsWeight,
- DimensionsValue = shell.DimensionsValue,
- DimensionsHasHeight = shell.DimensionsHasHeight,
- DimensionsHasLength = shell.DimensionsHasLength,
- DimensionsHasQuantity = shell.DimensionsHasQuantity,
- DimensionsHasWidth = shell.DimensionsHasWidth,
- DimensionsHasWeight = shell.DimensionsHasWeight,
- DimensionsUnitCode = shell.DimensionsUnitCode,
- DimensionsUnitDescription = shell.DimensionsUnitDescription,
- DimensionsUnitFormat = shell.DimensionsUnitFormat,
- DimensionsUnitFormula = shell.DimensionsUnitFormula,
- DimensionsUnitSize = shell.DimensionsUnitSize,
- Finish = shell.Finish,
- Units = shell.Units,
- DisplayUnits = shell.DisplayUnits,
- JobID = shell.JobID,
- JobName = shell.JobName,
- JobNumber = shell.JobNumber,
- DisplayJob = shell.DisplayJob,
- StyleName = shell.StyleName,
- StyleID = shell.StyleID,
- StyleCode = shell.StyleCode,
- ProductID = shell.ProductID,
- DisplaySize = shell.DisplaySize,
- LastRowHeight = shell.LastRowHeight,
- ImageID = shell.ImageID,
- ImageSource = shell.ImageSource,
- ImageVisible = shell.ImageVisible,
- Color = shell.Color
- };
- return NewShell;
- }
- // private void LoadImage(StockHoldingShell_Old shell)
- // {
- // Task.Run(() =>
- // {
- // CoreTable table = QueryImage(shell);
- // while (table == null)
- // table = QueryImage(shell);
- //
- // if (table.Rows.Any())
- // {
- // CoreRow docrow = table.Rows.FirstOrDefault();
- // if (docrow != null)
- // {
- // byte[] data = docrow.Get<Document, byte[]>(x => x.Data);
- // ImageSource src = ImageSource.FromStream(() => new MemoryStream(data));
- // if (src != null)
- // {
- // shell.ImageSource = src;
- // shell.ImageVisible = true;
- // if (DeviceType == "Tablet")
- // {
- // shell.LastRowHeight = 300;
- // }
- // else
- // {
- // shell.LastRowHeight = 150;
- // }
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // rightListView.ItemsSource = null;
- // rightListView.ItemsSource = stockHoldingShells;
- // });
- // }
- // }
- // }
- // });
- // }
- // private CoreTable QueryImage(StockHoldingShell_Old shell)
- // {
- // try
- // {
- // return new Client<Document>().Query(new Filter<Document>(x => x.ID).IsEqualTo(shell.ImageID));
- // }
- // catch (Exception ex)
- // {
- // InABox.Mobile.MobileLogging.Log(ex);
- // return null;
- // }
- //
- // }
- //private void LoadImages()
- //{
- // Task.Run(() =>
- // {
- // List<Guid> imageids = new List<Guid>();
- // foreach (StockHoldingShell_Old shell in stockHoldingShells)
- // {
- // if (shell.ImageID != Guid.Empty)
- // {
- // imageids.Add(shell.ImageID);
- // }
- // }
- // if (imageids.Count == 0)
- // return;
- //
- // CoreTable table = QueryImages(imageids);
- // while (table == null)
- // table = QueryImages(imageids);
- //
- // foreach (CoreRow row in table.Rows)
- // {
- // var item = stockHoldingShells.FirstOrDefault(x => x.ImageID == row.Get<Document, Guid>(x => x.ID));
- // item.ImageVisible = true;
- // item.ImageSource = ImageSource.FromStream(() => new MemoryStream(row.Get<Document, byte[]>(x => x.Data)));
- // if (DeviceType == "Tablet")
- // {
- // item.LastRowHeight = 300;
- // }
- // else
- // {
- // item.LastRowHeight = 150;
- // }
- // }
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // rightListView.ItemsSource = null;
- // rightListView.ItemsSource = stockHoldingShells;
- // });
- // });
- //}
- // private CoreTable QueryImages(List<Guid> imageids)
- // {
- // try
- // {
- // return new Client<Document>().Query(new Filter<Document>(x => x.ID).InList(imageids.ToArray()),
- // new Columns<Document>(x => x.ID, x => x.Data));
- // }
- // catch (Exception ex)
- // {
- // InABox.Mobile.MobileLogging.Log(ex);
- // return null;
- // }
- // }
- //private async void LoadHoldings(Filter<StockHolding> filter)
- //{
- // await Task.Run(() =>
- // {
- // CoreTable table = QueryStockHoldings(filter);
- // while(table == null)
- // table = QueryStockHoldings(filter);
- //
- // if (table.Rows.Any())
- // {
- // foreach (CoreRow row in table.Rows)
- // {
- // StockHoldingShell_Old shell = new StockHoldingShell_Old();
- //
- // shell.ID = row.Get<StockHolding, Guid>(x => x.Location.ID).ToString()
- // + row.Get<StockHolding, Guid>(x => x.Product.ID).ToString()
- // + row.Get<StockHolding, Guid>(x => x.Job.ID).ToString()
- // + row.Get<StockHolding, Guid>(x => x.Style.ID).ToString()
- // + row.Get<StockHolding, string>(x => x.Dimensions.UnitSize);
- // shell.Code = row.Get<StockHolding, string>(x => x.Product.Code);
- // shell.Name = row.Get<StockHolding, string>(x => x.Product.Name);
- // shell.Finish = row.Get<StockHolding, string>(x => x.Style.Description);
- // shell.StyleName = "Finish: " + shell.Finish;
- // shell.Units = row.Get<StockHolding, double>(x => x.Units);
- // shell.DimensionsUnitSize = row.Get<StockHolding, string>(x => x.Dimensions.UnitSize);
- // shell.DisplaySize = "UOM: " + shell.DimensionsUnitSize;
- // shell.DisplayUnits = "Units: " + shell.Units;
- // shell.JobID = row.Get<StockHolding, Guid>(x => x.Job.ID);
- // shell.JobName = row.Get<StockHolding, string>(x => x.Job.Name);
- // shell.JobNumber = row.Get<StockHolding, string>(x => x.Job.JobNumber);
- // shell.DisplayJob = "Job: " + shell.JobNumber;
- // shell.StyleID = row.Get<StockHolding, Guid>(x => x.Style.ID);
- // shell.StyleCode = row.Get<StockHolding, string>(x => x.Style.Code);
- // shell.ProductID = row.Get<StockHolding, Guid>(x => x.Product.ID);
- // shell.ImageID = row.Get<StockHolding, Guid>(x => x.Product.Image.ID);
- // shell.DimensionsUnitID = row.Get<StockHolding, Guid>(x => x.Dimensions.Unit.ID);
- // shell.DimensionsQuantity = row.Get<StockHolding, double>(x => x.Dimensions.Quantity);
- // shell.DimensionsLength = row.Get<StockHolding, double>(x => x.Dimensions.Length);
- // shell.DimensionsWidth = row.Get<StockHolding, double>(x => x.Dimensions.Width);
- // shell.DimensionsHeight = row.Get<StockHolding, double>(x => x.Dimensions.Height);
- // shell.DimensionsWeight = row.Get<StockHolding, double>(x => x.Dimensions.Weight);
- // shell.DimensionsValue = row.Get<StockHolding, double>(x => x.Dimensions.Value);
- // shell.DimensionsHasHeight = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasHeight);
- // shell.DimensionsHasWeight = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasWeight);
- // shell.DimensionsHasLength = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasLength);
- // shell.DimensionsHasQuantity = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasQuantity);
- // shell.DimensionsHasWidth = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasWidth);
- // shell.DimensionsUnitFormat = row.Get<StockHolding, string>(x => x.Dimensions.Unit.Format);
- // shell.DimensionsUnitFormula = row.Get<StockHolding, string>(x => x.Dimensions.Unit.Formula);
- //
- // if (!shell.Code.Contains("FREIGHT") && shell.Units != 0)
- // {
- // stockHoldingShells.Add(shell);
- // }
- //
- // }
- // LoadImages();
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // rightCountLbl.Text = "Items: " + stockHoldingShells.Count();
- // rightListView.ItemsSource = null;
- // rightListView.ItemsSource = stockHoldingShells;
- // });
- // }
- // });
- //}
- // private CoreTable QueryStockHoldings(Filter<StockHolding> filter)
- // {
- // try
- // {
- // return new Client<StockHolding>().Query
- // (
- // filter,
- // new Columns<StockHolding>
- // (
- // x => x.ID,
- // x => x.Product.Code,
- // x => x.Product.Name,
- // x => x.Style.Description,
- // x => x.Units,
- // x => x.Location.ID,
- // x => x.Job.ID,
- // x => x.Job.Name,
- // x => x.Job.JobNumber,
- // x => x.Style.ID,
- // x => x.Style.Code,
- // x => x.Product.ID,
- // x => x.Product.Image.ID,
- // x => x.Dimensions.UnitSize,
- // x => x.Dimensions.Unit.ID,
- // x => x.Dimensions.Quantity,
- // x => x.Dimensions.Length,
- // x => x.Dimensions.Width,
- // x => x.Dimensions.Height,
- // x => x.Dimensions.Weight,
- // x => x.Dimensions.Value,
- // x => x.Dimensions.Unit.HasQuantity,
- // x => x.Dimensions.Unit.HasLength,
- // x => x.Dimensions.Unit.HasWeight,
- // x => x.Dimensions.Unit.HasWidth,
- // x => x.Dimensions.Unit.HasHeight,
- // x => x.Dimensions.Unit.Format,
- // x => x.Dimensions.Unit.Formula
- // ),
- // null
- // );
- // }
- // catch (Exception ex)
- // {
- // InABox.Mobile.MobileLogging.Log(ex);
- // return null;
- // }
- // }
- #endregion
- private void Holding_Clicked(object sender, EventArgs e)
- {
- throw new NotImplementedException();
- }
- private void TransactionImage_Clicked(object sender, EventArgs e)
- {
- throw new NotImplementedException();
- }
- private void Transaction_Clicked(object sender, EventArgs e)
- {
- throw new NotImplementedException();
- }
- private void DeleteTransaction_Clicked(object sender, MobileMenuButtonClickedEventArgs args)
- {
- throw new NotImplementedException();
- }
- private void Image_Clicked(object sender, EventArgs e)
- {
- throw new NotImplementedException();
- }
- private void Save_Clicked(object sender, MobileMenuButtonClickedEventArgs args)
- {
- throw new NotImplementedException();
- }
- private void Location_Clicked(object sender, MobileButtonClickEventArgs args)
- {
- StockLocationSelectionPage page = new StockLocationSelectionPage(
- new Guid[] { ViewModel?.Location?.ID ?? Guid.Empty },
- false,
- false);
- page.OnLocationSelected += (s, e) =>
- {
- var location = e.Locations.FirstOrDefault();
- ViewModel.Location = location ?? new StockLocationShell();
- };
- Navigation.PushAsync(page);
- }
- }
- public class StockLocationShell_Old
- {
- public Guid ID { get; set; }
- public string Description { get; set; }
- public string Code { get; set; }
- public string Warehouse { get; set; }
- public string Area { get; set; }
- public string NumberOfHoldings { get; set; }
- public string OpenCloseLocation { get; set; }
- public Color Color { get; set; }
- public string JobNumber { get; set; }
- public Guid JobID { get; set; }
- public String JobName { get; set; }
- public List<POItemShell> PoItems { get; set; }
- public string NumberOfReceivedItems { get; set; }
- public StockLocationShell_Old()
- {
- ID = Guid.Empty;
- Description = "";
- Warehouse = "";
- Area = "";
- NumberOfHoldings = "";
- OpenCloseLocation = "Open";
- Color = Color.Default;
- JobNumber = "";
- Code = "";
- PoItems = new List<POItemShell>();
- NumberOfReceivedItems = "";
- JobID = Guid.Empty;
- JobName = "";
- }
- }
- }
|