Example #1
0
        private void WiegenButton_Click(object sender, EventArgs e)
        {
            try
            {
                weight = WSWmsHelper.GetGrossWeight(transportOrderAidID.ToString());
            }
            catch (Exception)
            {
                Log.Write(this,
                          $"Problem at WiegenButton in TransportOrderDetails, transportOrderAidID = {transportOrderAidID}",
                          Log.DebugLevels.ERROR);
            }

            if (string.IsNullOrEmpty(weight))
            {
                gewichtTextView.SetBackgroundColor(Color.Yellow);
                gewichtTextView.Text = "Fehler beim Wiegen!";
            }
            else
            {
                gewichtTextView.SetBackgroundColor(Color.LightGreen);
                gewichtTextView.Text = weight;
            }

            if (fotoButton.Visibility == ViewStates.Visible)
            {
                fotoButton.Enabled = true;
                hintTextView.Text  = GetString(Resource.String.hintPressFoto);
            }
        }
Example #2
0
        /// <summary>
        /// Resume picking from where the picker left off.
        /// </summary>
        private void ShowPickingForm()
        {
            Intent activity;
            string lastActivity = WSWmsHelper.GetPickingProgress(LoginActivity.User);

            if (lastActivity == PickingProgressLastActivity.PickingOverview.ToString())
            {
                activity = new Intent(this, typeof(NextOrderActivity));
            }
            else
            if (lastActivity == PickingProgressLastActivity.TuScan.ToString())
            {
                activity = new Intent(this, typeof(TuScanActivity));
            }
            else
            if (lastActivity == PickingProgressLastActivity.ItemScan.ToString())
            {
                activity = new Intent(this, typeof(ItemScanActivity));
            }
            else
            {
                activity = new Intent(this, typeof(PickActivity));
            }

            StartActivity(activity);
        }
Example #3
0
        private void Load()
        {
            hintTextView.Text = GetString(Resource.String.transportmittelScanOrChoose);
            try
            {
                dt = WSWmsHelper.LoadTransportAids();
                transportAidNummers.Clear();

                transportAidID = int.Parse(dt.Rows[0][0].ToString());

                foreach (DataRow i in dt.Rows)
                {
                    transportAidNummers.Add(i[1].ToString());
                }

                ArrayAdapter adapter = new ArrayAdapter(this, Resource.Layout.SpinnerItem2, transportAidNummers);

                adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                spinner.Adapter = adapter;

                string lastChosenNum = GetLastChosenNummer();
                GetTransportIdByNummer(lastChosenNum);
                if (lastChosenNum != string.Empty)
                {
                    spinner.SetSelection(spinnerIndex);
                }
            }
            catch (Exception e)
            {
                Utility.ShowErrorMessage(this, e.Message);
            }
        }
        private bool CheckWS(string wsUrl)
        {
            try
            {
                int    tryCount = 5;
                string result   = "";

                while (!result.Equals(WSWmsHelper.WS_RETURN_OK) && 0 < tryCount)
                {
                    result = WSWmsHelper.PingWS();
                    tryCount--;
                }

                if (!result.Equals(WSWmsHelper.WS_RETURN_OK))
                {
                    ShowSetupWebConnectionMessage();
                    return(false);
                }

                if (null != tvWSS)
                {
                    tvWSS.Text = lblWSS + wsUrl;
                }

                return(true);
            }
            catch (Exception ex)
            {
                Utility.ShowErrorMessage(this, GetString(Resource.String.NoConnection) + "\n" + ex.Message);
                return(false);
            }
        }
