public static Evento GetEventForTime(this Evento evento, DateTime dateCurrent) { // Das 8 as 10 = Entrada // Das 11 as 14 = Saida Almoço (Se não tiver ponto de saída ainda) // Das 12 as 15 = Entrada Almoço (Se ja houver ponto de saída) // Das maior que 17 = Saída GetRow getRow = new GetRow(RowServiceDependencies.Inject()); Evento?ev = null; var value = Task.FromResult(getRow.GetRowAsync(dateCurrent.ToString("dd/MM")).GetAwaiter().GetResult()); var rowValue = value.Result; int hoursCurrent = dateCurrent.Hour; if (hoursCurrent >= 8 && hoursCurrent <= 10) { ev = Evento.entrada; } else if (hoursCurrent >= 11 && hoursCurrent <= 14 && rowValue.SaidaAlmoco == null) { ev = Evento.saida_almoco; } else if (hoursCurrent >= 12 && hoursCurrent <= 15 && rowValue.SaidaAlmoco != null) { ev = Evento.entrada_almoco; } else if (hoursCurrent >= 17) { ev = Evento.saida; } return(ev.Value); }
private async void Btn_rmvPonto_Clicked(object sender, EventArgs e) { string[] ultPonto = infosCarouselList[0].Value.Split('/'); string batchId = string.Empty; bool remove = await DisplayAlert("Remover Ponto", $"Você realmente quer deletar esse ponto '{infosCarouselList[0].Value}'?", "Sim", "Não"); if (remove) { await Navigation.PushPopupAsync(new LoaderInserindoNovoPontoPopup("", DateTime.Now, false, true)); var rowDetails = Task.FromResult(await getRow.GetRowByDateAsync($"{ultPonto[0]}/{ultPonto[1]}")); if (rowDetails.IsCompleted) { var rowInfo = rowDetails.Result; batchId = rowInfo.BatchID; } var rowValues = Task.FromResult(await getRow.GetRowAsync($"{ultPonto[0]}/{ultPonto[1]}")); if (rowValues.IsCompleted) { var rowValue = rowValues.Result; if (rowValue.Entrada != null && rowValue.SaidaAlmoco == null && rowValue.EntradaAlmoco == null && rowValue.Saida == null) { batchId = batchId.Replace("C2", "C" + 3); } else if (rowValue.Entrada != null && rowValue.SaidaAlmoco != null && rowValue.EntradaAlmoco == null && rowValue.Saida == null) { batchId = batchId.Replace("C2", "C" + 4); } else if (rowValue.Entrada != null && rowValue.SaidaAlmoco != null && rowValue.EntradaAlmoco != null && rowValue.Saida == null) { batchId = batchId.Replace("C2", "C" + 5); } else if (rowValue.Entrada != null && rowValue.SaidaAlmoco != null && rowValue.EntradaAlmoco != null && rowValue.Saida != null) { batchId = batchId.Replace("C2", "C" + 6); } } var removePto = Task.FromResult(await removeDate.DeleteDateAsync(batchId)); if (removePto.IsCompleted) { await Navigation.PopPopupAsync(); await DisplayAlert("Sucesso", "Ponto excluido com sucesso", "OK"); } } else { return; } }
public async void CarregaInformacoes(string data) { var getRowTask = Task.FromResult(await getRow.GetRowAsync(data)); if (getRowTask.IsCompleted) { var rowValue = getRowTask.Result; lblData.Text += data; lblEntrada.Text += rowValue.Entrada.HasValue ? rowValue.Entrada.Value.ToLongTimeString() : "-"; lblSaidaAlm.Text += rowValue.SaidaAlmoco.HasValue ? rowValue.SaidaAlmoco.Value.ToLongTimeString() : "-"; lblEntradaAlm.Text += rowValue.EntradaAlmoco.HasValue ? rowValue.EntradaAlmoco.Value.ToLongTimeString() : "-"; lblSaida.Text += rowValue.Saida.HasValue ? rowValue.Saida.Value.ToLongTimeString() : "-"; lblExtras.Text += rowValue.HorasExtras.HasValue ? rowValue.HorasExtras.Value.ToShortTimeString() : "-"; } }
public static async Task <string> GetEventForTime(this DateTime dataPto) { GetRow getRow = new GetRow(RowServiceDependencies.Inject()); string ev = string.Empty; string[] partsData = dataPto.ToShortDateString().Split('/'); string horaPto = dataPto.ToShortTimeString(); string[] partsHora = horaPto.Split(':'); string dataParam = $"{partsData[0]}/{partsData[1]}"; int hrs = int.Parse(partsHora[0]); if (hrs >= 11 && hrs <= 15) { var rowResult = Task.FromResult(await getRow.GetRowAsync(dataParam)).Result; if (rowResult.SaidaAlmoco != null) { ev = Evento.entrada_almoco.ToString(); } else { ev = Evento.saida_almoco.ToString(); } } else if (hrs >= 8 && hrs <= 9) { ev = Evento.entrada.ToString(); } else { ev = Evento.saida.ToString(); } return(await Task.FromResult(ev)); }