MyHRHome.xaml.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using InABox.Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Comal.Classes;
  8. using InABox.Clients;
  9. using Xamarin.Forms;
  10. using Xamarin.Forms.Xaml;
  11. using System.IO;
  12. using comal.timesheets.QAForms;
  13. namespace comal.timesheets
  14. {
  15. [XamlCompilation(XamlCompilationOptions.Compile)]
  16. public partial class MyHRHome : ContentPage
  17. {
  18. #region Constructor and appearing
  19. ImageSource imageSource;
  20. public MyHRHome()
  21. {
  22. InitializeComponent();
  23. LoadScreen();
  24. }
  25. protected override void OnAppearing()
  26. {
  27. LoadButtons();
  28. base.OnAppearing();
  29. }
  30. private async void LoadScreen()
  31. {
  32. await Task.Run(() =>
  33. {
  34. LoadNames();
  35. });
  36. }
  37. private async void LoadButtons()
  38. {
  39. await Task.Run(() =>
  40. {
  41. if (GlobalVariables.UpdateHRItemsNeedingAttention())
  42. {
  43. Device.BeginInvokeOnMainThread(() =>
  44. {
  45. if (GlobalVariables.QualificationsNeedingAttention > 0)
  46. {
  47. //qualificationsBtn.Text = "Qualifications (" + GlobalVariables.QualificationsNeedingAttention + ")"
  48. //+ System.Environment.NewLine + "!";
  49. //qualificationsBtn.BackgroundColor = Color.Orange;
  50. //qualificationsBtn.Padding = new Thickness(60, 10, 10, 10);
  51. }
  52. else
  53. {
  54. //qualificationsBtn.Text = "Qualifications";
  55. //qualificationsBtn.BackgroundColor = Color.FromHex("#15C7C1");
  56. }
  57. if (GlobalVariables.EmployeeFormsToDo > 0)
  58. {
  59. //employeeFormsBtn.BackgroundColor = Color.Orange;
  60. }
  61. else
  62. {
  63. //employeeFormsBtn.Text = "Employee Forms";
  64. //employeeFormsBtn.BackgroundColor = Color.FromHex("#15C7C1");
  65. }
  66. });
  67. }
  68. });
  69. }
  70. private void LoadNames()
  71. {
  72. string teamName = "";
  73. CoreTable table = new Client<EmployeeTeam>().Query
  74. (
  75. new Filter<EmployeeTeam>(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID),
  76. new Columns<EmployeeTeam>(x => x.TeamLink.Name)
  77. );
  78. if (table.Rows.Any())
  79. {
  80. foreach (CoreRow row in table.Rows)
  81. {
  82. List<object> list = row.Values;
  83. if (list[0] == null) { list[0] = ""; }
  84. if (!string.IsNullOrWhiteSpace(list[0].ToString()))
  85. {
  86. if (list[0].ToString() != "All Staff")
  87. {
  88. teamName = list[0].ToString();
  89. }
  90. }
  91. }
  92. }
  93. Device.BeginInvokeOnMainThread(() =>
  94. {
  95. employeeNameLbl.Text = GlobalVariables.EmpName;
  96. employeeTeamLbl.Text = teamName;
  97. });
  98. }
  99. #endregion
  100. #region Buttons
  101. private void QualificationsBtn_Clicked(object sender, EventArgs e)
  102. {
  103. QualificationList qualificationsPage = new QualificationList();
  104. Navigation.PushAsync(qualificationsPage);
  105. }
  106. private void EmployeeFormsBtn_Clicked(object sender, EventArgs e)
  107. {
  108. EmployeeFormPicker employeeFormPicker = new EmployeeFormPicker();
  109. Navigation.PushAsync(employeeFormPicker);
  110. }
  111. private void LeaveBtn_Clicked(object sender, EventArgs e)
  112. {
  113. LeaveRequestList leaveRequestList = new LeaveRequestList();
  114. Navigation.PushAsync(leaveRequestList);
  115. }
  116. private void TimesheetsBtn_Clicked(object sender, EventArgs e)
  117. {
  118. var timesheetsForm = new Timesheets() { EmployeeID = GlobalVariables.EmpID };
  119. Navigation.PushAsync(timesheetsForm);
  120. }
  121. private void MyDetails_Clicked(object sender, EventArgs e)
  122. {
  123. MyDetailsPage page = new MyDetailsPage();
  124. Navigation.PushAsync(page);
  125. }
  126. #endregion
  127. }
  128. }