Example #5
0
        private void NextButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (from == CONST_SHIPMENT)
                {
                    if (WSWmsHelper.FinishShipmentTransport(trId, shipmentID, leId, weight))
                    {
                        if (secondLeLayout.Visibility == ViewStates.Visible)
                        {
                            if (!WSWmsHelper.FinishShipmentTransport(trId2, shipmentID, leId2, weight))
                            {
                                Utility.ShowErrorMessage(this, Resource.String.errProblemWithSecondLeFinish);
                            }

                            le2TextView.SetBackgroundResource(Resource.Color.formDefectGoodsBackColor);
                            le2TextView.Text = string.Empty;
                        }
                        isLeScanned   = false;
                        isZielScanned = false;
                        weight        = "0";
                        SetNewOrder();
                        Load();
                        zielTextView.SetBackgroundResource(Resource.Color.formDefectGoodsBackColor);
                    }
                    else
                    {
                        Log.Write(this, "Problem at nextButton in TransportOrderDetails, transportOrderAidID = " + transportOrderAidID, Log.DebugLevels.ERROR);
                        Utility.ShowErrorMessage(this, GetString(Resource.String.msgTitleError));
                    }
                }
                else if (from == FROM_PROD_PALLET)
                {
                    if (WSWmsHelper.FinishTransport(trId))
                    {
                        OnBackPressed();
                        return;
                    }
                    Log.Write(this, "Problem at nextButton in TransportOrderDetails, transportOrderAidID = " + transportOrderAidID, Log.DebugLevels.ERROR);
                    Utility.ShowErrorMessage(this, GetString(Resource.String.msgTitleError));
                }
                else
                {
                    if (WSWmsHelper.FinishTransport(trId))
                    {
                        SetNextTransport();
                    }
                    else
                    {
                        Log.Write(this, "Problem at nextButton in TransportOrderDetails, transportOrderAidID = " + transportOrderAidID, Log.DebugLevels.ERROR);
                        Utility.ShowErrorMessage(this, GetString(Resource.String.msgTitleError));
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowErrorMessage(this, ex.Message);
                Log.Write(this, "Problem at nextButton in TransportOrderDetails, transportOrderAidID = " + transportOrderAidID, Log.DebugLevels.ERROR);
            }
        }
Example #6
0
        private void UnpackBundle(Bundle bundle)
        {
            try
            {
                manualInputConf = WSWmsHelper.LoadConfiguration(TRANSPORT, MANUAL_LEVEL_INPUT).Equals("1");
                if (bundle == null)
                {
                    bundle = Intent.GetBundleExtra("b");
                }

                from      = bundle.GetString("from");
                trId      = bundle.GetInt("trid");
                leId      = bundle.GetInt("leid");
                leNummer  = bundle.GetString("lenum");
                leTyp     = bundle.GetString("letyp");
                sourceBin = bundle.GetString("sourceBin");
                targetBin = bundle.GetString("targetBin");
                if (from == FROM_TRANSPORT && manualInputConf)
                {
                    digitsToCutFromTargetBin = bundle.GetInt("digitsToCutFromTargetBin");
                    shortenedTargetBin       = bundle.GetString("targetBin").Substring(0, bundle.GetString("targetBin").Length - digitsToCutFromTargetBin);
                }
                priority            = bundle.GetInt("priority");
                transportOrderAidID = bundle.GetInt("transportAidId");

                if (from == CONST_SHIPMENT)
                {
                    shipmentID = bundle.GetInt("shipmentId");
                    places     = bundle.GetInt("places");

                    fotoButton.Enabled   = false;
                    wiegenButton.Enabled = false;

                    if (int.Parse(WSWmsHelper.LoadConfiguration(TRANSPORT, SCALES_INTERFACE_ACTIVE)) != 0)
                    {
                        wiegenButton.Visibility         = ViewStates.Visible;
                        gewichtLabelTextView.Visibility = ViewStates.Visible;
                        gewichtTextView.Visibility      = ViewStates.Visible;
                    }
                    if (int.Parse(WSWmsHelper.LoadConfiguration(TRANSPORT, PHOTOGATE_ACTIVE)) != 0)
                    {
                        fotoButton.Visibility = ViewStates.Visible;
                    }
                }
                if (from == FROM_PROD_PALLET)
                {
                    leNummer2 = bundle.GetString("lenum2");
                    thisLayout.SetBackgroundColor(Color.ParseColor("#00FFFF"));
                }
            }
            catch
            {
                Utility.ShowErrorMessage(this, GetString(Resource.String.msgTitleError));
            }
        }
