TimeSheetNotePage.xaml.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using InABox.Core;
  4. using Xamarin.Forms;
  5. using InABox.Clients;
  6. using Comal.Classes;
  7. using System.Threading.Tasks;
  8. using System.Linq;
  9. using InABox.Mobile;
  10. namespace PRS.Mobile
  11. {
  12. public partial class TimeSheetNotePage
  13. {
  14. TimeSheet timeSheet = new TimeSheet();
  15. protected void SaveTimeSheetCallback(TimeSheet entity, Exception e)
  16. {
  17. if (e != null)
  18. Device.BeginInvokeOnMainThread(() => { DisplayAlert("Error Adding Note", "Unable to Save Note\n\n" + e.Message, "OK"); });
  19. }
  20. public TimeSheetNotePage(TimeSheet _timeSheet)
  21. {
  22. InitializeComponent();
  23. timeSheet = _timeSheet;
  24. notesLbl.Text = _timeSheet.Notes;
  25. }
  26. private void SaveNewNotes()
  27. {
  28. try
  29. {
  30. string notesLableText = notesLbl.Text + "\n";
  31. if (string.IsNullOrWhiteSpace(notesLbl.Text))
  32. {
  33. notesLableText = "";
  34. }
  35. if (!string.IsNullOrWhiteSpace(notesEdt.Text))
  36. {
  37. timeSheet.Notes = notesLableText +
  38. notesEdt.Text + " (Added by " + App.Data.Me.Name + " at " + DateTime.Now + ")";
  39. new Client<TimeSheet>().Save(timeSheet, "Updated Note from Mobile");
  40. DisplayAlert("Success", "Note Saved", "OK");
  41. }
  42. }
  43. catch { }
  44. }
  45. private void Save_Clicked(object sender, MobileMenuButtonClickedEventArgs args)
  46. {
  47. SaveNewNotes();
  48. Navigation.PopAsync();
  49. }
  50. }
  51. }