예제 #1
0
        private void SignIn()
        {
            var db       = new SQLiteConnection(DBPath);
            var accounts = db.Table <Account>();
            var account  = accounts.Where(x => x.UserName == ViewModel.UserName).FirstOrDefault();

            Android.Support.V7.App.AlertDialog         alertDialog = null;
            Android.Support.V7.App.AlertDialog.Builder builder     = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                     .SetTitle("Account Information")
                                                                     .SetPositiveButton("Ok", (object s, Android.Content.DialogClickEventArgs dialogClickEventArgs) =>
            {
                alertDialog.Show();
            });

            alertDialog = builder.Create();

            if (account == null)
            {
                alertDialog.SetMessage("This account does not exist.");
            }
            else if (account.Password != ViewModel.Password)
            {
                alertDialog.SetMessage("Password is incorrect.");
            }
            else
            {
                alertDialog.SetMessage("User successfully found.");
            }

            alertDialog.Show();
        }
예제 #2
0
 private void CreatePositionsData(int id)
 {
     try
     {
         positionsList = new List <Position>();
         JsonSerializer serializer = new JsonSerializer();
         serializer.NullValueHandling = NullValueHandling.Ignore;
         var            json         = new WebClient().DownloadString("http://192.168.1.33/CMOS/CMOSS/GetPositionsPreorderApi/" + id.ToString());
         JObject        googleSearch = JObject.Parse(json);
         IList <JToken> results      = googleSearch["data"].Children().ToList();
         foreach (JToken result in results)
         {
             Position searchResult = result.ToObject <Position>();
             positionsList.Add(searchResult);
         }
         positionsList.Add(new Position {
             Code = "", Color = "", Loading = "", Name = "", Norm = 0, Order = "", ShortName = ""
         });
         isEdit = false;
     }
     catch (Exception ex)
     {
         RunOnUiThread(() =>
         {
             AlertDialog.Builder dialog = new AlertDialog.Builder(this);
             AlertDialog alert          = dialog.Create();
             alert.SetTitle("Сервер не отвечает");
             alert.SetMessage("Обратитесь к администратору" + ex.Message);
             alert.Show();
             return;
         });
     }
 }
예제 #3
0
 private void CreateOrdersData()
 {
     try
     {
         ordersList = new List <Order>();
         JsonSerializer serializer = new JsonSerializer();
         serializer.NullValueHandling = NullValueHandling.Ignore;
         var            json         = new WebClient().DownloadString("http://192.168.1.33/CMOS/CMOSS/GetTableNoClothingOrderApi");
         JObject        googleSearch = JObject.Parse(json);
         IList <JToken> results      = googleSearch["data"].Children().ToList();
         foreach (JToken result in results)
         {
             Order searchResult = result.ToObject <Order>();
             searchResult.PositionName      = searchResult.PositionName;
             searchResult.PercentComplited += "%";
             searchResult.Id       = "Заказ №: " + searchResult.Id;
             searchResult.NumberTN = "ПТМЦ №: " + searchResult.NumberTN;
             ordersList.Add(searchResult);
         }
         isEdit = false;
     }
     catch (Exception ex)
     {
         RunOnUiThread(() =>
         {
             AlertDialog.Builder dialog = new AlertDialog.Builder(this);
             AlertDialog alert          = dialog.Create();
             alert.SetTitle("Сервер не отвечает");
             alert.SetMessage("Обратитесь к администратору" + ex.Message);
             alert.Show();
             return;
         });
     }
 }