Example #7
0
        private void SetNewOrderFromProdPallet()
        {
            try
            {
                dt = WSWmsHelper.GetTransport(trId);
            }
            catch (Exception ex)
            {
                Utility.ShowErrorMessage(this, ex.Message);
                Log.Write(this, "Problem at SetNewOrderFromProdPallet in TransportOrderDetails, transportOrderAidID = " + transportOrderAidID, Log.DebugLevels.ERROR);
            }

            if (dt != null && dt.Rows.Count == 0)
            {
                OnBackPressed();
            }

            try
            {
                DataRow dr = dt.Rows[0];
                if (!string.IsNullOrEmpty(leNummer))
                {
                    foreach (DataRow drSearch in dt.Rows)
                    {
                        if (leNummer.Equals(drSearch[FieldNames.LeNummer].ToString()))
                        {
                            dr = drSearch;
                            break;
                        }
                    }
                }

                leNummer             = dr[FieldNames.LeNummer].ToString();
                le2TextView.Text     = leNummer2;
                leTyp                = dr[FieldNames.LeTyp].ToString();
                sourceBin            = dr[FieldNames.SourceBin].ToString();
                targetBin            = dr[FieldNames.TargetBin].ToString();
                priority             = int.Parse(dr[FieldNames.Priority].ToString());
                trId                 = int.Parse(dr[FieldNames.TrId].ToString());
                leId                 = int.Parse(dr[FieldNames.LeId].ToString());
                gewichtTextView.Text = string.Empty;
                hintTextView.Text    = GetString(Resource.String.scanLe);
                if (from == FROM_TRANSPORT && manualInputConf)
                {
                    digitsToCutFromTargetBin = int.Parse(dr[FieldNames.LevelDigits].ToString());
                    shortenedTargetBin       = targetBin.Substring(0, targetBin.Length - digitsToCutFromTargetBin);
                }
            }
            catch (Exception e)
            {
                Utility.ShowErrorMessage(this, e.Message);
                Log.Write(this, "Get order info from datatable for transportOrderAidID = " + transportOrderAidID, Log.DebugLevels.ERROR);
            }
        }
Example #8
0
        private void SetGoodsReceiptBin()
        {
            LayoutInflater      layoutInflater = LayoutInflater.From(this);
            View                view           = layoutInflater.Inflate(Resource.Layout.GoodsReceiptBinChoice, null);
            Spinner             sBin           = view.FindViewById <Spinner>(Resource.Id.spinnerWeBin);
            List <IdAndNameDto> places         = WSWmsHelper.WeLoadLocation();
            var          placeNames            = places.Select(x => x.Name).ToList();
            ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, placeNames);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            sBin.Adapter = adapter;

            IdAndNameDto binData       = Utility.WeBin;
            int          selectedIndex = 0;

            if (!string.IsNullOrEmpty(binData.Name))
            {
                for (int i = 0; i < places.Count; i++)
                {
                    if (places[i].Name.Equals(binData.Name))
                    {
                        selectedIndex = i;
                        break;
                    }
                }
            }

            sBin.SetSelection(selectedIndex);

            AlertDialog.Builder alertbuilder = new AlertDialog.Builder(this);
            alertbuilder.SetView(view);

            alertbuilder.SetCancelable(false)
            .SetPositiveButton(Resource.String.Yes, delegate
            {
                Utility.WeBin = new IdAndNameDto()
                {
                    Name = sBin.SelectedItem.ToString(),
                    Id   = places[(int)sBin.SelectedItemId].Id
                };

                ShowGoodsReceiptListForm();
            })
            .SetNegativeButton(Resource.String.No, delegate
            {
            });
            AlertDialog dialog = alertbuilder.Create();

            alertbuilder.Dispose();
            dialog.Show();
        }
