|
@@ -21,17 +21,12 @@ namespace comal.timesheets
|
|
|
#region Constructor / navigation
|
|
|
Guid JobID = new Guid();
|
|
|
List<SetoutShell> Setouts = new List<SetoutShell>();
|
|
|
- List<ManufacturingPacketShell> packets = new List<ManufacturingPacketShell>();
|
|
|
- Dictionary<string, Guid> fileNameIDS = new Dictionary<string, Guid>();
|
|
|
+ List<ManufacturingPacketShell> packetShells = new List<ManufacturingPacketShell>();
|
|
|
+ List<MiniManufacturingPacket> packets = new List<MiniManufacturingPacket>();
|
|
|
public SetoutsScreen()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
NavigationPage.SetHasBackButton(this, false);
|
|
|
- if (Device.RuntimePlatform == Device.iOS)
|
|
|
- {
|
|
|
- closeImg.HeightRequest = 45;
|
|
|
- closeImg.WidthRequest = 45;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private void ExitBtn_Clicked(object sender, EventArgs e)
|
|
@@ -50,8 +45,6 @@ namespace comal.timesheets
|
|
|
using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading"))
|
|
|
{
|
|
|
AddSetoutsToList(DoSetoutsQuery());
|
|
|
-
|
|
|
- DisplayList();
|
|
|
}
|
|
|
}
|
|
|
catch { }
|
|
@@ -68,33 +61,79 @@ namespace comal.timesheets
|
|
|
x => x.Description
|
|
|
)
|
|
|
);
|
|
|
+
|
|
|
+ DoPacketsQuery(table);
|
|
|
+
|
|
|
return table;
|
|
|
}
|
|
|
+
|
|
|
+ private void DoPacketsQuery(CoreTable table)
|
|
|
+ {
|
|
|
+ List<Guid> ids = new List<Guid>();
|
|
|
+ foreach (CoreRow row in table.Rows)
|
|
|
+ ids.Add(row.Get<Setout, Guid>(x => x.ID));
|
|
|
+
|
|
|
+ CoreTable packetstable = new Client<ManufacturingPacket>().Query(new Filter<ManufacturingPacket>(x => x.SetoutLink.ID).InList(ids.ToArray())
|
|
|
+ , Columns);
|
|
|
+
|
|
|
+ foreach (CoreRow row in packetstable.Rows)
|
|
|
+ {
|
|
|
+ packets.Add(new MiniManufacturingPacket
|
|
|
+ {
|
|
|
+ ID = row.Get<ManufacturingPacket, Guid>(x => x.ID),
|
|
|
+ OrderID = row.Get<ManufacturingPacket, Guid>(x => x.OrderItem.ID),
|
|
|
+ Serial = row.Get<ManufacturingPacket, string>(x => x.Serial),
|
|
|
+ Location = row.Get<ManufacturingPacket, string>(x => x.Location),
|
|
|
+ SetoutID = row.Get<ManufacturingPacket, Guid>(x => x.SetoutLink.ID),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
private void AddSetoutsToList(CoreTable table)
|
|
|
{
|
|
|
foreach (CoreRow row in table.Rows)
|
|
|
Setouts.Add(CreateSetoutShell(row));
|
|
|
+
|
|
|
+ foreach (var shell in Setouts)
|
|
|
+ {
|
|
|
+ var item = CreateSetOutViewItem(shell);
|
|
|
+ setoutsList.Children.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ private SetoutPacketGrid CreateSetOutViewItem(SetoutShell shell)
|
|
|
+ {
|
|
|
+ return new SetoutPacketGrid(shell);
|
|
|
+ }
|
|
|
+
|
|
|
private SetoutShell CreateSetoutShell(CoreRow row)
|
|
|
{
|
|
|
- List<object> list = row.Values;
|
|
|
- if (list[0] == null) list[0] = Guid.Empty;
|
|
|
- if (list[1] == null) list[1] = "";
|
|
|
- if (list[2] == null) list[2] = "";
|
|
|
+ SetoutShell shell = AddSetoutDetails(row);
|
|
|
+
|
|
|
+ shell = AddPacketDetails(shell);
|
|
|
+
|
|
|
+ return shell;
|
|
|
+ }
|
|
|
|
|
|
+ private SetoutShell AddSetoutDetails(CoreRow row)
|
|
|
+ {
|
|
|
SetoutShell shell = new SetoutShell();
|
|
|
- shell.ID = Guid.Parse(list[0].ToString());
|
|
|
- shell.Number = list[1].ToString();
|
|
|
- shell.Description = list[2].ToString();
|
|
|
+ shell.ID = row.Get<Setout, Guid>(x => x.ID);
|
|
|
+ shell.Number = row.Get<Setout, string>(x => x.Number);
|
|
|
+ shell.Description = row.Get<Setout, string>(x => x.Description);
|
|
|
|
|
|
return shell;
|
|
|
}
|
|
|
- private void DisplayList()
|
|
|
+
|
|
|
+ private SetoutShell AddPacketDetails(SetoutShell shell)
|
|
|
{
|
|
|
- Device.BeginInvokeOnMainThread(() =>
|
|
|
+ var list = packets.Where(x => x.SetoutID == shell.ID);
|
|
|
+ foreach (var packet in list)
|
|
|
{
|
|
|
- setoutsListView.ItemsSource = Setouts;
|
|
|
- });
|
|
|
+ shell.Packets.Add(packet);
|
|
|
+ }
|
|
|
+
|
|
|
+ return shell;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -110,225 +149,72 @@ namespace comal.timesheets
|
|
|
};
|
|
|
Navigation.PushAsync(page);
|
|
|
}
|
|
|
- private void SetoutsListView_Tapped(object sender, EventArgs e)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- SetoutShell shell = setoutsListView.SelectedItem as SetoutShell;
|
|
|
- QueryPDFsAndPackets(shell.ID);
|
|
|
- DisplayPackets();
|
|
|
- }
|
|
|
- catch { }
|
|
|
- }
|
|
|
- private async void ClosePackets_Clicked(object sender, EventArgs e)
|
|
|
- {
|
|
|
- await packetsFrame.TranslateTo(0, 900, 500);
|
|
|
- packetsFrame.IsVisible = false;
|
|
|
- packetsFrame.TranslateTo(0, 0, 500);
|
|
|
- packetsFrame.IsVisible = false;
|
|
|
- packetRow.Height = 0;
|
|
|
- }
|
|
|
- private void PDFs_Tapped(object sender, EventArgs e)
|
|
|
- {
|
|
|
- PDFList list = new PDFList(fileNameIDS);
|
|
|
- Navigation.PushAsync(list);
|
|
|
- }
|
|
|
- private void PacketListView_Tapped(object sender, EventArgs e)
|
|
|
- {
|
|
|
- ManufacturingPacketShell shell = packetListView.SelectedItem as ManufacturingPacketShell;
|
|
|
- ManufacturingPacketPopup popup = new ManufacturingPacketPopup(shell.ID, shell.OrderID);
|
|
|
- Navigation.PushAsync(popup);
|
|
|
- }
|
|
|
#endregion
|
|
|
|
|
|
- #region Loading Setout Details (Packets and PDFs)
|
|
|
- private async void DisplayPackets()
|
|
|
- {
|
|
|
- packetsFrame.IsVisible = false;
|
|
|
-
|
|
|
- int height = 60 + (packets.Count * 150);
|
|
|
- if (height > 600)
|
|
|
- height = 600;
|
|
|
-
|
|
|
- packetRow.Height = height;
|
|
|
-
|
|
|
- packetListView.ItemsSource = null;
|
|
|
- packetListView.ItemsSource = packets;
|
|
|
+ Columns<ManufacturingPacket> Columns = new Columns<ManufacturingPacket>(
|
|
|
+ x => x.ID,
|
|
|
+ x => x.OrderItem.ID,
|
|
|
+ x => x.Serial,
|
|
|
+ x => x.Location,
|
|
|
+ x => x.SetoutLink.ID
|
|
|
+ );
|
|
|
|
|
|
- packetsLbl.Text = "Packets (" + packets.Count + ")";
|
|
|
- await packetsFrame.TranslateTo(0, 900, 0);
|
|
|
- packetsFrame.IsVisible = true;
|
|
|
- await packetsFrame.TranslateTo(0, 0, 500);
|
|
|
- }
|
|
|
- private void QueryPDFsAndPackets(Guid setoutID)
|
|
|
- {
|
|
|
- QueryPackets(setoutID);
|
|
|
- Task.Run(() => { QueryPDFs(setoutID); });
|
|
|
- }
|
|
|
- private void AddPacketsToList(CoreTable table)
|
|
|
- {
|
|
|
- packets.Clear();
|
|
|
- foreach (CoreRow row in table.Rows)
|
|
|
- packets.Add(CreatePacket(row));
|
|
|
- }
|
|
|
- private ManufacturingPacketShell CreatePacket(CoreRow row)
|
|
|
+ #region Searching
|
|
|
+ private void SearchEnt_Changed(object sender, EventArgs e)
|
|
|
{
|
|
|
- List<object> list = row.Values;
|
|
|
- if (list[0] == null) { list[0] = ""; } //0
|
|
|
- if (list[1] == null) { list[1] = 0; } //1
|
|
|
- if (list[2] == null) { list[2] = Guid.Empty; } //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] = DateTime.MinValue; } //6
|
|
|
- if (list[7] == null) { list[7] = DateTime.MinValue; } //7
|
|
|
- if (list[8] == null) { list[8] = 0; } //8
|
|
|
- if (list[9] == null) { list[9] = 0.0; } //9
|
|
|
- if (list[10] == null) { list[10] = ""; } //10
|
|
|
- if (list[11] == null) { list[11] = ""; } //11
|
|
|
- if (list[12] == null) { list[12] = ""; } //12
|
|
|
- if (list[13] == null) { list[13] = Guid.Empty; } //13
|
|
|
- if (list[14] == null) { list[14] = ""; } //14
|
|
|
- if (list[15] == null) { list[15] = Guid.Empty; } //15
|
|
|
- if (list[16] == null) { list[16] = ""; } //16
|
|
|
- if (list[17] == null) { list[17] = ""; } //17
|
|
|
- if (list[18] == null) { list[18] = ""; } //18
|
|
|
- if (list[19] == null) { list[19] = ""; } //19
|
|
|
- if (list[20] == null) { list[20] = Guid.Empty; } //20
|
|
|
- if (list[21] == null) { list[21] = DateTime.MinValue; } //21
|
|
|
- if (list[22] == null) { list[22] = DateTime.MinValue; } //22
|
|
|
- if (list[23] == null) { list[23] = Guid.Empty; } //23
|
|
|
-
|
|
|
- ManufacturingPacketShell shell = new ManufacturingPacketShell()
|
|
|
- {
|
|
|
- Title = list[0].ToString(),
|
|
|
- Quantity = list[1].ToString(),
|
|
|
- DrawingID = Guid.Parse(list[2].ToString()),
|
|
|
- StageLinkSection = list[3].ToString(),
|
|
|
- JobNumber = list[4].ToString(),
|
|
|
- ITPCode = list[4].ToString() + " " + list[5].ToString(),
|
|
|
- Created = "C: " + DateTime.Parse(list[6].ToString()).ToString("dd MMM yy"),
|
|
|
- DueDate = "D: " + DateTime.Parse(list[7].ToString()).ToString("dd MMM yy"),
|
|
|
- StageLinkStation = int.Parse(list[8].ToString()),
|
|
|
- StageLinkPercentage = list[9].ToString() + "%",
|
|
|
- FactoryName = list[10].ToString(),
|
|
|
- Location = list[11].ToString(),
|
|
|
- SetoutID = Guid.Parse(list[13].ToString()),
|
|
|
- SetoutNumber = list[14].ToString(),
|
|
|
- ID = Guid.Parse(list[15].ToString()),
|
|
|
- TemplateLinkCode = list[16].ToString(),
|
|
|
- JobName = list[17].ToString(),
|
|
|
- OrderID = Guid.Parse(list[20].ToString()),
|
|
|
- OrderRecDate = DateTime.Parse(list[21].ToString()),
|
|
|
- JobID = Guid.Parse(list[23].ToString()),
|
|
|
- };
|
|
|
- if (!string.IsNullOrWhiteSpace(list[18].ToString()))
|
|
|
- {
|
|
|
- shell.Serial = "[" + list[18].ToString() + "] " + list[12].ToString() + ":";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- shell.Serial = list[12].ToString();
|
|
|
- }
|
|
|
- if (!string.IsNullOrWhiteSpace(shell.StageLinkSection))
|
|
|
- shell.StageLinkPercentage = shell.StageLinkPercentage + " of " + shell.StageLinkSection;
|
|
|
- else
|
|
|
- shell.StageLinkPercentage = "TBI";
|
|
|
-
|
|
|
- if (!string.IsNullOrWhiteSpace(list[19].ToString()))
|
|
|
+ if (!string.IsNullOrWhiteSpace(searchEnt.Text))
|
|
|
{
|
|
|
- shell.ImagePath = "notifications.png";
|
|
|
- shell.ImageHeight = 25.0;
|
|
|
- shell.ImageWidth = 25.0;
|
|
|
- if (Device.RuntimePlatform.Equals(Device.iOS))
|
|
|
+ foreach (var child in setoutsList.Children)
|
|
|
{
|
|
|
- shell.ImageHeight = 35.0;
|
|
|
- shell.ImageWidth = 35.0;
|
|
|
+ if (ConditionsMet(child, searchEnt.Text))
|
|
|
+ child.IsVisible = true;
|
|
|
+ else
|
|
|
+ child.IsVisible = false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (shell.OrderID != Guid.Empty && shell.OrderRecDate == DateTime.MinValue)
|
|
|
+ else
|
|
|
{
|
|
|
- shell.OnOrderVisible = true;
|
|
|
- shell.LastRowHeight = 30;
|
|
|
- if (DateTime.TryParse(list[22].ToString(), out DateTime ETA))
|
|
|
+ foreach (var c in setoutsList.Children)
|
|
|
{
|
|
|
- shell.OrderETA = "ON ORDER ETA: " + ETA.ToString("dd MMM yy");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- shell.OrderETA = "ON ORDER";
|
|
|
+ c.IsVisible = true;
|
|
|
}
|
|
|
}
|
|
|
- return shell;
|
|
|
}
|
|
|
- private void QueryPDFs(Guid setoutID)
|
|
|
+
|
|
|
+ private bool ConditionsMet(View child, string text)
|
|
|
{
|
|
|
- fileNameIDS.Clear();
|
|
|
- CoreTable table = new Client<SetoutDocument>().Query
|
|
|
- (
|
|
|
- new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(setoutID),
|
|
|
- new Columns<SetoutDocument>(x => x.DocumentLink.ID, x => x.DocumentLink.FileName)
|
|
|
- );
|
|
|
- if (table.Rows.Any())
|
|
|
- {
|
|
|
- foreach (CoreRow row in table.Rows)
|
|
|
- {
|
|
|
- fileNameIDS.Add(row.Get<string>("DocumentLink.FileName"), row.Get<Guid>("DocumentLink.ID"));
|
|
|
- }
|
|
|
- }
|
|
|
- Device.BeginInvokeOnMainThread(() =>
|
|
|
- {
|
|
|
- numberOfDocsLbl.Text = fileNameIDS.Count.ToString();
|
|
|
- });
|
|
|
+ var item = child as SetoutPacketGrid;
|
|
|
+ if (SetOutConditionsMatch(item, text) || PacketConditionsMet(item, text))
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
}
|
|
|
- private void QueryPackets(Guid setoutID)
|
|
|
+
|
|
|
+ private bool SetOutConditionsMatch(SetoutPacketGrid child, string text)
|
|
|
{
|
|
|
- AddPacketsToList(new Client<ManufacturingPacket>().Query
|
|
|
- (
|
|
|
- new Filter<ManufacturingPacket>(x => x.SetoutLink.ID).IsEqualTo(setoutID),
|
|
|
- Columns
|
|
|
- ));
|
|
|
+ if (child.Shell.Number.Contains(text) || child.Shell.Number.Contains(text.ToLower()) || child.Shell.Number.Contains(text.ToUpper())
|
|
|
+ || child.Shell.Number.Contains(SearchUtils.UpperCaseFirst(text)) ||
|
|
|
+ child.Shell.Description.Contains(text) || child.Shell.Description.Contains(text.ToLower()) || child.Shell.Description.Contains(text.ToUpper())
|
|
|
+ || child.Shell.Description.Contains(SearchUtils.UpperCaseFirst(text)))
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- Columns<ManufacturingPacket> Columns = new Columns<ManufacturingPacket>(
|
|
|
- x => x.Title, //0
|
|
|
- x => x.Quantity, //1
|
|
|
- x => x.Drawing.ID, //2
|
|
|
- x => x.StageLink.Section, //3
|
|
|
- x => x.SetoutLink.JobLink.JobNumber, //4
|
|
|
- x => x.ITP.Code, //5
|
|
|
- x => x.Created, //6
|
|
|
- x => x.DueDate, //7
|
|
|
- x => x.StageLink.Station, //8
|
|
|
- x => x.StageLink.PercentageComplete, //9
|
|
|
- x => x.ManufacturingTemplateLink.Factory.Name, //10
|
|
|
- x => x.Location, //11
|
|
|
- x => x.Serial, //12
|
|
|
- x => x.SetoutLink.ID, //13
|
|
|
- x => x.SetoutLink.Number, //14
|
|
|
- x => x.ID, //15
|
|
|
- x => x.ManufacturingTemplateLink.Code, //16
|
|
|
- x => x.SetoutLink.JobLink.Name, //17
|
|
|
- x => x.WaterMark, //18
|
|
|
- x => x.Issues, //19
|
|
|
- x => x.OrderItem.ID, //20
|
|
|
- x => x.OrderItem.ReceivedDate, //21
|
|
|
- x => x.OrderItem.Consignment.EstimatedWarehouseArrival, //22
|
|
|
- x => x.SetoutLink.JobLink.ID //23
|
|
|
- );
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region Searching
|
|
|
- private void SearchEnt_Changed(object sender, EventArgs e)
|
|
|
+ private bool PacketConditionsMet(SetoutPacketGrid child, string text)
|
|
|
{
|
|
|
- if (!string.IsNullOrWhiteSpace(searchEnt.Text))
|
|
|
- setoutsListView.ItemsSource = Setouts.Where(x => x.Number.Contains(searchEnt.Text)
|
|
|
- || x.Description.Contains(searchEnt.Text) || x.Description.Contains(SearchUtils.UpperCaseFirst(searchEnt.Text))
|
|
|
- || x.Description.Contains(searchEnt.Text.ToLower()) || x.Description.Contains(searchEnt.Text.ToUpper()));
|
|
|
- else
|
|
|
- setoutsListView.ItemsSource = Setouts;
|
|
|
+ foreach (var packet in child.Shell.Packets)
|
|
|
+ {
|
|
|
+ if (packet.Serial.Contains(text) || packet.Serial.Contains(text.ToUpper()) || packet.Serial.Contains(text.ToLower())
|
|
|
+ || packet.Serial.Contains(SearchUtils.UpperCaseFirst(text))
|
|
|
+ || packet.Location.Contains(text) || packet.Location.Contains(text.ToUpper()) || packet.Location.Contains(text.ToLower())
|
|
|
+ || packet.Location.Contains(SearchUtils.UpperCaseFirst(text)))
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
@@ -337,12 +223,31 @@ namespace comal.timesheets
|
|
|
public Guid ID { get; set; }
|
|
|
public string Number { get; set; }
|
|
|
public string Description { get; set; }
|
|
|
+ public List<MiniManufacturingPacket> Packets { get; set; }
|
|
|
|
|
|
public SetoutShell()
|
|
|
{
|
|
|
ID = Guid.Empty;
|
|
|
Number = "";
|
|
|
Description = "";
|
|
|
+ Packets = new List<MiniManufacturingPacket>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public class MiniManufacturingPacket
|
|
|
+ {
|
|
|
+ public Guid ID { get; set; }
|
|
|
+ public Guid OrderID { get; set; }
|
|
|
+ public Guid SetoutID { get; set; }
|
|
|
+ public string Serial { get; set; }
|
|
|
+ public string Location { get; set; }
|
|
|
+ public MiniManufacturingPacket()
|
|
|
+ {
|
|
|
+ ID = Guid.Empty;
|
|
|
+ OrderID = Guid.Empty;
|
|
|
+ Serial = "";
|
|
|
+ Location = "";
|
|
|
+ SetoutID = Guid.Empty;
|
|
|
}
|
|
|
}
|
|
|
}
|