예제 #4
0
 /// <summary>
 /// Called when a shared preference is changed, added, or removed.
 /// </summary>
 /// <param name="sharedPreferences">Changed shared preference.</param>
 /// <param name="key">The key of the preference that was changed, added, or removed.</param>
 public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
 {
     // if language is changed
     if (key == "list_languages")
     {
         // get new language value
         string newLanguageValue = sharedPreferences.GetString(key, "auto");
         // if new language differs from the previous language
         if (newLanguageValue != _previousLanguageValue)
         {
             // notify user that application must be restarted
             // create the dialog builder
             using (Android.Support.V7.App.AlertDialog.Builder dialogBuilder = new Android.Support.V7.App.AlertDialog.Builder(this))
             {
                 // create a button
                 dialogBuilder.SetPositiveButton(Resource.String.ok_button, (EventHandler <DialogClickEventArgs>)null);
                 // create a dialog
                 Android.Support.V7.App.AlertDialog dialog = dialogBuilder.Create();
                 // set dialog title
                 dialog.SetTitle(Resources.GetString(Resource.String.app_name));
                 // set dialog message
                 dialog.SetMessage(Resources.GetString(Resource.String.language_change_message));
                 // show on screen
                 dialog.Show();
             }
             _previousLanguageValue = newLanguageValue;
         }
     }
 }
예제 #5
0
        //Alert handler to improve code cleanliness
        public AlertDialog CreateAlert(AlertType type, string alertMessage, string alertTitle)
        {
            if (type == AlertType.Error)
            {
                AlertDialog.Builder dialogConnection = new AlertDialog.Builder(this);
                dialog = dialogConnection.Create();
                dialog.SetTitle(alertTitle);
                dialog.SetMessage(alertMessage);
            }
            else if (type == AlertType.Load)
            {
                dialog = new EDMTDialogBuilder()
                         .SetContext(this)
                         .SetMessage(alertMessage)
                         .Build();
            }
            else if (type == AlertType.Info)
            {
                AlertDialog.Builder dialogConnection = new AlertDialog.Builder(this);
                var btnOk = Resources.GetText(Resource.String.btnOk);
                dialogConnection.SetPositiveButton(btnOk, (senderAlert, args) => {
                    dialogConnection.Dispose();
                });
                dialog = dialogConnection.Create();
                dialog.SetTitle(alertTitle);
                dialog.SetMessage(alertMessage);
                dialog.SetCanceledOnTouchOutside(true);
            }

            dialog.Show();

            return(dialog);
        }
예제 #6
0
 private void BtnSubmit_Click(object sender, EventArgs e)
 {
     if (!DataManager.IsReadResult)
     {
         Android.Support.V7.App.AlertDialog.Builder dialog = new Android.Support.V7.App.AlertDialog.Builder(this);
         dialog.SetCancelable(true);
         dialog.SetPositiveButton("YES", delegate
         {
             countDownTimer.Stop();
             Intent intent = new Intent(this, typeof(ResultActivity));
             intent.PutExtra("Answers", DataManager.AnswersChoosed);
             StartActivityForResult(intent, REQUESTCODE);
         }
                                  );
         dialog.SetNegativeButton("NO", delegate { });
         Android.Support.V7.App.AlertDialog alert = dialog.Create();
         alert.SetTitle("Thông báo");
         alert.SetMessage("Bạn có chắc chắn muốn nộp bài?");
         alert.Show();
     }
     else
     {
         Intent intent = new Intent(this, typeof(ResultActivity));
         intent.PutExtra("Answers", DataManager.AnswersChoosed);
         StartActivityForResult(intent, REQUESTCODE);
         DataManager.IsReadResult = false;
     }
 }
예제 #7
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;
         });
     }
 }
예제 #8
0
 private void ErrorMessage(string ex)
 {
     RunOnUiThread(() =>
     {
         AlertDialog.Builder dialog = new AlertDialog.Builder(this);
         AlertDialog alert          = dialog.Create();
         alert.SetTitle("Ошибка программы");
         alert.SetMessage(ex);
         alert.Show();
         return;
     });
 }