Example #9
0
        private void Start()
        {
            try
            {
                bool success;
                bool success2 = false;

                if (from == CONST_SHIPMENT)
                {
                    if (le2TextView.Text == string.Empty)
                    {
                        success = WSWmsHelper.PickShipmentTransport(trId.ToString(), transportOrderAidID, shipmentID.ToString(), leId.ToString(), user.Id);
                        secondLeLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        success  = WSWmsHelper.PickShipmentTransport(trId.ToString(), transportOrderAidID, shipmentID.ToString(), leId.ToString(), user.Id);
                        success2 = WSWmsHelper.PickShipmentTransport(trId2.ToString(), transportOrderAidID, shipmentID.ToString(), leId2.ToString(), user.Id);
                    }
                }
                else
                {
                    success = WSWmsHelper.PickTransport(trId.ToString(), transportOrderAidID);
                }

                if (success)
                {
                    if (from == CONST_SHIPMENT && (secondLeLayout.Visibility == ViewStates.Visible && !success2))
                    {
                        Utility.ShowErrorMessage(this, Resource.String.errProblemWithSecondLeStart);
                        secondLeLayout.Visibility = ViewStates.Gone;
                    }
                    zielTextView.SetBackgroundColor(Color.Yellow);
                    hintTextView.Text = GetString(Resource.String.hintGoToTargetBinAndScan);
                }
                else
                {
                    Utility.ShowErrorMessage(this, GetString(Resource.String.msgTitleError));
                }

                scanEditText.Enabled = true;
                scanEditText.RequestFocus();
            }
            catch (Exception ex)
            {
                Utility.ShowErrorMessage(this, ex.Message);
            }
        }
