Ejemplo n.º 1
0
 public void DeleteChecklist(ChecklistModel checklist)
 {
     database.DeleteAll(checklist.GetAllQuestions());
     database.Delete(checklist);
 }
Ejemplo n.º 2
0
        //ResizingLayout layout;

        public CommentPage(Inspection inspection, Question initialQuestion)
        {
            this.inspection = inspection;
            ChecklistModel checklist = inspection.Checklist;

            this.Title = "Add/Edit Comment";

            StackLayout layout = new StackLayout
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            Page   frontPage = App.Navigation.NavigationStack.First();
            double width     = frontPage.Width;

            layout.WidthRequest = width * .95;

            //Choose comment type
            Label chooseCommentTypeLabel = new Label {
                Text = "Choose comment type"
            };

            commentTypePicker = new GenericPicker <CommentType>();
            commentTypePicker.AddItem(CommentType.Finding);
            commentTypePicker.AddItem(CommentType.Observation);
            commentTypePicker.AddItem(CommentType.Commendable);
            commentTypePicker.SelectedIndexChanged += SelectCommentType;

            //Choose question
            Label chooseQuestionLabel = new Label {
                Text = "Choose question"
            };

            questionPicker = new GenericPicker <Question>();
            foreach (Question question in checklist.GetAllQuestions().Where(q => !q.HasSubItems))
            {
                questionPicker.AddItem(question);
            }
            questionPicker.SelectedIndexChanged += SelectQuestion;

            //Comment description
            Label commentSubjectLabel = new Label {
                Text = "Subject"
            };

            subjectTextEditor = new Editor();
            subjectTextEditor.HeightRequest = 80;

            //Enter comment
            commentIndicatorLabel = new Label {
                Text = "Comment:"
            };
            commentText = new Editor();
            commentText.HeightRequest = 80;

            //Discussion
            Label DiscussionLabel = new Label {
                Text = "Discussion:"
            };

            discussionText = new Editor();
            discussionText.HeightRequest = 80;

            //Recommendation
            Label RecommendationLabel = new Label {
                Text = "Recommendation/Action Taken or Required:"
            };

            recommendationText = new Editor();
            recommendationText.HeightRequest = 80;

            //Choose date
            Label chooseDateLabel = new Label {
                Text = "Date:"
            };
            DatePicker date = new DatePicker();

            date.Date = DateTime.Now;

            //Save button
            Button saveButton = new Button {
                Text = "Save Comment"
            };

            saveButton.Clicked += SaveComment;

            //Delete button
            Button deleteButton = new Button {
                Text = "Delete Comment"
            };

            deleteButton.Clicked += DeleteComment;

            //TODO: choose inspector
            //TODO more fields, I guess.

            //Perform the setup actions.
            commentTypePicker.SelectedIndex = 0;
            questionPicker.SelectedIndex    = questionPicker.TItems.IndexOf(initialQuestion);

            layout.Children.Add(chooseCommentTypeLabel);
            layout.Children.Add(commentTypePicker);
            layout.Children.Add(chooseQuestionLabel);
            layout.Children.Add(questionPicker);
            layout.Children.Add(commentSubjectLabel);
            layout.Children.Add(subjectTextEditor);
            layout.Children.Add(commentIndicatorLabel);
            layout.Children.Add(commentText);
            layout.Children.Add(DiscussionLabel);
            layout.Children.Add(discussionText);
            layout.Children.Add(RecommendationLabel);
            layout.Children.Add(recommendationText);
            layout.Children.Add(chooseDateLabel);
            layout.Children.Add(date);
            layout.Children.Add(saveButton);
            layout.Children.Add(deleteButton);

            ScrollView scroll = new ScrollView();

            scroll.Content = layout;

            this.Content = scroll;
        }
