Ejemplo n.º 1
0
        /// <summary>
        /// bindable_TextChanged
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bindable_TextChanged(object sender, TextChangedEventArgs e)
        {
            var decimalChar = Convert.ToString(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);

            if (string.IsNullOrEmpty(e.NewTextValue) || e.NewTextValue == decimalChar)
            {
                return;
            }

            if (!string.IsNullOrEmpty(e.NewTextValue) && e.NewTextValue.Contains(" "))
            {
                ((Entry)sender).Text = e.OldTextValue;
                return;
            }

            if (e.NewTextValue == "-" || e.NewTextValue == string.Format("-{0}", decimalChar))
            {
                ((Entry)sender).Text = string.Empty;
                return;
            }

            try
            {
                HACCPUtil.ConvertToDouble(e.NewTextValue);
            }
            catch
            {
                ((Entry)sender).Text = e.OldTextValue;
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ShowAreyousureyouwanttoexittheapp
        /// </summary>
        /// <returns></returns>
        public async Task ShowAreyousureyouwanttoexittheapp()
        {
            var res =
                await
                ShowConfirmAlert(HACCPUtil.GetResourceString("HACCP"),
                                 HACCPUtil.GetResourceString("Areyousureyouwanttoexittheapp"));

            if (res)
            {
                DependencyService.Get <IAppExit>().CloseApp();
            }
        }
Ejemplo n.º 4
0
        public object ProvideValue(IServiceProvider serviceProvider)
        {
            if (Text == null)
            {
                return(null);
            }
            Debug.WriteLine("Provide: " + Text);
            // Do your translation lookup here, using whatever method you require
            //if (translated == string.Empty)
            //if(HACCPAppSettings.SharedInstance.SiteSettings.ServerAddress !=  null && HACCPAppSettings.SharedInstance.SiteSettings.ServerAddress != string.Empty )
            var translated = HACCPUtil.GetResourceString(Text);

            //else
            //translated = Localization.Localize (Text, Text);
            return(translated);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Helper function that converts a string to a byte, and writes it to the DataWriter
        /// </summary>
        /// <param name="message"></param>
        /// <param name="writer"></param>
        /// <returns></returns>
        private bool FillDatawriterWithBytes(string message, DataWriter writer)
        {
            byte[] bytes;
            try
            {
                bytes = HACCPUtil.GetBytesFromString(message);
            }
            catch (Exception)
            {
                // Utilities.OnExceptionWithMessage(e, "Needs to be a decimal from 0-255.");
                Debug.WriteLine("Needs to be a decimal from 0-255.");
                return(false);
            }

            writer.WriteBytes(bytes);
            return(true);
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
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"));
 }
Ejemplo n.º 8
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")));
 }
Ejemplo n.º 9
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"));
 }
Ejemplo n.º 10
0
        /// <summary>
        /// App Constructor
        /// </summary>
        public App()
        {
            HaccpAppSettings.SharedInstance.IsWindows = Device.OS == TargetPlatform.Windows ||
                                                        Device.OS == TargetPlatform.WinPhone;


            if (HaccpAppSettings.SharedInstance.IsWindows)
            {
                Task.Run(
                    async() =>
                {
                    HaccpAppSettings.SharedInstance.ResourceString =
                        await DependencyService.Get <IResourceFileHelper>().LoadResourceAsync("ResourceFile.xml");
                });
            }

            else
            {
                try
                {
                    HaccpAppSettings.SharedInstance.ResourceString =
                        DependencyService.Get <IResourceFileHelper>().LoadResource("ResourceFile.xml");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }


            IDataStore dataStore = new SQLiteDataStore();

            dataStore.LoadAppSettings(HaccpAppSettings.SharedInstance);
            Localization.SetLocale();
            HACCPUtil.PreCalculateSlopes();


            var netLanguage = DependencyService.Get <ILocale>().GetCurrent();

            AppResources.Culture = netLanguage;

            Styles.LoadStyles();


            if (string.IsNullOrEmpty(HaccpAppSettings.SharedInstance.SiteSettings.ServerAddress))
            {
                MainPage = new NavigationPage(new ServerSettings())
                {
                    BarBackgroundColor = Color.FromRgb(20, 34, 43),
                    BarTextColor       = Color.FromRgb(225, 225, 225),
                    HeightRequest      = 41
                };
            }
            else
            {
                MainPage = new NavigationPage(new Home())
                {
                    BarBackgroundColor = Color.FromRgb(20, 34, 43),
                    BarTextColor       = Color.FromRgb(225, 225, 225),
                    HeightRequest      = 41
                };
            }
        }
Ejemplo n.º 11
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
                });
            }
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
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;
                }
            };
        }
Ejemplo n.º 14
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;
        }