public static void SaveData(Sms sms) { const string sConn = "Data Source=isostore:/HRDatabase.sdf"; using (var db = new HrContext(sConn)) { db.Sms.InsertOnSubmit(sms); db.SubmitChanges(); } }
private void Create(object sender, EventArgs e) { var date = (DateTime) DatePicker.Value; var time = (DateTime) TimePicker.Value; DateTime beginTime = date + time.TimeOfDay; if (NumberTextBox.Text == "") { MessageBox.Show("Please enter a number phone or add a contact"); return; } if (BodyTextBox.Text == "") { MessageBox.Show("Please enter a body message"); return; } if (beginTime < DateTime.Now) { MessageBox.Show("The date must be in the future."); return; } var random = new Random(DateTime.Now.Millisecond); int randomNumber = random.Next(1, 500000); string alarmName = NumberTextBox.Text + randomNumber.ToString(CultureInfo.InvariantCulture); DateTime MyDateTime = ((DateTime) DatePicker.Value).Date.Add(((DateTime) TimePicker.Value).TimeOfDay); var sms = new Sms(BodyTextBox.Text, NumberTextBox.Text, NameTextBox.Text, MyDateTime, alarmName); SmsDb.SaveData(sms); var alarm = new Alarm(alarmName) { Content = "Hey, you planned to send a sms \r\nto " + NumberTextBox.Text + " " + NameTextBox.Text + "\r\nat " + MyDateTime, BeginTime = beginTime, ExpirationTime = beginTime, RecurrenceType = RecurrenceInterval.None }; ScheduledActionService.Add(alarm); NavigationService.Navigate(new Uri("/View/MainPage.xaml", UriKind.Relative)); }
public static void Update(Sms sms) { const string sConn = "Data Source=isostore:/HRDatabase.sdf"; using (var db = new HrContext(sConn)) { Sms updateSms = db.Sms.FirstOrDefault(s => s.Id == sms.Id); ScheduledActionService.Remove(updateSms.AlarmName); updateSms.AlarmName = sms.AlarmName; updateSms.Body = sms.Body; updateSms.Date = sms.Date; updateSms.Name = sms.Name; updateSms.Number = sms.Number; db.SubmitChanges(); } }
private void ShowSms(Sms sms) { if (sms == null) return; NavigationService.Navigate(new Uri("/View/ShowReminder.xaml?id=" + sms.Id, UriKind.Relative)); }
private void OnSelectionElement(SelectionChangedEventArgs args) { Messenger.Default.Send(Selection); Selection = null; }