MyDetailsPage.xaml.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using Comal.Classes;
  2. using InABox.Clients;
  3. using InABox.Core;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Xamarin.Forms;
  10. using Xamarin.Forms.Xaml;
  11. namespace comal.timesheets
  12. {
  13. [XamlCompilation(XamlCompilationOptions.Compile)]
  14. public partial class MyDetailsPage : ContentPage
  15. {
  16. public MyDetailsPage()
  17. {
  18. InitializeComponent();
  19. NavigationPage.SetHasBackButton(this, false);
  20. }
  21. private void ExitBtn_Clicked(object sender, EventArgs e)
  22. {
  23. Navigation.PopAsync();
  24. }
  25. protected override void OnAppearing()
  26. {
  27. base.OnAppearing();
  28. LoadDetails();
  29. }
  30. private void SaveBtn_Clicked(object sender, EventArgs e)
  31. {
  32. try
  33. {
  34. Employee emp = new Employee
  35. {
  36. ID = GlobalVariables.EmpID,
  37. Email = emailEnt.Text,
  38. Mobile = mobileEnt.Text
  39. };
  40. new Client<Employee>().Save(emp, "Email and mobile updated from Mobile My HR module");
  41. DisplayAlert("Success", "Employee Details Saved", "OK");
  42. }
  43. catch
  44. { }
  45. }
  46. void MySignature_Clicked(object sender, EventArgs e)
  47. {
  48. var signature = new SignatureSaver();
  49. signature.OnSignatureSaved += (() =>
  50. {
  51. DisplayAlert("Success", "Signature Saved", "OK");
  52. });
  53. Navigation.PushAsync(signature);
  54. }
  55. private void LoadDetails()
  56. {
  57. try
  58. {
  59. CoreTable table = new Client<Employee>().Query(new Filter<Employee>(x => x.ID).IsEqualTo(GlobalVariables.EmpID),
  60. new Columns<Employee>(x => x.ID, x => x.Email, x => x.Mobile));
  61. if (table.Rows.Any())
  62. PopulateScreen(table.Rows.FirstOrDefault());
  63. }
  64. catch { }
  65. }
  66. private void PopulateScreen(CoreRow row)
  67. {
  68. var emp = row.ToObject<Employee>();
  69. mobileEnt.Text = emp.Mobile;
  70. emailEnt.Text = emp.Email;
  71. }
  72. }
  73. }