Exemplo n.º 1
0
        /// <summary>
        ///     Add toolbar with Done button
        /// </summary>
        protected void AddDoneButton()
        {
            var toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, 50.0f, 44.0f));

//			var doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate {
//				this.Control.ResignFirstResponder ();
//			});

            var doneButton = new UIBarButtonItem(HACCPUtil.GetResourceString("Done"), UIBarButtonItemStyle.Plain,
                                                 delegate { Control.ResignFirstResponder(); });

            toolbar.Items = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                doneButton
            };
            doneButton.TintColor       = UIColor.Black;
            Control.InputAccessoryView = toolbar;
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Displaies the alert message.
 /// </summary>
 /// <param name="title">Title.</param>
 /// <param name="message">Message.</param>
 public void DisplayAlertMessage(string title, string message)
 {
     DisplayAlertMessage(title, message, HACCPUtil.GetResourceString("OK"));
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Shows the confirm alert.
 /// </summary>
 /// <returns>The confirm alert.</returns>
 /// <param name="title">Title.</param>
 /// <param name="message">Message.</param>
 public async Task <bool> ShowConfirmAlert(string title, string message)
 {
     return
         (await
          DisplayAlert(title, message, HACCPUtil.GetResourceString("Yes"), HACCPUtil.GetResourceString("No")));
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Shows the alert.
 /// </summary>
 /// <returns>The alert.</returns>
 /// <param name="title">Title.</param>
 /// <param name="message">Message.</param>
 public async Task ShowAlert(string title, string message)
 {
     await DisplayAlert(title, message, HACCPUtil.GetResourceString("OK"));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Record Answer screen constructor
        /// </summary>
        /// <param name="selectedQuestion"></param>
        public RecordAnswer(object selectedQuestion)
        {
            InitializeComponent();

            var question = (Question)selectedQuestion;

            NavigationPage.SetBackButtonTitle(this, string.Empty);

            BindingContext            = _viewModel = new RecordAnswerViewModel(this);
            _viewModel.Subtitle       = question.QuestionName;
            _viewModel.RecordResponse = question;

            switch (question.QuestionType)
            {
            case (short)QuestionType.NumericAnswer:
                _viewModel.IsNumeric = true;
                _viewModel.IsYesNo   = false;
                break;

            case (short)QuestionType.YesOrNo:
                _viewModel.IsYesNo   = true;
                _viewModel.IsNumeric = false;
                _viewModel.Answer    = HACCPUtil.GetResourceString("Yes");
                break;
            }
            correctiveActionList.ItemSelected += (sender, e) =>
            {
                if (correctiveActionList.SelectedItem == null)
                {
                    return;
                }
                var correctiveAction = ((CorrectiveAction)e.SelectedItem).CorrActionName;

                if (!string.IsNullOrEmpty(_viewModel.Answer))
                {
                    if ((_viewModel.IsYesNo && _viewModel.Answer == HACCPUtil.GetResourceString("No")) ||
                        (!_viewModel.IsYesNo &&
                         (HACCPUtil.ConvertToDouble(_viewModel.Answer) <
                          HACCPUtil.ConvertToDouble(_viewModel.RecordResponse.Min) ||
                          HACCPUtil.ConvertToDouble(_viewModel.Answer) >
                          HACCPUtil.ConvertToDouble(_viewModel.RecordResponse.Max))))
                    {
                        if (correctiveAction != HACCPUtil.GetResourceString("None"))
                        {
                            _viewModel.SelectedCorrectiveAction  = correctiveAction;
                            _viewModel.IsCorrctiveOptionsVisible = false;
                        }
                    }
                    else
                    {
                        _viewModel.SelectedCorrectiveAction  = correctiveAction;
                        _viewModel.IsCorrctiveOptionsVisible = false;
                    }
                }
                else
                {
                    _viewModel.SelectedCorrectiveAction  = correctiveAction;
                    _viewModel.IsCorrctiveOptionsVisible = false;
                }
                correctiveActionList.SelectedItem = null;
            };

            actionBtn.Clicked += (sender, e) => { numericValueEntry.Unfocus(); };

            toggleBtn.Clicked += (sender, e) =>
            {
                if (_viewModel.IsNumeric)
                {
                    if (numericValueEntry.IsFocused)
                    {
                        numericValueEntry.Unfocus();
                    }
                    else
                    {
                        numericValueEntry.Focus();
                    }
                }
            };
            if (HaccpAppSettings.SharedInstance.IsWindows)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Icon    = "logout.png",
                    Order   = ToolbarItemOrder.Primary,
                    Command = _viewModel.LogInCommand
                });
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Show Popup Data
        /// </summary>
        /// <param name="record"></param>
        public void ShowPopupData(ItemTemperature record)
        {
            var list  = _viewModel.Items;
            var item  = list.FirstOrDefault(x => x.ItemId == _selectedItem.ItemId);
            var index = list.IndexOf(item);

            if (index == 0)
            {
                prevImage.Source     = "prevDisable.png";
                prevButton.IsEnabled = false;
            }
            else
            {
                prevImage.Source     = "prev.png";
                prevButton.IsEnabled = true;
            }

            if (index == list.Count - 1)
            {
                nextImage.Source     = "nextDisable.png";
                nextButton.IsEnabled = false;
            }
            else
            {
                nextImage.Source     = "next.png";
                nextButton.IsEnabled = true;
            }

            var tempUnit = HaccpAppSettings.SharedInstance.DeviceSettings.TempScale == 0
                ? TemperatureUnit.Fahrenheit
                : TemperatureUnit.Celcius;
            var temperature = HACCPUtil.ConvertToDouble(record.Temperature);
            var min         = HACCPUtil.ConvertToDouble(record.Min);
            var max         = HACCPUtil.ConvertToDouble(record.Max);

            var unit = HACCPUtil.GetResourceString("FahrenheitUnit");

            if (tempUnit == TemperatureUnit.Celcius)
            {
                temperature = Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(temperature), 1);
                min         = Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(min));
                max         = Math.Round(HACCPUtil.ConvertFahrenheitToCelsius(max));
                unit        = HACCPUtil.GetResourceString("CelsciustUnit");
            }

            _viewModel.IsReviewItemVisible = true;
            questionLabel.Text             = record.ItemName;

            RecordedTemp.Text = string.Format("{0}: {1}{2}", HACCPUtil.GetResourceString("RecordedTemperature"),
                                              temperature.ToString("0.0"), unit);
            CorrectiveAction.IsVisible = true;
            CorrectiveAction.Text      = string.Format("{0}: {1}", HACCPUtil.GetResourceString("CorrectiveAction"),
                                                       record.CorrAction);
            if (!string.IsNullOrEmpty(record.Note))
            {
                Notes.Text      = string.Format("{0}: {1}", HACCPUtil.GetResourceString("NotesLabel"), record.Note);
                Notes.IsVisible = true;
            }
            else
            {
                Notes.IsVisible = false;
            }
            TempRange.Text = string.Format("{0}: {1}{2}, {3}: {4}{5}", HACCPUtil.GetResourceString("Min").ToUpper(), min,
                                           unit, HACCPUtil.GetResourceString("Max").ToUpper(), max, unit);
            UserName.Text = string.Format("{0}: {1}", HACCPUtil.GetResourceString("Recordedby"), record.UserName);

            var date = new DateTime(Convert.ToInt32(record.Year), Convert.ToInt32(record.Month),
                                    Convert.ToInt32(record.Day), Convert.ToInt32(record.Hour), Convert.ToInt32(record.Minute),
                                    Convert.ToInt32(record.Sec));
            var dateString = date.ToString();


            TimeStamp.Text = string.Format("{0}: {1}", HACCPUtil.GetResourceString("Time"),
                                           HACCPUtil.GetFormattedDate(dateString));
        }