예제 #9
0
 private void OnTimedEvent(object sender, ElapsedEventArgs e)
 {
     RunOnUiThread(() =>
     {
         AlertDialog.Builder dialog = new AlertDialog.Builder(this);
         AlertDialog alert          = dialog.Create();
         alert.SetTitle("Вы давно не сохранялись");
         alert.SetMessage("Возможно стоит нажать кнопку СОХРАНИТЬ? :)");
         alert.Show();
         return;
     });
 }
        /// <summary>
        /// Shows a dialog.
        /// </summary>
        /// <param name="title">A dialog title.</param>
        /// <param name="value">A dialog value.</param>
        /// <param name="canCopy">Indicates that "Copy value" is activated.</param>
        /// <param name="valueToCopy">Value to copy by button.</param>
        internal void ShowInfoDialog(string title, string value, bool canCopy, string valueToCopy)
        {
            // dialog builder
            using (Android.Support.V7.App.AlertDialog.Builder dialogBuilder = new Android.Support.V7.App.AlertDialog.Builder(new ContextThemeWrapper(this, Resource.Style.AlertDialogTheme)))
            {
                // create button
                dialogBuilder.SetPositiveButton(Resources.GetString(Resource.String.ok_button), (EventHandler <DialogClickEventArgs>)null);
                if (canCopy)
                {
                    dialogBuilder.SetNeutralButton(Resources.GetString(Resource.String.copy_value_button), (EventHandler <DialogClickEventArgs>)null);
                    _infoDialogValueToCopy = valueToCopy;
                }
                // create dialog
                _infoDialog = dialogBuilder.Create();

                _infoDialog.Window.SetBackgroundDrawableResource(Android.Resource.Drawable.ScreenBackgroundDarkTransparent);
                // set dialog title
                _infoDialog.SetTitle(title);
                // set dialog message
                _infoDialog.SetMessage(value);
                // show on screen
                _infoDialog.Show();

                // get display size
                DisplayMetrics displayMetrics = new DisplayMetrics();
                WindowManager.DefaultDisplay.GetMetrics(displayMetrics);
                int height = (int)(displayMetrics.HeightPixels * 3 / 4);

                // if dialog content height is greater than 3/4 of screen height
                if (_infoDialog.Window.Attributes.Height > height)
                {
                    _infoDialog.Window.SetLayout(_infoDialog.Window.Attributes.Width, height);
                }

                TextView dialogTextView = _infoDialog.FindViewById <TextView>(Android.Resource.Id.Message);
                // allow to select dialog text
                dialogTextView.SetTextIsSelectable(true);
                // allow to click links
                dialogTextView.MovementMethod = LinkMovementMethod.Instance;
                dialogTextView.LinksClickable = true;
                // add links
                Utils.MyLinkify.AddLinks(dialogTextView, Patterns.EmailAddress, null);
                Utils.MyLinkify.AddLinks(dialogTextView, Patterns.WebUrl, null, new Utils.MyLinkify(), null);

                if (canCopy)
                {
                    _infoDialogNeutralButton         = _infoDialog.GetButton((int)DialogButtonType.Neutral);
                    _infoDialogNeutralButton.Click  += NeutralButton_Click;
                    _infoDialogPositiveButton        = _infoDialog.GetButton((int)DialogButtonType.Positive);
                    _infoDialogPositiveButton.Click += PositiveButton_Click;
                }
            }
        }
예제 #11
0
 private void UpdateDataToServer()
 {
     try
     {
         int stopPosition = positionsList.Count - 1;
         for (int i = 0; i < stopPosition; i++)
         {
             if (positionsList[i].IsUpdate == true)
             {
                 try
                 {
                     string link = positionsList[i].Id.ToString() + "a" + positionsList[i].Rate.ToString().Replace(".", ",") + "a" + positionsList[i].Weight.ToString().Replace(".", ",");
                     new WebClient().DownloadString("http://192.168.1.33/CMOS/CMOSS/PostPositionsPreorderApi/" + link);
                 }
                 catch (Exception ex)
                 {
                     ordersRecyclerView.Visibility = ViewStates.Visible;
                     RunOnUiThread(() =>
                     {
                         AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                         AlertDialog alert          = dialog.Create();
                         alert.SetTitle("Сервер не отвечает");
                         alert.SetMessage("Повторите попытку" + " Ошибка: " + ex.Message);
                         alert.Show();
                         return;
                     });
                 }
             }
         }
         isEdit = false;
         CreateTimer();
         RunOnUiThread(() =>
         {
             AlertDialog.Builder dialog = new AlertDialog.Builder(this);
             AlertDialog alert          = dialog.Create();
             alert.SetTitle("Сохранено");
             alert.SetMessage("");
             alert.Show();
             return;
         });
     }
     catch (Exception ex)
     {
         ErrorMessage("MainActivity - UpdateDataToServer:" + ex.Message);
     }
 }
