Пример #1
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            _isEnableSaveBtn = true;
            data             = new RequestHeader();
            if (!IsBack)
            {
                UserDialogs.Instance.ShowLoading("Loading", MaskType.Black); //IsLoading = true;
                Task.Run(async() =>
                {
                    try
                    {
                        if (RequestID != 0)
                        {
                            DataManager manager = new DataManager();
                            data = await manager.GetRequestHeaderbyID(RequestID);
                        }
                        else
                        {
                            data = null;
                        }

                        Device.BeginInvokeOnMainThread(() =>
                        {
                            DisplayData(data);
                            UserDialogs.Instance.HideLoading(); //IsLoading = false;
                        });
                    }
                    catch (OperationCanceledException ex)
                    {
                        UserDialogs.Instance.HideLoading(); //IsLoading = false;
                        //DependencyService.Get<IMessage>().LongAlert(ex.Message.ToString());
                        UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
                    }
                    catch (Exception ex)
                    {
                        UserDialogs.Instance.HideLoading(); //IsLoading = false;
                        //DependencyService.Get<IMessage>().LongAlert(ex.Message.ToString());
                        UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
                    }
                });
            }
        }
Пример #2
0
 void DisplayData(RequestHeader record)
 {
     if (record != null)
     {
         RequestID           = record.ID;
         RequestNoLabel.Text = record.RequestNo;
         //RequestDatePicker.Date = Convert.ToDateTime(record.RequestDate);
         RequestDateTimeLabel.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt");;
         guid = record.EntryNo;
     }
     else
     {
         RequestID = 0;
         guid      = Guid.NewGuid().ToString();
         DataManager manager = new DataManager();
         RequestNoLabel.Text = manager.GetLastNoSeries(App.gRSPrefix);
         //RequestDatePicker.Date = DateTime.Today;
         RequestDateTimeLabel.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt");
     }
 }
        async void SendRequest()
        {
            try
            {
                if (recItems != null)
                {
                    if (recItems.Count == 0)
                    {
                        UserDialogs.Instance.ShowError("No items for send request", 3000);
                        return;
                    }

                    UserDialogs.Instance.ShowLoading("Loading", MaskType.Black);
                    string        alertmsg = string.Empty;
                    DataManager   manager  = new DataManager();
                    RequestHeader objhead  = new RequestHeader();
                    objhead = await manager.GetSQLite_RequestHeadebyKey(HeaderNo);

                    if (objhead != null)
                    {
                        string retmsg = "Success";
                        //string retmsg = App.svcManager.ExportRequestStock(objhead.EntryNo, App.gSalesPersonCode, objhead.RequestNo, objhead.RequestDate, "topick");
                        if (retmsg == "Success")
                        {
                            manager = new DataManager();
                            string retval = await manager.SaveSQLite_RequestHeader(new RequestHeader
                            {
                                ID              = objhead.ID,
                                EntryNo         = objhead.EntryNo,
                                SalesPersonCode = objhead.SalesPersonCode,
                                RequestNo       = objhead.RequestNo,
                                RequestDate     = objhead.RequestDate,
                                IsSync          = "true",
                                SyncDateTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt"),
                                CurStatus       = "picking"
                            });
                        }
                        else
                        {
                            alertmsg = "Can not able to sync doc No " + objhead.RequestNo + ". Err message: " + retmsg;
                            UserDialogs.Instance.ShowError(alertmsg, 3000);
                        }

                        ObservableCollection <RequestLine> lstline = new ObservableCollection <RequestLine>();
                        lstline = await manager.GetRequestLinesbyDocNo(objhead.EntryNo);

                        if (lstline != null && lstline.Count > 0)
                        {
                            foreach (RequestLine l in lstline)
                            {
                                //retmsg = App.svcManager.ExportRequestLine(l.EntryNo, l.HeaderEntryNo, l.UserID, l.ItemNo, l.QtyperBag, l.NoofBags, l.Quantity, l.PickQty, l.LoadQty,l.UnloadQty,l.UomCode, l.VendorNo, l.InHouse, objhead.RequestNo);
                                if (retmsg == "Success")
                                {
                                    manager = new DataManager();
                                    RequestLine line = new RequestLine()
                                    {
                                        ID            = l.ID,
                                        EntryNo       = l.EntryNo,
                                        HeaderEntryNo = l.HeaderEntryNo,
                                        UserID        = l.UserID,
                                        ItemNo        = l.ItemNo,
                                        ItemDesc      = l.ItemDesc,
                                        QtyperBag     = l.QtyperBag,
                                        NoofBags      = l.NoofBags,
                                        Quantity      = l.Quantity,
                                        PickQty       = l.Quantity, //l.PickQty,
                                        LoadQty       = l.LoadQty,
                                        UomCode       = l.UomCode,
                                        VendorNo      = l.VendorNo,
                                        InHouse       = l.InHouse,
                                        RequestNo     = l.RequestNo,
                                        IsSync        = "picking",
                                        SyncDateTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt")
                                    };
                                    await manager.SaveSQLite_RequestLine(line);
                                }
                                else
                                {
                                    alertmsg = "Can not able to sync doc no " + objhead.RequestNo + " -> Item No" + l.ItemNo + ". Err message: " + retmsg;
                                    UserDialogs.Instance.ShowError(alertmsg, 3000);
                                    return;
                                }
                            }
                            // await Task.Delay(10000);
                            retmsg = "Success";// App.svcManager.ImportDataToNAV("SalesRequest", "picking");
                            if (retmsg == "Success")
                            {
                                //DependencyService.Get<INetworkConnection>().CheckNetworkConnection();
                                //if (DependencyService.Get<INetworkConnection>().IsConnected)
                                //{
                                //    string result = DependencyService.Get<INetworkConnection>().IsServiceOnline(Helpers.Settings.GeneralSettings);
                                //    if (result != "true")
                                //    {
                                //        //DependencyService.Get<IMessage>().LongAlert("Error : Service is offline. [" + result + "]");
                                //        UserDialogs.Instance.ShowError("Error : Service is offline. [" + result + "]", 3000);
                                //        return;
                                //    }
                                //}
                                //else
                                //{
                                //    UserDialogs.Instance.ShowError("Error : No internet connection", 3000);
                                //    return;
                                //}
                                // SyncNumberSeries();
                                UserDialogs.Instance.HideLoading();
                                alertmsg = "Request Stock sync success!";
                                UserDialogs.Instance.ShowSuccess(alertmsg, 3000);
                                Navigation.PopAsync();
                            }
                            else
                            {
                                UserDialogs.Instance.HideLoading();
                                UserDialogs.Instance.ShowError(retmsg, 3000);
                                return;
                            }
                        }
                        else
                        {
                            UserDialogs.Instance.HideLoading();
                            retmsg = "No line records";
                        }
                        // Sync Num series
                        //SyncNumberSeries();
                    }
                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    UserDialogs.Instance.ShowError("No items for send request", 3000);
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
            }
        }
Пример #4
0
        void ConfirmLoad()
        {
            try
            {
                string             retmsg    = string.Empty;
                DataManager        manager   = new DataManager();
                RequestHeader      recHeader = new RequestHeader();
                List <RequestLine> reclines  = new List <RequestLine>();

                Device.BeginInvokeOnMainThread(() => UserDialogs.Instance.ShowLoading("Loading", MaskType.Black));
                Task.Run(async() =>
                {
                    recHeader = await manager.GetSQLite_RequestHeadebyRequestNo(HDRequestNo);
                    if (recHeader != null)
                    {
                        reclines.Clear();
                        reclines = recItems.Where(x => x.HeaderEntryNo == recHeader.EntryNo).ToList();

                        if (reclines != null)
                        {
                            if (reclines.Count > 0)
                            {
                                string retStatus = retmsg;
                                foreach (RequestLine ln in reclines)
                                {
                                    // Step 3 -> Update loaded items quantity Inventory
                                    //Get current load Qty for loop item
                                    decimal ivnLoadQty = await manager.GetSQLite_ItemLoadedQty(ln.ItemNo);
                                    ivnLoadQty         = ivnLoadQty + ln.PickQty;
                                    retmsg             = await manager.UpdateSQLite_LoadInventory(ln.ItemNo, ivnLoadQty);

                                    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       = ln.PickQty,
                                        LoadQty       = ln.PickQty,
                                        SoldQty       = ln.SoldQty,
                                        UnloadQty     = ln.UnloadQty,
                                        UomCode       = ln.UomCode,
                                        VendorNo      = ln.VendorNo,
                                        RequestNo     = ln.RequestNo,
                                        UserID        = ln.UserID,
                                        InHouse       = ln.InHouse,
                                        IsSync        = "loaded",
                                        SyncDateTime  = string.Empty
                                    };
                                    // Step 2 -> Update Request Line to mobile database
                                    string retval = await manager.SaveSQLite_RequestLine(line);



                                    VanItem ckitm = new VanItem();
                                    ckitm         = await manager.GetSQLite_VanItembyItemNo(ln.ItemNo);
                                    if (ckitm != null)
                                    {
                                        decimal vanqty = ckitm.LoadQty + ln.PickQty;
                                        retmsg         = await manager.UpdateSQLite_VanItem(ln.ItemNo, vanqty);
                                    }
                                    else
                                    {
                                        Item itm = new Item();
                                        itm      = manager.GetSQLite_ItembyItemNo(ln.ItemNo);

                                        VanItem vitm = new VanItem()
                                        {
                                            ID          = 0,
                                            ItemNo      = itm.ItemNo,
                                            Description = itm.Description,
                                            BarCode     = itm.BarCode,
                                            BaseUOM     = ln.UomCode,
                                            UnitPrice   = itm.UnitPrice,
                                            Str64Img    = itm.Str64Img,
                                            LoadQty     = ln.PickQty,
                                            SoldQty     = 0,
                                            ReturnQty   = 0,
                                            BadQty      = 0,
                                            UnloadQty   = 0,
                                            Balance     = 0
                                        };
                                        retmsg = await manager.SaveSQLite_VanItem(vitm);
                                    }
                                }

                                manager        = new DataManager();
                                string rethead = await manager.SaveSQLite_RequestHeader(new RequestHeader
                                {
                                    ID              = recHeader.ID,
                                    EntryNo         = recHeader.EntryNo,
                                    SalesPersonCode = recHeader.SalesPersonCode,
                                    RequestNo       = recHeader.RequestNo,
                                    RequestDate     = recHeader.RequestDate,
                                    IsSync          = recHeader.IsSync,
                                    SyncDateTime    = recHeader.SyncDateTime,
                                    CurStatus       = "loaded"
                                });
                                retmsg = "Success";
                            }
                        }
                        else
                        {
                            retmsg = "No requested lines to load!";
                        }
                    }
                    else
                    {
                        retmsg = "No data to load!";
                    }
                }).ContinueWith(result => Device.BeginInvokeOnMainThread(() =>
                {
                    UserDialogs.Instance.HideLoading();
                    if (!string.IsNullOrEmpty(retmsg))
                    {
                        if (retmsg == "Success")
                        {
                            UserDialogs.Instance.ShowSuccess(retmsg, 3000);
                            Navigation.PushAsync(new MainPage(9));
                        }
                        else
                        {
                            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);
            }
        }
Пример #5
0
        private async void PrintButton_Clicked(object sender, EventArgs e)
        {
            if (_isEnablePrintBtn)
            {
                _isEnablePrintBtn = false;

                var item = (Button)sender;
                //item.CommandParameter.ToString()
                string        retval  = string.Empty;
                string        retmsg  = string.Empty;
                DataManager   manager = new DataManager();
                RequestHeader head    = new RequestHeader();
                ObservableCollection <RequestLine> recs = new ObservableCollection <RequestLine>();
                DeviceInfo info     = new DeviceInfo();
                bool       canPrint = false;
                try
                {
                    var answer = await DisplayAlert("Print", "Are you sure to print Check In Report?", "Yes", "No");

                    UserDialogs.Instance.ShowLoading("Loading", MaskType.Black);
                    if (answer)
                    {
                        canPrint = true;
                        //var devices = await _bluetoothClient.GetPairedDevices();
                        //if (devices != null)
                        //{
                        //    if (devices.Count > 0)
                        //    {
                        //        canPrint = true;
                        //    }
                        //    else
                        //    {
                        //        UserDialogs.Instance.AlertAsync("Not found bluetooth device!", "Alert");
                        //        return;
                        //    }
                        //}
                        //else
                        //{
                        //    UserDialogs.Instance.AlertAsync("Not found bluetooth device!", "Alert");
                        //    return;
                        //}
                    }
                    else
                    {
                        UserDialogs.Instance.HideLoading();
                        _isEnablePrintBtn = true;
                        return;
                    }

                    if (canPrint)
                    {
                        info = await manager.GetDeviceInfo();

                        if (info != null)
                        {
                            if (!string.IsNullOrEmpty(info.DeviceName))
                            {
                                try
                                {
                                    manager = new DataManager();
                                    head    = await manager.GetRequestHeaderbyID(int.Parse(item.CommandParameter.ToString())); //GetRequestLinesbyRequestNo

                                    if (head != null)
                                    {
                                        recs = await manager.GetRequestLinesbyRequestNo(head.RequestNo);

                                        if (recs != null)
                                        {
                                            if (recs.Count > 0)
                                            {
                                                retmsg = "Success";
                                            }
                                            else
                                            {
                                                retmsg = "No request lines";
                                            }
                                        }
                                        else
                                        {
                                            retmsg = "No request lines";
                                        }
                                    }
                                    else
                                    {
                                        retmsg = "No request document";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    retmsg = ex.Message.ToString();
                                }
                            }
                            else
                            {
                                retmsg = "Required to setup bluetooth printer!";
                            }
                        }
                        else
                        {
                            retmsg = "Required to setup bluetooth printer!";
                        }
                    }

                    UserDialogs.Instance.HideLoading();
                    if (retmsg == "Success")
                    {
                        bool isBeforeConfirm = true;
                        if (App.gCurStatus == "loaded")
                        {
                            isBeforeConfirm = false;
                        }
                        var a = Utils.Print_CheckIn(info.DeviceName, head, recs, App.gCompanyName, App.gSalesPersonCode + "/" + App.gSalesPersonName, isBeforeConfirm); //head, recs, customer, sellTo, App.gSalesPersonCode + "/" + App.gSalesPersonName);
                        UserDialogs.Instance.Alert(a);
                        //  Navigation.PopAsync();
                    }
                    else
                    {
                        UserDialogs.Instance.ShowError(retmsg, 3000);
                        _isEnablePrintBtn = true;
                    }
                }
                catch (OperationCanceledException ex)
                {
                    Acr.UserDialogs.UserDialogs.Instance.HideLoading(); //IsLoading = false;
                    UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
                    _isEnablePrintBtn = true;
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading(); //IsLoading = false;
                    UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
                    _isEnablePrintBtn = true;
                }
            }
        }