Exemple #1
0
 void OnPositionClick(object sender, int position)
 {
     try
     {
         pos          = positionsList[position];
         pos.IsUpdate = true;
         maxCount     = pos.Norm;
         positionItem = positionsList.FindIndex(a => a.Id == pos.Id);
         MainThread.BeginInvokeOnMainThread(() =>
         {
             adapterPosition            = new PositionsAdapter(positionsList);
             adapterPosition.ItemClick += OnPositionClick;
             ordersRecyclerView.SetAdapter(adapterPosition);
             ordersRecyclerView.ScrollToPosition(positionItem);
         });
         RunOnUiThread(() => codeInput.Text = pos.Code);
         if (pos.Rate == 0)
         {
             RunOnUiThread(() => quentityInput.Text = "");
         }
         else
         {
             RunOnUiThread(() => quentityInput.Text = pos.Rate.ToString());
         }
         RunOnUiThread(() => weightInput.Text = pos.Weight.ToString());
     }
     catch (Exception ex)
     {
         ErrorMessage("MainActivity - OnPositionClick:" + ex.Message);
     }
 }
Exemple #2
0
 private void RadioButtonDef_Click(object sender, EventArgs e)
 {
     try
     {
         if (isEdit == true)
         {
             UpdateDataToServer();
         }
         if (isShortList == true)
         {
             CreatePositionsData(orderId);
             SetupPositionsRecyclerView();
         }
         positionsList = positionsList.Where(a => a.Rate != a.Norm || a.Id == 0).ToList();
         RunOnUiThread(() => codeInput.Text     = "");
         RunOnUiThread(() => quentityInput.Text = "");
         RunOnUiThread(() => weightInput.Text   = "");
         MainThread.BeginInvokeOnMainThread(() =>
         {
             adapterPosition            = new PositionsAdapter(positionsList);
             adapterPosition.ItemClick += OnPositionClick;
             ordersRecyclerView.SetAdapter(adapterPosition);
             ordersRecyclerView.ScrollToPosition(0);
         });
         codeInput.ClearFocus();
         quentityInput.ClearFocus();
         weightInput.ClearFocus();
         isEdit      = false;
         isShortList = true;
     }
     catch (Exception ex)
     {
         ErrorMessage("MainActivity - RadioButtonDef_Click :" + ex.Message);
     }
 }
Exemple #3
0
 private void SavePosData()
 {
     try
     {
         if (pos != null)
         {
             int quentity = Int32.Parse(quentityInput.Text);
             if (quentity > pos.Norm)
             {
                 quentity = pos.Norm;
             }
             pos.Rate = quentity;
             if (pos.Weight != Double.Parse(weightInput.Text.Replace(".", ",")))
             {
                 pos.IsWeight = true;
             }
             pos.Weight   = Double.Parse(weightInput.Text.Replace(".", ","));
             positionItem = positionsList.FindIndex(a => a.Id == pos.Id);
             foreach (var t in positionsList)
             {
                 if (t.Code == pos.Code)
                 {
                     t.Weight = pos.Weight;
                 }
             }
             RunOnUiThread(() => codeInput.Text     = pos.Code);
             RunOnUiThread(() => quentityInput.Text = pos.Rate.ToString());
             RunOnUiThread(() => weightInput.Text   = pos.Weight.ToString());
             MainThread.BeginInvokeOnMainThread(() =>
             {
                 adapterPosition            = new PositionsAdapter(positionsList);
                 adapterPosition.ItemClick += OnPositionClick;
                 ordersRecyclerView.SetAdapter(adapterPosition);
                 ordersRecyclerView.ScrollToPosition(positionItem);
             });
             codeInput.ClearFocus();
             quentityInput.ClearFocus();
             weightInput.ClearFocus();
             isEdit = true;
         }
     }
     catch (Exception ex)
     {
         RunOnUiThread(() =>
         {
             AlertDialog.Builder dialog = new AlertDialog.Builder(this);
             AlertDialog alert          = dialog.Create();
             alert.SetTitle("Ошибка сохранения");
             alert.SetMessage("Ошибка: " + ex.Message);
             alert.Show();
             return;
         });
     }
 }
Exemple #4
0
 private void SetupPositionsRecyclerView()
 {
     try
     {
         ordersRecyclerView.SetLayoutManager(new LinearLayoutManager(ordersRecyclerView.Context));
         adapterPosition            = new PositionsAdapter(positionsList);
         adapterPosition.ItemClick += OnPositionClick;
         ordersRecyclerView.SetAdapter(adapterPosition);
         isEdit = false;
     }
     catch (Exception ex)
     {
         ErrorMessage("MainActivity - SetupPositionsRecyclerView:" + ex.Message);
     }
 }
Exemple #5
0
 private void Scanner_Data(object sender, Scanner.DataEventArgs e)
 {
     try
     {
         if (part != "")
         {
             var scanDataCollection = e.P0;
             if ((scanDataCollection != null) && (scanDataCollection.Result == ScannerResults.Success))
             {
                 var scanData = scanDataCollection.GetScanData();
                 if (scanData[0].Data == null)
                 {
                     return;
                 }
                 string scanDataRes = GetSKUID(scanData[0].Data);
                 sku     = GetSKU(scanDataRes);
                 skuPart = GetSKUPart(scanDataRes);
                 if (part != skuPart && skuPart != "")
                 {
                     RunOnUiThread(() =>
                     {
                         AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                         AlertDialog alert          = dialog.Create();
                         alert.SetTitle("Ошибка партии");
                         alert.SetMessage(sku + " из другой партии");
                         alert.Show();
                         return;
                     });
                 }
                 else
                 {
                     try
                     {
                         pos          = positionsList.First(a => a.Code == sku && a.Rate < a.Norm);
                         pos.IsUpdate = true;
                         positionItem = positionsList.FindIndex(a => a.Id == pos.Id);
                         pos.Rate++;
                         maxCount = pos.Norm;
                         RunOnUiThread(() => codeInput.Text     = sku);
                         RunOnUiThread(() => quentityInput.Text = pos.Rate.ToString());
                         RunOnUiThread(() => weightInput.Text   = pos.Weight.ToString());
                         isEdit = true;
                     }
                     catch
                     {
                         RunOnUiThread(() =>
                         {
                             AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                             AlertDialog alert          = dialog.Create();
                             alert.SetTitle("ТМЦ не найдено");
                             alert.SetMessage(sku + " - нет/избыток");
                             alert.Show();
                             return;
                         });
                     }
                     if (weightInput.Text == "0")
                     {
                         RunOnUiThread(() =>
                         {
                             AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                             AlertDialog alert          = dialog.Create();
                             alert.SetTitle("Масса не задана");
                             alert.SetMessage(sku + " взвесте ТМЦ");
                             alert.Show();
                             return;
                         });
                     }
                     MainThread.BeginInvokeOnMainThread(() =>
                     {
                         adapterPosition = new PositionsAdapter(positionsList);
                         ordersRecyclerView.SetAdapter(adapterPosition);
                         ordersRecyclerView.ScrollToPosition(positionItem);
                     });
                     RunOnUiThread(ProcessScan);
                 }
             }
         }
         else
         {
             RunOnUiThread(() =>
             {
                 AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                 AlertDialog alert          = dialog.Create();
                 alert.SetTitle("Партия не выбрана");
                 alert.SetMessage("Нажмите на пункт партии");
                 alert.Show();
                 return;
             });
         }
     }
     catch (Exception ex)
     {
         ErrorMessage("MainActivity - Scanner_Data:" + ex.Message);
     }
 }