Exemplo n.º 7
0
        /// <summary>
        ///To  Show Popup
        /// </summary>
        /// <param name="response"></param>
        public void ShowPopupData(CheckListResponse response)
        {
            var list  = _viewModel.Records;
            var item  = list.FirstOrDefault(x => x.RecordNo == _selectedItem.RecordNo);
            var index = list.IndexOf(item);


            if (index == 0)
            {
                prevImage.Source     = "prevDisable.png";
                prevButton.IsEnabled = false;
            }
            else
            {
                prevImage.Source     = "prev.png";
                prevButton.IsEnabled = true;
            }

            if (index == list.Count - 1)
            {
                nextImage.Source     = "nextDisable.png";
                nextButton.IsEnabled = false;
            }
            else
            {
                nextImage.Source     = "next.png";
                nextButton.IsEnabled = true;
            }

            _viewModel.IsReviewAnswerVisible = true;
            questionLabel.Text = response.Question;



            if (response.IsNa == 1)
            {
                correctiveActionLabel.IsVisible = false;
                answerLabel.Text = HACCPUtil.GetResourceString("NA");
            }
            else
            {
                correctiveActionLabel.IsVisible = true;
                correctiveActionLabel.Text      = string.Format("{0}: {1}", HACCPUtil.GetResourceString("CorrectiveAction"),
                                                                response.CorrAction);
                answerLabel.Text = response.QuestionType == "2"
                                                ? ((response.Answer == HACCPUtil.GetResourceString("Yes"))?HACCPUtil.GetResourceString("Yes"):HACCPUtil.GetResourceString("No"))
                    : response.Answer;
            }

            UserName.Text = string.Format("{0}: {1}", HACCPUtil.GetResourceString("Recordedby"), response.UserName);

            var date = new DateTime(Convert.ToInt32(response.Year), Convert.ToInt32(response.Month),
                                    Convert.ToInt32(response.Day), Convert.ToInt32(response.Hour), Convert.ToInt32(response.Minute),
                                    Convert.ToInt32(response.Sec));

            TimeStamp.Text = string.Format("{0}: {1}", HACCPUtil.GetResourceString("Time"),
                                           HACCPUtil.GetFormattedDate(date, false));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Menu Check list Screen Constructor
        /// </summary>
        /// <param name="isMenu"></param>
        public MenuChecklist(object isMenu)
        {
            InitializeComponent();

            NavigationPage.SetBackButtonTitle(this, string.Empty);

            BindingContext = _viewModel = new MenuChecklistViewModel(this);

            _viewModel.IsMenu = Convert.ToBoolean(isMenu);

            _viewModel.Title = HACCPUtil.GetResourceString(_viewModel.IsMenu ? "SelectMenu" : "SelectChecklist");


            menuListView.ItemSelected += (sender, e) =>
            {
                if (menuListView.SelectedItem == null)
                {
                    return;
                }

                if (!IsListViewSelected || !HaccpAppSettings.SharedInstance.IsWindows)
                {
                    IsListViewSelected = true;
                    var menu = menuListView.SelectedItem;

                    if (_viewModel != null)
                    {
                        _viewModel.ShowSelectMenuChecklistAlert(message: HACCPUtil.GetResourceString("Themenuhasbeenupdatedsuccessfully"), selectedItem: menu);
                    }

                    menuListView.SelectedItem = null;
                }
                else
                {
                    IsListViewSelected = false;
                }
            };

            checklistListView.ItemSelected += (sender, e) =>
            {
                if (checklistListView.SelectedItem == null)
                {
                    return;
                }


                if (!IsListViewSelected || !HaccpAppSettings.SharedInstance.IsWindows)
                {
                    IsListViewSelected = true;
                    if (checklistListView.SelectedItem == null)
                    {
                        return;
                    }
                    var checklist = (Checklist)checklistListView.SelectedItem;

                    //       if (!HaccpAppSettings.SharedInstance.IsWindows)
                    checklistListView.SelectedItem = null;

                    if (_viewModel != null)
                    {
                        _viewModel.ShowSelectMenuChecklistAlert(HACCPUtil.GetResourceString("Thechecklisthasbeenaddedsuccessfully"), checklist);
                    }
                }
                else
                {
                    IsListViewSelected = false;
                }
            };
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Add toolbar with Done button
        /// </summary>
        protected void AddDoneButton()
        {
            var toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, 50.0f, 44.0f));

//			var doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done,  delegate {
//				this.Control.ResignFirstResponder ();
//			});

            var doneButton = new UIBarButtonItem(HACCPUtil.GetResourceString("Done"), UIBarButtonItemStyle.Plain,
                                                 delegate { Control.ResignFirstResponder(); });

            var haccpEntry = Element as HACCPEntry;

            if (haccpEntry != null && (Element != null && haccpEntry.ShowPlusMinus))
            {
                var decimalChar = Convert.ToString(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);

                var plussMinusButton = new UIBarButtonItem("  +/-  ", UIBarButtonItemStyle.Plain, delegate
                {
                    if (!string.IsNullOrEmpty(Element.Text) && Element.Text != decimalChar)
                    {
                        double val;

                        if (double.TryParse(Element.Text, out val))
                        {
                            if (val != 0)
                            {
                                if (!Element.Text.Contains("-"))
                                {
                                    Element.Text = "-" + Element.Text;
                                }
                                else if (Element.Text.Contains("-"))
                                {
                                    Element.Text = Element.Text.Replace("-", "");
                                }
                            }
                        }
                    }
                });

                if (UIScreen.MainScreen.Bounds.Width > 500.0)
                {
                    toolbar.Items = new[]
                    {
                        new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                        plussMinusButton
                    };
                }
                else
                {
                    var space = (float)(UIScreen.MainScreen.Bounds.Width - 140);

                    toolbar.Items = new[]
                    {
                        new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                        plussMinusButton,
                        new UIBarButtonItem(new UIView(new RectangleF(0.0f, 0.0f, space, 44.0f))),
                        doneButton
                    };
                }

                plussMinusButton.TintColor = doneButton.TintColor = UIColor.Black;
            }
            else
            {
                toolbar.Items = new[]
                {
                    new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                    doneButton
                };

                doneButton.TintColor = UIColor.Black;
            }


            Control.InputAccessoryView = toolbar;
        }