Esempio n. 1
0
 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
 {
     using (var db = new DatabaseManager())
     {
         listBox1.ItemsSource = db.GovBidContext.Bids.Where(p => p.Favorite == true);
     }
 }
Esempio n. 2
0
        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                //Get the selected bid
                var bid = listBox1.Items[listBox1.SelectedIndex] as Bid;

                //From DB
                using (var databaseManager = new DatabaseManager())
                {
                    if (databaseManager.GovBidContext.BidsViewed.Count(p => p.Id == bid.ItemID) <= 0)
                    {
                        bid.Viewed = true;
                        databaseManager.GovBidContext.BidsViewed.InsertOnSubmit(new BidsViewed() { Date = DateTime.Now, Id = bid.ItemID });
                        databaseManager.GovBidContext.SubmitChanges();
                    }
                }

                //Navigate to the web browser bid view
                NavigationService.Navigate(new Uri("/Pages/BidWebView.xaml?Id=" + bid.ItemID, UriKind.Relative));
            }
        }
Esempio n. 3
0
        private void updateDb()
        {
            using (var db = new DatabaseManager())
            {
                List<Bid> bids = db.GovBidContext.Bids.ToList();
                var bidsV = (from b in db.GovBidContext.BidsViewed select b);
                foreach (var bV in bidsV)
                {
                    try
                    {
                        bids.First(p => p.ItemID == bV.Id).Viewed = true;
                    }

                    catch { }
                }
                listBox1.ItemsSource = bids;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Event that handles the application loaded state.
        /// Use for loading data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            //Retrieve all

            if ((App.Current as App).filterSettings.Update)
            {
                (App.Current as App).filterSettings.Update = false;
                updateWeb();
            }

            else
            {
                using (var db = new DatabaseManager())
                {
                    if (db.GovBidContext.Bids.Count() > 0)
                    {
                        var settings = IsolatedStorageSettings.ApplicationSettings;

                        DateTime last = new DateTime(1995, 6, 22);

                        if (!settings.TryGetValue("LastUpdated", out last))
                            settings.Add("LastUpdated", last);

                        if ((last - DateTime.Now).TotalDays > 0)
                        {
                            updateWeb();
                        }

                        else
                        {
                            updateDb();
                        }
                    }

                    else
                        updateWeb();
                }
            }
        }
Esempio n. 5
0
        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            //Get the menu item
            var menuItem = sender as MenuItem;
            //Get the id
            string Id = menuItem.Tag.ToString();

            using (var db = new DatabaseManager())
            {
                //Get the bid
                var bid = db.GovBidContext.Bids.First(p => p.ItemID.ToString() == Id) as Bid;

                if (bid.Favorite)
                    bid.Favorite = false;

                else
                    bid.Favorite = true;

                db.GovBidContext.SubmitChanges();

                updateDb();
            }
        }
Esempio n. 6
0
        //Mark as... click event
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            //Get the menu item
            var menuItem = sender as MenuItem;
            //Get the id
            string Id = menuItem.Tag.ToString();
            //Get the bid
            var bid = (from m in listBox1.Items where (m as Bid).ItemID.ToString() == Id select m).First();

            using (var databaseManager = new DatabaseManager())
            {
                if ((bid as Bid).Viewed)
                {
                    var bV = from p in databaseManager.GovBidContext.BidsViewed where p.Id.ToString() == Id select p;
                    databaseManager.GovBidContext.BidsViewed.DeleteOnSubmit(bV.First());
                }

                else
                {
                    databaseManager.GovBidContext.BidsViewed.InsertOnSubmit(new BidsViewed() { Date = DateTime.Now, Id = Convert.ToInt32(Id) });
                    databaseManager.GovBidContext.SubmitChanges();
                }

                databaseManager.GovBidContext.SubmitChanges();
                updateDb();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Event handler for the Soap Client when it finishes a call to GetBids
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void client_GetBidsCompleted(object sender, GetBidsCompletedEventArgs e)
        {
            //Get the progress indicator from the system tray
            var proggressIndicator = SystemTray.GetProgressIndicator(this);
            proggressIndicator.IsIndeterminate = false;
            proggressIndicator.IsVisible = false;

            //Detect errors
            if (e.Error == null)
            {
                (IsolatedStorageSettings.ApplicationSettings)["LastUpdated"] = DateTime.Now;
                (IsolatedStorageSettings.ApplicationSettings).Save();
                var bids = getBidListFromXml(e.Result);

                //From DB
                using (var databaseManager = new DatabaseManager())
                {
                    var bidsV = (from b in databaseManager.GovBidContext.BidsViewed select b);
                    foreach (var bV in bidsV)
                    {
                        try
                        {
                            bids.First(p => p.ItemID == bV.Id).Viewed = true;
                        }

                        catch { }
                    }

                    databaseManager.GovBidContext.Bids.DeleteAllOnSubmit(databaseManager.GovBidContext.Bids);
                    databaseManager.GovBidContext.Bids.InsertAllOnSubmit(bids);
                    databaseManager.GovBidContext.SubmitChanges();
                }

                listBox1.ItemsSource = bids;
            }

            else
                MessageBox.Show("Error con conexión de internet.");
        }