/// <summary> /// Handles the Click event of the SaveNoteButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void SaveNoteButton_Click(object sender, RoutedEventArgs e) { try { editCourse.TITLE = courseTitle.Text; editCourse.INTRO = courseContent.Text; editCourse.PRICE = Convert.ToDecimal(price.Text); editCourse.CATEGORY = (categoryComboBox.SelectedItem as CATEGORY).ID; editCourse.PG = (pgComboBox.SelectedItem as PARENT_GUIDE).ID; } catch { ShowMessageDialog("Format error1! Please check your input."); return; } try { ctx.UpdateObject(editCourse); TaskFactory <DataServiceResponse> tf = new TaskFactory <DataServiceResponse>(); await tf.FromAsync(ctx.BeginSaveChanges(null, null), iar => ctx.EndSaveChanges(iar)); } catch { ShowMessageDialog("Edit failed! Network connection error.2"); EditCoursePopup.IsOpen = false; return; } ShowMessageDialog("Edit successfully!"); EditCoursePopup.IsOpen = false; }
/// <summary> /// Handles the Click event of the SaveNoteButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void SaveNoteButton_Click(object sender, RoutedEventArgs e) { NOTE updatedNote = null; try { DataServiceQuery <NOTE> naDsq = (DataServiceQuery <NOTE>)(from selNote in ctx.NOTE where selNote.ID == changedNote.ID select selNote); TaskFactory <IEnumerable <NOTE> > changeNote = new TaskFactory <IEnumerable <NOTE> >(); updatedNote = (await changeNote.FromAsync(naDsq.BeginExecute(null, null), iar => naDsq.EndExecute(iar))).FirstOrDefault(); } catch { ShowMessageDialog("Network connection error!24"); return; } updatedNote.TITLE = noteTitle.Text; updatedNote.CONTENT = noteContent.Text; updatedNote.LESSON_ID = changedLessonID; updatedNote.DATE = DateTime.Now; updatedNote.SHARE = sharableCheckBox.IsChecked ?? false; try { ctx.UpdateObject(updatedNote); TaskFactory <DataServiceResponse> tf = new TaskFactory <DataServiceResponse>(); await tf.FromAsync(ctx.BeginSaveChanges(null, null), iar => ctx.EndSaveChanges(iar)); } catch { ShowMessageDialog("Update error25! Please check your network."); addNotePopup.IsOpen = false; return; } ShowMessageDialog("Update successfully!"); addNotePopup.IsOpen = false; }
/// <summary> /// Handles the Tapped event of the SaveImage control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="TappedRoutedEventArgs"/> instance containing the event data.</param> private async void SaveImage_Tapped(object sender, TappedRoutedEventArgs e) { if (passwordBox.Password.Equals(string.Empty) || retypePasswordBox.Password.Equals(string.Empty)) { var messageDialog = new MessageDialog("Please Check your input, Password can't be empty!"); await messageDialog.ShowAsync(); return; } if (!Constants.isEmailAvailable(email.Text)) { var messageDialog = new MessageDialog("Please Check your input, EMAIL is not Available!"); await messageDialog.ShowAsync(); return; } if (!passwordBox.Password.Equals(retypePasswordBox.Password)) { var dialog = new MessageDialog("Passwords are not same! Try again, thx!"); await dialog.ShowAsync(); return; } foreach (CUSTOMER c in csl) { if (c.NAME == Constants.User.NAME) { c.DEGREE = (string)degreeBox.SelectedItem; c.PASSWORD = Constants.ComputeMD5(passwordBox.Password); c.EMAIL = email.Text; c.BIRTHDAY = Convert.ToDateTime(birthday.Text); changedCustomer = c; ctx.UpdateObject(c); ctx.BeginSaveChanges(OnCustomerSaveChange, null); } } }
/// <summary> /// Edits the note. /// </summary> /// <param name="note">The note.</param> /// <param name="onComplete">The on complete.</param> public void EditNote(NOTE note, OnQueryComplete onComplete) { ctx.UpdateObject(note); this.onUQC = onComplete; ctx.BeginSaveChanges(onQueryComplete2, null); }