| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using System.Collections.Generic;
- using InABox.Core;
- using Xamarin.Forms;
- using InABox.Clients;
- using Comal.Classes;
- using System.Threading.Tasks;
- using System.Linq;
- using InABox.Mobile;
- namespace PRS.Mobile
- {
- public partial class TimeSheetNotePage
- {
- TimeSheet timeSheet = new TimeSheet();
- protected void SaveTimeSheetCallback(TimeSheet entity, Exception e)
- {
- if (e != null)
- Device.BeginInvokeOnMainThread(() => { DisplayAlert("Error Adding Note", "Unable to Save Note\n\n" + e.Message, "OK"); });
- }
- public TimeSheetNotePage(TimeSheet _timeSheet)
- {
- InitializeComponent();
- timeSheet = _timeSheet;
- notesLbl.Text = _timeSheet.Notes;
- notesLbl.IsVisible = !String.IsNullOrWhiteSpace(_timeSheet.Notes);
- notesSeparator.IsVisible = !String.IsNullOrWhiteSpace(_timeSheet.Notes);
- }
-
- private void SaveNewNotes()
- {
- try
- {
- string prevNotes = String.IsNullOrWhiteSpace(notesLbl.Text)
- ? ""
- : notesLbl.Text.EndsWith("\n")
- ? notesLbl.Text
- : $"{notesLbl.Text}\n";
-
- if (!string.IsNullOrWhiteSpace(notesEdt.Text))
- {
- timeSheet.Notes =
- $"{prevNotes}{DateTime.Now:yy-MM-dd HH:mm} {App.Data.Me.Code}: {notesEdt.Text}";
- new Client<TimeSheet>().Save(timeSheet, "Updated Note from Mobile");
- DisplayAlert("Success", "Note Saved", "OK");
- }
- }
- catch { }
- }
- private void Save_Clicked(object sender, MobileMenuButtonClickedEventArgs args)
- {
- SaveNewNotes();
- Navigation.PopAsync();
- }
- }
- }
|