| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using ZXing.PDF417.Internal;
- using static comal.timesheets.RequiItems;
- namespace comal.timesheets.StoreRequis
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class StoreRequiList : ContentPage
- {
- List<RequiShell> requiShells = new List<RequiShell>();
- public StoreRequiList()
- {
- InitializeComponent();
- LoadHoldingsCache();
- if (Device.RuntimePlatform.Equals(Device.iOS))
- {
- imageBtn0.Margin = new Thickness(0);
- imageBtn0.VerticalOptions = LayoutOptions.FillAndExpand;
- imageBtn0.HeightRequest = 160;
- takerequinow.Margin = new Thickness(0);
- takerequinow.VerticalOptions = LayoutOptions.FillAndExpand;
- takerequinow.HeightRequest = 160;
- storereqimg.Margin = new Thickness(0);
- storereqimg.HeightRequest = 120;
- }
- }
- protected override void OnAppearing()
- {
- LoadList();
- base.OnAppearing();
- }
- private async void LoadList()
- {
- await Task.Run(() =>
- {
- requiShells.Clear();
- CoreTable table = new Client<Requisition>().Query(
- new Filter<Requisition>(x => x.Filled).IsEqualTo(DateTime.MinValue),
- new Columns<Requisition>(
- x => x.ID, //0
- x => x.Number, //1
- x => x.Due, //2
- x => x.RequestedBy.Name, //3
- x => x.JobLink.JobNumber, //4
- x => x.JobLink.Name, //5
- x => x.Request //6
- ),
- new SortOrder<Requisition>(x => x.Due)
- );
- foreach (var row in table.Rows)
- {
- List<object> list = row.Values;
- if (list[0] == null) { list[0] = Guid.Empty; } //0
- if (list[1] == null) { list[1] = 0; } //1
- if (list[2] == null) { list[2] = DateTime.MinValue; } //2
- if (list[3] == null) { list[3] = ""; } //3
- if (list[4] == null) { list[4] = ""; } //4
- if (list[5] == null) { list[5] = ""; } //5
- if (list[6] == null) { list[6] = ""; } //6
- RequiShell requiShell = new RequiShell();
- requiShell.ID = Guid.Parse(list[0].ToString());
- requiShell.Number = "No. " + list[1].ToString();
- requiShell.Due = "Due " + DateTime.Parse(list[2].ToString()).ToString("dd MMM yy");
- requiShell.Contact = "Contact: " + list[3].ToString();
- requiShell.Job = "(" + list[4].ToString() + ") " + list[5].ToString();
- requiShell.Request = list[6].ToString();
- requiShells.Add(requiShell);
- }
- Device.BeginInvokeOnMainThread(() =>
- {
- requisListView.ItemsSource = null;
- requisListView.ItemsSource = requiShells;
- listLbl.Text = "List of Unfilled Requis (" + requiShells.Count + ")";
- });
- });
- }
- private void Requi_Clicked(object sender, EventArgs e)
- {
- RequiShell requiShell = requisListView.SelectedItem as RequiShell;
- StoreRequiScannerPage storeRequiScannerPage = new StoreRequiScannerPage(requiShell.ID);
- Navigation.PushAsync(storeRequiScannerPage);
- }
- private void TakeStockNow_Tapped(object sender, EventArgs e)
- {
- StoreRequiScannerPage page = new StoreRequiScannerPage(Guid.Empty);
- Navigation.PushAsync(page);
- }
- private void NewRequiRequest_Tapped(object sender, EventArgs e)
- {
- StoreRequiConfirmationPage storeRequiConfirmationPage = new StoreRequiConfirmationPage();
- Navigation.PushAsync(storeRequiConfirmationPage);
- }
- #region Utilities
- private async void LoadHoldingsCache()
- {
- await Task.Run(() =>
- {
- holdingsCache = new List<HoldingsCacheShell>();
- CoreTable table = new Client<StockHolding>().Query(
- new Filter<StockHolding>(x => x.Qty).IsGreaterThan(0),
- new Columns<StockHolding>(
- x => x.ID,
- x => x.Product.ID,
- x => x.Location.ID,
- x => x.Location.Description,
- x => x.Units,
- x => x.Job.ID,
- x => x.Job.JobNumber,
- x => x.Job.Name,
- x => x.Style.ID,
- x => x.Style.Code,
- x => x.Style.Description,
- x => x.Dimensions.Unit.ID,
- x => x.Dimensions.Unit.HasQuantity,
- x => x.Dimensions.Unit.HasLength,
- x => x.Dimensions.Unit.HasHeight,
- x => x.Dimensions.Unit.HasWeight,
- x => x.Dimensions.Unit.HasWidth,
- x => x.Dimensions.Quantity,
- x => x.Dimensions.Length,
- x => x.Dimensions.Height,
- x => x.Dimensions.Weight,
- x => x.Dimensions.Width,
- x => x.Dimensions.Unit.Format,
- x => x.Dimensions.Unit.Formula,
- x => x.Dimensions.UnitSize
- )
- );
- foreach (CoreRow row in table.Rows)
- {
- if (row.Get<StockHolding, double>(x => x.Units) == 0.0)
- continue;
- HoldingsCacheShell holding = new HoldingsCacheShell()
- {
- ProductID = row.Get<StockHolding, Guid>(x => x.Product.ID),
- LocationID = row.Get<StockHolding, Guid>(x => x.Location.ID),
- LocationName = row.Get<StockHolding, string>(x => x.Location.Description),
- Units = row.Get<StockHolding, double>(x => x.Units).ToString(),
- JobID = row.Get<StockHolding, Guid>(x => x.Job.ID),
- JobNumber = row.Get<StockHolding, string>(x => x.Job.JobNumber),
- JobName = row.Get<StockHolding, string>(x => x.Job.Name),
- StyleID = row.Get<StockHolding, Guid>(x => x.Style.ID),
- StyleCode = row.Get<StockHolding, string>(x => x.Style.Code),
- StyleDescription = row.Get<StockHolding, string>(x => x.Style.Description)
- };
- holding.Dimensions.Unit.ID = row.Get<StockHolding, Guid>(x => x.Dimensions.Unit.ID);
- holding.Dimensions.Unit.HasQuantity = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasQuantity);
- holding.Dimensions.Unit.HasLength = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasLength);
- holding.Dimensions.Unit.HasHeight = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasHeight);
- holding.Dimensions.Unit.HasWeight = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasWeight);
- holding.Dimensions.Unit.HasWidth = row.Get<StockHolding, bool>(x => x.Dimensions.Unit.HasWidth);
- holding.Dimensions.Quantity = row.Get<StockHolding, double>(x => x.Dimensions.Quantity);
- holding.Dimensions.Length = row.Get<StockHolding, double>(x => x.Dimensions.Length);
- holding.Dimensions.Height = row.Get<StockHolding, double>(x => x.Dimensions.Height);
- holding.Dimensions.Weight = row.Get<StockHolding, double>(x => x.Dimensions.Weight);
- holding.Dimensions.Width = row.Get<StockHolding, double>(x => x.Dimensions.Width);
- holding.Dimensions.Unit.Format = row.Get<StockHolding, string>(x => x.Dimensions.Unit.Format);
- holding.Dimensions.Unit.Formula = row.Get<StockHolding, string>(x => x.Dimensions.Unit.Formula);
- holding.Dimensions.UnitSize = row.Get<StockHolding, string>(x => x.Dimensions.UnitSize);
- holding.LocationName = holding.LocationName + " (Units: " + holding.Units + ")" +
- Environment.NewLine + "Style: " + holding.StyleDescription
- + Environment.NewLine + "Job: " + holding.JobNumber
- + Environment.NewLine + "Size: " + holding.Dimensions.UnitSize;
- holdingsCache.Add(holding);
- }
- ;
- RequiItems.HoldingsLoaded = true;
- });
- }
- #endregion
- }
- public class RequiShell
- {
- public Guid ID { get; set; }
- public string Number { get; set; }
- public string Due { get; set; }
- public string Contact { get; set; }
- public string Job { get; set; }
- public string Request { get; set; }
- public RequiShell()
- {
- ID = Guid.Empty;
- Number = "";
- Due = "";
- Due = "";
- Job = "";
- Request = "";
- }
- }
- }
|