| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace PRS.Mobile
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class MovementViewer
- {
- Guid productID = Guid.Empty;
- ObservableList<StockMovementShell_Old> stockMovementShells = new ObservableList<StockMovementShell_Old>();
- string productName = "";
- public MovementViewer(Guid _productID, string _productName)
- {
- InitializeComponent();
- productID = _productID;
- productName = _productName;
- LoadMovements();
- }
- private async void LoadMovements()
- {
- titleLbl.Text = "Loading Movements...";
- await Task.Run(() =>
- {
- CoreTable table = new Client<StockMovement>().Query
- (
- new Filter<StockMovement>(x => x.Product.ID).IsEqualTo(productID),
- new Columns<StockMovement>(ColumnTypeFlags.None).Add
- (
- x => x.Date, //0
- x => x.Location.Code, //1
- x => x.Style.Code, //2
- x => x.Qty, //3
- x => x.Dimensions.UnitSize //4
- ),
- new SortOrder<StockMovement>(x => x.Date, SortDirection.Descending)
- );
- if (table.Rows.Any())
- {
- string emptyString = "";
- foreach (CoreRow row in table.Rows)
- {
- List<object> list = row.Values;
- if (list[0] == null) { list[0] = DateTime.MinValue; } //0
- if (list[1] == null) { list[1] = emptyString; } //1
- if (list[2] == null) { list[2] = emptyString; } //2
- if (list[3] == null) { list[3] = 0.0; } //3
- if (list[4] == null) { list[4] = emptyString; } //4
- StockMovementShell_Old stockMovementShell = new StockMovementShell_Old();
- stockMovementShell.Date = DateTime.Parse(list[0].ToString());
- stockMovementShell.Pack = list[1].ToString();
- stockMovementShell.Finish = list[2].ToString();
- stockMovementShell.Qty = double.Parse(list[3].ToString());
- stockMovementShells.Add(stockMovementShell);
- qtyLbl.Text = "Qty: (" + list[4].ToString() + ")";
- }
- }
- Device.BeginInvokeOnMainThread(() =>
- {
- movementListView.ItemsSource = stockMovementShells;
- titleLbl.Text = productName;
- });
- });
- }
- }
- }
|