Example #10
0
        private bool ExistsStartedOrder()
        {
            try
            {
                if (from == CONST_SHIPMENT)
                {
                    dt = WSWmsHelper.LoadShipmentTransportOrders(transportOrderAidID, shipmentID);
                }
                else
                {
                    if (from.Equals(FROM_PROD_PALLET))
                    {
                        dt = WSWmsHelper.GetTransport(trId);
                    }
                    else
                    {
                        dt = WSWmsHelper.LoadTransportOrders(transportOrderAidID);
                    }
                }

                foreach (DataRow row in dt.Rows)
                {
                    if (from == FROM_PROD_PALLET)
                    {
                        if (row[FieldNames.transpStatus].ToString() == "PICKED" && row[FieldNames.LeNummer].ToString() == leNummer)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (row[FieldNames.transpStatus].ToString() == "PICKED")
                        {
                            leNummer = row[FieldNames.LeNummer].ToString();
                            secondLeLayout.Visibility = ViewStates.Gone;
                            return(true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Utility.ShowErrorMessage(this, e.Message);
            }

            return(false);
        }
Example #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.TransportOrderDetails);
            GetWidgetIDs();

            hintTextView.Text = GetString(Resource.String.scanLe);

            username = LoginActivity.LoadUser();
            user     = WSWmsHelper.GetAllUsers().First(u => u.Login == username);

            fotoButton.Text       = GetString(Resource.String.fotobtn);
            fotoButton.Visibility = BUTTON_INVISIBLE;
            fotoButton.Click     += FotoButton_Click;

            wiegenButton.Text       = GetString(Resource.String.wiegenBtn);
            wiegenButton.Visibility = BUTTON_INVISIBLE;
            wiegenButton.Click     += WiegenButton_Click;

            printButton.Text       = GetString(Resource.String.menuBtnPrintLabels).ToUpper(); ///etiketten
            printButton.Visibility = BUTTON_INVISIBLE;
            printButton.Click     += PrintButton_Click;

            nextButton.Text       = GetString(Resource.String.btnNext_txt);
            nextButton.Visibility = FastFinishTransport ? BUTTON_INVISIBLE : ViewStates.Visible;
            nextButton.Click     += NextButton_Click;

            btnBinEmpty.Text       = GetString(Resource.String.btnTitleBinEmpty).ToUpper();
            btnBinEmpty.Click     += BtnBinEmpty_Click;;
            btnBinEmpty.Visibility = BUTTON_INVISIBLE;

            btnBinFull.Text       = GetString(Resource.String.btnTitleBinFull).ToUpper();
            btnBinFull.Visibility = BUTTON_INVISIBLE;
            btnBinFull.Click     += BtnBinFull_Click;;

            UnpackBundle(null);
            Load();


            btnKeyboard.Click     += BtnKeyboard_Click;
            scanEditText.KeyPress += ScanEditText_KeyPress;
            scanEditText.InputType = Android.Text.InputTypes.Null;

            SetTitle(Resource.String.labelTransportOrderDetails);
        }
Example #12
0
 private void AssignValues(int index)
 {
     if (dt.Rows.Count > 0)
     {
         DataRow dr = dt.Rows[index];
         trId      = int.Parse(dr[FieldNames.TrId].ToString());
         leId      = int.Parse(dr[FieldNames.LeId].ToString());
         leNummer  = dr[FieldNames.LeNummer].ToString();
         leTyp     = dr[FieldNames.LeTyp].ToString();
         sourceBin = dr[FieldNames.SourceBin].ToString();
         targetBin = dr[FieldNames.TargetBin].ToString();
         priority  = int.Parse(dr[FieldNames.Priority].ToString());
         if (from == "Transport" && int.Parse(WSWmsHelper.LoadConfiguration(TRANSPORT, MANUAL_LEVEL_INPUT)) != 0)
         {
             digitsToCutFromTargetBin = int.Parse(dr[FieldNames.LevelDigits].ToString());
         }
     }
 }
Example #13
0
        private void Spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            spinnerIndex = spinner.SelectedItemPosition;
            WriteLastChosenNummer(spinner.SelectedItem.ToString());
            transportAidID = GetTransportIdByNummer(spinner.GetItemAtPosition(spinnerIndex).ToString());
            try
            {
                counts = WSWmsHelper.GetTransportLoadingCount(transportAidID);
            }
            catch (Exception ex)
            {
                Utility.ShowErrorMessage(this, ex.Message);
                return;
            }
            if (int.Parse(counts.Rows[0][FieldNames.TransportCount].ToString()) > 0)
            {
                transportCount.Text       = GetString(Resource.String.transportCountIs) + counts.Rows[0][FieldNames.TransportCount].ToString();
                transportCount.Visibility = ViewStates.Visible;
                transportCount.Enabled    = true;
            }
            else
            {
                transportCount.Visibility = ViewStates.Invisible;
            }

            if (isTansport)
            {
                if (int.Parse(counts.Rows[0][FieldNames.LoadingCount].ToString()) > 0)
                {
                    loadingCount.Text       = GetString(Resource.String.loadingCountIs) + counts.Rows[0][FieldNames.LoadingCount].ToString();
                    loadingCount.Visibility = ViewStates.Visible;
                }
                else
                {
                    loadingCount.Visibility = ViewStates.Invisible;
                }
            }
            else
            {
                transportCount.Enabled  = false;
                loadingCount.Visibility = ViewStates.Visible;
                loadingCount.Text       = GetString(Resource.String.btnNext_txt);
            }
        }
Example #14
0
        private void FotoButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!WSWmsHelper.TakeLePictures(leNummer))
                {
                    Utility.ShowErrorMessage(this, GetString(Resource.String.couldNotTakeFotoErr));
                }
            }
            catch (Exception)
            {
                Utility.ShowErrorMessage(this, GetString(Resource.String.couldNotTakeFotoErr));
                Log.Write(this, "Problem at fotoButton in TransportOrderDetails, transportOrderAidID = " + transportOrderAidID, Log.DebugLevels.ERROR);
            }

            nextButton.Enabled   = true;
            fotoButton.Enabled   = false;
            wiegenButton.Enabled = false;
            hintTextView.Text    = GetString(Resource.String.hintPressNext);
        }