예제 #12
0
        private void PlaceOrder_Click(object sender, System.EventArgs e)
        {
            mProgressBar.Visibility = ViewStates.Visible;
            if (string.IsNullOrEmpty(mLocationAddressTextView.Text))
            {
                Android.Support.V7.App.AlertDialog.Builder dialog = new Android.Support.V7.App.AlertDialog.Builder(this);
                Android.Support.V7.App.AlertDialog         alert  = dialog.Create();
                alert.SetTitle("No Address");
                alert.SetMessage("Address Not Entered");
                alert.SetButton(1, "OK", (c, ev) =>
                {
                    // Ok button click task
                });
            }
            else
            {
                try
                {
                    Order odr = new Order()
                    {
                        Amount  = totAmt,
                        Address = mLocationAddressTextView.Text,
                        Status  = "Confirmed",
                        Uid     = uid
                    };
                    Order ordr  = odr;
                    var   query = db.insertOrder(odr);
                }

                catch (Exception ex)
                {
                    Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Short).Show();
                }
                mProgressBar.Visibility = ViewStates.Invisible;
            }

            Snackbar snackBar = Snackbar.Make(odrBtn, "Your Order is Placed !", Snackbar.LengthIndefinite).SetAction("Ok", (v) =>
            {
                NotifyNotification();
            });

            snackBar.Show();
        }
예제 #13
0
        /// <summary>
        /// Shows a dialog with information.
        /// </summary>
        /// <param name="title">A dialog title.</param>
        /// <param name="value">A dialog value.</param>
        internal void ShowInfoDialog(string title, string value)
        {
            // create the dialog builder
            using (Android.Support.V7.App.AlertDialog.Builder dialogBuilder = new Android.Support.V7.App.AlertDialog.Builder(this))
            {
                // create a button
                dialogBuilder.SetPositiveButton(Resource.String.ok_button, (EventHandler <DialogClickEventArgs>)null);

                // create a dialog
                _infoDialog = dialogBuilder.Create();

                // set dialog title
                _infoDialog.SetTitle(title);
                // set dialog message
                _infoDialog.SetMessage(value);
                // show on screen
                _infoDialog.Show();

                // get display size
                DisplayMetrics displayMetrics = new DisplayMetrics();
                WindowManager.DefaultDisplay.GetMetrics(displayMetrics);
                int height = (int)(displayMetrics.HeightPixels * 3 / 4);

                // if dialog content height is greater than 3/4 of screen height
                if (_infoDialog.Window.Attributes.Height > height)
                {
                    _infoDialog.Window.SetLayout(_infoDialog.Window.Attributes.Width, height);
                }

                TextView dialogTextView = _infoDialog.FindViewById <TextView>(Android.Resource.Id.Message);
                // allow to select dialog text
                dialogTextView.SetTextIsSelectable(true);
                // allow to click links
                dialogTextView.MovementMethod = LinkMovementMethod.Instance;
                dialogTextView.LinksClickable = true;
                // add links
                Utils.MyLinkify.AddLinks(dialogTextView, Patterns.EmailAddress, null);
                Utils.MyLinkify.AddLinks(dialogTextView, Patterns.WebUrl, null, new Utils.MyLinkify(), null);
            }
        }
예제 #14
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);
     }
 }