123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- 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 StoreRequiList
- {
- List<RequiShell> requiShells = new List<RequiShell>();
- public StoreRequiList()
- {
- InitializeComponent();
- RequiItems.HoldingsLoaded = true;
- 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 void LoadList()
- {
- Task.Run(() =>
- {
- requiShells.Clear();
- CoreTable table = DoRequisitionQuery();
- while (table == null)
- table = DoRequisitionQuery();
- foreach (var row in table.Rows)
- {
- RequiShell requiShell = new RequiShell();
- requiShell.ID = row.Get<Requisition, Guid>(x => x.ID);
- requiShell.Number = "No. " + row.Get<Requisition,int>(x => x.Number);
- requiShell.Due = "Due " + row.Get<Requisition, DateTime>(x => x.Due).ToString("dd MMM yy");
- requiShell.Contact = "Contact: " + row.Get<Requisition, string>(x => x.RequestedBy.Name);
- requiShell.Job = "(" + row.Get<Requisition, string>(x => x.JobLink.JobNumber) + ") " + row.Get<Requisition, string>(x => x.JobLink.Name);
- requiShell.Request = row.Get<Requisition, string>(x => x.Request);
- string notes = CheckNotes(row.Get<Requisition, string[]>(x => x.Notes));
- requiShell.Request = requiShell.Request + System.Environment.NewLine + notes;
- requiShells.Add(requiShell);
- }
- Device.BeginInvokeOnMainThread(() =>
- {
- requisListView.ItemsSource = null;
- requisListView.ItemsSource = requiShells;
- listLbl.Text = "List of Unfilled Requis (" + requiShells.Count + ")";
- });
- });
- }
- private CoreTable DoRequisitionQuery()
- {
- try
- {
- return new Client<Requisition>().Query(
- new Filter<Requisition>(x => x.Filled).IsEqualTo(DateTime.MinValue),
- new Columns<Requisition>(ColumnTypeFlags.None).Add(
- x => x.ID,
- x => x.Number,
- x => x.Due,
- x => x.RequestedBy.Name,
- x => x.JobLink.JobNumber,
- x => x.JobLink.Name,
- x => x.Request,
- x => x.Notes
- ),
- new SortOrder<Requisition>(x => x.Due)
- );
- }
- catch (Exception ex)
- {
- InABox.Mobile.MobileLogging.Log(ex);
- return null;
- }
- }
- private string CheckNotes(string[] notes)
- {
- string combinednotes = "----------" + System.Environment.NewLine + "NOTES: " + System.Environment.NewLine;
- if (notes.Count() > 0)
- {
- foreach (var note in notes)
- {
- combinednotes = combinednotes + note + System.Environment.NewLine;
- }
- }
- return combinednotes;
- }
- 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);
- }
- }
- 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 = "";
- }
- }
- }
|