Example #15
0
        void SetLeScanedOk()
        {
            leTextView.SetBackgroundColor(Color.LightGreen);
            bool printalble = false;

            try
            {
                if (WSWmsHelper.CheckForLePrintable(leNummer))
                {
                    printButton.Visibility = ViewStates.Visible;
                    printButton.Enabled    = true;
                }
            }
            catch (Exception e)
            {
                printButton.Visibility = BUTTON_INVISIBLE;
                Utility.ShowErrorMessage(this, e.Message);
                return;
            }
        }
Example #16
0
 private void EmptyBinAction()
 {
     try
     {
         string binToDelete = quelleTextView.Text;
         if (WSWmsHelper.DeleteTranspBinEmpty(binToDelete, leNummer))
         {
             SetNextTransport();
         }
         else
         {
             Utility.ShowErrorMessage(this, Resources.GetString(Resource.String.msgOperationFailed));
         }
     }
     catch (Exception ex)
     {
         Utility.ShowErrorMessage(this, "EmptyBinAction - ERROR:" + ex.Message);
         return;
     }
 }
Example #17
0
 private bool GetDatatable()
 {
     try
     {
         if (shipmentID == 0)
         {
             dt = WSWmsHelper.LoadTransportOrders(transportAidID);
         }
         else
         {
             dt = WSWmsHelper.LoadShipmentTransportOrders(transportAidID, shipmentID);
         }
     }
     catch (Exception e)
     {
         Utility.ShowErrorMessage(this, e.Message + "Load orders exception: transpAidID = " + transportAidID);
         return(false);
     }
     return(true);
 }
