protected override void OnNavigatedTo(NavigationEventArgs e) { Sqlite sqlData = new Sqlite(); var plan = (Plans)e.Parameter; Days d; //startDate.Text = "From " + plan.StartDate.Date.ToString("d", DateTimeFormatInfo.InvariantInfo) + " To " + plan.EndDate.Date.ToString("d", DateTimeFormatInfo.InvariantInfo); startDate.Text = "From " + plan.StartDate.ToString("dd/MM/yyyy") + " To " + plan.EndDate.ToString("dd/MM/yyyy"); location.Text = "in " + plan.Location; maxDay.Text = plan.MaxDay.ToString(); if (plan.MaxDay == 0) { addNewEvent.IsEnabled = false; } //DaysList = DayList.getDayList(plan.StartDate, plan.EndDate); // Initialize date instance var queryDay = from pd in sqlData.conn.Table<Days>() where pd.PlanID_FK.Equals(plan.PlanID) select pd; // create date if there is no date if (queryDay.Count<Days>() == 0) { for (int i = 1; i <= Convert.ToInt16(maxDay.Text); i++) { d = new Days(plan.PlanID, "No Activities on this day!", "Day " + i.ToString()); sqlData.conn.Insert(d); } } DaysList = DayList.getDayList(plan); }
//private ObservableCollection<Plans> PlanList; public MainPage() { this.InitializeComponent(); Sqlite data = new Sqlite(); PlanList = data.conn.Table<Plans>(); }
private void addNewActivity_Click(object sender, RoutedEventArgs e) { string actTextContent; activityContent.Document.GetText(Windows.UI.Text.TextGetOptions.UseObjectText, out actTextContent); TripPlanner.Classes.DayEvents activity = new TripPlanner.Classes.DayEvents(_planId, _dayId, activityStartTime.Time, activityEndTime.Time, actTextContent, activityLocation.Text); Sqlite sqlData = new Sqlite(); sqlData.conn.Insert(activity); }
private void addNewPlan_Click(object sender, RoutedEventArgs e) { bool validationLocationClear = true; bool validationDateClear = true; //check location not blank if (String.IsNullOrEmpty(planLocation.Text)) { Flyout myFlyout = Resources["validationFlyout"] as Flyout; myFlyout.ShowAt(planLocation); if(validationLocationClear == true) { validationLocationClear = false; } } else { validationLocationClear = true; } //Check End Date > Start Date if(planStartDate.Date.DateTime.Date > planEndDate.Date.DateTime.Date) { Flyout dateValidationFlyout = Resources["endDateValidation"] as Flyout; dateValidationFlyout.ShowAt(planStartDate); if(validationDateClear == true) { validationDateClear = false; } } else { validationDateClear = true; } if(validationLocationClear == true & validationDateClear ==true) { if (String.IsNullOrEmpty(planBudget.Text)) { planBudget.Text = "0"; } Plans plan = new Plans(planStartDate.Date.DateTime, planEndDate.Date.DateTime, planLocation.Text, Convert.ToDouble(planBudget.Text)); Sqlite sqlData = new Sqlite(); sqlData.conn.Insert(plan); //plan.SetPlanDetails(planStartDate.Date.DateTime, planEndDate.Date.DateTime, planLocation.Text, Convert.ToDouble(planBudget.Text)); Frame.Navigate(typeof(PlanDetails), plan); } }
//public static ObservableCollection<Days> getDayList(DateTime startDate, DateTime endDate) //{ // var dayList = new ObservableCollection<Days>(); // //int maxDay = CalculateMaxDay(startDate, endDate); // //for (int i = 1; i <= maxDay; i++) // //{ // //dayList.Add(new Days("No Activities on this day!", "Day " +i.ToString())); // //} // return dayList; //} public static TableQuery<Days> getDayList(Plans p) { Sqlite sqlData = new Sqlite(); var queryDay = from d in sqlData.conn.Table<Days>() where d.PlanID_FK.Equals(p.PlanID) select d; //int maxDay = CalculateMaxDay(startDate, endDate); //for (int i = 1; i <= maxDay; i++) //{ //dayList.Add(new Days("No Activities on this day!", "Day " +i.ToString())); //} return queryDay; }