| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- 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 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, //0
- x => x.Product.ID, //1
- x => x.Location.ID, //2
- x => x.Location.Description, //3
- x => x.Units, //4
- x => x.Dimensions.UnitSize, //5
- x => x.Job.ID, //6
- x => x.Job.JobNumber, //7
- x => x.Job.Name, //8
- x => x.Style.ID, //9
- x => x.Style.Code, //10
- x => x.Style.Description //11
- )
- );
- foreach (CoreRow row in table.Rows)
- {
- List<object> list = row.Values;
- if (list[4] == null) { list[4] = 0.0; } //4
- double dble = 0.0;
- if (double.TryParse(list[4].ToString(), out dble))
- {
- if (dble != 0.0 && dble > 0) //filtering out zero quantities
- {
- if (list[0] == null) { list[0] = Guid.Empty; } //0
- if (list[1] == null) { list[1] = Guid.Empty; } //1
- if (list[2] == null) { list[2] = Guid.Empty; } //2
- if (list[3] == null) { list[3] = ""; } //3
- if (list[5] == null) { list[5] = ""; } //5
- if (list[6] == null) { list[6] = Guid.Empty; } //6
- if (list[7] == null) { list[7] = ""; } //7
- if (list[8] == null) { list[8] = ""; } //8
- if (list[9] == null) { list[9] = Guid.Empty; } //9
- if (list[10] == null) { list[10] = ""; } //10
- if (list[11] == null) { list[11] = ""; } //11
- HoldingsCacheShell holdingsCacheShell = new HoldingsCacheShell()
- {
- ID = Guid.Parse(list[0].ToString()),
- ProductID = Guid.Parse(list[1].ToString()),
- LocationID = Guid.Parse(list[2].ToString()),
- LocationName = list[3].ToString(),
- Units = double.Parse(list[4].ToString()).ToString(),
- DimensionsUnitSize = list[5].ToString(),
- JobID = Guid.Parse(list[6].ToString()),
- JobNumber = list[7].ToString(),
- JobName = list[8].ToString(),
- StyleID = Guid.Parse(list[9].ToString()),
- StyleCode = list[10].ToString(),
- StyleDescription = list[11].ToString(),
- };
- if (holdingsCacheShell.Units != "0")
- {
- holdingsCache.Add(holdingsCacheShell);
- }
- }
- }
- }
- 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 = "";
- }
- }
- }
|