Example #18
0
        private void FullBinAction()
        {
            string newBin = "";

            try
            {
                newBin = WSWmsHelper.TranspBinFull(zielTextView.Text, leNummer);
            }
            catch (Exception ex)
            {
                Utility.ShowErrorMessage(this, "TranspBinFull - ERROR:" + ex.Message);
                return;
            }

            if (string.IsNullOrEmpty(newBin))
            {
                Utility.ShowErrorMessage(this, "NO New bin");
                return;
            }

            zielTextView.Text = newBin;
        }
        private void InitLogin()
        {
            editTextPort.Visibility     = tvPortLbl.Visibility = ViewStates.Gone;
            spinnerLoginName.Visibility = tvUserLbl.Visibility = ViewStates.Visible;

            btnLogin.Text      = GetString(Resource.String.btnLogin_txt);
            tvPasswordLbl.Text = GetString(Resource.String.lblPassword_txt);
            btnSettings.SetText(Resource.String.btnSettings_txt);

            txtPassword.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword;
            txtPassword.Text      = string.Empty;

            if (!loadUsers || null == spinnerLoginName)
            {
                btnRefresh.Enabled = false;
                return;
            }

            btnRefresh.Enabled = true;

            try
            {
                List <UserDto> usersList = WSWmsHelper.GetAllUsers();
                if (null == usersList)
                {
                    return;
                }

                if (0 < usersList.Count)
                {
                    string savedLogin = LoadUser();

                    int      idx             = 0;
                    int      selectedUserIdx = -1;
                    string[] spinnerItems    = new string[usersList.Count];
                    foreach (UserDto udr in usersList)
                    {
                        if (string.Empty != savedLogin && udr.Login == savedLogin)
                        {
                            selectedUserIdx = idx;
                        }
                        spinnerItems[idx++] = udr.Login;
                    }

                    CustomArrayAdapter adapter = new CustomArrayAdapter(this, spinnerItems.ToList());
                    spinnerLoginName.Adapter = adapter;

                    if (-1 != selectedUserIdx)
                    {
                        spinnerLoginName.SetSelection(selectedUserIdx);
                    }
                }
            }
            catch (WebException wex)
            {
                string msgWSnotAvailable = GetString(Resource.String.msgWSnotAvailable);
                new AlertDialog.Builder(this).SetTitle(msgWSnotAvailable)
                .SetMessage(GetString(Resource.String.msgActivateInetWSandTryAgain))
                .SetPositiveButton(GetString(Resource.String.Ok), (s, e) => { Recreate(); })
                .Show();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }
        }
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            bool isSettingsMode = false;

            if (!GetString(Resource.String.btnTitleSave).Equals(btnLogin.Text))  //try login
            {
                if (spinnerLoginName.SelectedItem != null && !string.IsNullOrEmpty(spinnerLoginName.SelectedItem.ToString()))
                {
                    UserAuthentication.SetUserAndPassword(spinnerLoginName.SelectedItem.ToString(), txtPassword.Text);
                    string result = WSWmsHelper.AuthenticateUser(this);
                    if (result != WSWmsHelper.WS_RETURN_OK)
                    {
                        UserAuthentication.SetUserAndPassword("", "");
                        Utility.ShowErrorMessage(this, result);
                        return;
                    }
                }
                else
                {
                    Utility.ShowErrorMessage(this, Resource.String.msgUserOrPasswordError);
                    return;
                }
            }
            else //check WS connection and save settitngs
            {
                isSettingsMode = true;
                if (string.Empty != txtPassword.Text && string.Empty != editTextPort.Text) //save settings
                {
                    if (CheckWS(Utility.BuildWsUrlFromServerIpAndPort(txtPassword.Text)))
                    {
                        Save_WS_Url(txtPassword.Text, editTextPort.Text);
                        loadUsers = true;
                        editTextPort.Visibility = ViewStates.Visible;
                        tvPortLbl.Visibility    = ViewStates.Visible;
                        InitLogin();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (isSettingsMode)
            {
                return;
            }

            EnableUserMenus(spinnerLoginName.SelectedItem.ToString());

            base.OnBackPressed();
            _userName = spinnerLoginName.SelectedItem.ToString();

            SaveUser();

            Log.Write(this, "User logged in.", Log.DebugLevels.INFO);

            Utility.SetActivityOrientation(Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels);
        }
        private void EnableUserMenus(string userName)
        {
            try
            {
                foreach (int btnId in MainActivity.ButtonIds)
                {
                    MainActivity.ButtonEnable[btnId] = MainActivity.BUTTON_HIDE_ID;
                }

                List <string> menuOptions = WSWmsHelper.GetUserMenuOptions(userName);
                if (null == menuOptions)
                {
                    return;
                }

                int nextIdx = 0;
                foreach (string option in menuOptions)
                {
                    int nextButtonId = MainActivity.ButtonIds[nextIdx++];
                    if (option.Equals(MenuOptions.PUT_AWAY.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonWEEinlagerung;
                    }
                    else if (option.Equals(MenuOptions.GOODS_RECEIPT.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonGoodsReceipt;
                    }
                    else if (option.Equals(MenuOptions.INVENTORY.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonInventory;
                    }
                    else if (option.Equals(MenuOptions.PICKING.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonPick;
                    }
                    else if (option.Equals(MenuOptions.REALLOCATION.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonReallocation;
                    }
                    else if (option.Equals(MenuOptions.TRANSPORT.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonTransport;
                    }
                    else if (option.Equals(MenuOptions.STORE_PRODUCTION.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonStoreProduction;
                    }
                    else if (option.Equals(MenuOptions.PRINT_SHIPPING_LABELS.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonPrintLabels;
                    }
                    else if (option.Equals(MenuOptions.INITIAL_STOCKTAKING.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonInitialStocktaking;
                    }
                    else if (option.Equals(MenuOptions.INFO.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonInfo;
                    }
                    else if (option.Equals(MenuOptions.WE_HANDELSWARE.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonWeHandelsware;
                    }
                    else if (option.Equals(MenuOptions.SPLIT_LE.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonSplitTU;
                    }
                    else if (option.Equals(MenuOptions.REPACK.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonRepack;
                    }
                    else if (option.Equals(MenuOptions.DELETE_LE.ToString()))
                    {
                        MainActivity.ButtonEnable[nextButtonId] = Resource.Id.buttonDeleteTU;
                    }
                }
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this)
                .SetTitle(Resource.String.msgWSnotAvailable)
                .SetMessage(Resource.String.msgActivateInetWSandTryAgain)
                .SetPositiveButton(Resource.String.Ok, delegate { Recreate(); })
                .Show();
            }
        }