void LoadData()
 {
     try
     {
         string retmsg = string.Empty;
         recItems = new ObservableCollection <Item>();
         DataManager manager = new DataManager();
         Device.BeginInvokeOnMainThread(() => UserDialogs.Instance.ShowLoading("Loading", MaskType.Black));
         Task.Run(async() =>
         {
             recItems = manager.GetSQLite_ItemtoUnload();
             if (recItems != null)
             {
                 if (recItems.Count > 0)
                 {
                     foreach (Item i in recItems)
                     {
                         ChangedItem citm = new ChangedItem();
                         citm             = manager.GetSQLite_ChangedItembyItemNo(i.ItemNo);
                         if (citm == null)
                         {
                             await manager.UpdateSQLite_UnloadInventory(i.ItemNo, i.BalQty);
                         }
                     }
                 }
                 recItems.Clear();
                 recItems = manager.GetSQLite_ItemtoUnload();
             }
         }).ContinueWith(result => Device.BeginInvokeOnMainThread(() =>
         {
             UserDialogs.Instance.HideLoading();
             if (recItems != null)
             {
                 if (recItems.Count > 0)
                 {
                     listview.BeginRefresh();
                     listview.ItemsSource = recItems;
                     listview.EndRefresh();
                     DataLayout.IsVisible  = true;
                     Emptylayout.IsVisible = false;
                 }
                 else
                 {
                     listview.ItemsSource = null;
                     retmsg = string.Empty;
                     DataLayout.IsVisible  = false;
                     Emptylayout.IsVisible = true;
                 }
             }
             else
             {
                 listview.ItemsSource = null;
                 retmsg = string.Empty;
                 DataLayout.IsVisible  = false;
                 Emptylayout.IsVisible = true;
             }
             listview.Unfocus();
             if (!string.IsNullOrEmpty(retmsg))
             {
                 UserDialogs.Instance.ShowError(retmsg, 3000);
             }
         }));
     }
     catch (OperationCanceledException ex)
     {
         Acr.UserDialogs.UserDialogs.Instance.HideLoading(); //IsLoading = false;
         UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
     }
     catch (Exception ex)
     {
         UserDialogs.Instance.HideLoading(); //IsLoading = false;
         UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
     }
 }
        private async void UpdateButtonOnClicked(object sender, EventArgs e)
        {
            try
            {
                string      retval  = string.Empty;
                DataManager manager = new DataManager();
                if (ParentPage == "Load")
                {
                    OnLoadValidated();
                    RequestLine line = new RequestLine()
                    {
                        ID            = ln.ID,
                        EntryNo       = ln.EntryNo,
                        HeaderEntryNo = ln.HeaderEntryNo,
                        ItemNo        = ln.ItemNo,
                        ItemDesc      = ln.ItemDesc,
                        QtyperBag     = ln.QtyperBag,
                        NoofBags      = ln.NoofBags,
                        Quantity      = ln.Quantity,
                        PickQty       = decimal.Parse(QuantityEntry.Text),
                        LoadQty       = ln.LoadQty,
                        SoldQty       = ln.SoldQty,
                        UnloadQty     = ln.UnloadQty,
                        UomCode       = ln.UomCode,
                        VendorNo      = ln.VendorNo,
                        RequestNo     = ln.RequestNo,
                        UserID        = ln.UserID,
                        InHouse       = ln.InHouse,
                        IsSync        = ln.IsSync,
                        SyncDateTime  = ln.SyncDateTime
                    };
                    retval = await manager.SaveSQLite_RequestLine(line);

                    if (retval == "Success")
                    {
                        MessagingCenter.Send <App>((App)Application.Current, "OnLoadData");
                        await PopupNavigation.PopAsync();
                    }
                }
                else
                {
                    OnUnloadValidated();
                    var record = new Item
                    {
                        ID           = item.ID,
                        EntryNo      = item.EntryNo,
                        ItemNo       = item.ItemNo,
                        Description  = item.Description,
                        Description2 = item.Description2,
                        BaseUOM      = item.BaseUOM,
                        Str64Img     = item.Str64Img,
                        UnitPrice    = item.UnitPrice,
                        CategoryCode = item.CategoryCode,
                        BarCode      = item.BarCode,
                        InvQty       = item.InvQty,
                        LoadQty      = item.LoadQty,
                        SoldQty      = item.SoldQty,
                        ReturnQty    = item.ReturnQty,
                        BadQty       = item.BadQty,
                        UnloadQty    = decimal.Parse(QuantityEntry.Text)
                    };
                    retval = await manager.SaveSQLite_ItemInfo(record);

                    if (retval == "Success")
                    {
                        int         id  = 0;
                        ChangedItem itm = new ChangedItem();
                        itm = manager.GetSQLite_ChangedItembyItemNo(item.ItemNo);
                        if (itm != null)
                        {
                            id = itm.ID;
                        }
                        var cObj = new ChangedItem
                        {
                            ID       = id,
                            ItemNo   = item.ItemNo,
                            Quantity = decimal.Parse(QuantityEntry.Text)
                        };
                        retval = await manager.SaveSQLite_ChangedItem(cObj);

                        MessagingCenter.Send <App>((App)Application.Current, "OnUnLoadData");
                        await PopupNavigation.PopAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
            }
        }