Пример #1
0
        async void onDeleteTapped(object sender, EventArgs args)
        {
            var customSearchesSelected = ((TappedEventArgs)args).Parameter;
            customSearchesItem        customSearches     = (customSearchesItem)customSearchesSelected;
            List <customSearchesItem> tempcustomSearches = (List <customSearchesItem>)listView.ItemsSource;

            var answer = await DisplayAlert("Remove Favourite Search", "Are you sure you want to remove favourite search '" + customSearches.identifier + "'?", "YES", "NO");

            if (answer)
            {
                //remove bookmark from listview
                foreach (var searchesItem in tempcustomSearches.ToList())
                {
                    if (searchesItem == customSearches)
                    {
                        int index = tempcustomSearches.IndexOf(searchesItem);
                        tempcustomSearches.Remove(searchesItem);
                    }
                }

                //Refresh listview
                listView.ItemsSource = tempcustomSearches.ToList();

                //Display error message when there are no bookmark
                if (tempcustomSearches.Count <= 0)
                {
                    errorMsg.Text      = "No favourite searches found.";
                    errorMsg.IsVisible = true;
                    upBtn.IsVisible    = false;
                }

                //Remove bookmark from database
                string httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageSearchBookmark(customSearches.searchID, customSearches.tenderReference, customSearches.tenderTitle, customSearches.originatingSource, customSearches.closingDateFrom, customSearches.closingDateTo, userSession.username, customSearches.identifier, "delete"));

                Console.WriteLine(customSearches.identifier);
                var httpResult = httpTask.ToString();
                Console.WriteLine(httpResult);
                int count = 0;

                while (count < 3 && httpResult != "Success")
                {
                    Console.WriteLine("Looping for failure delete");
                    httpTask = await Task.Run <string>(() => HttpRequestHandler.PostManageSearchBookmark(customSearches.searchID, customSearches.tenderReference, customSearches.tenderTitle, customSearches.originatingSource, customSearches.closingDateFrom, customSearches.closingDateTo, userSession.username, customSearches.identifier, "delete"));

                    httpResult = httpTask.ToString();
                    count++;
                }
            }
        }
Пример #2
0
        public searchTenderPage(customSearchesItem aCustomSearchItem)
        {
            BindingContext = this;
            InitializeComponent();
            string username = "", password = "";

            username = adminAuth.Username;
            password = adminAuth.Password;

            activityIndicator.IsVisible = true;
            activityIndicator.IsRunning = true;

            displayBookmarkedSearchFields(aCustomSearchItem);

            activityIndicator.IsVisible = false;
            activityIndicator.IsRunning = false;
        }
Пример #3
0
        async void displayBookmarkedSearchFields(customSearchesItem aCustomSearchItem)
        {
            var tapRecognizer = new TapGestureRecognizer();

            tapRecognizer.Tapped += OnSearchBookmarkTapped;
            bookmarkImg.GestureRecognizers.Add(tapRecognizer);

            //---------DatePicker Control Section---------------
            //set datepicker text color to light gray to simulate not-filled
            closingdateFrom.TextColor     = Color.LightGray;
            closingdateTo.TextColor       = Color.LightGray;
            closingdateFrom.DateSelected += DatePicker_DateSelected;
            closingdateTo.DateSelected   += DatePicker_DateSelected;
            //---------End DatePicker Control Section-----------

            stkTab2.IsVisible                = false;
            normalTabButton.TextColor        = Color.White;
            keywordTabButton.TextColor       = Color.White;
            normalTabButton.BackgroundColor  = Color.FromHex("#4A6FB8");
            keywordTabButton.BackgroundColor = Color.FromHex("#527DD4");
            searchButton.Clicked            += OnSubmitButtonClicked;
            clearButton.Clicked             += OnClearButtonClicked;

            keywordSubmitButton.Clicked += OnKeywordSubmitButtonClicked;
            keywordClearButton.Clicked  += OnClearButtonClicked;

            searchButton.Clicked += OnSubmitButtonClicked;
            clearButton.Clicked  += OnClearButtonClicked;

            await retrieveOriginatingSource();

            if (!string.IsNullOrEmpty(aCustomSearchItem.searchID))
            {
                if (aCustomSearchItem.tenderTitle == "NULL")
                {
                    tenderTitleInput.Text = "";
                    Console.WriteLine("IS NULL OR EMPTY");
                }
                else
                {
                    tenderTitleInput.Text = aCustomSearchItem.tenderTitle;
                }

                if (aCustomSearchItem.tenderReference == "NULL")
                {
                    tenderReferenceInput.Text = "";
                }
                else
                {
                    tenderReferenceInput.Text = aCustomSearchItem.tenderReference;
                }


                for (int x = 0; x < globalSourceList.Count; x++)
                {
                    if (globalSourceList[x] == aCustomSearchItem.originatingSource)
                    {
                        sourcePicker.SelectedIndex = x;
                        selectedSource             = aCustomSearchItem.originatingSource;
                    }
                    else if (x == globalSourceList.Count && globalSourceList[x] != aCustomSearchItem.originatingSource)
                    {
                        await DisplayAlert("Error", "There are no available tenders with the chosen originating station. Please choose the originating station again", "Okay");
                    }
                }



                if (!string.IsNullOrEmpty(aCustomSearchItem.closingDateFrom))
                {
                    closingdateFrom.Date      = DateTime.Parse(aCustomSearchItem.closingDateFrom);
                    closingdateFrom.TextColor = Color.Black;
                }

                if (!string.IsNullOrEmpty(aCustomSearchItem.closingDateTo))
                {
                    closingdateTo.Date      = DateTime.Parse(aCustomSearchItem.closingDateTo);
                    closingdateTo.TextColor = Color.Black;
                }
            }
        }