using InABox.Core; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Comal.Classes; using InABox.Clients; using Xamarin.Forms; using Xamarin.Forms.Xaml; using System.IO; using comal.timesheets.QAForms; namespace comal.timesheets { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class MyHRHome : ContentPage { #region Constructor and appearing ImageSource imageSource; public MyHRHome() { InitializeComponent(); LoadScreen(); } protected override void OnAppearing() { LoadButtons(); base.OnAppearing(); } private async void LoadScreen() { await Task.Run(() => { LoadNames(); }); } private async void LoadButtons() { await Task.Run(() => { if (GlobalVariables.UpdateHRItemsNeedingAttention()) { Device.BeginInvokeOnMainThread(() => { if (GlobalVariables.QualificationsNeedingAttention > 0) { //qualificationsBtn.Text = "Qualifications (" + GlobalVariables.QualificationsNeedingAttention + ")" //+ System.Environment.NewLine + "!"; //qualificationsBtn.BackgroundColor = Color.Orange; //qualificationsBtn.Padding = new Thickness(60, 10, 10, 10); } else { //qualificationsBtn.Text = "Qualifications"; //qualificationsBtn.BackgroundColor = Color.FromHex("#15C7C1"); } if (GlobalVariables.EmployeeFormsToDo > 0) { //employeeFormsBtn.BackgroundColor = Color.Orange; } else { //employeeFormsBtn.Text = "Employee Forms"; //employeeFormsBtn.BackgroundColor = Color.FromHex("#15C7C1"); } }); } }); } private void LoadNames() { string teamName = ""; CoreTable table = new Client().Query ( new Filter(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID), new Columns(x => x.TeamLink.Name) ); if (table.Rows.Any()) { foreach (CoreRow row in table.Rows) { List list = row.Values; if (list[0] == null) { list[0] = ""; } if (!string.IsNullOrWhiteSpace(list[0].ToString())) { if (list[0].ToString() != "All Staff") { teamName = list[0].ToString(); } } } } Device.BeginInvokeOnMainThread(() => { employeeNameLbl.Text = GlobalVariables.EmpName; employeeTeamLbl.Text = teamName; }); } #endregion #region Buttons private void QualificationsBtn_Clicked(object sender, EventArgs e) { QualificationList qualificationsPage = new QualificationList(); Navigation.PushAsync(qualificationsPage); } private void EmployeeFormsBtn_Clicked(object sender, EventArgs e) { EmployeeFormPicker employeeFormPicker = new EmployeeFormPicker(); Navigation.PushAsync(employeeFormPicker); } private void LeaveBtn_Clicked(object sender, EventArgs e) { LeaveRequestList leaveRequestList = new LeaveRequestList(); Navigation.PushAsync(leaveRequestList); } private void TimesheetsBtn_Clicked(object sender, EventArgs e) { var timesheetsForm = new Timesheets() { EmployeeID = GlobalVariables.EmpID }; Navigation.PushAsync(timesheetsForm); } private void MyDetails_Clicked(object sender, EventArgs e) { MyDetailsPage page = new MyDetailsPage(); Navigation.PushAsync(page); } #endregion } }