Beispiel #1
0
        private async void getData()
        {
            try
            {
                List<localEventsTable> events = await App.MobileService.GetTable<localEventsTable>().ToListAsync();

                events = events.OrderBy(o => o.CreatedAt).ToList();
                if (events.Count != 0)
                {
                    localEventsTable lastEvent = new localEventsTable();
                    foreach (localEventsTable evt in events)
                    {
                        PushItems item = new PushItems(evt);

                        item.Content = evt.HandleName;
                        item.Name = (evt.HandleName).Replace(" ", "");
                        item.Height = 40;
                        item.Width = 300;
                        item.Margin = new Thickness(0, 10, 0, 0);
                        item.Background = new SolidColorBrush(new Windows.UI.Color { A = 124, R = 255, G = 255, B = 255 });
                        item.Foreground = new SolidColorBrush(new Windows.UI.Color { A = 255, R = 255, G = 255, B = 255 });
                        item.HorizontalContentAlignment = HorizontalAlignment.Left;
                        //item.VerticalContentAlignment = VerticalAlignment.Center;
                        item.Click += new RoutedEventHandler(handleItem);

                        list.Items.Add(item);

                        lastEvent = evt;
                    }

                    string currDateTime = DateTime.Now.ToString();
                    string currDate = ReverseDateFormat(currDateTime.Remove(10));
                    string currTime = currDateTime.Remove(0, 11);

                    string lastEventDate = ReverseDateFormat(lastEvent.EndDate);
                    string lastEventTime = lastEvent.EndTime;

                    int dateCompRes = string.Compare(currDate, lastEventDate);
                    int timeCompRes = string.Compare(currTime, lastEventTime);

                    if (dateCompRes < 0 || (dateCompRes == 0 && timeCompRes < 0))
                        runningEvent = lastEvent.HandleName;
                    else
                        runningEvent = "";
                }
            }
            catch (NotSupportedException err)
            {
                Debug.WriteLine("Exception in Push : " + err.Message);
            }
            catch (SQLite.Net.SQLiteException err)
            {
                Debug.WriteLine("Exception in Push : " + err.Message);
            }
            catch (NullReferenceException err)
            {
                Debug.WriteLine("Exception in Push : " + err.Message);
            }
        }
        private async void getData()
        {
            try
            {
                List<localEventsTable> events = await App.MobileService.GetTable<localEventsTable>().ToListAsync();
                events = events.OrderBy(o => o.CreatedAt).ToList();
                if (events.Count != 0)
                {
                    lastEvent = events.Last();

                    string startDate = lastEvent.StartDate;
                    string startTime = lastEvent.StartTime;

                    string stD, stM, stY, stH, stMin;

                    getDMY(startDate, out stD, out stM, out stY);
                    getHM(startTime, out stH, out stMin);

                    string endDate = lastEvent.EndDate;
                    string endTime = lastEvent.EndTime;

                    string eD, eM, eY, eH, eMin;

                    getDMY(endDate, out eD, out eM, out eY);
                    getHM(endTime, out eH, out eMin);

                    handleName.Text = lastEvent.HandleName;
                    startDay.Text = stD;
                    startMonth.Text = getMonth(stM);
                    startYear.Text = stY;
                    startHour.Text = stH;
                    startMinute.Text = stMin;

                    endDay.Text = eD;
                    endMonth.Text = getMonth(eM);
                    endYear.Text = eY;
                    endHour.Text = eH;
                    endMinute.Text = eMin;
                }
            }
            catch (NotSupportedException err)
            {
                Debug.WriteLine("Exception in RunningEvent : " + err.Message);
            }
        }
Beispiel #3
0
        private async void startBtn_Click(object sender, RoutedEventArgs e)
        {
            string currDateTime = DateTime.Now.ToString();
            string currDate = ReverseDateFormat(currDateTime.Remove(10));
            string currTime = currDateTime.Remove(0, 11);
            currTime = currTime.Remove(currTime.Length - 2);
            currTime += "00";

            string hn = handleName.Text;

            if(hn.Length == 0)
            {
                await new MessageDialog("Event Name cannot be empty.").ShowAsync();
                return;
            }



            string sd = startDate.Date.ToString().Remove(10);
            string st = startTime.Time.ToString();

            string sdRev = ReverseDateFormat(sd);

            int compRes = string.Compare(sdRev, currDate);

            Debug.WriteLine("curr:" + currTime);
            Debug.WriteLine("st:" + st);

            if (compRes < 0 || (compRes == 0 && string.Compare(st, currTime) < 0))
            {
                await new MessageDialog("Start Date must be present or future").ShowAsync();
                return;
            }


            string ed = endDate.Date.ToString().Remove(10);
            string et = endTime.Time.ToString();

            string edRev = ReverseDateFormat(ed);

            compRes = string.Compare(sdRev, edRev);
            if (compRes > 0 || (compRes == 0 && string.Compare(st, et) >= 0))
            {
                await new MessageDialog("End Date must be greater than Start Date.").ShowAsync();
                return;
            }

            localEventsTable evt = new localEventsTable
            {
                HandleName = hn,
                StartDate = sd,
                StartTime = st,
                EndDate = ed,
                EndTime = et,
                CreatedAt = DateTime.Now.Date,
                pushed = false
            };

            await App.MobileService.GetTable<localEventsTable>().InsertAsync(evt);

            this.Frame.Navigate(typeof(MainPage));
        }
Beispiel #4
0
 public PushItems(localEventsTable h)
 {
     handler = h;
 }
Beispiel #5
0
 public PushItems()
 {
     handler = new localEventsTable();
 }
Beispiel #6
0
 public imagefile(StorageFile f, localEventsTable h, string hn)
 {
     file = f;
     handler = h;
     handleName = hn;
 }