Ejemplo n.º 3
0
        //ResizingLayout layout;

        public CommentPage(Inspection inspection, Question initialQuestion)
        {
            this.inspection = inspection;
            ChecklistModel checklist = inspection.Checklist;

            this.Title = "Add/Edit Comment";

            StackLayout layout = new StackLayout
            {
                Padding = new Thickness(20, 28)
            };
            Page   frontPage = App.Navigation.NavigationStack.First();
            double width     = frontPage.Width;

            layout.WidthRequest = width * .95;

            //Choose comment type
            Label chooseCommentTypeLabel = new Label {
                Text = "Choose Comment Type:", FontAttributes = FontAttributes.Bold
            };

            commentTypePicker = new GenericPicker <CommentType>();
            commentTypePicker.AddItem(CommentType.Finding);
            commentTypePicker.AddItem(CommentType.Observation);
            commentTypePicker.AddItem(CommentType.Commendable);
            commentTypePicker.SelectedIndexChanged += SelectCommentType;

            //Choose question
            Label chooseQuestionLabel = new Label {
                Text = "Choose Question:", FontAttributes = FontAttributes.Bold
            };

            questionPicker = new GenericPicker <Question>();
            foreach (Question question in checklist.GetAllQuestions().Where(q => !q.HasSubItems))
            {
                questionPicker.AddItem(question);
            }
            questionPicker.SelectedIndexChanged += SelectQuestion;

            //Comment description
            Label commentSubjectLabel = new Label {
                Text = "Subject:", FontAttributes = FontAttributes.Bold
            };

            subjectTextEditor = new Editor();
            subjectTextEditor.HeightRequest = 80;

            //Enter comment
            commentIndicatorLabel = new Label {
                Text = "Comment:", FontAttributes = FontAttributes.Bold
            };
            commentText = new Editor();
            commentText.HeightRequest = 80;

            //Discussion
            Label DiscussionLabel = new Label {
                Text = "Discussion:", FontAttributes = FontAttributes.Bold
            };

            discussionText = new Editor();
            discussionText.HeightRequest = 80;

            //Recommendation
            Label RecommendationLabel = new Label {
                Text = "Recommendation/Action Taken or Required:", FontAttributes = FontAttributes.Bold
            };

            recommendationText = new Editor();
            recommendationText.HeightRequest = 80;

            //Choose date
            Label chooseDateLabel = new Label {
                Text = "Date:", FontAttributes = FontAttributes.Bold
            };
            DatePicker date = new DatePicker()
            {
                Format = "MMMM dd, yyyy", HorizontalOptions = LayoutOptions.Start
            };

            date.Date = DateTime.Now;

            //Save button
            Button saveButton = new Button {
                Text = "Save Comment"
            };

            saveButton.Clicked += SaveComment;

            //Delete button
            Button deleteButton = new Button {
                Text = "Delete Comment"
            };

            deleteButton.Clicked += DeleteComment;

            //TODO: choose inspector
            //TODO more fields, I guess.

            //Perform the setup actions.
            commentTypePicker.SelectedIndex = 0;
            questionPicker.SelectedIndex    = questionPicker.TItems.IndexOf(initialQuestion);

            double spaceBetweenQuestions = 2;

            layout.Children.Add(
                new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new StackLayout {
                        WidthRequest = width * 2 / 3,
                        Children     =
                        {
                            chooseCommentTypeLabel,
                            commentTypePicker
                        }
                    },
                    LayoutHelper.GetHorizontalSpacing(10),
                    new StackLayout {
                        WidthRequest = width * 1 / 3,
                        Children     =
                        {
                            chooseDateLabel,
                            date
                        }
                    },
                }
            });

            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(chooseQuestionLabel);
            layout.Children.Add(questionPicker);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(commentSubjectLabel);
            layout.Children.Add(subjectTextEditor);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(commentIndicatorLabel);
            layout.Children.Add(commentText);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(DiscussionLabel);
            layout.Children.Add(discussionText);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(RecommendationLabel);
            layout.Children.Add(recommendationText);
            layout.Children.Add(LayoutHelper.GetVerticalSpacing(spaceBetweenQuestions));

            layout.Children.Add(
                new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    saveButton,
                    LayoutHelper.GetHorizontalSpacing(30),
                    deleteButton
                }
            });

            ScrollView scroll = new ScrollView();

            scroll.Content = layout;

            this.Content = scroll;
        }