Selaa lähdekoodia

Fixed invalid transport crash at startup
Added ability to add purchase order to consignment

Frank van den Bos 10 kuukautta sitten
vanhempi
commit
677c18d8dc

+ 10 - 2
prs.mobile.new/PRS.Mobile/App.xaml.cs

@@ -40,8 +40,16 @@ namespace PRS.Mobile
             
             if (!urls.Any())
                 return TransportStatus.BadConfiguration;
-            
-            Transport.Connect();
+
+            try
+            {
+
+                Transport.Connect();
+            }
+            catch (Exception e)
+            {
+                MobileLogging.Log(e);
+            }
             if (!Transport.IsConnected())
                 return TransportStatus.NoConnection;
             

+ 6 - 2
prs.mobile.new/PRS.Mobile/Data Models/Lists/Consignment/ConsignmentShell.cs

@@ -23,8 +23,12 @@ namespace PRS.Mobile
                 .Map(nameof(ActualWarehouseArrival), x => x.ActualWarehouseArrival);
 
         }
-        
-        public string Number => Get<string>();
+
+        public string Number
+        {
+            get => Get<string>();
+            set => Set(value);
+        }
 
         public string Description
         {

+ 8 - 17
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Consignments/ConsignmentsModule.xaml.cs

@@ -155,24 +155,15 @@ namespace PRS.Mobile
                 },
                 (orders) =>
                 {
-                    
+                    var order = orders.FirstOrDefault() ?? new PurchaseOrderShell();
                     _newshell = _consignments.CreateItem();
-                    Navigation.PushAsync(new ConsignmentEdit(_newshell));
-                    
-                    
-                    var model = new PurchaseOrderItemModel(App.Data,
-                        () => new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.ID).IsEqualTo(orders.FirstOrDefault()?.ID ?? Guid.Empty));
-                    model.Refresh(false);
-                    foreach (var item in model.Items)
-                    {
-                        var newitem = ViewModel.Items.AddItem();
-                        newitem.Row.LoadValues(item.Row.Values);
-                    }
-                    Dispatcher.BeginInvokeOnMainThread(() =>
-                    {
-                        _itemsList.ItemsSource = null;
-                        _itemsList.ItemsSource = ViewModel.Items;
-                    });
+                    _newshell.SupplierID = order.SupplierID;
+                    _newshell.SupplierName = order.SupplierName;
+                    _newshell.Number = order.PONumber;
+                    _newshell.EstimatedWarehouseArrival = order.DueDate;
+                    _newshell.ActualWarehouseArrival = DateTime.Now;
+                    _newshell.Description = $"Goods Received on PO {order.PONumber}";
+                    Navigation.PushAsync(new ConsignmentEdit(_newshell, orders.FirstOrDefault()));
                     DismissPopup();
                 }));
             

+ 13 - 18
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Consignments/Edit/ConsignmentEdit.xaml

@@ -22,26 +22,21 @@
     
     <mobile:MobilePage.PrimaryMenu>
         
-        <mobile:MobileMenuButton
-            x:Name="_saveNew"
-            Image="save"
-            Clicked="_save_OnClicked">
-            <mobile:MobileMenuButton.IsVisible>
-                <MultiBinding Converter="{StaticResource MatchAll}">
-                    <Binding Path="IsChanged"/>
-                    <Binding Source="{x:Reference _tabStrip}" Path="SelectedIndex" Converter="{StaticResource DetailsPageVisible}" />
-                </MultiBinding>
-            </mobile:MobileMenuButton.IsVisible>
-        </mobile:MobileMenuButton>
+        <!-- <mobile:MobileMenuButton -->
+        <!--     x:Name="_saveNew" -->
+        <!--     Image="save" -->
+        <!--     Clicked="_save_OnClicked"> -->
+        <!--     <mobile:MobileMenuButton.IsVisible> -->
+        <!--         <MultiBinding Converter="{StaticResource MatchAll}"> -->
+        <!--             <Binding Path="IsChanged"/> -->
+        <!--             <Binding Source="{x:Reference _tabStrip}" Path="SelectedIndex" Converter="{StaticResource DetailsPageVisible}" /> -->
+        <!--         </MultiBinding> -->
+        <!--     </mobile:MobileMenuButton.IsVisible> -->
+        <!-- </mobile:MobileMenuButton> -->
         
         <mobile:MobileMenuButton
-            Image="plus" Clicked="AddItem_Clicked">
-            <mobile:MobileMenuButton.IsVisible>
-                <MultiBinding Converter="{StaticResource MatchAll}">
-                    <Binding Path="IsChanged" Converter="{StaticResource NotTrue}"/>
-                    <Binding Source="{x:Reference _tabStrip}" Path="SelectedIndex" Converter="{StaticResource ItemsPageVisible}" />
-                </MultiBinding>
-            </mobile:MobileMenuButton.IsVisible>
+            Image="plus" Clicked="AddItem_Clicked"
+            IsVisible="{Binding Source={x:Reference _tabStrip}, Path=SelectedIndex, Converter={StaticResource ItemsPageVisible}}">
         </mobile:MobileMenuButton>
         
         <mobile:MobileMenuButton

+ 3 - 1
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Consignments/Edit/ConsignmentEdit.xaml.cs

@@ -13,10 +13,12 @@ namespace PRS.Mobile
     public partial class ConsignmentEdit
     {
         
-        public ConsignmentEdit(ConsignmentShell consignment)
+        public ConsignmentEdit(ConsignmentShell consignment, PurchaseOrderShell? order = null)
         {
             InitializeComponent();
             ViewModel.Item = consignment;
+            if (order != null)
+                ViewModel.LoadOrder(order);
         }
 
         private void _save_OnClicked(object sender, MobileMenuButtonClickedEventArgs args)

+ 13 - 0
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Consignments/Edit/ConsignmentEditViewModel.cs

@@ -26,6 +26,19 @@ namespace PRS.Mobile
             //Forms = new PurchaseOrderItemFormModel(App.Data, 
             //    () => new Filter<PurchaseOrderItemForm>(x => x.Parent.ID).IsEqualTo(Item?.ID ?? Guid.Empty));
         }
+
+        public void LoadOrder(PurchaseOrderShell order)
+        {
+            var orderitems = new PurchaseOrderItemModel(App.Data, 
+                () => new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.ID).IsEqualTo(order.ID));
+            orderitems.Refresh(true);
+            foreach (var orderitem in orderitems.Items)
+            {
+                var consitem = Items.CreateItem();
+                consitem.Row.LoadValues(orderitem.Row.Values);
+                Items.CommitItem(consitem);
+            }
+        }
         
         protected override void DoLoad()
         {

+ 30 - 2
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Consignments/Views/ConsignmentEditDetailsView.xaml

@@ -79,7 +79,35 @@
                 </mobile:MobileCard>
             </views:DockLayout>
             
-
+            <views:DockLayout
+                views:DockLayout.Dock="Bottom">
+                <mobile:MobileButton
+                    Image="lines"
+                    views:DockLayout.Dock="Right"
+                    WidthRequest="35" 
+                    Margin="5,0,0,0"
+                    Clicked="SelectATA_Clicked"/>
+                <mobile:MobileCard
+                    views:DockLayout.Dock="Top"
+                    BackgroundColor="WhiteSmoke">
+                    <mobile:MobileEntry 
+                        views:DockLayout.Dock="Left"
+                        Text="{Binding Item.ActualWarehouseArrival, StringFormat='{}{0:dd MMMM yy}'}"
+                        IsReadOnly="True"
+                        HorizontalTextAlignment="Center"
+                        BackgroundColor="Transparent"
+                        Margin="5,0,5,0"
+                    />
+                </mobile:MobileCard>
+            </views:DockLayout>
+            
+            <Label
+                Text="Actual Delivery Date:"
+                FontSize="{StaticResource Theme.Text.Body.Size}"
+                views:DockLayout.Dock="Bottom"
+                Margin="0,5,0,0"/>
+            
+            
             <views:DockLayout
                 views:DockLayout.Dock="Bottom">
                 <mobile:MobileButton
@@ -103,7 +131,7 @@
             </views:DockLayout>
             
             <Label
-                Text="Estimated Arrival:"
+                Text="Estimated Arrival Date:"
                 FontSize="{StaticResource Theme.Text.Body.Size}"
                 views:DockLayout.Dock="Bottom"
                 Margin="0,5,0,0"/>

+ 22 - 0
prs.mobile.new/PRS.Mobile/Modules/Warehousing/Consignments/Views/ConsignmentEditDetailsView.xaml.cs

@@ -98,5 +98,27 @@ namespace PRS.Mobile
         {
             DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.Description));
         }
+
+        private void SelectATA_Clicked(object sender, MobileButtonClickEventArgs args)
+        {
+            ShowPopup(
+                () =>
+                {
+                    var selector = new MobileDateSelector();
+                    selector.Date = ViewModel.Item.ActualWarehouseArrival;
+                    selector.Changed += (o, changedArgs) =>
+                    {
+                        ViewModel.Item.ActualWarehouseArrival = changedArgs.Date;
+                        DismissPopup();
+                    };
+                    selector.Cancelled += (o, eventArgs) => DismissPopup();
+                    return selector;
+                }, 
+                new PopupManagerConfiguration()
+                {
+                    Modal = true
+                }
+            );
+        }
     }
 }